Network Modeling and Simulation with Network Simulator 2

  • Slides: 58
Download presentation
Network Modeling and Simulation with Network Simulator 2 (ns 2) Department of Computer Science

Network Modeling and Simulation with Network Simulator 2 (ns 2) Department of Computer Science and Engineering University of Bologna. Italy difelice@cs. unibo. it Marco Di Felice NS 2: An Overview

Outline NS 2: Use Cases and Features NS 2: Architecture and Design NS 2:

Outline NS 2: Use Cases and Features NS 2: Architecture and Design NS 2: Building simple network models NS 2: Demo & Analysis Marco Di Felice NS 2: An Overview

Ns 2: An Overview NS 2: A (discrete event) network simulator tool. Generally speaking,

Ns 2: An Overview NS 2: A (discrete event) network simulator tool. Generally speaking, a network simulator is a dedicated software that allows to: Ø Model the behaviour of network protocols/applications (e. g. TCP protocol). Ø Reproduce the behaviour of a computer network as a whole (e. g. a wireless LAN). Ø Quantify the network performance, through welldefined network metrics (e. g. system throughput). Marco Di Felice NS 2: An Overview

Ns 2: WHAT Q. When may I use a network simulator? Case 1: Network

Ns 2: WHAT Q. When may I use a network simulator? Case 1: Network planning Ø Need to build a network infrastructure, with coverage and Quality of Service (Qo. S) issues. Q 1. Where to place the network gateways? Q 2. How many gateways do I really need? Marco Di Felice NS 2: An Overview

Ns 2: WHAT Q. When may I use a network simulator? Case 2: Network

Ns 2: WHAT Q. When may I use a network simulator? Case 2: Network Evaluation Ø Need to evaluate the performance of a (possibly large-scale) network infrastructure or network application. An example: Early Collision Detection Systems In VANETs Ø Use an existing testbed BUT … Q 1. What is the cost of setting up the experiments? Q 2. Are the experiments easily reproducible? Marco Di Felice NS 2: An Overview

Ns 2: WHAT Q. When may I use a network simulator? Case 3: Research

Ns 2: WHAT Q. When may I use a network simulator? Case 3: Research on Networking Systems Ø Need to evaluate the performance of a new network protocol, architecture, or application. An example: Proposing a new TCP variant for wireless LANs. 1. A real deployment might not be feasible, or might be too costly. 2. Analytical models might be too complex to model all the components of the scenario under study. Marco Di Felice NS 2: An Overview

Ns 2: WHAT Ø Network simulators might be used to model several kinds of

Ns 2: WHAT Ø Network simulators might be used to model several kinds of networking systems (wired, wireless, optical, etc). Ø In practice, simulation constitutes the main evaluation technique for wireless systems. ² Possibility to build reproducible experiments (hard to guarantee with wireless testbeds). ² Possibility to reproduce wireless propagation phenomena in an accurate way through probabilistic models (e. g. fading) ² Possibility to model large-scale wireless networks composed by several interacting nodes. Marco Di Felice NS 2: An Overview

Ns 2: WHAT Ø Simulation is a meaningful evaluation approach only when it produces

Ns 2: WHAT Ø Simulation is a meaningful evaluation approach only when it produces “trustable” results. Ø Validation is needed to certify that the simulation models reproduce correctly the characteristics and dynamics of the system under study. Ø HOW to VALIDATE a NETWORK MODEL? ² Compare Simulation vs Analytical Model ² Compare Simulation vs Real Measurements EXPERIMENTS Marco Di Felice SIM. THROUGPUT ANALYTICAL NS 2: An Overview

Ns 2: WHAT NS 2: A network simulation tool Ø Discrete Event simulator (details

Ns 2: WHAT NS 2: A network simulation tool Ø Discrete Event simulator (details later …) NS 2 allows to model and evaluate several IP networking systems (LAN/WAN). It includes: ² Network protocols model (e. g. MAC, routing, …) ² Network applications model (e. g. CBR, FTP, …) ² Queue management algorithms (e. g. FIFO, RED, …) ² Network link models (e. g. lossy link) ²… Marco Di Felice NS 2: An Overview

Ns 2: WHERE v http: //www. isi. edu/nsnam/ns v http: //sourceforge. net/projects/nsnam Ø download

Ns 2: WHERE v http: //www. isi. edu/nsnam/ns v http: //sourceforge. net/projects/nsnam Ø download ns-allinone Ø includes several tools (ns 2, nam, awk, otcl, …) v mailing list: ns-users@isi. edu v documentation: Ø Reference manual and Tutorials on the website Ø Other tutorials on the Web Marco Di Felice NS 2: An Overview

Ns 2: WHEN v The project started from REAL project in 1989 Ø ns-1

Ns 2: WHEN v The project started from REAL project in 1989 Ø ns-1 by Floyd and Mc. Canne at Lawrance Berkeley National Laboratory (LBNL). Ø ns-2 by Steve Mc. Canne, within the VINT project involving a consortium of US universities (LBL, PARC, USC, . . . ) Ø currently maintained at USC/ISI (University of Southern California), but several forks available. v NS 3 relased in 2008 (now NS 3. 15) Ø Deployed by a team lead by Tom Henderson and Sally Floyd (University of Washington) Ø A completely new tool, not a mere extension of Ns 2 ! Marco Di Felice NS 2: An Overview

Ns 2: WHY NS 2: A network simulation tool Ø Discrete Event simulator (details

Ns 2: WHY NS 2: A network simulation tool Ø Discrete Event simulator (details later …) OTHER SIMULATION TOOLS ² ² ² OMNET++ OPNET Ji. ST NS 3 GLOMOSIM … Q. WHY should I use NS 2 for my research? Marco Di Felice NS 2: An Overview

Ns 2: WHY Ø NS 2 includes a vast model library of network components.

Ns 2: WHY Ø NS 2 includes a vast model library of network components. Link Models: Ø Wired Links, Ø Wireless Links, Ø Satellite Links, … Application Layer FTP, Telnet, HTTP, Multimedia, Exponential traffic, … Transport Layer UDP, TCP (Reno, New. Reno, Vegas, SACK), … Network Layer Wired routing (RIP), Ad Hoc Routing (AODV, OLSR, DSR), … MAC Layer Ethernet, 802. 11 (WIFI), 802. 15. 4, Bluetooth, 802. 16 (WIMAX), … Marco Di Felice NS 2: An Overview

Ns 2: WHY Ø NS 2 is distributed with GNU General Public Licence (GPL)

Ns 2: WHY Ø NS 2 is distributed with GNU General Public Licence (GPL) v Collaborative deployment environment Ø possibility to freely modify the existing NS 2 code based on each user’s needs. Ø possibility to share network models for research/education purposes (e. g. a new implementation of TCP). Ø possibility to compare his/her own model with models implemented by other research teams. v Multi-platform support Ø GNU/Linux, MAC OSX, Solaris, Windows, … Marco Di Felice NS 2: An Overview

Ns 2: WHY Ø NS 2 is a popular tool, widely adopted by researchers

Ns 2: WHY Ø NS 2 is a popular tool, widely adopted by researchers working on the field of computer networks. Number of Users: 10 K Institutes: 1 K % Papers: 44. 4% MOBIHOC Conference: Statistics on tools used to produce a simulation study within the papers submitted at the ACM MOBIHOC conference (2000 -2006). Marco Di Felice NS 2: An Overview

Ns 2: WHY Q. WHY NOT to use NS 2 for my research? ²

Ns 2: WHY Q. WHY NOT to use NS 2 for my research? ² Monolithic (basic) scheduler, scalability constitutes a big issue. Ø Architectural issues ² Not really a modular architecture, difficult to share the code of network models. Ø Evaluation issues ² No support for the trace analysis. CPU time Ø Performance issues ? #nodes NS 2 TRACE Marco Di Felice NS 2: An Overview

NS 2: HOW Ø Two programming languages: C++ and OTCL. Ø OTCL for simulation

NS 2: HOW Ø Two programming languages: C++ and OTCL. Ø OTCL for simulation setup and execution Ø Quickly define the simulation environment Ø C++ for model deployment Ø Implement the behaviour of a network component Marco Di Felice NS 2: An Overview

NS 2: HOW Ø The core of the NS 2 simulator is the Scheduler

NS 2: HOW Ø The core of the NS 2 simulator is the Scheduler ² Discrete-event scheduler. ² Basic implementation, few optimization. Event in NS 2 ID TYPE TIME Packet sent Packet received Packet dropped Packet Events Timer Events HANDLER NS 2 Object + function name that should be invoked once the event is fired. Simulation time of the event Marco Di Felice NS 2: An Overview

NS 2: HOW Ø The Scheduler manages the simulation event list. ² The elements

NS 2: HOW Ø The Scheduler manages the simulation event list. ² The elements are the events of the simulation. ² The list is ordered on the basis of the time field. SIMULATION TIME: E 1. time t E 1 E 2 E 3 E 4 E 5 E 6 At each simulation step: 1 TYPE TIME HANDLER 1. The head element of the list is removed 2. The simulation time is set to E 1. time 3. The event handler (E 1. handler) is executed. Marco Di Felice NS 2: An Overview

NS 2: HOW Ø The Scheduler manages the simulation event list. ² The elements

NS 2: HOW Ø The Scheduler manages the simulation event list. ² The elements are the events of the simulation. ² The list is ordered on the basis of the time field. E 2 E 3 E 4 E 5 E 6 E 7 At each simulation step: SIMULATION TIME: E 1. time t E 1. HANDLER Ø E 1. handler is executed, and it might generate new events (e. g. E 7), that are inserted into the event list (at a position denoted by E 7. time) Marco Di Felice NS 2: An Overview

NS 2: HOW Ø Let’s make an example on a network scenario … NODE

NS 2: HOW Ø Let’s make an example on a network scenario … NODE A NODE B APPLICATION MAC ETHERNET LINK SIMULATION TIME: 0 EVENT LIST Ø At t=0, the Application module of node A is invoked Marco Di Felice NS 2: An Overview

NS 2: HOW Ø Let’s make an example on a network scenario … NODE

NS 2: HOW Ø Let’s make an example on a network scenario … NODE A NODE B APPLICATION MAC ETHERNET LINK SIMULATION TIME: 0 E 1 EVENT LIST 1 Send 4 A. APPLICATION Ø A timer event is scheduled at time 4 by node A Marco Di Felice NS 2: An Overview

NS 2: HOW Ø Let’s make an example on a network scenario … NODE

NS 2: HOW Ø Let’s make an example on a network scenario … NODE A NODE B APPLICATION MAC ETHERNET LINK SIMULATION TIME: 4 E 2 E 3 EVENT LIST Marco Di Felice 2 Recv 4. 5 A. MAC 3 Send 8 A. APPLICATION NS 2: An Overview

NS 2: HOW Ø Let’s make an example on a network scenario … NODE

NS 2: HOW Ø Let’s make an example on a network scenario … NODE A NODE B APPLICATION MAC ETHERNET LINK SIMULATION TIME: 4. 5 E 4 E 3 EVENT LIST Marco Di Felice 4 Recv 5. 0 B. MAC 3 Send 8 A. APPLICATION NS 2: An Overview

NS 2: HOW Ø Let’s make an example on a network scenario … NODE

NS 2: HOW Ø Let’s make an example on a network scenario … NODE A NODE B APPLICATION MAC ETHERNET LINK SIMULATION TIME: 5 E 3 EVENT LIST Marco Di Felice 5 Recv 5. 2 B. APPLICATION 3 Send 8 A. APPLICATION NS 2: An Overview

NS 2: HOW Ø Let’s make an example on a network scenario … NODE

NS 2: HOW Ø Let’s make an example on a network scenario … NODE A NODE B APPLICATION MAC ETHERNET LINK SIMULATION TIME: 5. 2 E 3 EVENT LIST 3 Send 8 A. APPLICATION Ø The message is processed by Node B at time 5. 2 Marco Di Felice NS 2: An Overview

Ns 2: HOW v Two ways of interactions: Ø Modify/Create a new network model

Ns 2: HOW v Two ways of interactions: Ø Modify/Create a new network model NOT EASY - Network models: network protocols, applications, queue policies, network architecture models, etc. - Coding in C++ - Recompile at the end. Ø Configure/Run a network simulation QUITE EASY - Coding in OTCL - Executed by an interpreter, no need to recompile. Marco Di Felice NS 2: An Overview

Ns 2: HOW v Running an OTCL script: ns script-file. tcl [parameters] Ø Initialize

Ns 2: HOW v Running an OTCL script: ns script-file. tcl [parameters] Ø Initialize the scheduler Ø Define the simulation parameters (e. g. start time) Ø Build the network topology Ø Generate the traffic load Ø Define the protocol stack used by each node v OTCL scripting language, OO-extension of TCL Marco Di Felice NS 2: An Overview

Ns 2: OTCL inside v Assign a value to a variable OTCL Overview set

Ns 2: OTCL inside v Assign a value to a variable OTCL Overview set x 0 v Keyword $ returns the value of a variable set y $x v Selection Statements if (if < expr >. . . else. . . ) if {$x == $y } { puts “Hello world” } v Iterative Statements for {set i 0; $i < $x ; incr i}{puts “Hello world” } v Function Declaration proc name_FUNCTION Marco Di Felice {par 1, . . . parn} {. . . return $x} NS 2: An Overview

Ns 2: HOW v Running an OTCL script: ns script-file. tcl [parameters] Ø Initialize

Ns 2: HOW v Running an OTCL script: ns script-file. tcl [parameters] Ø Initialize the scheduler Ø Define the simulation parameters (e. g. start time) Ø Build the network topology Ø Generate the traffic load Ø Define the protocol stack used by each node v OTCL scripting language, OO-extension of TCL Marco Di Felice NS 2: An Overview

Ns 2: Initialize the Scheduler v Creating the Event Scheduler set ns [new Simulator]

Ns 2: Initialize the Scheduler v Creating the Event Scheduler set ns [new Simulator] v Starting the simulation $ns run v Initializing the random number generator $ns-random SEED v Scheduling the events $ns at <time> <event> SEED=0 current timestamp All the random variable used by the current simulation are initialized with this SEED. v Stopping the simulation at time 300 $ns at 300 "finish“ Marco Di Felice NS 2: An Overview

Ns 2: HOW v Running an OTCL script: ns script-file. tcl [parameters] Ø Initialize

Ns 2: HOW v Running an OTCL script: ns script-file. tcl [parameters] Ø Initialize the scheduler Ø Define the simulation parameters (e. g. start time) Ø Build the network topology Ø Generate the traffic load Ø Define the protocol stack used by each node v OTCL scripting language, OO-extension of TCL Marco Di Felice NS 2: An Overview

Ns 2: Building the network (WIRED) CASE 1. Modeling a wired network. v Define

Ns 2: Building the network (WIRED) CASE 1. Modeling a wired network. v Define the nodes of the network set n 0 [$ns node] set n 1 [$ns node] v Define the Links among nodes #Nodes connected with an Ethernet cable, 10 Mb/s $ns duplex-link $n 0 $n 1 10 Mb 100 ms Drop. Tail Specifies bandwidth, delay, and queue policy: Drop. Tail, RED, CBQ, FQ, SFQ, DRR Marco Di Felice NS 2: An Overview

Ns 2: Building the network (WIRED) CASE 1. Modeling a wired network. v Define

Ns 2: Building the network (WIRED) CASE 1. Modeling a wired network. v Define the error model on wired links set loss_module [new Error. Model] $loss_module set rate_ 0. 1 $loss_module ranvar [new Random. Variable/Uniform] $loss_module drop-target [new Agent/Null] $ns lossmodel $loss_module $n 0 $n 1 Lossy link between node 0 and node 1, with error rate equal to 0. 1. Packets with errors are sent to Agent/Null, i. e. they are discarded. Marco Di Felice NS 2: An Overview

Ns 2: Building the network (WIRED) CASE 1. Modeling a wireless network. v Define

Ns 2: Building the network (WIRED) CASE 1. Modeling a wireless network. v Define the nodes of the network set n 0 [$ns node] set n 1 [$ns node] v Define the position set topograpy [new Topography] $topography load_flatgrid 400 Set simulation area to 400 mx 400 m v Define the position $n 0 set X_ 300 $n 0 set Y_ 400 $n 0 set Z_ 0 Marco Di Felice Set node 0 at position <300, 400, 0> NS 2: An Overview

Ns 2: Building the network (WIRED) CASE 1. Modeling a wireless network. v Define

Ns 2: Building the network (WIRED) CASE 1. Modeling a wireless network. v Define the mobility of wireless nodes NS_OBJ at TIME “NODE setdest X_COOR Y_COOR SPEED” $ns at 10. 5 “$node(0) setdest 100 5. 0” At time 10. 5, node 0 will move toward position (100, 100) with speed equal to 5 m/s (constant speed) v Utilize the General Object Director (GOD) set $god [new God] Marco Di Felice Object that stores global information about the state of the environment (e. g. the matrix of connectivity among nodes) NS 2: An Overview

Ns 2: Building the network (WIRED) CASE 1. Modeling a wireless network. v The

Ns 2: Building the network (WIRED) CASE 1. Modeling a wireless network. v The mobility traces of wireless nodes can be pregenerated by using the setdest tool (random waypoint model). /setdest [-n num_of_nodes] [-p pausetime] [-maxspeed] [-t simtime] [-x][-y] > [file. Output] In the TCL script: source “file. Output” v Any mobility simulator can be used for trace generation. MOBILITY SIMULATOR e. g. SUMO Marco Di Felice OTCL SCRIPT MOB. TRACE SOURCE NS 2: An Overview NS 2

Ns 2: HOW v Running an OTCL script: ns script-file. tcl [parameters] Ø Initialize

Ns 2: HOW v Running an OTCL script: ns script-file. tcl [parameters] Ø Initialize the scheduler Ø Define the simulation parameters (e. g. start time) Ø Build the network topology Ø Generate the traffic load Ø Define the protocol stack used by each node v OTCL scripting language, OO-extension of TCL Marco Di Felice NS 2: An Overview

Ns 2: Creating connections (UDP/TCP) v Define the end-points of the communication TCP Connections:

Ns 2: Creating connections (UDP/TCP) v Define the end-points of the communication TCP Connections: set src [new Agent/TCP] set dst [new Agent/TCPSink] UDP Connections: set src [new Agent/UDP] set dst [new Agent/Null] Several TCP variants: Ø TCP Tahoe Ø TCP Reno Ø TCP New. Reno Ø TCP Vegas Ø TCP SACK … v Connect sender and receiver $ns attach-agent $n 0 $src $ns attach-agent $n 1 $dst $ns connect $src $dst Marco Di Felice NS 2: An Overview

Ns 2: Attaching Applications v Define the application and attach it to the sender

Ns 2: Attaching Applications v Define the application and attach it to the sender FTP Agent set ftp [new Application/FTP] $ftp attach-agent $src $ns at TIME “$ftp start” CBR Agent set cbr [new Application/Traffic/CBR] $cbr attach-agent $src $ns at TIME “$cbr start” Exponential Traffic Generator set exp [new Application/Traffic/Exponential] Marco Di Felice NS 2: An Overview

Ns 2: HOW v Running an OTCL script: ns script-file. tcl [parameters] Ø Initialize

Ns 2: HOW v Running an OTCL script: ns script-file. tcl [parameters] Ø Initialize the scheduler Ø Define the simulation parameters (e. g. start time) Ø Build the network topology Ø Generate the traffic load Ø Define the protocol stack used by each node v OTCL scripting language, OO-extension of TCL Marco Di Felice NS 2: An Overview

Ns 2: HOW v A wireless environment can be modeled by configuring the protocol

Ns 2: HOW v A wireless environment can be modeled by configuring the protocol stack of each node. $ns_ node-config –phy. Type $val(netif) -prop. Type $val(prop) NET LAYER -ant. Type $val(type) -ll. Type $val(ll) QUEUE -mac. Type $val(mac) LL LAYER -ifq. Type $val(ifq) -ifq. Len $val(ifqlen) -adhoc. Routing $val(rp) MAC LAYER -topo. Instance $topo ANTENNA PROPAGATION -channel $chan_ PHY LAYER Marco Di Felice NS 2: An Overview

Ns 2: HOW v A wireless environment can be modeled by configuring the protocol

Ns 2: HOW v A wireless environment can be modeled by configuring the protocol stack of each node. $ns_ node-config –phy. Type $val(netif) -prop. Type $val(prop) NET LAYER -ant. Type $val(type) -ll. Type $val(ll) QUEUE -mac. Type $val(mac) LL LAYER -ifq. Type $val(ifq) -ifq. Len $val(ifqlen) -adhoc. Routing $val(rp) MAC LAYER -topo. Instance $topo ANTENNA PROPAGATION -channel $chan_ PHY LAYER Marco Di Felice NS 2: An Overview

Ns 2: HOW v Configuring the PHY Layer set val(netif) Phy/Wireless. Phy[Ext] ² Some

Ns 2: HOW v Configuring the PHY Layer set val(netif) Phy/Wireless. Phy[Ext] ² Some parameters to be tuned: Phy/Wireless. Phy set Pt 2. 07983391 e-01 Phy/Wireless. Phy set RXThresh 2. 591168 e-08 Phy/Wireless. Phy set CSThresh 3. 497734 e-09 ² Functionalities offered by the PHY Layers Ø Ø Signal capture Modulation & Bit-rate setting Modeling of collision/transmission errors … Marco Di Felice NS 2: An Overview

Ns 2: HOW v A wireless environment can be modeled by configuring the protocol

Ns 2: HOW v A wireless environment can be modeled by configuring the protocol stack of each node. $ns_ node-config –phy. Type $val(netif) -prop. Type $val(prop) NET LAYER -ant. Type $val(type) -ll. Type $val(ll) QUEUE -mac. Type $val(mac) LL LAYER -ifq. Type $val(ifq) -ifq. Len $val(ifqlen) -adhoc. Routing $val(rp) MAC LAYER -topo. Instance $topo ANTENNA PROPAGATION -channel $chan_ PHY LAYER Marco Di Felice NS 2: An Overview

Ns 2: HOW v Configuring the Propagation model set val(prop) Propagation/Two. Ray. Ground set

Ns 2: HOW v Configuring the Propagation model set val(prop) Propagation/Two. Ray. Ground set val(prop) Propagation/Free. Space FREE SPACE TWORAY RECEIVER SENDER v Configuring the Antenna model set val(ant. Type) Antenna/Omni. Antenna set val(ant. Type) Antenna/Directional DIRECTIONAL Marco Di Felice OMNIDIRECTIONAL NS 2: An Overview

Ns 2: HOW v A wireless environment can be modeled by configuring the protocol

Ns 2: HOW v A wireless environment can be modeled by configuring the protocol stack of each node. $ns_ node-config –phy. Type $val(netif) -prop. Type $val(prop) NET LAYER -ant. Type $val(type) -ll. Type $val(ll) QUEUE -mac. Type $val(mac) LL LAYER -ifq. Type $val(ifq) -ifq. Len $val(ifqlen) -adhoc. Routing $val(rp) MAC LAYER -topo. Instance $topo ANTENNA PROPAGATION -channel $chan PHY LAYER Marco Di Felice NS 2: An Overview

Ns 2: HOW v Configuring the LL layer set val(ll) LL Include ARP protocol

Ns 2: HOW v Configuring the LL layer set val(ll) LL Include ARP protocol v Configuring the MAC model set val(mac) Mac/802_11 v Configuring the Queue Layer Select a MAC protocol: Ø 802. 11 (Wifi) Ø 802. 15. 4 (Sensors) Ø CSMA/CA Ø … set val(ifq) Queue/Drop. Tail/Primary. Queue set val(ifqlen) 50 Set the queue length Marco Di Felice Define the queue policy: Ø Primary. Queue Ø RED Queue … NS 2: An Overview

Ns 2: HOW v A wireless environment can be modeled by configuring the protocol

Ns 2: HOW v A wireless environment can be modeled by configuring the protocol stack of each node. $ns_ node-config –phy. Type $val(netif) -prop. Type $val(prop) NET LAYER -ant. Type $val(type) -ll. Type $val(ll) QUEUE -mac. Type $val(mac) LL LAYER -ifq. Type $val(ifq) -ifq. Len $val(ifqlen) -adhoc. Routing $val(rp) MAC LAYER -topo. Instance $topo ANTENNA PROPAGATION -channel $chan PHY LAYER Marco Di Felice NS 2: An Overview

Ns 2: HOW v Configuring the routing protocol set val(adhocrouting) AODV Select a routing

Ns 2: HOW v Configuring the routing protocol set val(adhocrouting) AODV Select a routing protocol for multi-hop networks: Ø AODV, DSR, TORA, …. SOURCE ROUTING PATH Marco Di Felice DESTINATION NS 2: An Overview

Ns 2: HOW v Two ways of interactions: Ø Modify/Create a new network model

Ns 2: HOW v Two ways of interactions: Ø Modify/Create a new network model NOT EASY - Network models: network protocols, applications, queue policies, network architecture models, etc. - Coding in C++ - Recompile at the end. Ø Configure/Run a network simulation QUITE EASY - Coding in OTCL - Executed by an interpreter, no need to recompile. Marco Di Felice NS 2: An Overview

Ns 2: HOW v In C++, each model extends the class NSObject. v Each

Ns 2: HOW v In C++, each model extends the class NSObject. v Each NSObject has a correspective in OTCL. Marco Di Felice NS 2: An Overview

Ns 2: HOW v. When creating a new model in C++: Ø Extend the

Ns 2: HOW v. When creating a new model in C++: Ø Extend the NSObject class Ø Create the corresponding OTCL class Ø Implement these methods recv(Packet* p, Handler* h) Callback once a packet is received from the upper layer. command(int argc, const char*const* argv) Binding between C++ and OTCL for the parameter passing from the TCL script. Marco Di Felice NS 2: An Overview

Ns 2: Simulation Output (TRACE) v The output of the simulation is a trace

Ns 2: Simulation Output (TRACE) v The output of the simulation is a trace file, containing the description of the events occurred during the simulation. s 10. 00000 0 MAC --- 0 RTS 44 [253 e 1 0 0] r 10. 00041 1 MAC --- 0 RTS 44 [253 e 1 0 0] s 10. 00042 1 MAC --- 0 CTS 38 [2404 0 0 0] r 10. 00075 0 MAC --- 0 CTS 38 [2404 0 0 0] s 10. 00076 0 MAC --- 100 cbr 1112 [13 a 1 0 800] r 10. 00982 1 MAC --- 100 cbr 1112 [13 a 1 0 800] Simulation Time Node Packet ID Traffic type Packet size MAC Header Event Type Marco Di Felice NS 2: An Overview

Ns 2: Simulation Output (TRACE) v Depending on the length of the simulation, the

Ns 2: Simulation Output (TRACE) v Depending on the length of the simulation, the trace file might occupy lots of bytes on the disk. $ns_ node-config –agent. Trace ON/OFF -router. Trace ON/OFF -mac. Trace ON/OFF -mobility. Trace ON/OFF Configure the granularity of the tracing process … s 10. 00078 1 AGT --- 100 cbr 1112 [13 a 1 0 800] s 10. 00078 1 MAC --- 100 cbr 1112 [13 a 1 0 800] r 10. 00078 0 AGT --- 100 cbr 1112 [13 a 1 0 800] Marco Di Felice NS 2: An Overview

Ns 2: Simulation Output (NAM) v The output of the simulation can be visualized

Ns 2: Simulation Output (NAM) v The output of the simulation can be visualized by using the Network Animator (NAM) tool. Marco Di Felice NS 2: An Overview

Ns 2: Analysis of Simulation Results v NS 2 does NOT provide any specific

Ns 2: Analysis of Simulation Results v NS 2 does NOT provide any specific support for the data analysis/validation and for the computation of performance metrics (e. g. throughput, delay). v Run multiple simulations with different seeds v Remove the transient phase from the trace file v Extract the performance metrics from the trace file v Compute the average and confidence intervals v Plot the results GNUPLOT AWK, PERL, … v External data processing tools must be used. Marco Di Felice NS 2: An Overview

Ns 2: Analysis of Simulation Results v. Example: Computing the system throughput in AWK.

Ns 2: Analysis of Simulation Results v. Example: Computing the system throughput in AWK. BEGIN { recv. Byte=sim_time=transient=0. 0 } ($1==‘r’) && ($4==‘AGT’) && ($2>transient) { recv. Byte+=$8 sim_time=$2 } END { print recv. Byte/(sime_time-transient) } Marco Di Felice NS 2: An Overview