fixup: mobility model and loss

This commit is contained in:
Tim Schubert 2020-08-07 18:03:55 +02:00
parent 582d6c58d0
commit 42f5bac245
4 changed files with 131 additions and 121 deletions

View file

@ -113,16 +113,19 @@ MockChannel::GetDevice (std::size_t i) const
} }
Time Time
MockChannel::GetDelay (Ptr<const MockNetDevice> src, Ptr<const MockNetDevice> dst, Time txTime) const MockChannel::GetPropagationDelay (Ptr<MobilityModel> srcMob, Ptr<MobilityModel> dstMob, Time txTime) const
{ {
NS_LOG_FUNCTION (this << src << dst << txTime); NS_LOG_FUNCTION (this << srcMob << dstMob << txTime);
Ptr<MobilityModel> modSrc = src->GetNode ()->GetObject<MobilityModel> (); if (GetPropagationDelay ())
Ptr<MobilityModel> modDst = dst->GetNode ()->GetObject<MobilityModel> (); {
Time propagationDelay = m_propagationDelay->GetDelay (srcMob, dstMob);
Time propagationDelay = m_propagationDelay->GetDelay (modSrc, modDst); return propagationDelay;
}
return txTime + propagationDelay; else
{
return Time (0);
}
} }
// TODO optimize // TODO optimize
@ -160,15 +163,23 @@ MockChannel::Deliver (
Time txTime) Time txTime)
{ {
NS_LOG_FUNCTION (this << p << src->GetAddress () << dst->GetAddress () << txTime); NS_LOG_FUNCTION (this << p << src->GetAddress () << dst->GetAddress () << txTime);
Time delay = txTime;
double rxPower = GetPropagationLoss ()->CalcRxPower (1.0, src, dst); Ptr<MobilityModel> srcMob = src->GetObject<MobilityModel> ();
Ptr<MobilityModel> dstMob = dst->GetObject<MobilityModel> ();
if (rxPower == 0.0) if (srcMob != 0 && dstMob != 0)
{
Ptr<PropagationLossModel> pLoss = GetPropagationLoss ();
if (pLoss != 0)
{
if (pLoss->CalcRxPower (1.0, srcMob, dstMob) == 0.0)
{ {
return false; return false;
} }
}
Time delay = GetDelay (src, dst, txTime); delay += GetPropagationDelay (srcMob, dstMob, txTime);
}
Simulator::ScheduleWithContext (dst->GetNode ()->GetId (), Simulator::ScheduleWithContext (dst->GetNode ()->GetId (),
delay, delay,

View file

@ -81,10 +81,10 @@ protected:
> m_txrxMock; > m_txrxMock;
/** /**
* \brief Get the delay associated with this channel * \brief Get the propagation delay associated with this channel
* \returns Time delay * \returns Propagation time delay
*/ */
Time GetDelay (Ptr<const MockNetDevice> first, Ptr<const MockNetDevice> second, Time txTime) const; Time GetPropagationDelay (Ptr<MobilityModel> first, Ptr<MobilityModel> second, Time txTime) const;
Ptr<PropagationDelayModel> GetPropagationDelay () const; Ptr<PropagationDelayModel> GetPropagationDelay () const;
Ptr<PropagationLossModel> GetPropagationLoss () const; Ptr<PropagationLossModel> GetPropagationLoss () const;

View file

@ -582,7 +582,7 @@ bool
MockNetDevice::IsBroadcast (void) const MockNetDevice::IsBroadcast (void) const
{ {
NS_LOG_FUNCTION (this); NS_LOG_FUNCTION (this);
return false; return true;
} }
// //
@ -601,7 +601,7 @@ bool
MockNetDevice::IsMulticast (void) const MockNetDevice::IsMulticast (void) const
{ {
NS_LOG_FUNCTION (this); NS_LOG_FUNCTION (this);
return false; return true;
} }
Address Address

View file

@ -43,7 +43,6 @@ LeoMockChannelTransmitUnknownTestCase::DoRun (void)
Time txTime; Time txTime;
channel->SetAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel")); channel->SetAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel"));
channel->SetAttribute ("PropagationLoss", StringValue ("ns3::LeoPropagationLossModel")); channel->SetAttribute ("PropagationLoss", StringValue ("ns3::LeoPropagationLossModel"));
dev->SetAttribute ("MobilityModel", StringValue ("ns3::ConstantPositionMobilityModel"));
bool result = channel->TransmitStart (p, srcId, destAddr, txTime); bool result = channel->TransmitStart (p, srcId, destAddr, txTime);
NS_TEST_ASSERT_MSG_EQ (result, false, "Unknown destination fails to deliver"); NS_TEST_ASSERT_MSG_EQ (result, false, "Unknown destination fails to deliver");