11#include "ns3/aodv-module.h"
12#include "ns3/core-module.h"
13#include "ns3/internet-module.h"
14#include "ns3/mobility-module.h"
15#include "ns3/network-module.h"
16#include "ns3/ping-helper.h"
17#include "ns3/point-to-point-module.h"
18#include "ns3/yans-wifi-helper.h"
64 void Report(std::ostream& os);
99main(
int argc,
char** argv)
102 if (!
test.Configure(argc, argv))
108 test.Report(std::cout);
131 cmd.AddValue(
"pcap",
"Write PCAP traces.",
pcap);
132 cmd.AddValue(
"printRoutes",
"Print routing table dumps.",
printRoutes);
133 cmd.AddValue(
"size",
"Number of nodes.",
size);
134 cmd.AddValue(
"time",
"Simulation time, s.",
totalTime);
135 cmd.AddValue(
"step",
"Grid step, m",
step);
137 cmd.Parse(argc, argv);
151 std::cout <<
"Starting simulation for " <<
totalTime <<
" s ...\n";
166 std::cout <<
"Creating " << (unsigned)
size <<
" nodes " <<
step <<
" m apart.\n";
171 std::ostringstream os;
177 mobility.SetPositionAllocator(
"ns3::GridPositionAllocator",
190 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
191 mobility.Install(
nodes);
198 wifiMac.
SetType(
"ns3::AdhocWifiMac");
203 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
222 stack.SetRoutingHelper(aodv);
223 stack.Install(
nodes);
225 address.SetBase(
"10.0.0.0",
"255.0.0.0");
252 Vector(1e5, 1e5, 1e5));
bool Configure(int argc, char **argv)
Configure script parameters.
void CreateDevices()
Create the devices.
void InstallApplications()
Create the simulation applications.
Ipv4InterfaceContainer interfaces
interfaces used in the example
bool printRoutes
Print routes if true.
bool pcap
Write per-device PCAP traces if true.
NodeContainer nodes
nodes used in the example
double totalTime
Simulation time, seconds.
void CreateNodes()
Create the nodes.
void Run()
Run simulation.
uint32_t size
Number of nodes.
void Report(std::ostream &os)
Report results.
void InstallInternetStack()
Create the network.
NetDeviceContainer devices
devices used in the example
double step
Distance between nodes, meters.
Helper class that adds AODV routing to nodes.
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.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at a particular time.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
void SetPosition(const Vector &position)
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
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.
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
Create a ping application and associate it to a node.
Smart pointer class similar to boost::intrusive_ptr.
static void SetSeed(uint32_t seed)
Set the seed.
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 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.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
void SetType(std::string type, Args &&... args)
manage and create wifi channel objects for the YANS model.
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
Ptr< YansWifiChannel > Create() const
Make it easy to create and manage PHY objects for the YANS model.
void SetChannel(Ptr< YansWifiChannel > channel)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
-ns3 Test suite for the ns3 wrapper script