Create command line options for orbit trace

This commit is contained in:
Tim Schubert 2020-08-23 19:37:40 +02:00
parent f214b48dbf
commit b7f459e36a
10 changed files with 266 additions and 97 deletions

48
helper/leo-orbit-helper.h Normal file
View file

@ -0,0 +1,48 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
#ifndef LEO_ORBIT_NODE_HELPER_H
#define LEO_ORBIT_NODE_HELPER_H
#include <string>
#include "ns3/object-factory.h"
#include "ns3/node-container.h"
#include "ns3/constant-position-mobility-model.h"
/**
* \brief Builds a node container of nodes with constant positions
*
* Adds waypoints from file for each node.
*/
namespace ns3
{
class LeoGndNodeHelper
{
public:
LeoGndNodeHelper ();
virtual ~LeoGndNodeHelper ();
/**
*
* \param wpFile path to waypoint file
* \returns a node container containing nodes using the specified attributes
*/
NodeContainer Install (const std::string &wpFile);
/**
* Set an attribute for each node
*
* \param name name of the attribute
* \param value value of the attribute
*/
void SetAttribute (std::string name, const AttributeValue &value);
private:
ObjectFactory m_gndNodeFactory;
};
}; // namespace ns3
#endif

View file

@ -0,0 +1,69 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
#include <fstream>
#include "ns3/log.h"
#include "ns3/config.h"
#include "ns3/waypoint.h"
#include "ns3/mobility-helper.h"
#include "ns3/double.h"
#include "ns3/integer.h"
#include "leo-orbit-node-helper.h"
#include "../model/leo-orbit.h"
using namespace std;
namespace ns3
{
NS_LOG_COMPONENT_DEFINE ("LeoOrbitNodeHelper");
LeoOrbitNodeHelper::LeoOrbitNodeHelper ()
{
m_nodeFactory.SetTypeId ("ns3::Node");
}
LeoOrbitNodeHelper::~LeoOrbitNodeHelper ()
{
}
void
LeoOrbitNodeHelper::SetAttribute (string name, const AttributeValue &value)
{
m_nodeFactory.Set (name, value);
}
NodeContainer
LeoOrbitNodeHelper::Install (const std::string &orbitFile)
{
NS_LOG_FUNCTION (this << orbitFile);
NodeContainer nodes;
ifstream orbits;
orbits.open (orbitFile, ifstream::in);
LeoOrbit orbit;
while ((orbits >> orbit))
{
MobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::LeoCircularOrbitPostionAllocator",
"NumOrbits", IntegerValue (orbit.inc),
"NumSatellites", IntegerValue (orbit.sats));
mobility.SetMobilityModel ("ns3::LeoCircularOrbitMobilityModel",
"Altitude", DoubleValue (orbit.alt),
"Inclination", DoubleValue (orbit.inc));
NodeContainer c;
Ptr<Node> node = m_nodeFactory.Create<Node> ();
c.Add (node);
mobility.Install (c);
nodes.Add (c);
NS_LOG_DEBUG ("Added orbit plane");
}
orbits.close ();
NS_LOG_DEBUG ("Added " << nodes.GetN () << " nodes");
return nodes;
}
}; // namespace ns3

View file

@ -0,0 +1,50 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
#ifndef LEO_ORBIT_NODE_HELPER_H
#define LEO_ORBIT_NODE_HELPER_H
#include <string>
#include "ns3/object-factory.h"
#include "ns3/node-container.h"
#include "ns3/leo-circular-orbit-mobility-model.h"
#include "ns3/leo-circular-orbit-position-allocator.h"
/**
* \brief Builds a node container of nodes with LEO positions using a list of
* orbit definitions.
*
* Adds orbits with from a file for each node.
*/
namespace ns3
{
class LeoOrbitNodeHelper
{
public:
LeoOrbitNodeHelper ();
virtual ~LeoOrbitNodeHelper ();
/**
*
* \param orbitFile path to orbit definitions file
* \returns a node container containing nodes using the specified attributes
*/
NodeContainer Install (const std::string &orbitFile);
/**
* Set an attribute for each node
*
* \param name name of the attribute
* \param value value of the attribute
*/
void SetAttribute (std::string name, const AttributeValue &value);
private:
ObjectFactory m_nodeFactory;
};
}; // namespace ns3
#endif