mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 10:03:58 +02:00
Add lat long conversion
This commit is contained in:
parent
b7f459e36a
commit
70c70a19ce
8 changed files with 171 additions and 16 deletions
|
@ -155,8 +155,8 @@ given as pairs of longitude and latitude.
|
||||||
--orbitsFile=orbits.csv \
|
--orbitsFile=orbits.csv \
|
||||||
--groundFile=ground-stations.csv \
|
--groundFile=ground-stations.csv \
|
||||||
--traceFile=delay-trace.csv \
|
--traceFile=delay-trace.csv \
|
||||||
--source=54.4,77.1 \
|
--source=54.4:77.1 \
|
||||||
--destination=-10.0,25.8 \
|
--destination=-10.0:25.8 \
|
||||||
--islRate=1Gbps \
|
--islRate=1Gbps \
|
||||||
--constellation="StarlinkGateway" \
|
--constellation="StarlinkGateway" \
|
||||||
--duration=10.0 \
|
--duration=10.0 \
|
||||||
|
|
|
@ -26,28 +26,59 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
CommandLine cmd;
|
CommandLine cmd;
|
||||||
std::string orbitFile;
|
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("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
|
// TODO write position allocator for long,lat
|
||||||
cmd.AddValue("groundFile", "CSV file with ground station locations", orbitFile);
|
cmd.AddValue("groundFile", "CSV file with ground station locations", groundFile);
|
||||||
cmd.AddValue("precision", "ns3::LeoCircularOrbitMobilityModel");
|
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);
|
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;
|
LeoOrbitNodeHelper orbit;
|
||||||
NodeContainer satellites = orbit.Install (orbitFile);
|
NodeContainer satellites = orbit.Install (orbitFile);
|
||||||
|
|
||||||
LeoGndNodeHelper ground;
|
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;
|
NetDeviceContainer islNet, utNet;
|
||||||
|
|
||||||
IslHelper islCh;
|
IslHelper islCh;
|
||||||
islCh.SetDeviceAttribute ("DataRate", StringValue ("1Gbps"));
|
islCh.SetDeviceAttribute ("DataRate", StringValue (islRate));
|
||||||
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);
|
||||||
|
|
||||||
LeoChannelHelper utCh;
|
LeoChannelHelper utCh;
|
||||||
utCh.SetConstellation ("StarlinkUser");
|
utCh.SetConstellation (constellation);
|
||||||
utNet = utCh.Install (satellites, stations);
|
utNet = utCh.Install (satellites, stations);
|
||||||
|
|
||||||
// Install internet stack on nodes
|
// 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");
|
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 (server);
|
ApplicationContainer serverApps = echoServer.Install (server);
|
||||||
|
@ -78,8 +106,8 @@ int main (int argc, char *argv[])
|
||||||
ApplicationContainer clientApps;
|
ApplicationContainer clientApps;
|
||||||
Address remote = server->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();
|
Address remote = server->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();
|
||||||
UdpClientHelper echoClient (remote, 9);
|
UdpClientHelper echoClient (remote, 9);
|
||||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (6000));
|
echoClient.SetAttribute ("MaxPackets", UintegerValue (duration.GetDouble ()/interval.GetDouble ()));
|
||||||
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1)));
|
echoClient.SetAttribute ("Interval", TimeValue (Seconds (interval)));
|
||||||
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
||||||
clientApps.Add (echoClient.Install (client));
|
clientApps.Add (echoClient.Install (client));
|
||||||
|
|
||||||
|
@ -91,10 +119,10 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
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));
|
||||||
clientApps.Start (Seconds (1));
|
//clientApps.Start (Seconds (1));
|
||||||
|
|
||||||
Simulator::Stop (Minutes (10));
|
Simulator::Stop (duration);
|
||||||
Simulator::Run ();
|
Simulator::Run ();
|
||||||
Simulator::Destroy ();
|
Simulator::Destroy ();
|
||||||
|
|
||||||
|
@ -102,5 +130,8 @@ int main (int argc, char *argv[])
|
||||||
std::cout << "Received,Lost" << std::endl
|
std::cout << "Received,Lost" << std::endl
|
||||||
<< result->GetReceived () << "," << result->GetLost () << std::endl;
|
<< result->GetReceived () << "," << result->GetLost () << std::endl;
|
||||||
|
|
||||||
|
out.close ();
|
||||||
|
std::cout.rdbuf(coutbuf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
#include "math.h"
|
||||||
|
|
||||||
#include "ns3/log.h"
|
#include "ns3/log.h"
|
||||||
#include "ns3/config.h"
|
#include "ns3/config.h"
|
||||||
#include "ns3/waypoint.h"
|
#include "ns3/waypoint.h"
|
||||||
|
@ -52,4 +54,39 @@ LeoGndNodeHelper::Install (const std::string &wpFile)
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector3D
|
||||||
|
LeoGndNodeHelper::GetEarthPosition (const LeoLatLong &loc)
|
||||||
|
{
|
||||||
|
double lat = loc.latitude * (M_PI / 90);
|
||||||
|
double lon = loc.longitude * (M_PI / 180);
|
||||||
|
Vector3D pos = Vector3D (LEO_GND_RAD_EARTH * sin (lat) * cos (lon),
|
||||||
|
LEO_GND_RAD_EARTH * sin (lat) * sin (lon),
|
||||||
|
LEO_GND_RAD_EARTH * cos (lat));
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeContainer
|
||||||
|
LeoGndNodeHelper::Install (const LeoLatLong &location1,
|
||||||
|
const LeoLatLong &location2)
|
||||||
|
{
|
||||||
|
NS_LOG_FUNCTION (this << location1 << location2);
|
||||||
|
|
||||||
|
NodeContainer nodes;
|
||||||
|
|
||||||
|
for (const LeoLatLong loc : { location1, location2 })
|
||||||
|
{
|
||||||
|
Vector pos = GetEarthPosition (loc);
|
||||||
|
Ptr<ConstantPositionMobilityModel> mob = CreateObject<ConstantPositionMobilityModel> ();
|
||||||
|
mob->SetPosition (pos);
|
||||||
|
Ptr<Node> node = m_gndNodeFactory.Create<Node> ();
|
||||||
|
node->AggregateObject (mob);
|
||||||
|
nodes.Add (node);
|
||||||
|
NS_LOG_INFO ("Added ground node at " << pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_LOG_INFO ("Added " << nodes.GetN () << " ground nodes");
|
||||||
|
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
|
||||||
}; // namespace ns3
|
}; // namespace ns3
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
#include "ns3/object-factory.h"
|
#include "ns3/object-factory.h"
|
||||||
#include "ns3/node-container.h"
|
#include "ns3/node-container.h"
|
||||||
#include "ns3/constant-position-mobility-model.h"
|
#include "ns3/constant-position-mobility-model.h"
|
||||||
|
#include "ns3/leo-lat-long.h"
|
||||||
|
|
||||||
|
#define LEO_GND_RAD_EARTH 6.371e6
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Builds a node container of nodes with constant positions
|
* \brief Builds a node container of nodes with constant positions
|
||||||
|
@ -31,6 +34,15 @@ public:
|
||||||
*/
|
*/
|
||||||
NodeContainer Install (const std::string &wpFile);
|
NodeContainer Install (const std::string &wpFile);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* \param location1 first location
|
||||||
|
* \param location2 second location
|
||||||
|
* \returns a node container containing nodes using the specified attributes
|
||||||
|
*/
|
||||||
|
NodeContainer Install (const LeoLatLong &location1,
|
||||||
|
const LeoLatLong &location2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set an attribute for each node
|
* Set an attribute for each node
|
||||||
*
|
*
|
||||||
|
@ -41,6 +53,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ObjectFactory m_gndNodeFactory;
|
ObjectFactory m_gndNodeFactory;
|
||||||
|
|
||||||
|
static Vector3D GetEarthPosition (const LeoLatLong &loc);
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace ns3
|
}; // namespace ns3
|
||||||
|
|
28
model/leo-lat-long.cc
Normal file
28
model/leo-lat-long.cc
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||||
|
|
||||||
|
#include "leo-lat-long.h"
|
||||||
|
|
||||||
|
namespace ns3 {
|
||||||
|
|
||||||
|
std::ostream &operator << (std::ostream &os, const LeoLatLong &l)
|
||||||
|
{
|
||||||
|
os << l.latitude << ":" << l.longitude;
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::istream &operator >> (std::istream &is, LeoLatLong &l)
|
||||||
|
{
|
||||||
|
char c1;
|
||||||
|
is >> l.latitude >> c1 >> l.longitude;
|
||||||
|
if (c1 != ':')
|
||||||
|
{
|
||||||
|
is.setstate (std::ios_base::failbit);
|
||||||
|
}
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
LeoLatLong::LeoLatLong () : latitude (0), longitude (0) {}
|
||||||
|
LeoLatLong::LeoLatLong (double la, double lo) : latitude (la), longitude (lo) {}
|
||||||
|
LeoLatLong::~LeoLatLong () {}
|
||||||
|
|
||||||
|
};
|
26
model/leo-lat-long.h
Normal file
26
model/leo-lat-long.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||||
|
|
||||||
|
#ifndef LEO_LAT_LONG_H
|
||||||
|
#define LEO_LAT_LONG_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace ns3 {
|
||||||
|
|
||||||
|
class LeoLatLong
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LeoLatLong ();
|
||||||
|
LeoLatLong (double latitude, double longitude);
|
||||||
|
virtual ~LeoLatLong();
|
||||||
|
|
||||||
|
double latitude;
|
||||||
|
double longitude;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::ostream &operator << (std::ostream &os, const LeoLatLong &latLong);
|
||||||
|
std::istream &operator >> (std::istream &is, LeoLatLong &latLong);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
17
model/orbit.h
Normal file
17
model/orbit.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||||
|
|
||||||
|
#ifndef LEO_ORBIT_H
|
||||||
|
#define LEO_ORBIT_H
|
||||||
|
|
||||||
|
#include "ns3/uinteger.h"
|
||||||
|
|
||||||
|
class Orbit {
|
||||||
|
public:
|
||||||
|
Orbit (double a, double i, double p, double s) : alt (a), inc (i), planes (p), sats (s) {}
|
||||||
|
double alt;
|
||||||
|
double inc;
|
||||||
|
uint16_t planes;
|
||||||
|
uint16_t sats;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
4
wscript
4
wscript
|
@ -22,6 +22,7 @@ def build(bld):
|
||||||
'model/leo-mock-channel.cc',
|
'model/leo-mock-channel.cc',
|
||||||
'model/leo-mock-net-device.cc',
|
'model/leo-mock-net-device.cc',
|
||||||
'model/leo-orbit.cc',
|
'model/leo-orbit.cc',
|
||||||
|
'model/leo-lat-long.cc',
|
||||||
'model/leo-propagation-loss-model.cc',
|
'model/leo-propagation-loss-model.cc',
|
||||||
'model/mock-net-device.cc',
|
'model/mock-net-device.cc',
|
||||||
'model/mock-channel.cc',
|
'model/mock-channel.cc',
|
||||||
|
@ -63,6 +64,8 @@ def build(bld):
|
||||||
'model/leo-mock-channel.h',
|
'model/leo-mock-channel.h',
|
||||||
'model/leo-mock-net-device.h',
|
'model/leo-mock-net-device.h',
|
||||||
'model/leo-oneweb-constants.h',
|
'model/leo-oneweb-constants.h',
|
||||||
|
'model/leo-orbit.h',
|
||||||
|
'model/leo-lat-long.h',
|
||||||
'model/leo-propagation-loss-model.h',
|
'model/leo-propagation-loss-model.h',
|
||||||
'model/leo-starlink-constants.h',
|
'model/leo-starlink-constants.h',
|
||||||
'model/leo-telesat-constants.h',
|
'model/leo-telesat-constants.h',
|
||||||
|
@ -70,7 +73,6 @@ def build(bld):
|
||||||
'model/mock-channel.h',
|
'model/mock-channel.h',
|
||||||
'model/isl-mock-channel.h',
|
'model/isl-mock-channel.h',
|
||||||
'model/isl-propagation-loss-model.h',
|
'model/isl-propagation-loss-model.h',
|
||||||
'model/leo-orbit.h',
|
|
||||||
'utils/leo-input-fstream-container.h',
|
'utils/leo-input-fstream-container.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue