mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 01:53:58 +02:00
Make examples runable as tests
This commit is contained in:
parent
fccc05f6c2
commit
3f4ba0a8c1
5 changed files with 107 additions and 26 deletions
|
@ -22,7 +22,7 @@ int main(int argc, char *argv[])
|
|||
CommandLine cmd;
|
||||
std::string orbitFile;
|
||||
std::string traceFile;
|
||||
double duration;
|
||||
double duration = 60;
|
||||
cmd.AddValue("orbitFile", "CSV file with orbit parameters", orbitFile);
|
||||
cmd.AddValue("traceFile", "CSV file to store mobility trace in", traceFile);
|
||||
cmd.AddValue("precision", "ns3::LeoCircularOrbitMobilityModel::Precision");
|
||||
|
@ -30,7 +30,16 @@ int main(int argc, char *argv[])
|
|||
cmd.Parse (argc, argv);
|
||||
|
||||
LeoOrbitNodeHelper orbit;
|
||||
NodeContainer satellites = orbit.Install (orbitFile);
|
||||
NodeContainer satellites;
|
||||
if (orbitFile.empty())
|
||||
{
|
||||
satellites = orbit.Install (orbitFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
satellites = orbit.Install ({ LeoOrbit (1200, 20, 32, 16),
|
||||
LeoOrbit (1180, 30, 12, 10) });
|
||||
}
|
||||
|
||||
Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
|
||||
MakeCallback (&CourseChange));
|
||||
|
|
|
@ -74,18 +74,18 @@ int main (int argc, char *argv[])
|
|||
CommandLine cmd;
|
||||
std::string orbitFile;
|
||||
std::string traceFile;
|
||||
LeoLatLong source;
|
||||
LeoLatLong destination;
|
||||
std::string islRate;
|
||||
std::string constellation;
|
||||
LeoLatLong source (51.84, 10.28);
|
||||
LeoLatLong destination (40.76, -73.96);
|
||||
std::string islRate = "2Gbps";
|
||||
std::string constellation = "TelesatGateway";
|
||||
uint32_t latGws = 20;
|
||||
uint32_t lonGws = 20;
|
||||
double interval;
|
||||
double duration;
|
||||
bool islEnabled = false;
|
||||
bool traceDrops = false;
|
||||
bool traceTxRx = false;
|
||||
bool traceFwd = false;
|
||||
double interval = 1;
|
||||
double duration = 100;
|
||||
bool islEnabled = true;
|
||||
bool traceDrops = true;
|
||||
bool traceTxRx = true;
|
||||
bool traceFwd = true;
|
||||
std::string routingProto = "aodv";
|
||||
cmd.AddValue("orbitFile", "CSV file with orbit parameters", orbitFile);
|
||||
cmd.AddValue("traceFile", "CSV file to store mobility trace in", traceFile);
|
||||
|
@ -117,7 +117,16 @@ int main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
LeoOrbitNodeHelper orbit;
|
||||
NodeContainer satellites = orbit.Install (orbitFile);
|
||||
NodeContainer satellites;
|
||||
if (orbitFile.empty())
|
||||
{
|
||||
satellites = orbit.Install (orbitFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
satellites = orbit.Install ({ LeoOrbit (1200, 20, 32, 16),
|
||||
LeoOrbit (1180, 30, 12, 10) });
|
||||
}
|
||||
|
||||
LeoGndNodeHelper ground;
|
||||
NodeContainer stations = ground.Install (latGws, lonGws);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/config.h"
|
||||
|
@ -10,7 +11,6 @@
|
|||
#include "ns3/integer.h"
|
||||
|
||||
#include "leo-orbit-node-helper.h"
|
||||
#include "../model/leo-orbit.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -33,6 +33,26 @@ LeoOrbitNodeHelper::SetAttribute (string name, const AttributeValue &value)
|
|||
m_nodeFactory.Set (name, value);
|
||||
}
|
||||
|
||||
NodeContainer
|
||||
LeoOrbitNodeHelper::Install (const LeoOrbit &orbit)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << orbit);
|
||||
|
||||
MobilityHelper mobility;
|
||||
mobility.SetPositionAllocator ("ns3::LeoCircularOrbitPostionAllocator",
|
||||
"NumOrbits", IntegerValue (orbit.planes),
|
||||
"NumSatellites", IntegerValue (orbit.sats));
|
||||
mobility.SetMobilityModel ("ns3::LeoCircularOrbitMobilityModel",
|
||||
"Altitude", DoubleValue (orbit.alt),
|
||||
"Inclination", DoubleValue (orbit.inc));
|
||||
|
||||
NodeContainer c;
|
||||
c.Create (orbit.sats*orbit.planes);
|
||||
mobility.Install (c);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
NodeContainer
|
||||
LeoOrbitNodeHelper::Install (const std::string &orbitFile)
|
||||
{
|
||||
|
@ -44,18 +64,7 @@ LeoOrbitNodeHelper::Install (const std::string &orbitFile)
|
|||
LeoOrbit orbit;
|
||||
while ((orbits >> orbit))
|
||||
{
|
||||
MobilityHelper mobility;
|
||||
mobility.SetPositionAllocator ("ns3::LeoCircularOrbitPostionAllocator",
|
||||
"NumOrbits", IntegerValue (orbit.planes),
|
||||
"NumSatellites", IntegerValue (orbit.sats));
|
||||
mobility.SetMobilityModel ("ns3::LeoCircularOrbitMobilityModel",
|
||||
"Altitude", DoubleValue (orbit.alt),
|
||||
"Inclination", DoubleValue (orbit.inc));
|
||||
|
||||
NodeContainer c;
|
||||
c.Create (orbit.sats*orbit.planes);
|
||||
mobility.Install (c);
|
||||
nodes.Add (c);
|
||||
nodes.Add (Install (orbit));
|
||||
NS_LOG_DEBUG ("Added orbit plane");
|
||||
}
|
||||
orbits.close ();
|
||||
|
@ -65,4 +74,21 @@ LeoOrbitNodeHelper::Install (const std::string &orbitFile)
|
|||
return nodes;
|
||||
}
|
||||
|
||||
NodeContainer
|
||||
LeoOrbitNodeHelper::Install (const vector<LeoOrbit> &orbits)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << orbits);
|
||||
|
||||
NodeContainer nodes;
|
||||
for (uint64_t i = 0; i < orbits.size(); i++)
|
||||
{
|
||||
nodes.Add (Install (orbits[i]));
|
||||
NS_LOG_DEBUG ("Added orbit plane");
|
||||
}
|
||||
|
||||
NS_LOG_DEBUG ("Added " << nodes.GetN () << " nodes");
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "ns3/node-container.h"
|
||||
#include "ns3/leo-circular-orbit-mobility-model.h"
|
||||
#include "ns3/leo-circular-orbit-position-allocator.h"
|
||||
#include "ns3/leo-orbit.h"
|
||||
|
||||
/**
|
||||
* \brief Builds a node container of nodes with LEO positions using a list of
|
||||
|
@ -33,6 +34,20 @@ public:
|
|||
*/
|
||||
NodeContainer Install (const std::string &orbitFile);
|
||||
|
||||
/**
|
||||
*
|
||||
* \param orbits orbit definitions
|
||||
* \returns a node container containing nodes using the specified attributes
|
||||
*/
|
||||
NodeContainer Install (const std::vector<LeoOrbit> &orbits);
|
||||
|
||||
/**
|
||||
*
|
||||
* \param orbit orbit definition
|
||||
* \returns a node container containing nodes using the specified attributes
|
||||
*/
|
||||
NodeContainer Install (const LeoOrbit &orbit);
|
||||
|
||||
/**
|
||||
* Set an attribute for each node
|
||||
*
|
||||
|
|
22
test/examples-to-run.py
Normal file
22
test/examples-to-run.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
#! /usr/bin/env python3
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
# A list of C++ examples to run in order to ensure that they remain
|
||||
# buildable and runnable over time. Each tuple in the list contains
|
||||
#
|
||||
# (example_name, do_run, do_valgrind_run).
|
||||
#
|
||||
# See test.py for more information.
|
||||
cpp_examples = [
|
||||
("leo-orbit", "True", "True"),
|
||||
("leo-delay", "True", "True"),
|
||||
("leo-bulk-send", "True", "True"),
|
||||
]
|
||||
|
||||
# A list of Python examples to run in order to ensure that they remain
|
||||
# runnable over time. Each tuple in the list contains
|
||||
#
|
||||
# (example_name, do_run).
|
||||
#
|
||||
# See test.py for more information.
|
||||
python_examples = []
|
Loading…
Add table
Add a link
Reference in a new issue