25 #include "ns3/aodv-module.h"    26 #include "ns3/core-module.h"    27 #include "ns3/network-module.h"    28 #include "ns3/internet-module.h"    29 #include "ns3/mobility-module.h"    30 #include "ns3/point-to-point-module.h"    31 #include "ns3/v4ping-helper.h"    32 #include "ns3/yans-wifi-helper.h"    57   bool Configure (
int argc, 
char **argv);
    64   void Report (std::ostream & os);
    92   void CreateDevices ();
    94   void InstallInternetStack ();
    96   void InstallApplications ();
    99 int main (
int argc, 
char **argv)
   102   if (!test.Configure (argc, argv))
   106   test.Report (std::cout);
   126   SeedManager::SetSeed (12345);
   129   cmd.AddValue (
"pcap", 
"Write PCAP traces.", 
pcap);
   130   cmd.AddValue (
"printRoutes", 
"Print routing table dumps.", 
printRoutes);
   131   cmd.AddValue (
"size", 
"Number of nodes.", 
size);
   132   cmd.AddValue (
"time", 
"Simulation time, s.", 
totalTime);
   133   cmd.AddValue (
"step", 
"Grid step, m", 
step);
   135   cmd.Parse (argc, argv);
   148   std::cout << 
"Starting simulation for " << 
totalTime << 
" s ...\n";
   152   Simulator::Destroy ();
   163   std::cout << 
"Creating " << (unsigned)
size << 
" nodes " << 
step << 
" m apart.\n";
   166   for (uint32_t i = 0; i < 
size; ++i)
   168       std::ostringstream os;
   170       Names::Add (os.str (), 
nodes.
Get (i));
   174   mobility.SetPositionAllocator (
"ns3::GridPositionAllocator",
   181   mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
   189   wifiMac.
SetType (
"ns3::AdhocWifiMac");
   194   wifi.SetRemoteStationManager (
"ns3::ConstantRateWifiManager", 
"DataMode", 
StringValue (
"OfdmRate6Mbps"), 
"RtsCtsThreshold", 
UintegerValue (0));
   209   stack.SetRoutingHelper (aodv); 
   212   address.SetBase (
"10.0.0.0", 
"255.0.0.0");
 holds a vector of ns3::Application pointers. 
  AttributeValue implementation for Boolean. 
holds a vector of std::pair of Ptr<Ipv4> and interface index. 
Hold variables of type string. 
Make it easy to create and manage PHY objects for the yans model. 
void SetAttribute(std::string name, const AttributeValue &value)
Configure ping applications attribute. 
bool Configure(int argc, char **argv)
Configure script parameters. 
uint32_t size
Number of nodes. 
aggregate IP/TCP/UDP functionality to existing Nodes. 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate. 
helps to create WifiNetDevice objects 
static void SetPosition(Ptr< Node > node, Vector position)
bool printRoutes
Print routes if true. 
Ptr< YansWifiChannel > Create(void) const
Ipv4InterfaceContainer interfaces
interfaces used in the example 
Keep track of the current position and velocity of an object. 
void SetChannel(Ptr< YansWifiChannel > channel)
void CreateDevices()
Create the devices. 
NodeContainer nodes
nodes used in the example 
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 ...
void InstallInternetStack()
Create the network. 
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Hold an unsigned integer type. 
holds a vector of ns3::NetDevice pointers 
void InstallApplications()
Create the simulation applications. 
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments. 
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object. 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
keep track of a set of node pointers. 
void Report(std::ostream &os)
Report results. 
manage and create wifi channel objects for the yans model. 
bool pcap
Write per-device PCAP traces if true. 
create MAC layers for a ns3::WifiNetDevice. 
double totalTime
Simulation time, seconds. 
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
Helper class used to assign positions and mobility models to nodes. 
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Time Seconds(double value)
Construct a Time in the indicated unit. 
NetDeviceContainer devices
devices used in the example 
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index. 
A helper class to make life easier while doing simple IPv4 address assignment in scripts. 
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer. 
Helper class that adds AODV routing to nodes. 
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void CreateNodes()
Create the nodes. 
Create a IPv4 ping application and associate it to a node. 
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at a particular time. 
void Run()
Run simulation. 
double step
Distance between nodes, meters.