ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation...
Transcript of ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation...
![Page 1: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/1.jpg)
Session 8: Monday 3:30pm
ns-3 Annual Meeting
May 2014
1
ns-3 Training
![Page 2: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/2.jpg)
Outline
• Emulation modes
– Tap Bridge
– FdNetDevice
• Direct Code Execution (DCE)
– Applications
– Linux Kernel
– DCE Cradle
NS-3 Annual Meeting
May 2014
![Page 3: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/3.jpg)
Emulation support
• Support moving between simulation and testbeds or live
systems
• A real-time scheduler, and support for two modes of
emulation
• Linux is only operating system supported
• Must run simulator in real time
– GlobalValue::Bind (“SimulatorImplementationType”,
StringValue (“ns3::RealTimeSimulatorImpl”));
• Must enable checksum calculations across models
– GlobalValue::Bind (“ChecksumEnabled”, BooleanValue
(true));
• Must run as root, or with the --enable-sudo
NS-3 Annual Meeting
May 2014
![Page 4: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/4.jpg)
ns-3 emulation modes
NS-3 Annual Meeting
May 2014
4
virtualmachine
ns-3
virtualmachine
1) ns-3 interconnects real or virtual
machines
realmachine
ns-3
Testbed
realmachine
ns-3
2) testbeds interconnect ns-3
stacks
real machine
Various hybrids of the above are possible
![Page 5: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/5.jpg)
Example use case: testbeds
NS-3 Annual Meeting
May 2014
• Support for use of Rutgers WINLAB
ORBIT radio grid
![Page 6: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/6.jpg)
Example use case: PlanetLab
• The PlanetLabFdNetDeviceHelper creates TAP devices
on PlanetLab nodes using specific PlanetLab
mechanisms (i.e. the vsys system), and associates the
TAP device to a FdNetDevice in ns-3.
NS-3 Annual Meeting
May 2014
![Page 7: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/7.jpg)
Example use case: mininet
• Mininet is popular in the Software-Defined
Networking (SDN) community
• Mininet uses "TapBridge" integration
• https://github.com/mininet/mininet/wiki/Link-modeling-using-ns-3
NS-3 Annual Meeting
May 2014
![Page 8: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/8.jpg)
Emulation Devices
![Page 9: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/9.jpg)
Device models
• File Descriptor Net Device (FdNetDevice)
– read and write traffic using a file descriptor
provided by the user
– this file descriptor can be associated to a TAP
device, to a raw socket, to a user space
process generating/consuming traffic, etc.
• Tap Bridge
– Integrate Tun/Tap devices with ns-3 devices
• EmuNetDevice
– Deprecated (ns-3.17) in favor of FdNetDeviceNS-3 Annual Meeting
May 2014
![Page 10: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/10.jpg)
“TapBridge": netns and ns-3 integration
NS-3 Annual Meeting
May2013
10
Container
ns-3
Linux
tapX
/dev/tunX
TapBridge
WiFi
ghost nodeWifi
ghost node
tapY
Tap device pushed into namespaces; no bridging needed
/dev/tunY
Container
TapBridge
WiFi
![Page 11: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/11.jpg)
TapBridge modes
• ConfigureLocal (default mode)
– ns-3 configures the tap device
– useful for host to ns-3 interaction
• UseLocal
– user has responsibility for device creation
– ns-3 informed of device using “DeviceName”
attribute
• UseBridge
– TapDevice connected to existing Linux bridge
NS-3 Annual Meeting
May 2014
![Page 12: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/12.jpg)
ConfigureLocal
NS-3 Annual Meeting
May 2014
ns-3 ensures that Mac addresses
are consistent
![Page 13: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/13.jpg)
UseLocal
NS-3 Annual Meeting
May 2014
Mac X spoofed to Mac Y
![Page 14: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/14.jpg)
UseBridge
NS-3 Annual Meeting
May 2014
ns-3 devices must support SendFrom()
(i.e. bridging)
![Page 15: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/15.jpg)
TapCsma example
• Demo the TapCsma example
NS-3 Annual Meeting
May 2014
![Page 16: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/16.jpg)
FdNetDevice
• Unified handling of reading/writing from file
descriptor
• Three supported helper configurations:
– EmuFdNetDeviceHelper (to associate the ns-3 device
with a physical device in the host machine)
– TapFdNetDeviceHelper (to associate the ns-3 device
with the file descriptor from a tap device in the host
machine) (not the same as TapBridge)
– PlanetLabFdNetDeviceHelper (to automate the
creation of tap devices in PlanetLab nodes, enabling
ns-3 simulations that can send and receive traffic
though the Internet using PlanetLab resource.
NS-3 Annual Meeting
May 2014
![Page 17: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/17.jpg)
EmuFdNetDeviceHelper
NS-3 Consortium Meeting
May 2014
• Device performs MAC spoofing to
separate emulation from host traffic
![Page 18: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/18.jpg)
PlanetLabFdNetDeviceHelper
• Special case of TapFdNetDeviceHelper where
Tap devices configured according to PlanetLab
conventions
NS-3 Annual Meeting
May 2014
![Page 19: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/19.jpg)
ns-3 over host sockets
• Two publications about how to run ns-3
applications over real hosts and sockets
– "Simulator-agnostic ns-3 Applications",
Abraham and Riley, WNS3 2012
– Gustavo Carneiro, Helder Fontes, Manuel
Ricardo, "Fast prototyping of network
protocols through ns-3 simulation model
reuse", Simulation Modelling Practice and
Theory (SIMPAT), vol. 19, pp. 2063–2075,
2011.
NS-3 Annual Meeting
May 2014
![Page 20: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/20.jpg)
Generic Emulation Issues
• Ease of use
– Configuration management and coherence
– Information coordination (two sets of state)
• e.g. IP/MAC address coordination
– Output data exists in two domains
– Debugging can be more challenging
• Error-free operation (avoidance of misuse)
– Synchronization, information sharing, exception handling
• Checkpoints for execution bring-up
• Inoperative commands within an execution domain
• Deal with run-time errors
– Soft performance degradation (CPU) and time discontinuities
NS-3 Annual Meeting
May 2014
![Page 21: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/21.jpg)
Direct Code Execution
NS-3 Consortium Meeting
March 2013
![Page 22: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/22.jpg)
Goals
• Lightweight virtualization of kernel and application processes, interconnected by simulated networks
• Benefits:
– Implementation realism in controlled topologies or wireless environments
– Model availability
– Debugging a whole network within a single process
• Limitations:
– Not as scalable as pure simulation
– Tracing more limited
– Configuration different
NS-3 Annual Meeting
May 2014
![Page 23: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/23.jpg)
Direct Code Execution
NS-3 Annual Meeting
May 2014
• DCE/ns-3 framework requires the virtualization of
a series of services
– Multiple isolated instances of the same
protocol on the same machine
• System calls are captured and treated by DCE
• Network stack protocols calls are captured and
redirected
• To perform its work DCE
re-implement the Linux
program loader and parts
of libc and libpthread
![Page 24: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/24.jpg)
Direct Code Execution
• Developed by Mathieu Lacage and Frederic Urbani,
INRIA, Hajime Tazaki (University of Tokyo)
NS-3 Annual Meeting
May 2014
24
Figure source: Direct Code Execution: Revisiting Library OS Architecture
for Reproducible Network Experiments (CONEXT 13)
![Page 25: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/25.jpg)
DCE modes
• DCE modes in context of possible
approaches
NS-3 Annual Meeting
May 2014
Figure source: DCE Cradle: Simulate Network Protocols with Real Stacks
for Better Realism, Tazaki et al, WNS3 2013.
![Page 26: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/26.jpg)
Paper references
• Direct Code Execution: Revisiting Library OS
Architecture for Reproducible Network
Experiments
– Tazaki et al, CONEXT 2013
– http://hal.archives-
ouvertes.fr/docs/00/88/08/70/PDF/con013-hal.pdf
• DCE Cradle: Simulate Network Protocols
with Real Stacks for Better Realism– Tazaki et al, WNS3 2013
– http://hal.archives-
ouvertes.fr/docs/00/78/15/91/PDF/wns3-2013.pdf
NS-3 Annual Meeting
May 2014
![Page 27: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/27.jpg)
27ns-3 - consortium
Hands on, what do we need
o What do you need to start using the framework!• ns-3 – The network simulator
http://www.nsnam.org/
• DCE http://www.nsnam.org/overview/projects/direct-code-execution/
• Applications iperf, wget, thttpd
* All software must be re-compiled with –fpic and linked with –pie to generate the code with Position Independent Code (PIC) and permit context switch
o To make things easier• Bake – Installation tool
http://planete.inria.fr/software/bake/index.html
• Mercurial – source control management tool http://mercurial.selenic.com/
• Python – for running bake www.python.org
![Page 28: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/28.jpg)
28ns-3 - consortium
The plan is
o The plan is to present
• Installation
• Examples of: iperf with ns-3 stack
www server and wget with ns-3 stack
iperf with Linux stack
![Page 29: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/29.jpg)
29ns-3 - consortium
The shared scenario
o The shared scenario is a simple three nodes network
iperf/HTTPD10.1.1.1 10.1.1.2 10.1.2.1 10.1.2.2
Node 0 Node 1 Node 2
5 Mbps, 1 ms 5 Mbps, 1 ms
iperf/wget
![Page 30: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/30.jpg)
30ns-3 - consortium
Step by step example - Installing the required software
* Into a Linux machine1) > mkdir dce_tutorial; cd dce_tutorial
2) > hg clone http://code.nsnam.org/bake bake
3) > export BAKE_HOME=`pwd`/bake
4) > export PATH=$PATH:$BAKE_HOME
5) > export PYTHONPATH=$PYTHONPATH:$BAKE_HOME
6) > mkdir DCE; cd DCE
7) > bake.py configure -e dce-ns3
8) > bake.py install
9) >. bakeSetEnv.sh
![Page 31: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/31.jpg)
31ns-3 - consortium
Step by step example - What we need to do!
1. Create the nodes
2. Create stack
3. Create devices
4. Set addresses
5. Connect devices
6. Create DCE
7. Configuration the applications to run
8. Set start time for server and client
9. Set simulation time
10. Start simulation
![Page 32: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/32.jpg)
32ns-3 - consortium
Step by step example - What we need to do!
1) Create the nodes
2) Create stack
3) Create devices
4) Set addresses
5) Connect devices
6) Create DCE
7) Configuration the applications to run
8) Set start time for server and client
9) Set simulation time
10) Start simulation Standard ns-3 proceduresDCE specific
![Page 33: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/33.jpg)
33ns-3 - consortium
Step by step example- iperf with ns-3 stack (I)
int main (int argc, char *argv[]){// Node Container creationNodeContainer nodes;nodes.Create (3);
// Linux stack creationInternetStackHelper stack; stack.Install (nodes);
// For real time // GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl")); // GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));
// Device and channel creationPointToPointHelper p2p;p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps“));p2p.SetChannelAttribute ("Delay", StringValue ("1ms"));
![Page 34: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/34.jpg)
34ns-3 - consortium
Step by step example- iperf with ns-3 stack (II)
// Node0-Node1 setupIpv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.252"); // Node0-Node1 addresses
NetDeviceContainer devices;devices = p2p.Install (nodes.Get (0), nodes.Get (1)); // connecting nodesIpv4InterfaceContainer interfaces = address.Assign (devices); // assign addresses
// Node1-Node2 setupdevices = p2p.Install (nodes.Get (1), nodes.Get (2)); // connecting nodesaddress.SetBase ("10.1.2.0", "255.255.255.252"); // Node1-Node2 addressesinterfaces = address.Assign (devices); // assign addresses
// setup ip routesIpv4GlobalRoutingHelper::PopulateRoutingTables ();
![Page 35: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/35.jpg)
35ns-3 - consortium
Step by step example- iperf with ns-3 stack (III)
DceManagerHelper dceManager;dceManager.Install (nodes);
DceApplicationHelper dce;ApplicationContainer apps;dce.SetStackSize (1 << 20); // 1MB stack
dce.SetBinary ("iperf"); // Launch iperf client on node 0dce.ResetArguments (); // clean arguments dce.ResetEnvironment (); // clean environnentdce.AddArgument ("-c"); // client dce.AddArgument ("10.1.2.2"); //target machine addressdce.AddArgument ("-i"); // interval dce.AddArgument ("1"); dce.AddArgument ("--time"); // how longdce.AddArgument ("10");apps = dce.Install (nodes.Get (0)); //install application
apps.Start (Seconds (0.7)); //start at 0.7 simulation timeapps.Stop (Seconds (20)); //stop at 20s simulation time
dce.SetBinary ("iperf"); // Launch iperf server on node 2dce.ResetArguments (); // clean arguments dce.ResetEnvironment (); // clean environnentdce.AddArgument ("-s"); // serverdce.AddArgument ("-P"); // number of paralell serversdce.AddArgument ("1");apps = dce.Install (nodes.Get (2));apps = dce.Install (nodes.Get (2));apps.Start (Seconds (0.6));
DCE Setup
![Page 36: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/36.jpg)
36ns-3 - consortium
Step by step example- iperf with ns-3 stack (IV)
// Simulation stop timeSimulator::Stop (Seconds (40.0));
// Run Simulator::Run ();
// StopSimulator::Destroy ();
return 0;}
![Page 37: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/37.jpg)
37ns-3 - consortium
Step by step example – iperf, ns-3
o Generated
• elf-cache – program files
• exitprocs – execution process information
• files-0 files-2 – execution filesystem
o files-x
• var – “/root” of the machine
• files-x/var/log/<pid>/ cmdline – command executed
status – execution information
stderr – standard error output
stdout – standard output
syslog – syslog output
![Page 38: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/38.jpg)
38ns-3 - consortium
Step by step example- HTTP with ns-3 stack (I)
int main (int argc, char *argv[]){// Node Container creationNodeContainer nodes;nodes.Create (3);
// Linux stack creationInternetStackHelper stack; stack.Install (nodes);
// For real time // GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl")); // GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));
// Device and channel creationPointToPointHelper p2p;p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps“));p2p.SetChannelAttribute ("Delay", StringValue ("1ms"));
![Page 39: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/39.jpg)
39ns-3 - consortium
Step by step example- HTTP with ns-3 stack (II)
// Node0-Node1 setupIpv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.252"); // Node0-Node1 addresses
NetDeviceContainer devices;devices = p2p.Install (nodes.Get (0), nodes.Get (1)); // connecting nodesIpv4InterfaceContainer interfaces = address.Assign (devices); // assign addresses
// Node1-Node2 setupdevices = p2p.Install (nodes.Get (1), nodes.Get (2)); // connecting nodesaddress.SetBase ("10.1.2.0", "255.255.255.252"); // Node1-Node2 addressesinterfaces = address.Assign (devices); // assign addresses
// setup ip routesIpv4GlobalRoutingHelper::PopulateRoutingTables ();
![Page 40: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/40.jpg)
40ns-3 - consortium
Step by step example- HTTP with ns-3 stack (III)
// Launch the server HTTPdce.SetBinary ("thttpd");dce.ResetArguments (); // clean arguments dce.ResetEnvironment (); // clean environnentdce.SetUid (1); // Set httpd for super user executiondce.SetEuid (1);apps = dce.Install (nodes.Get (0)); // install http daemonapps.Start (Seconds (1)); // start time
// Launch the client WGETdce.SetBinary ("wget");dce.ResetArguments (); // clean arguments dce.ResetEnvironment (); // clean environnentdce.AddArgument ("-r"); // recursive wgetdce.AddArgument ("http://10.1.1.1/index.html");apps = dce.Install (nodes.Get (2));apps.Start (Seconds (2)); // start time
DCE Setup
![Page 41: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/41.jpg)
41ns-3 - consortium
Step by step example- HTTP with ns-3 stack (IV)
// Simulation stop timeSimulator::Stop (Seconds (40.0));
// Run Simulator::Run ();
// StopSimulator::Destroy ();
return 0;}
![Page 42: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/42.jpg)
42ns-3 - consortium
Step by step example- iperf with linux stack (I)
int main (int argc, char *argv[]){// Node Container creationNodeContainer nodes;nodes.Create (3);
// Linux stack creationdceManager.SetNetworkStack ("ns3::LinuxSocketFdFactory", "Library", StringValue ("liblinux.so"));LinuxStackHelper stack;stack.Install (nodes);
// For real time // GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl")); // GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));
// Device and channel creationPointToPointHelper p2p;p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps“));p2p.SetChannelAttribute ("Delay", StringValue ("1ms"));
![Page 43: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/43.jpg)
43ns-3 - consortium
Step by step example- iperf with linux stack (II)
// Node0-Node1 setupIpv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.252"); // Node0-Node1 addresses
NetDeviceContainer devices;devices = p2p.Install (nodes.Get (0), nodes.Get (1)); // connecting nodesIpv4InterfaceContainer interfaces = address.Assign (devices); // assign addresses
// Node1-Node2 setupdevices = p2p.Install (nodes.Get (1), nodes.Get (2)); // connecting nodesaddress.SetBase ("10.1.2.0", "255.255.255.252"); // Node1-Node2 addressesinterfaces = address.Assign (devices); // assign addresses
// setup ip routesIpv4GlobalRoutingHelper::PopulateRoutingTables ();
![Page 44: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/44.jpg)
44ns-3 - consortium
Step by step example- iperf with linux stack (III)
DceManagerHelper dceManager;dceManager.Install (nodes);
DceApplicationHelper dce;ApplicationContainer apps;dce.SetStackSize (1 << 20); // 1MB stack
dce.SetBinary ("iperf"); // Launch iperf client on node 0dce.ResetArguments (); // clean arguments dce.ResetEnvironment (); // clean environnentdce.AddArgument ("-c"); // client dce.AddArgument ("10.1.2.2"); //target machine addressdce.AddArgument ("-i"); // interval dce.AddArgument ("1"); dce.AddArgument ("--time"); // how longdce.AddArgument ("10");apps = dce.Install (nodes.Get (0)); //install application
apps.Start (Seconds (0.7)); //start at 0.7 simulation timeapps.Stop (Seconds (20)); //stop at 20s simulation time
dce.SetBinary ("iperf"); // Launch iperf server on node 2dce.ResetArguments (); // clean arguments dce.ResetEnvironment (); // clean environnentdce.AddArgument ("-s"); // serverdce.AddArgument ("-P"); // number of paralell serversdce.AddArgument ("1");apps = dce.Install (nodes.Get (2));apps = dce.Install (nodes.Get (2));apps.Start (Seconds (0.6));
DCE Setup( Similar to the ns-3 stack one)
![Page 45: ns-3 overview for WiFi-Alliance June 2008 prepared by Tom … · 2014. 5. 6. · ns-3 emulation modes NS-3 Annual Meeting May 2014 4 virtual machine ns-3 virtual machine 1) ns-3 interconnects](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbcdd62e68f2e3a4e5c541b/html5/thumbnails/45.jpg)
45ns-3 - consortium
Step by step example- iperf with linux stack (IV)
// Simulation stop timeSimulator::Stop (Seconds (40.0));
// Run Simulator::Run ();
// StopSimulator::Destroy ();
return 0;}