Add lat long conversion

This commit is contained in:
Tim Schubert 2020-08-23 21:25:54 +02:00
parent b7f459e36a
commit 70c70a19ce
8 changed files with 171 additions and 16 deletions

View file

@ -26,28 +26,59 @@ int main (int argc, char *argv[])
CommandLine cmd;
std::string orbitFile;
std::string groundFile;
std::string traceFile;
LeoLatLong source;
LeoLatLong destination;
std::string islRate;
std::string constellation;
Time interval;
Time duration;
cmd.AddValue("orbitFile", "CSV file with orbit parameters", orbitFile);
cmd.AddValue("traceFile", "CSV file to store mobility trace in", traceFile);
// TODO write position allocator for long,lat
cmd.AddValue("groundFile", "CSV file with ground station locations", orbitFile);
cmd.AddValue("precision", "ns3::LeoCircularOrbitMobilityModel");
cmd.AddValue("groundFile", "CSV file with ground station locations", groundFile);
cmd.AddValue("precision", "ns3::LeoCircularOrbitMobilityModel::Precision");
cmd.AddValue("duration", "Duration of the simulation", duration);
// TODO LeoLatLong
cmd.AddValue("source", "Traffic source", source);
cmd.AddValue("destination", "Traffic destination", destination);
cmd.AddValue("islRate", "Throughput of the ISL link", islRate);
cmd.AddValue("constellation", "LEO constellation link settings name", constellation);
cmd.AddValue("interval", "Echo interval", interval);
cmd.Parse (argc, argv);
std::streambuf *coutbuf = std::cout.rdbuf();
// redirect cout if traceFile
std::ofstream out;
out.open (traceFile);
if (out.is_open ())
{
std::cout.rdbuf(out.rdbuf());
}
LeoOrbitNodeHelper orbit;
NodeContainer satellites = orbit.Install (orbitFile);
LeoGndNodeHelper ground;
NodeContainer stations = ground.Install ("contrib/leo/data/ground-stations/usa-60.waypoints");
NodeContainer stations = ground.Install (groundFile);
NodeContainer users = ground.Install (source, destination);
stations.Add (users);
// TODO create source and sink with ConstantPosition MobilityHelper
Ptr<Node> client = users.Get (0);
Ptr<Node> server = users.Get (1);
NetDeviceContainer islNet, utNet;
IslHelper islCh;
islCh.SetDeviceAttribute ("DataRate", StringValue ("1Gbps"));
islCh.SetDeviceAttribute ("DataRate", StringValue (islRate));
islCh.SetChannelAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel"));
islCh.SetChannelAttribute ("PropagationLoss", StringValue ("ns3::IslPropagationLossModel"));
islNet = islCh.Install (satellites);
LeoChannelHelper utCh;
utCh.SetConstellation ("StarlinkUser");
utCh.SetConstellation (constellation);
utNet = utCh.Install (satellites, stations);
// Install internet stack on nodes
@ -67,9 +98,6 @@ int main (int argc, char *argv[])
ipv4.SetBase ("10.3.0.0", "255.255.0.0");
Ipv4InterfaceContainer utIp = ipv4.Assign (utNet);
Ptr<Node> client = stations.Get (0);
Ptr<Node> server = stations.Get (1);
// we want to ping terminals
UdpServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (server);
@ -78,8 +106,8 @@ int main (int argc, char *argv[])
ApplicationContainer clientApps;
Address remote = server->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();
UdpClientHelper echoClient (remote, 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (6000));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1)));
echoClient.SetAttribute ("MaxPackets", UintegerValue (duration.GetDouble ()/interval.GetDouble ()));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (interval)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
clientApps.Add (echoClient.Install (client));
@ -91,10 +119,10 @@ int main (int argc, char *argv[])
std::cout << "Context,Sequence Number,Timestamp,Delay" << std::endl;
serverApps.Start (Seconds (1));
clientApps.Start (Seconds (1));
//serverApps.Start (Seconds (1));
//clientApps.Start (Seconds (1));
Simulator::Stop (Minutes (10));
Simulator::Stop (duration);
Simulator::Run ();
Simulator::Destroy ();
@ -102,5 +130,8 @@ int main (int argc, char *argv[])
std::cout << "Received,Lost" << std::endl
<< result->GetReceived () << "," << result->GetLost () << std::endl;
out.close ();
std::cout.rdbuf(coutbuf);
return 0;
}