Bugfixes and performance optimizations

This commit is contained in:
Tim Schubert 2020-08-18 01:02:39 +02:00
parent 0f49ceb4aa
commit dd55b495c4
7 changed files with 19 additions and 17 deletions

View file

@ -67,8 +67,8 @@ IslMockChannel::TransmitStart (
NS_LOG_ERROR ("Source device unknown");
return false;
}
Ptr<MockNetDevice> src = DynamicCast<MockNetDevice> (GetDevice (srcId));
Ptr<MockNetDevice> dst = DynamicCast<MockNetDevice> (GetDevice (destAddr));
Ptr<MockNetDevice> src = StaticCast<MockNetDevice> (GetDevice (srcId));
Ptr<MockNetDevice> dst = StaticCast<MockNetDevice> (GetDevice (destAddr));
if (dst == nullptr)
{
@ -78,7 +78,7 @@ IslMockChannel::TransmitStart (
for (size_t i = 0; i < GetNDevices (); i ++)
{
if (i == srcId) continue;
dst = DynamicCast<MockNetDevice> (GetDevice (i));
dst = StaticCast<MockNetDevice> (GetDevice (i));
Deliver (p, src, dst, txTime);
}
return true;

View file

@ -89,7 +89,7 @@ IslPropagationLossModel::DoCalcRxPower (double txPowerDbm,
{
if (!GetLos (a, b))
{
return 0.0;
return -1000.0;
}
NS_LOG_INFO ("LOS;"<<a->GetPosition ()<<";"<<b->GetPosition ());

View file

@ -50,7 +50,7 @@ LeoMockChannel::TransmitStart (Ptr<const Packet> p,
return false;
}
Ptr<MockNetDevice> srcDev = DynamicCast<MockNetDevice> (GetDevice (devId));
Ptr<MockNetDevice> srcDev = StaticCast<MockNetDevice> (GetDevice (devId));
if (srcDev == 0)
{
NS_LOG_ERROR ("Source device unknown");
@ -89,7 +89,7 @@ LeoMockChannel::TransmitStart (Ptr<const Packet> p,
int32_t
LeoMockChannel::Attach (Ptr<MockNetDevice> device)
{
Ptr<LeoMockNetDevice> leodev = DynamicCast<LeoMockNetDevice> (device);
Ptr<LeoMockNetDevice> leodev = StaticCast<LeoMockNetDevice> (device);
// Add to index
switch (leodev->GetDeviceType ())

View file

@ -23,7 +23,7 @@ LeoPropagationLossModel::GetTypeId (void)
.AddConstructor<LeoPropagationLossModel> ()
.AddAttribute ("MaxDistance",
"Cut-off distance for signal propagation",
DoubleValue (100000.0),
DoubleValue (1000000.0),
MakeDoubleAccessor (&LeoPropagationLossModel::m_cutoffDistance),
MakeDoubleChecker<double> ())
.AddAttribute ("ElevationAngle",
@ -78,13 +78,14 @@ LeoPropagationLossModel::DoCalcRxPower (double txPowerDbm,
{
if (a->GetDistanceFrom (b) > m_cutoffDistance || GetAngle (a, b) > m_elevationAngle / 2.0)
{
return 0.0;
return -1000.0;
}
// txPowerDbm includes tx antenna gain and losses
// receiver loss and gain added at net device
// P_{RX} = P_{TX} + G_{TX} - L_{TX} - L_{FS} - L_M + G_{RX} - L_{RX}
double rxc = txPowerDbm - m_atmosphericLoss - m_freeSpacePathLoss - m_linkMargin;
NS_LOG_DEBUG("rxc="<<rxc);
return rxc;
}

View file

@ -179,22 +179,23 @@ MockChannel::Deliver (
if (srcMob != 0 && dstMob != 0)
{
// performance optimization
if (srcMob->GetDistanceFrom (dstMob) > 3.0e6)
{
return false;
}
Ptr<PropagationLossModel> pLoss = GetPropagationLoss ();
if (pLoss != 0)
{
// check if signal reaches destination
rxPower = pLoss->CalcRxPower (txPower, srcMob, dstMob);
if (rxPower == 0.0)
if (rxPower == -1000.0)
{
return false;
}
}
delay += GetPropagationDelay (srcMob, dstMob, txTime);
}
else
{
return false;
}
Simulator::ScheduleWithContext (dst->GetNode ()->GetId (),
delay,

View file

@ -72,7 +72,7 @@ MockNetDevice::GetTypeId (void)
MakeTimeChecker ())
.AddAttribute ("RxThreshold",
"Receive threshold in dBm",
DoubleValue (0.0),
DoubleValue (-1000.0),
MakeDoubleAccessor (&MockNetDevice::m_rxThreshold),
MakeDoubleChecker<double> ())
.AddAttribute ("TxPower",