mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-07-29 18:20:07 +02:00
fixup: mobility model and loss
This commit is contained in:
parent
582d6c58d0
commit
42f5bac245
4 changed files with 131 additions and 121 deletions
|
@ -113,16 +113,19 @@ MockChannel::GetDevice (std::size_t i) const
|
|||
}
|
||||
|
||||
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> ();
|
||||
Ptr<MobilityModel> modDst = dst->GetNode ()->GetObject<MobilityModel> ();
|
||||
|
||||
Time propagationDelay = m_propagationDelay->GetDelay (modSrc, modDst);
|
||||
|
||||
return txTime + propagationDelay;
|
||||
if (GetPropagationDelay ())
|
||||
{
|
||||
Time propagationDelay = m_propagationDelay->GetDelay (srcMob, dstMob);
|
||||
return propagationDelay;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Time (0);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO optimize
|
||||
|
@ -160,15 +163,23 @@ MockChannel::Deliver (
|
|||
Time 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;
|
||||
}
|
||||
|
||||
Time delay = GetDelay (src, dst, txTime);
|
||||
}
|
||||
delay += GetPropagationDelay (srcMob, dstMob, txTime);
|
||||
}
|
||||
|
||||
Simulator::ScheduleWithContext (dst->GetNode ()->GetId (),
|
||||
delay,
|
||||
|
|
|
@ -81,10 +81,10 @@ protected:
|
|||
> m_txrxMock;
|
||||
|
||||
/**
|
||||
* \brief Get the delay associated with this channel
|
||||
* \returns Time delay
|
||||
* \brief Get the propagation delay associated with this channel
|
||||
* \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<PropagationLossModel> GetPropagationLoss () const;
|
||||
|
|
|
@ -582,7 +582,7 @@ bool
|
|||
MockNetDevice::IsBroadcast (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -601,7 +601,7 @@ bool
|
|||
MockNetDevice::IsMulticast (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
Address
|
||||
|
|
|
@ -43,7 +43,6 @@ LeoMockChannelTransmitUnknownTestCase::DoRun (void)
|
|||
Time txTime;
|
||||
channel->SetAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel"));
|
||||
channel->SetAttribute ("PropagationLoss", StringValue ("ns3::LeoPropagationLossModel"));
|
||||
dev->SetAttribute ("MobilityModel", StringValue ("ns3::ConstantPositionMobilityModel"));
|
||||
bool result = channel->TransmitStart (p, srcId, destAddr, txTime);
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (result, false, "Unknown destination fails to deliver");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue