From ad22221f42337f66dad5d73a1d09912cc256a490 Mon Sep 17 00:00:00 2001 From: Tim Schubert Date: Wed, 19 Aug 2020 11:39:02 +0200 Subject: [PATCH] Fix LEO propagation loss --- .../leo-circular-orbit-tracing-example.cc | 2 +- examples/leo-delay-tracing-example.cc | 29 ++++++----- model/leo-propagation-loss-model.cc | 49 ++++++++++++++++--- model/leo-propagation-loss-model.h | 6 +++ model/mock-channel.cc | 5 -- utils/plot-satellites.gnuplot | 2 +- 6 files changed, 65 insertions(+), 28 deletions(-) diff --git a/examples/leo-circular-orbit-tracing-example.cc b/examples/leo-circular-orbit-tracing-example.cc index 4ccb63e..28c1045 100644 --- a/examples/leo-circular-orbit-tracing-example.cc +++ b/examples/leo-circular-orbit-tracing-example.cc @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) outfile << "Time,Satellite,x,y,z,Speed" << std::endl; - Simulator::Stop (Hours (24)); + Simulator::Stop (Hours (1)); Simulator::Run (); Simulator::Destroy (); } diff --git a/examples/leo-delay-tracing-example.cc b/examples/leo-delay-tracing-example.cc index 66cb3f9..7969fcc 100644 --- a/examples/leo-delay-tracing-example.cc +++ b/examples/leo-delay-tracing-example.cc @@ -33,12 +33,11 @@ public: int main (int argc, char *argv[]) { std::vector orbits = { - Orbit (1.150, 53.0, 32, 50), - Orbit (1.110, 53.8, 32, 50), - Orbit (1.130, 74.0, 8, 50), - Orbit (1.275, 81, 5, 75), - Orbit (1.325, 70, 6, 75), - + Orbit (1150, 53.0, 32, 50), + Orbit (1110, 53.8, 32, 50), + Orbit (1130, 74.0, 8, 50), + Orbit (1275, 81, 5, 75), + Orbit (1325, 70, 6, 75), }; NodeContainer satellites; for (Orbit orb: orbits) @@ -64,8 +63,7 @@ int main (int argc, char *argv[]) NetDeviceContainer islNet, utNet; IslHelper islCh; - islCh.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); - islCh.SetDeviceAttribute ("ReceiveErrorModel", StringValue ("ns3::BurstErrorModel")); + islCh.SetDeviceAttribute ("DataRate", StringValue ("1Gbps")); islCh.SetChannelAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel")); islCh.SetChannelAttribute ("PropagationLoss", StringValue ("ns3::IslPropagationLossModel")); islNet = islCh.Install (satellites); @@ -76,15 +74,15 @@ int main (int argc, char *argv[]) // Install internet stack on nodes AodvHelper aodv; - aodv.Set ("HelloInterval", TimeValue (Seconds (10))); + aodv.Set ("HelloInterval", TimeValue (Seconds (1))); aodv.Set ("TtlStart", UintegerValue (10)); aodv.Set ("TtlIncrement", UintegerValue (10)); - aodv.Set ("TtlThreshold", UintegerValue (1000)); + aodv.Set ("TtlThreshold", UintegerValue (100)); aodv.Set ("RreqRetries", UintegerValue (100)); - aodv.Set ("RreqRateLimit", UintegerValue (100)); - aodv.Set ("RerrRateLimit", UintegerValue (100)); - aodv.Set ("ActiveRouteTimeout", TimeValue (Seconds (10))); - aodv.Set ("NextHopWait", TimeValue (MilliSeconds (100))); + aodv.Set ("RreqRateLimit", UintegerValue (10)); + aodv.Set ("RerrRateLimit", UintegerValue (10)); + aodv.Set ("ActiveRouteTimeout", TimeValue (Minutes (1))); + aodv.Set ("NextHopWait", TimeValue (MilliSeconds (200))); aodv.Set ("NetDiameter", UintegerValue (1000)); aodv.Set ("PathDiscoveryTime", TimeValue (Seconds (1))); @@ -107,9 +105,10 @@ int main (int argc, char *argv[]) // install a client on one of the terminals ApplicationContainer clientApps; Address remote = stations.Get (1)->GetObject ()->GetAddress (1, 0).GetLocal ();//utIp.GetAddress (1, 0); + std::cout << "REMOTE=" << Ipv4Address::ConvertFrom (remote); UdpClientHelper echoClient (remote, 9); echoClient.SetAttribute ("MaxPackets", UintegerValue (360)); - echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0))); + echoClient.SetAttribute ("Interval", TimeValue (Seconds (10.0))); echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); clientApps.Add (echoClient.Install (stations.Get (3))); diff --git a/model/leo-propagation-loss-model.cc b/model/leo-propagation-loss-model.cc index 1b372b1..29761fe 100644 --- a/model/leo-propagation-loss-model.cc +++ b/model/leo-propagation-loss-model.cc @@ -23,13 +23,15 @@ LeoPropagationLossModel::GetTypeId (void) .AddConstructor () .AddAttribute ("MaxDistance", "Cut-off distance for signal propagation", - DoubleValue (1000000.0), - MakeDoubleAccessor (&LeoPropagationLossModel::m_cutoffDistance), + DoubleValue (3000), + MakeDoubleAccessor (&LeoPropagationLossModel::SetCutoffDistance, + &LeoPropagationLossModel::GetCutoffDistance), MakeDoubleChecker ()) .AddAttribute ("ElevationAngle", "Cut-off angle for signal propagation", DoubleValue (M_PI / 9), - MakeDoubleAccessor (&LeoPropagationLossModel::m_elevationAngle), + MakeDoubleAccessor (&LeoPropagationLossModel::SetElevationAngle, + &LeoPropagationLossModel::GetElevationAngle), MakeDoubleChecker ()) .AddAttribute ("AtmosphericLoss", "Atmospheric loss due to attenuation in dB", @@ -71,21 +73,56 @@ LeoPropagationLossModel::GetAngle (Ptr a, Ptr b) return acos (prod / norm); } +void +LeoPropagationLossModel::SetElevationAngle (double angle) +{ + m_elevationAngle = angle * (M_PI/180.0); +} + +double +LeoPropagationLossModel::GetElevationAngle () const +{ + return m_elevationAngle * (180.0/M_PI); +} + +void +LeoPropagationLossModel::SetCutoffDistance (double d) +{ + m_cutoffDistance = d * 1000.0; +} + +double +LeoPropagationLossModel::GetCutoffDistance () const +{ + return m_cutoffDistance / 1000.0; +} + double LeoPropagationLossModel::DoCalcRxPower (double txPowerDbm, Ptr a, Ptr b) const { - if (a->GetDistanceFrom (b) > m_cutoffDistance || GetAngle (a, b) > m_elevationAngle / 2.0) + double distance = a->GetDistanceFrom (b); + double angle = GetAngle (a, b); + double rxc = txPowerDbm - m_atmosphericLoss - m_freeSpacePathLoss - m_linkMargin; + + NS_LOG_DEBUG ("LEO propagation: a=" << a->GetPosition () << " b=" << b->GetPosition () << " m_cutOff="< m_elevationAngle / 2.0) + { + NS_LOG_DEBUG ("LEO DROP ANGLE: " << angle <<"; " << distance); 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) { diff --git a/utils/plot-satellites.gnuplot b/utils/plot-satellites.gnuplot index c36b468..cc35ed1 100644 --- a/utils/plot-satellites.gnuplot +++ b/utils/plot-satellites.gnuplot @@ -26,6 +26,6 @@ numsamples=ARG4 do for [j=0:numsamples-1] { splot [-pi:pi][-pi/2:pi/2] EARTH*cos(u)*cos(v), EARTH*sin(u)*cos(v), EARTH*sin(v), \ ground using 1:2:3 lt rgb "green", \ - sats using 3:4:5:2 every ::(j*numsats)::((j+1)*numsats) lt rgb "blue" + sats using 3:4:5:2 every ::(j*numsats)::((j+1)*numsats) }