Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to ns-2: “The” Network Simulator

Similar presentations


Presentation on theme: "Introduction to ns-2: “The” Network Simulator"— Presentation transcript:

1 Introduction to ns-2: “The” Network Simulator
Goals: tutorial overview of ns flavor of ns: simple example, model specification, execution and trace analysis Daniel Figueiredo November, 2004

2 Ns-2, the network simulator
Academic project over 10 years old freely distributed, open source Currently maintained by ISI DARPA + NSF projects ~ 200K LoC, ~400 page manual Large user base mostly academics “de facto” standard in networking research Main website:

3 Ns Functionality Discrete event simulator
Traffic models and applications Web, FTP, telnet, audio, sensor nets Transport protocols TCP (Reno, SACK, etc), UDP, multicast Routing and queuing static routing, DV routing, multicast, ad-hoc routing queuing disciplines: drop-tail, RED, FQ Link layer wired, wireless, satellite Infrastructure tracing, visualization, error models, etc modify or create your own modules

4 Ns components Ns, the simulator itself (this is all we’ll have time for) nam, the Network AniMator visualize Ns (or other) output GUI input simple Ns scenarios pre-processing: traffic and topology generators post-processing: simple trace analysis, often in Awk, Perl, or Tcl Tutorial: Ns by example:

5 Ns Software Structure: C++ and OTCL
Uses two languages C++ for packet-processing per packet processing fast to run, detailed, complete control OTCL for control [our focus] simulation setup, configuration, occasional actions fast to write and change

6 Steps when using Ns Create OTCL script with network model
nodes, links, traffic sources, sinks, etc. Parameterize simulation objects queue sizes, link speeds, TCP flavor and parameters (more than 30) Collect statistics dump everything to trace, post process it gather stats during simulation within OTCL script modify Ns source code Run Ns multiple times confidence intervals

7 Creating a Basic Ns Model
Create the event scheduler Create nodes and links Create connection Create traffic sources/sinks Enable tracing

8 Creating Event Scheduler
Create scheduler set ns [new Simulator] Schedule event $ns at <time> <event> <event>: any legitimate Ns/TCL commands Start scheduler $ns run

9 Creating Network (Nodes + Links)
set n0 [$ns node] set n1 [$ns node] Links: connect together two nodes $ns duplex-link $n0 $n1 <bandwidth> <delay> <queue_type> <delay> determines propagation delay <queue_type> determines queueing policy DropTail, RED, CBQ, FQ, SFQ, DRR

10 Transport and Traffic Models
Two layer approach Transports: TCP, UDP, multicast, etc. transport protocol instances attach to nodes Traffic (applications): (known as agents) Web, ftp, telnet, audio, etc. application instances attach to transport protocol instances generates traffic into transport protocol

11 Creating Transport Channels: TCP
source and sink set t_src [new Agent/TCP/Newreno] set t_dst [new Agent/TCPSink] “Newreno” flavor of TCP attach to nodes and each other $ns attach-agent $n0 $t_src $ns attach-agent $n1 $t_dst $ns connect $t_src $t_dst

12 Creating Traffic over TCP Channels
FTP create traffic model set ftp [new Application/FTP] default is “infinite” file size attach to TCP channel $ftp attach-agent $t_src schedule start time $ns at <time> “$ftp start”

13 Creating Transport Channels: UDP
source and sink set u_src [new Agent/UDP] set u_dst [new Agent/NULL] attach them to nodes, then connect to each other $ns attach-agent $n0 $u_src $ns attach-agent $n1 $u_dst $ns connect $u_src $u_dst

14 Creating Traffic over UDP Channels
CBR set cbr [new Application/Traffic/CBR] $cbr set packetSize_ 512 $cbr set interval_ 0.250 $cbr attach-agent $u_src $ns at <time> “$cbr start”

15 Tracing Trace packets on individual links Tracefile format: packet
<event> <time> <from> <to> <pkt> <size>--<flowid> <src> <dst> <seqno> <aseqno> tcp tcp r tcp packet type packet flags time seq number packet ID + enqueue dequeue r receive d drop packet length flow ID nodes involved in this event source dest addresses

16 Tracing via Monitors Queue monitor Flow monitor
queue to access the link Flow monitor particular flow within queue set fmon [$ns makeflowmon Fid] $ns attach-fmon $link $fmon $ns at <time> “puts $fmon set pdrops_” to specify a link, we need: set link [$ns link $n0 $n1]

17 Walk-through example FTP/TCP 10 FTP/TCP dest 2 FTP/TCP sources sources
TCP SACK W_max = 32 MSS = 1400 TCP NewReno W_max = 32 MSS = 1400 1 CBR/UDP source FTP/TCP dest 10 FTP/TCP sources 2 FTP/TCP sources 1 2 acks acks 1 On-Off (voice) UDP source OnOff/UDP CBR/UDP dest 2 Mbps full duplex 5 msec prop delay 100 packet buffer Drop-tail policy 1 Mbps full duplex 10 msec prop delay 700 packet buffer Drop-tail policy

18 Ns Trace file : NS-trace.txt
... tcp r tcp exp cbr r tcp tcp r exp cbr tcp r cbr exp tcp tcp r tcp r exp exp

19 Flow Monitor Trace : packet-trace.txt
...

20 Results - Queue Statistics
Red - instantaneous Green - running average Blue - average w/o transient Light blue - packet drops

21 Results - Flow Statistics
Red - TCP flow 1 Green - TCP flow 2 Number of packets in queue mimics TCP Window behavior

22 Performance Queue Statistics
Multiple runs to obtain confidence intervals


Download ppt "Introduction to ns-2: “The” Network Simulator"

Similar presentations


Ads by Google