From dd55b495c4dbba4028bf9cf019f7232871f19fc4 Mon Sep 17 00:00:00 2001 From: Tim Schubert Date: Tue, 18 Aug 2020 01:02:39 +0200 Subject: [PATCH] Bugfixes and performance optimizations --- helper/leo-channel-helper.cc | 6 +++--- model/isl-mock-channel.cc | 6 +++--- model/isl-propagation-loss-model.cc | 2 +- model/leo-mock-channel.cc | 4 ++-- model/leo-propagation-loss-model.cc | 5 +++-- model/mock-channel.cc | 11 ++++++----- model/mock-net-device.cc | 2 +- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/helper/leo-channel-helper.cc b/helper/leo-channel-helper.cc index 7a12444..3a00451 100644 --- a/helper/leo-channel-helper.cc +++ b/helper/leo-channel-helper.cc @@ -114,11 +114,11 @@ LeoChannelHelper::SetConstellationAttributes (double eirp, m_gndDeviceFactory.Set ("TxPower", DoubleValue (eirp)); m_satDeviceFactory.Set ("TxPower", DoubleValue (eirp)); - m_gndDeviceFactory.Set ("RxGain", DoubleValue (rxGain)); m_gndDeviceFactory.Set ("RxLoss", DoubleValue (rxLoss)); + m_gndDeviceFactory.Set ("RxGain", DoubleValue (rxGain)); - m_satDeviceFactory.Set ("RxLoss", DoubleValue (rxGain)); - m_satDeviceFactory.Set ("RxGain", DoubleValue (rxLoss)); + m_satDeviceFactory.Set ("RxLoss", DoubleValue (rxLoss)); + m_satDeviceFactory.Set ("RxGain", DoubleValue (rxGain)); m_gndDeviceFactory.Set ("DataRate", DataRateValue (DataRate (dataRate))); m_satDeviceFactory.Set ("DataRate", DataRateValue (DataRate (dataRate))); diff --git a/model/isl-mock-channel.cc b/model/isl-mock-channel.cc index 46c4f6f..6d1bf32 100644 --- a/model/isl-mock-channel.cc +++ b/model/isl-mock-channel.cc @@ -67,8 +67,8 @@ IslMockChannel::TransmitStart ( NS_LOG_ERROR ("Source device unknown"); return false; } - Ptr src = DynamicCast (GetDevice (srcId)); - Ptr dst = DynamicCast (GetDevice (destAddr)); + Ptr src = StaticCast (GetDevice (srcId)); + Ptr dst = StaticCast (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 (GetDevice (i)); + dst = StaticCast (GetDevice (i)); Deliver (p, src, dst, txTime); } return true; diff --git a/model/isl-propagation-loss-model.cc b/model/isl-propagation-loss-model.cc index 681e22e..bc2813f 100644 --- a/model/isl-propagation-loss-model.cc +++ b/model/isl-propagation-loss-model.cc @@ -89,7 +89,7 @@ IslPropagationLossModel::DoCalcRxPower (double txPowerDbm, { if (!GetLos (a, b)) { - return 0.0; + return -1000.0; } NS_LOG_INFO ("LOS;"<GetPosition ()<<";"<GetPosition ()); diff --git a/model/leo-mock-channel.cc b/model/leo-mock-channel.cc index cee2ba5..e6011ee 100644 --- a/model/leo-mock-channel.cc +++ b/model/leo-mock-channel.cc @@ -50,7 +50,7 @@ LeoMockChannel::TransmitStart (Ptr p, return false; } - Ptr srcDev = DynamicCast (GetDevice (devId)); + Ptr srcDev = StaticCast (GetDevice (devId)); if (srcDev == 0) { NS_LOG_ERROR ("Source device unknown"); @@ -89,7 +89,7 @@ LeoMockChannel::TransmitStart (Ptr p, int32_t LeoMockChannel::Attach (Ptr device) { - Ptr leodev = DynamicCast (device); + Ptr leodev = StaticCast (device); // Add to index switch (leodev->GetDeviceType ()) diff --git a/model/leo-propagation-loss-model.cc b/model/leo-propagation-loss-model.cc index 7557b3c..1b372b1 100644 --- a/model/leo-propagation-loss-model.cc +++ b/model/leo-propagation-loss-model.cc @@ -23,7 +23,7 @@ LeoPropagationLossModel::GetTypeId (void) .AddConstructor () .AddAttribute ("MaxDistance", "Cut-off distance for signal propagation", - DoubleValue (100000.0), + DoubleValue (1000000.0), MakeDoubleAccessor (&LeoPropagationLossModel::m_cutoffDistance), MakeDoubleChecker ()) .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="<GetDistanceFrom (dstMob) > 3.0e6) + { + return false; + } Ptr 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, diff --git a/model/mock-net-device.cc b/model/mock-net-device.cc index 1a8ff6f..050f9af 100644 --- a/model/mock-net-device.cc +++ b/model/mock-net-device.cc @@ -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 ()) .AddAttribute ("TxPower",