29#include "ns3/applications-module.h"
30#include "ns3/assert.h"
31#include "ns3/core-module.h"
32#include "ns3/global-route-manager.h"
33#include "ns3/internet-module.h"
34#include "ns3/ipv4-global-routing-helper.h"
35#include "ns3/mobility-module.h"
36#include "ns3/netanim-module.h"
37#include "ns3/network-module.h"
38#include "ns3/point-to-point-module.h"
54void printMatrix(
const char* description, std::vector<std::vector<bool>> array);
79 srand((
unsigned)time(
nullptr));
81 std::string
tr_name(
"n-node-ppp.tr");
84 std::string
anim_name(
"n-node-ppp.anim.xml");
118 <<
n_nodes <<
" not equal to the number of nodes in adjacency matrix size "
162 NS_LOG_INFO(
"matrix element [" <<
i <<
"][" <<
j <<
"] is 1");
166 NS_LOG_INFO(
"matrix element [" <<
i <<
"][" <<
j <<
"] is 0");
193 n0->AggregateObject(
nLoc);
239 double rn =
x->GetValue();
245 "ns3::UdpSocketFactory",
287std::vector<std::vector<bool>>
296 std::vector<std::vector<bool>> array;
306 NS_LOG_WARN(
"WARNING: Ignoring blank row in the array: " <<
i);
310 std::istringstream
iss(line);
312 std::vector<bool>
row;
330 <<
" not equal to number of elements in line 0: " <<
n_nodes);
331 NS_FATAL_ERROR(
"ERROR: The number of rows is not equal to the number of columns! in "
332 "the adjacency matrix");
336 array.push_back(
row);
344 NS_FATAL_ERROR(
"ERROR: The number of rows is not equal to the number of columns! in the "
352std::vector<std::vector<double>>
375 std::istringstream
iss(line);
377 std::vector<double>
row;
389 <<
" which is not equal to 2 for node coordinates file");
404printMatrix(
const char* description, std::vector<std::vector<bool>> array)
406 std::cout <<
"**** Start " << description <<
"********" << std::endl;
407 for (
size_t m = 0; m < array.size(); m++)
409 for (
size_t n = 0; n < array[m].size(); n++)
411 std::cout << array[m][n] <<
' ';
413 std::cout << std::endl;
415 std::cout <<
"**** End " << description <<
"********" << std::endl;
421 std::cout <<
"**** Start " << description <<
"********" << std::endl;
428 std::cout << std::endl;
430 std::cout <<
"**** End " << description <<
"********" << std::endl;
Interface to network animator.
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
Manage ASCII trace files for device models.
Parse command-line arguments.
Mobility model for which the current position does not change once it has been set and until it is se...
Class for representing data rates.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetAny()
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
Access to the IPv4 forwarding table, interfaces, and configuration.
a class to store IPv4 address information on an interface
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
static NodeContainer GetGlobal()
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Build a set of PointToPointNetDevice objects.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
void SetDefault(std::string name, const AttributeValue &value)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#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_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
AnimationInterface * anim
void printMatrix(const char *description, std::vector< std::vector< bool > > array)
void printCoordinateArray(const char *description, std::vector< std::vector< double > > coord_array)
std::vector< std::vector< bool > > readNxNMatrix(std::string adj_mat_file_name)
std::vector< std::vector< double > > readCoordinatesFile(std::string node_coordinates_file_name)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< PacketSink > sink
Pointer to the packet sink application.