Add sat and gnd node helpers

This commit is contained in:
Tim Schubert 2020-07-16 22:37:18 +02:00
parent 6c154b6d60
commit c2d69b4d03
11 changed files with 442 additions and 20 deletions

View file

@ -0,0 +1,96 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/applications-module.h"
#include "ns3/node-container.h"
#include "ns3/core-module.h"
#include "ns3/leo-module.h"
#include "ns3/test.h"
using namespace ns3;
class EmptyGndNodeHelperTestCase : public TestCase
{
public:
EmptyGndNodeHelperTestCase ();
virtual ~EmptyGndNodeHelperTestCase ();
private:
virtual void DoRun (void);
};
EmptyGndNodeHelperTestCase::EmptyGndNodeHelperTestCase ()
: TestCase ("Empty list of positions")
{
}
EmptyGndNodeHelperTestCase::~EmptyGndNodeHelperTestCase ()
{
Simulator::Destroy ();
}
void
EmptyGndNodeHelperTestCase::DoRun (void)
{
std::vector<std::string> gndWps = {};
LeoGndNodeHelper gndHelper;
NodeContainer nodes = gndHelper.Install ("contrib/leo/data/test/empty");
NS_ASSERT_MSG (nodes.GetN () == 0, "Empty position file produces non-empty node container");
}
// ------------------------------------------------------------------------- //
class SomeGndNodeHelperTestCase : public TestCase
{
public:
SomeGndNodeHelperTestCase ();
virtual ~SomeGndNodeHelperTestCase ();
private:
virtual void DoRun (void);
};
SomeGndNodeHelperTestCase::SomeGndNodeHelperTestCase ()
: TestCase ("Some ground stations")
{
}
SomeGndNodeHelperTestCase::~SomeGndNodeHelperTestCase ()
{
Simulator::Destroy ();
}
void
SomeGndNodeHelperTestCase::DoRun (void)
{
LeoGndNodeHelper gndHelper;
NodeContainer nodes = gndHelper.Install ("contrib/leo/data/test/ground-stations.txt");
NS_ASSERT_MSG (nodes.GetN () > 1, "No ground stations");
Ptr<MobilityModel> mob = nodes.Get (0)->GetObject<MobilityModel> ();
NS_ASSERT_MSG (mob != Ptr<MobilityModel> (), "Mobility model is valid");
}
class GndNodeHelperTestSuite : public TestSuite
{
public:
GndNodeHelperTestSuite ();
};
GndNodeHelperTestSuite::GndNodeHelperTestSuite ()
: TestSuite ("gnd-node-helper", UNIT)
{
// TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER
AddTestCase (new EmptyGndNodeHelperTestCase, TestCase::QUICK);
AddTestCase (new SomeGndNodeHelperTestCase, TestCase::QUICK);
}
// Do not forget to allocate an instance of this TestSuite
static GndNodeHelperTestSuite gndNodeHelperTestSuite;

View file

@ -8,7 +8,6 @@
#include "ns3/core-module.h"
#include "ns3/leo-module.h"
#include "ns3/test.h"
using namespace ns3;
@ -38,17 +37,23 @@ LeoTestCase1::DoRun (void)
{
Time::SetResolution (Time::NS);
NodeContainer satellites;
satellites.Create (100);
NodeContainer gateways;
gateways.Create (10);
NodeContainer terminals;
terminals.Create (20);
std::vector<std::string> satWps =
{
"../contrib/leo/data/starlink/45212.waypoints",
"../contrib/leo/data/starlink/45213.waypoints",
"../contrib/leo/data/starlink/45214.waypoints",
"../contrib/leo/data/starlink/45215.waypoints",
};
LeoSatNodeHelper satHelper;
NodeContainer satellites = satHelper.Install (satWps);
LeoGndNodeHelper gndHelper;
NodeContainer gateways = gndHelper.Install ("../contrib/leo/data/gateways");
NodeContainer terminals = gndHelper.Install ("../contrib/leo/data/terminals");
LeoHelper leo;
leo.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
leo.SetChannelAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel"));
leo.SetDeviceAttribute ("MobilityModel", StringValue ("ns3::WaypointMobilityModel"));
NetDeviceContainer allDevices = leo.Install (satellites, gateways, terminals);

View file

@ -0,0 +1,100 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/applications-module.h"
#include "ns3/node-container.h"
#include "ns3/core-module.h"
#include "ns3/leo-module.h"
#include "ns3/test.h"
using namespace ns3;
class EmptySatNodeHelperTestCase : public TestCase
{
public:
EmptySatNodeHelperTestCase ();
virtual ~EmptySatNodeHelperTestCase ();
private:
virtual void DoRun (void);
};
EmptySatNodeHelperTestCase::EmptySatNodeHelperTestCase ()
: TestCase ("Empty list of waypoint files")
{
}
EmptySatNodeHelperTestCase::~EmptySatNodeHelperTestCase ()
{
Simulator::Destroy ();
}
void
EmptySatNodeHelperTestCase::DoRun (void)
{
std::vector<std::string> satWps = {};
LeoSatNodeHelper satHelper;
NodeContainer satellites = satHelper.Install (satWps);
NS_ASSERT_MSG (satellites.GetN () == 0, "Empty list of waypoint files produces non-empty node container");
}
// ------------------------------------------------------------------------- //
class SingleSatNodeHelperTestCase : public TestCase
{
public:
SingleSatNodeHelperTestCase ();
virtual ~SingleSatNodeHelperTestCase ();
private:
virtual void DoRun (void);
};
SingleSatNodeHelperTestCase::SingleSatNodeHelperTestCase ()
: TestCase ("Single waypoint file")
{
}
SingleSatNodeHelperTestCase::~SingleSatNodeHelperTestCase ()
{
Simulator::Destroy ();
}
void
SingleSatNodeHelperTestCase::DoRun (void)
{
std::vector<std::string> satWps =
{
"contrib/leo/data/test/waypoints.txt"
};
LeoSatNodeHelper satHelper;
NodeContainer satellites = satHelper.Install (satWps);
NS_ASSERT_MSG (satellites.GetN () == 1, "No satellite nodes");
Ptr<MobilityModel> mob = satellites.Get (0)->GetObject<MobilityModel> ();
NS_ASSERT_MSG (mob != Ptr<MobilityModel> (), "Mobility model is valid");
}
class SatNodeHelperTestSuite : public TestSuite
{
public:
SatNodeHelperTestSuite ();
};
SatNodeHelperTestSuite::SatNodeHelperTestSuite ()
: TestSuite ("sat-node-helper", UNIT)
{
// TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER
AddTestCase (new EmptySatNodeHelperTestCase, TestCase::QUICK);
AddTestCase (new SingleSatNodeHelperTestCase, TestCase::QUICK);
}
// Do not forget to allocate an instance of this TestSuite
static SatNodeHelperTestSuite satNodeHelperTestSuite;