51#include "ns3/buildings-module.h"
52#include "ns3/core-module.h"
53#include "ns3/network-module.h"
54#include <ns3/mobility-module.h>
82 NS_LOG_LOGIC(
"Node: " << node->GetId() <<
" Position: " << model->GetPosition());
84 << model->GetPosition() << std::endl;
95 std::ofstream outFile;
96 outFile.open(filename, std::ios_base::out | std::ios_base::trunc);
97 if (!outFile.is_open())
106 Box box = (*it)->GetBoundaries();
107 outFile <<
"set object " << index <<
" rect from " << box.
xMin <<
"," << box.
yMin <<
" to "
108 << box.
xMax <<
"," << box.
yMax << std::endl;
113main(
int argc,
char* argv[])
117 bool useHelper =
false;
120 cmd.AddValue(
"useHelper",
"Whether to use helper code", useHelper);
121 cmd.Parse(argc, argv);
123 g_timeSeries.open(
"outdoor-group-mobility-time-series.mob");
146 std::vector<Ptr<Building>> buildingVector;
148 building->SetBoundaries(
Box(45, 55, 5, 15, 0, 10));
149 buildingVector.push_back(building);
151 building->SetBoundaries(
Box(45, 55, 35, 45, 0, 10));
152 buildingVector.push_back(building);
154 building->SetBoundaries(
Box(17.5, 22.5, 22.5, 27.5, 0, 10));
155 buildingVector.push_back(building);
157 building->SetBoundaries(
Box(77.5, 82.5, 22.5, 27.5, 0, 10));
158 buildingVector.push_back(building);
167 int64_t streamIndex = 1;
183 outdoorMm->SetAttribute(
"Tolerance",
DoubleValue(2));
185 outdoorMm->SetPosition(Vector(10, 10, 0));
186 streamIndex += outdoorMm->AssignStreams(streamIndex);
194 hierarchical0->SetParent(outdoorMm);
198 child0->SetPosition(Vector(1, 0, 0));
201 hierarchical0->SetChild(child0);
206 hierarchical1->SetParent(outdoorMm);
208 child1->SetPosition(Vector(-1, 0, 0));
209 hierarchical1->SetChild(child1);
212 hierarchical2->SetParent(outdoorMm);
214 child2->SetPosition(Vector(0, 1, 0));
215 hierarchical2->SetChild(child2);
234 listPosition->Add(Vector(10, 10, 0));
239 listPosition->Add(Vector(1, 0, 0));
240 listPosition->Add(Vector(-1, 0, 0));
241 listPosition->Add(Vector(0, 1, 0));
257 for (
unsigned int i = 0; i < numPrints; i++)
259 for (
auto nodeIt = n.
Begin(); nodeIt != n.
End(); ++nodeIt)
Manage ASCII trace files for device models.
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
double yMax
The y coordinate of the top bound of the box.
double xMin
The x coordinate of the left bound of the box.
double yMin
The y coordinate of the bottom bound of the box.
double xMax
The x coordinate of the right bound of the box.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Helper class used to assign positions and mobility models to nodes for a group mobility configuration...
void SetMemberMobilityModel(std::string type, Ts &&... args)
Configure the mobility model which will be installed as the member (child) mobility model during Grou...
int64_t AssignStreams(NodeContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the mobility models on t...
void SetMemberPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of the member mobility...
void Install(Ptr< Node > node)
Install and configure a hierarchical mobility model to the given node, based on the configured refere...
void SetReferenceMobilityModel(Ptr< MobilityModel > mobility)
Set the reference mobility model which will be installed as the parent mobility model during GroupMob...
void SetReferencePositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of the reference mobil...
static void EnableAsciiAll(Ptr< OutputStreamWrapper > stream)
Keep track of the current position and velocity of an object.
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void PrintGnuplottableBuildingListToFile(std::string filename)
Print the buildings list in a format that can be used by Gnuplot to draw them.
std::ofstream g_timeSeries
The time series file.
void PrintPosition(Ptr< Node > node)
Print the node position to the time series file.