|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
26 #include "ns3/aodv-module.h"
27 #include "ns3/core-module.h"
28 #include "ns3/network-module.h"
29 #include "ns3/internet-module.h"
30 #include "ns3/mobility-module.h"
31 #include "ns3/point-to-point-module.h"
32 #include "ns3/wifi-module.h"
33 #include "ns3/v4traceroute-helper.h"
64 bool Configure (
int argc,
char **argv);
71 void Report (std::ostream & os);
96 void CreateDevices ();
98 void InstallInternetStack ();
101 void InstallApplications ();
104 int main (
int argc,
char **argv)
107 if (!test.Configure (argc, argv))
113 test.Report (std::cout);
133 SeedManager::SetSeed (12345);
136 cmd.AddValue (
"pcap",
"Write PCAP traces.",
pcap);
137 cmd.AddValue (
"printRoutes",
"Print routing table dumps.",
printRoutes);
138 cmd.AddValue (
"size",
"Number of nodes.",
size);
139 cmd.AddValue (
"time",
"Simulation time, s.",
totalTime);
140 cmd.AddValue (
"step",
"Grid step, m",
step);
142 cmd.Parse (argc, argv);
157 std::cout <<
"Starting simulation for " <<
totalTime <<
" s ...\n";
161 Simulator::Destroy ();
172 std::cout <<
"Creating " << (unsigned)
size <<
" nodes " <<
step <<
" m apart.\n";
175 for (uint32_t i = 0; i <
size; ++i)
177 std::ostringstream os;
179 Names::Add (os.str (),
nodes.
Get (i));
183 mobility.SetPositionAllocator (
"ns3::GridPositionAllocator",
190 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
198 wifiMac.
SetType (
"ns3::AdhocWifiMac");
203 wifi.SetRemoteStationManager (
"ns3::ConstantRateWifiManager",
"DataMode",
StringValue (
"OfdmRate6Mbps"),
"RtsCtsThreshold",
UintegerValue (0));
218 stack.SetRoutingHelper (aodv);
221 address.SetBase (
"10.0.0.0",
"255.0.0.0");
holds a vector of ns3::NetDevice pointers
bool Configure(int argc, char **argv)
Configure script parameters.
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at a particular time.
Make it easy to create and manage PHY objects for the YANS model.
ApplicationContainer Install(NodeContainer nodes) const
Install a TraceRoute application on each Node in the provided NodeContainer.
Parse command-line arguments.
AttributeValue implementation for Boolean.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
Helper class that adds AODV routing to nodes.
helps to create WifiNetDevice objects
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void InstallInternetStack()
Create the network.
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 ...
bool printRoutes
Print aodv routes if true.
void InstallApplications()
Create the simulation applications.
void SetAttribute(std::string name, const AttributeValue &value)
Configure traceRoute applications attribute.
Ipv4 addresses are stored in host order in this class.
void SetChannel(Ptr< YansWifiChannel > channel)
This class can be used to hold variables of floating point type such as 'double' or 'float'.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ipv4InterfaceContainer interfaces
interfaces used in the example
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Ptr< YansWifiChannel > Create(void) const
double step
Distance between nodes, meters.
void Run()
Run simulation.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
double totalTime
Simulation time, seconds.
void CreateNodes()
Create the nodes.
Create a IPv4 traceroute application and associate it to a node.
NodeContainer nodes
nodes used in the example
Hold variables of type string.
void Report(std::ostream &os)
Report results.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
uint32_t size
Number of nodes.
Time Seconds(double value)
Construct a Time in the indicated unit.
NetDeviceContainer devices
devices used in the example
holds a vector of ns3::Application pointers.
keep track of a set of node pointers.
void SetType(std::string type, Args &&... args)
bool pcap
Write per-device PCAP traces if true.
Hold an unsigned integer type.
manage and create wifi channel objects for the YANS model.
create MAC layers for a ns3::WifiNetDevice.
aggregate IP/TCP/UDP functionality to existing Nodes.
Helper class used to assign positions and mobility models to nodes.
void CreateDevices()
Create the devices.