Fix LEO propagation loss

This commit is contained in:
Tim Schubert 2020-08-19 11:39:02 +02:00
parent a92c54703f
commit ad22221f42
6 changed files with 65 additions and 28 deletions

View file

@ -62,7 +62,7 @@ int main(int argc, char *argv[])
outfile << "Time,Satellite,x,y,z,Speed" << std::endl; outfile << "Time,Satellite,x,y,z,Speed" << std::endl;
Simulator::Stop (Hours (24)); Simulator::Stop (Hours (1));
Simulator::Run (); Simulator::Run ();
Simulator::Destroy (); Simulator::Destroy ();
} }

View file

@ -33,12 +33,11 @@ public:
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
std::vector<Orbit> orbits = { std::vector<Orbit> orbits = {
Orbit (1.150, 53.0, 32, 50), Orbit (1150, 53.0, 32, 50),
Orbit (1.110, 53.8, 32, 50), Orbit (1110, 53.8, 32, 50),
Orbit (1.130, 74.0, 8, 50), Orbit (1130, 74.0, 8, 50),
Orbit (1.275, 81, 5, 75), Orbit (1275, 81, 5, 75),
Orbit (1.325, 70, 6, 75), Orbit (1325, 70, 6, 75),
}; };
NodeContainer satellites; NodeContainer satellites;
for (Orbit orb: orbits) for (Orbit orb: orbits)
@ -64,8 +63,7 @@ int main (int argc, char *argv[])
NetDeviceContainer islNet, utNet; NetDeviceContainer islNet, utNet;
IslHelper islCh; IslHelper islCh;
islCh.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); islCh.SetDeviceAttribute ("DataRate", StringValue ("1Gbps"));
islCh.SetDeviceAttribute ("ReceiveErrorModel", StringValue ("ns3::BurstErrorModel"));
islCh.SetChannelAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel")); islCh.SetChannelAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel"));
islCh.SetChannelAttribute ("PropagationLoss", StringValue ("ns3::IslPropagationLossModel")); islCh.SetChannelAttribute ("PropagationLoss", StringValue ("ns3::IslPropagationLossModel"));
islNet = islCh.Install (satellites); islNet = islCh.Install (satellites);
@ -76,15 +74,15 @@ int main (int argc, char *argv[])
// Install internet stack on nodes // Install internet stack on nodes
AodvHelper aodv; AodvHelper aodv;
aodv.Set ("HelloInterval", TimeValue (Seconds (10))); aodv.Set ("HelloInterval", TimeValue (Seconds (1)));
aodv.Set ("TtlStart", UintegerValue (10)); aodv.Set ("TtlStart", UintegerValue (10));
aodv.Set ("TtlIncrement", UintegerValue (10)); aodv.Set ("TtlIncrement", UintegerValue (10));
aodv.Set ("TtlThreshold", UintegerValue (1000)); aodv.Set ("TtlThreshold", UintegerValue (100));
aodv.Set ("RreqRetries", UintegerValue (100)); aodv.Set ("RreqRetries", UintegerValue (100));
aodv.Set ("RreqRateLimit", UintegerValue (100)); aodv.Set ("RreqRateLimit", UintegerValue (10));
aodv.Set ("RerrRateLimit", UintegerValue (100)); aodv.Set ("RerrRateLimit", UintegerValue (10));
aodv.Set ("ActiveRouteTimeout", TimeValue (Seconds (10))); aodv.Set ("ActiveRouteTimeout", TimeValue (Minutes (1)));
aodv.Set ("NextHopWait", TimeValue (MilliSeconds (100))); aodv.Set ("NextHopWait", TimeValue (MilliSeconds (200)));
aodv.Set ("NetDiameter", UintegerValue (1000)); aodv.Set ("NetDiameter", UintegerValue (1000));
aodv.Set ("PathDiscoveryTime", TimeValue (Seconds (1))); aodv.Set ("PathDiscoveryTime", TimeValue (Seconds (1)));
@ -107,9 +105,10 @@ int main (int argc, char *argv[])
// install a client on one of the terminals // install a client on one of the terminals
ApplicationContainer clientApps; ApplicationContainer clientApps;
Address remote = stations.Get (1)->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();//utIp.GetAddress (1, 0); Address remote = stations.Get (1)->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();//utIp.GetAddress (1, 0);
std::cout << "REMOTE=" << Ipv4Address::ConvertFrom (remote);
UdpClientHelper echoClient (remote, 9); UdpClientHelper echoClient (remote, 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (360)); echoClient.SetAttribute ("MaxPackets", UintegerValue (360));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0))); echoClient.SetAttribute ("Interval", TimeValue (Seconds (10.0)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
clientApps.Add (echoClient.Install (stations.Get (3))); clientApps.Add (echoClient.Install (stations.Get (3)));

View file

@ -23,13 +23,15 @@ LeoPropagationLossModel::GetTypeId (void)
.AddConstructor<LeoPropagationLossModel> () .AddConstructor<LeoPropagationLossModel> ()
.AddAttribute ("MaxDistance", .AddAttribute ("MaxDistance",
"Cut-off distance for signal propagation", "Cut-off distance for signal propagation",
DoubleValue (1000000.0), DoubleValue (3000),
MakeDoubleAccessor (&LeoPropagationLossModel::m_cutoffDistance), MakeDoubleAccessor (&LeoPropagationLossModel::SetCutoffDistance,
&LeoPropagationLossModel::GetCutoffDistance),
MakeDoubleChecker<double> ()) MakeDoubleChecker<double> ())
.AddAttribute ("ElevationAngle", .AddAttribute ("ElevationAngle",
"Cut-off angle for signal propagation", "Cut-off angle for signal propagation",
DoubleValue (M_PI / 9), DoubleValue (M_PI / 9),
MakeDoubleAccessor (&LeoPropagationLossModel::m_elevationAngle), MakeDoubleAccessor (&LeoPropagationLossModel::SetElevationAngle,
&LeoPropagationLossModel::GetElevationAngle),
MakeDoubleChecker<double> ()) MakeDoubleChecker<double> ())
.AddAttribute ("AtmosphericLoss", .AddAttribute ("AtmosphericLoss",
"Atmospheric loss due to attenuation in dB", "Atmospheric loss due to attenuation in dB",
@ -71,21 +73,56 @@ LeoPropagationLossModel::GetAngle (Ptr<MobilityModel> a, Ptr<MobilityModel> b)
return acos (prod / norm); 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 double
LeoPropagationLossModel::DoCalcRxPower (double txPowerDbm, LeoPropagationLossModel::DoCalcRxPower (double txPowerDbm,
Ptr<MobilityModel> a, Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const Ptr<MobilityModel> 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_cutoffDistance<<" m_angle="<<m_elevationAngle<<" dist=" << distance << "angle=" << angle << "rxc=" << rxc);
if (distance > m_cutoffDistance)
{ {
NS_LOG_DEBUG ("LEO DROP DISTANCE: " << distance);
return -1000.0;
}
if (angle > m_elevationAngle / 2.0)
{
NS_LOG_DEBUG ("LEO DROP ANGLE: " << angle <<"; " << distance);
return -1000.0; return -1000.0;
} }
// txPowerDbm includes tx antenna gain and losses // txPowerDbm includes tx antenna gain and losses
// receiver loss and gain added at net device // receiver loss and gain added at net device
// P_{RX} = P_{TX} + G_{TX} - L_{TX} - L_{FS} - L_M + G_{RX} - L_{RX} // 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; return rxc;
} }

View file

@ -61,6 +61,12 @@ private:
* can return zero * can return zero
*/ */
virtual int64_t DoAssignStreams (int64_t stream); virtual int64_t DoAssignStreams (int64_t stream);
void SetElevationAngle (double angle);
double GetElevationAngle () const;
void SetCutoffDistance (double d);
double GetCutoffDistance () const;
}; };
} }

View file

@ -179,11 +179,6 @@ MockChannel::Deliver (
if (srcMob != 0 && dstMob != 0) if (srcMob != 0 && dstMob != 0)
{ {
// performance optimization
if (srcMob->GetDistanceFrom (dstMob) > 3.0e6)
{
return false;
}
Ptr<PropagationLossModel> pLoss = GetPropagationLoss (); Ptr<PropagationLossModel> pLoss = GetPropagationLoss ();
if (pLoss != 0) if (pLoss != 0)
{ {

View file

@ -26,6 +26,6 @@ numsamples=ARG4
do for [j=0:numsamples-1] { 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), \ 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", \ 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)
} }