mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 10:03:58 +02:00
Fix angle and delay computation
This commit is contained in:
parent
98468c4857
commit
6a31de4a0e
3 changed files with 40 additions and 23 deletions
|
@ -58,7 +58,7 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
LeoGndNodeHelper ground;
|
LeoGndNodeHelper ground;
|
||||||
NodeContainer stations = ground.Install ("contrib/leo/data/ground-stations/usa.waypoints");
|
NodeContainer stations = ground.Install ("contrib/leo/data/ground-stations/usa-60.waypoints");
|
||||||
|
|
||||||
NetDeviceContainer islNet, utNet;
|
NetDeviceContainer islNet, utNet;
|
||||||
|
|
||||||
|
@ -75,15 +75,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 (Minutes (1)));
|
//aodv.Set ("HelloInterval", TimeValue (Minutes (1)));
|
||||||
aodv.Set ("TtlStart", UintegerValue (5));
|
//aodv.Set ("TtlStart", UintegerValue (2));
|
||||||
aodv.Set ("TtlIncrement", UintegerValue (5));
|
//aodv.Set ("TtlIncrement", UintegerValue (1));
|
||||||
aodv.Set ("TtlThreshold", UintegerValue (200));
|
//aodv.Set ("TtlThreshold", UintegerValue (20));
|
||||||
aodv.Set ("RreqRetries", UintegerValue (1000));
|
//aodv.Set ("RreqRetries", UintegerValue (1000));
|
||||||
aodv.Set ("RreqRateLimit", UintegerValue (100));
|
//aodv.Set ("RreqRateLimit", UintegerValue (1));
|
||||||
//aodv.Set ("RerrRateLimit", UintegerValue (1));
|
//aodv.Set ("RerrRateLimit", UintegerValue (1));
|
||||||
//aodv.Set ("ActiveRouteTimeout", TimeValue (Minutes (1)));
|
//aodv.Set ("ActiveRouteTimeout", TimeValue (Minutes (1)));
|
||||||
//aodv.Set ("NextHopWait", TimeValue (MilliSeconds (200)));
|
//aodv.Set ("NextHopWait", TimeValue (MilliSeconds (200)));
|
||||||
aodv.Set ("NetDiameter", UintegerValue (100));
|
//aodv.Set ("NetDiameter", UintegerValue (300));
|
||||||
//aodv.Set ("AllowedHelloLoss", UintegerValue (10000));
|
//aodv.Set ("AllowedHelloLoss", UintegerValue (10000));
|
||||||
//aodv.Set ("PathDiscoveryTime", TimeValue (Seconds (1)));
|
//aodv.Set ("PathDiscoveryTime", TimeValue (Seconds (1)));
|
||||||
|
|
||||||
|
@ -99,23 +99,28 @@ int main (int argc, char *argv[])
|
||||||
ipv4.SetBase ("10.3.0.0", "255.255.0.0");
|
ipv4.SetBase ("10.3.0.0", "255.255.0.0");
|
||||||
Ipv4InterfaceContainer utIp = ipv4.Assign (utNet);
|
Ipv4InterfaceContainer utIp = ipv4.Assign (utNet);
|
||||||
|
|
||||||
|
Ptr<Node> client = stations.Get (0);
|
||||||
|
Ptr<Node> server = stations.Get (1);
|
||||||
|
|
||||||
// we want to ping terminals
|
// we want to ping terminals
|
||||||
UdpServerHelper echoServer (9);
|
UdpServerHelper echoServer (9);
|
||||||
ApplicationContainer serverApps = echoServer.Install (stations.Get (100));
|
ApplicationContainer serverApps = echoServer.Install (server);
|
||||||
|
|
||||||
// install a client on one of the terminals
|
// install a client on one of the terminals
|
||||||
ApplicationContainer clientApps;
|
ApplicationContainer clientApps;
|
||||||
Address remote = stations.Get (100)->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();//utIp.GetAddress (1, 0);
|
Address remote = server->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();
|
||||||
std::cout << "REMOTE=" << Ipv4Address::ConvertFrom (remote);
|
|
||||||
UdpClientHelper echoClient (remote, 9);
|
UdpClientHelper echoClient (remote, 9);
|
||||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (60));
|
echoClient.SetAttribute ("MaxPackets", UintegerValue (60));
|
||||||
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1)));
|
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1)));
|
||||||
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
||||||
clientApps.Add (echoClient.Install (stations.Get (103)));
|
clientApps.Add (echoClient.Install (client));
|
||||||
|
|
||||||
Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::UdpServer/Rx",
|
Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::UdpServer/Rx",
|
||||||
MakeCallback (&EchoRx));
|
MakeCallback (&EchoRx));
|
||||||
|
|
||||||
|
std::cout << "LOCAL =" << client->GetId () << std::endl;
|
||||||
|
std::cout << "REMOTE=" << server->GetId () << std::endl;
|
||||||
|
|
||||||
std::cout << "Context,Sequence Number,Timestamp,Delay" << std::endl;
|
std::cout << "Context,Sequence Number,Timestamp,Delay" << std::endl;
|
||||||
|
|
||||||
serverApps.Start (Seconds (1));
|
serverApps.Start (Seconds (1));
|
||||||
|
@ -127,9 +132,9 @@ int main (int argc, char *argv[])
|
||||||
Simulator::Run ();
|
Simulator::Run ();
|
||||||
Simulator::Destroy ();
|
Simulator::Destroy ();
|
||||||
|
|
||||||
Ptr<UdpServer> server = StaticCast<UdpServer> (serverApps.Get (0));
|
Ptr<UdpServer> result = StaticCast<UdpServer> (serverApps.Get (0));
|
||||||
std::cout << "Received,Lost" << std::endl
|
std::cout << "Received,Lost" << std::endl
|
||||||
<< server->GetReceived () << "," << server->GetLost () << std::endl;
|
<< result->GetReceived () << "," << result->GetLost () << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,13 @@ LeoPropagationLossModel::GetTypeId (void)
|
||||||
.AddConstructor<LeoPropagationLossModel> ()
|
.AddConstructor<LeoPropagationLossModel> ()
|
||||||
.AddAttribute ("MaxDistance",
|
.AddAttribute ("MaxDistance",
|
||||||
"Cut-off distance for signal propagation",
|
"Cut-off distance for signal propagation",
|
||||||
DoubleValue (3000),
|
DoubleValue (4000.0),
|
||||||
MakeDoubleAccessor (&LeoPropagationLossModel::SetCutoffDistance,
|
MakeDoubleAccessor (&LeoPropagationLossModel::SetCutoffDistance,
|
||||||
&LeoPropagationLossModel::GetCutoffDistance),
|
&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 (40.0),
|
||||||
MakeDoubleAccessor (&LeoPropagationLossModel::SetElevationAngle,
|
MakeDoubleAccessor (&LeoPropagationLossModel::SetElevationAngle,
|
||||||
&LeoPropagationLossModel::GetElevationAngle),
|
&LeoPropagationLossModel::GetElevationAngle),
|
||||||
MakeDoubleChecker<double> ())
|
MakeDoubleChecker<double> ())
|
||||||
|
@ -63,12 +63,23 @@ LeoPropagationLossModel::~LeoPropagationLossModel ()
|
||||||
double
|
double
|
||||||
LeoPropagationLossModel::GetAngle (Ptr<MobilityModel> a, Ptr<MobilityModel> b)
|
LeoPropagationLossModel::GetAngle (Ptr<MobilityModel> a, Ptr<MobilityModel> b)
|
||||||
{
|
{
|
||||||
Vector3D pa = a->GetPosition () - b->GetPosition ();
|
Vector3D x = a->GetPosition ();
|
||||||
Vector3D pb = b->GetPosition ();
|
Vector3D y = b->GetPosition ();
|
||||||
pb = Vector3D (-pb.x, -pb.y, -pb.z);
|
|
||||||
|
|
||||||
double prod = abs ((pa.x * pb.x) + (pa.y * pb.y) + (pa.z * pb.z));
|
Vector3D pa, pb;
|
||||||
double norm = pb.GetLength () * pa.GetLength ();
|
if (x.GetLength () < y.GetLength ())
|
||||||
|
{
|
||||||
|
pa = x - y;
|
||||||
|
pb = y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pa = y - x;
|
||||||
|
pb = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
double prod = (pa.x*-pb.x) + (pa.y*-pb.y) + (pa.z*-pb.z);
|
||||||
|
double norm = pa.GetLength () * pb.GetLength ();
|
||||||
|
|
||||||
return acos (prod / norm);
|
return acos (prod / norm);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +133,7 @@ LeoPropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
||||||
// 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;
|
double rxc = txPowerDbm - m_atmosphericLoss - m_freeSpacePathLoss - m_linkMargin;
|
||||||
NS_LOG_INFO ("LEO TRANSMIT: angle=" << angle <<";distance=" << distance << ";rxc=" << rxc);
|
NS_LOG_DEBUG ("LEO TRANSMIT: angle=" << angle <<";distance=" << distance << ";rxc=" << rxc);
|
||||||
|
|
||||||
return rxc;
|
return rxc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,12 +184,13 @@ MockChannel::Deliver (
|
||||||
{
|
{
|
||||||
// check if signal reaches destination
|
// check if signal reaches destination
|
||||||
rxPower = pLoss->CalcRxPower (txPower, srcMob, dstMob);
|
rxPower = pLoss->CalcRxPower (txPower, srcMob, dstMob);
|
||||||
if (rxPower == -1000.0)
|
if (rxPower <= -1000.0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay += GetPropagationDelay (srcMob, dstMob, txTime);
|
delay = GetPropagationDelay (srcMob, dstMob, txTime);
|
||||||
|
NS_LOG_DEBUG ("delay = "<<delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
Simulator::ScheduleWithContext (dst->GetNode ()->GetId (),
|
Simulator::ScheduleWithContext (dst->GetNode ()->GetId (),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue