Housekeeping
A3 Simulation Tools,
Housekeeping
Reynolds 114 Reminder from SOCS: No Food / Drink Allowed inside of this lab room
Outline
Basic Setup of the Simulation Breaking the scenario into multiple files Defining Topology Defining Traffic Models Defining Routing Models
Possible to split up the scenario files Common to split topology generation away from the scenario itself This way if you have two different scenarios which both use that same topology it modular
Use the source directive For example, if you want to include the topology.tcl file into your simulation.tcl file:
simulation.tcl
set n0 [$ns node] set n1 [$ns node] ... $ns duplex-link $n0 $n2 1Mb 10ms DropTail $ns duplex-link $n1 $n2 1Mb 10ms DropTail
Larger Topologies:
Use a loop:
} for {set i 0} {$i < 7} {incr i} { $ns duplex-link $n($i) $n([expr ($i+1)%7]) 1Mb 10ms DropTail }
You could do a large ring of 25 nodes or more for your assignment, but likely not very interesting It is up to you to figure out how to connect the more complicated topologies It may however be interesting to compare a ring against a grid topology if you wish
$node_(0) set X_ 0.0 $node_(1) set X_ 200.0 $node_(2) set X_ 400.0 $node_(3) set X_ 600.0 $node_(4) set X_ 800.0
# Create and configure topography (used for mobile scenarios) set topo [new Topography] # 1000x1000m terrain $topo load_flatgrid 1000 1000
By default, uses static routing which is similar to Dijkstra's algorithm Could compare against DV easily
Outline
Basic Setup of the Simulation Breaking the scenario into multiple files Defining Topology Defining Traffic Models Defining Routing Models
#include "ns3/core-module.h" #include "ns3/network-module.h" #include "ns3/internet-module.h" #include "ns3/point-to-point-module.h" #include "ns3/applications-module.h Others depending on if you use wireless, other modules
Saves you having to do ns3::xxx for functions etc. similar to being able to use cout rather than std::cout
Can be managed in the same way any C/C++ source is using #include Should be modular like any C/C++ code Break into functions, header files where necessary
Nodes exist within containers to help refer to them Used to apply actions later to entire groups of nodes
CSMA is like a shared wire, uses collision avoidance no need for routing operating on this P2P connections should be used to connect where routing should be used For a straightforward grid, see ns3source/examples/animation/grid-animation.cc
P2P Grid
P2P Hierarchical
GridHelper:
PointToPointHelper pointToPoint; pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
// Create Grid PointToPointGridHelper grid (5, 5, pointToPoint);
/* Set up mobility model */ mobility.SetPositionAllocator ( "ns3::GridPositionAllocator", "MinX", DoubleValue (0.0), "MinY", DoubleValue (0.0), "DeltaX", DoubleValue (SEPARATIONDISTANCE), "DeltaY", DoubleValue (SEPARATIONDISTANCE), "GridWidth", UintegerValue (XNODES), "LayoutType", StringValue ("RowFirst") ); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install(nodes);
Interface: maps between node and device Install IP addresses & stack on all nodes:
InternetStackHelper internetStack; Ipv4InterfaceContainer interfaces; internetStack.Install (nodes); Ipv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.0"); interfaces = address.Assign (meshRouterDevices);
UDPClient / UDPServer
On/Off Client/Server Bulksend
Ping
UDP Echo Client/Server
http://www.nsnam.org/tutorials/ns-3-tutorial-tunis-apr09.pdf
UdpServerHelper server(PORT); ApplicationContainer serverapp = server.Install (nodes.Get (0)); serverapp.Start (Seconds (1)); Note: you may find it serverapp.Stop (Seconds (TOTALTIME));
good to start the application after time 0, particularly with wireless simluations
UdpClientHelper client (interfaces.GetAddress (0), PORT); client.SetAttribute ("MaxPackets", UintegerValue (MAXPACKETS)); client.SetAttribute ("PacketSize", UintegerValue (PACKETSIZE)); client.SetAttribute ("Interval", TimeValue (Seconds (PACKETINTERVAL))); ApplicationContainer clientapp = client.Install (nodes.Get (1)); clientapp.Start (Seconds (2)); clientapp.Stop (Seconds (TOTALTIME)); Good to start the client,
after the server is already listening
Why we need to specify the node & interface on that node (each node may have multiple interfaces)
In ns3, you can use a single sink for multiple sources, in ns2 this is not the case, you must have a corresponding sink for each source
See ns3 source/examples/routing for more details For some types of routing it is as simple as setting the routing model when initializing the InternetStack:
InternetStackHelper internetStack; stack.SetRoutingHelper (aodv); Ipv4InterfaceContainer interfaces; internetStack.Install (nodes); Ipv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.0"); interfaces = address.Assign (meshRouterDevices);
Next Classes
Generating Data Files Parsing Data files Extracting Results Generating Graphs with GNUPlot, Xgraph Automating Multiple Experiments
Delay tolerant networks Wireless mesh networks Wireless sensor networks 3G, 4G, LTE, Mobile Networks Heterogeneous networks Green Communication
References
http://www.evanjones.ca/ns2/