Beruflich Dokumente
Kultur Dokumente
Introduction[1]
Ns-2 is a discrete event simulator targeted at network research Focused on modeling network protocols
wired, wireless, satellite TCP, UDP, multicast, unicast web, telnet, ftp ad hoc routing, sensor networks
Introduction[2]
Physical activities are translated to events Events are queued and processed in the order of their scheduled occurrences Time progresses as the events are processed
Time: 1.5 sec Time: 1.7 sec
1
Time: 2.0 sec
2
Time: 1.8 sec
Components of ns
visualize ns (or other) output GUI input simple ns scenarios traffic and topology generators simple trace analysis, often in Awk, Perl, or Tcl
Pre-processing:
Post-processing:
pros: trade-off running vs. writing speed, powerful/documented config language cons: two languages to learn and debug in
NS-2 programming
Computing routes and Setup routing - rtproto Creating transport connections Agents Creating traffic Applications
Monitoring
Schedule events
$ns at <time> <event> <event>: any legitimate ns/tcl commands $ns run
Start scheduler
Tracing
Creating Network
Nodes
n0
n1
Creating Network
UDP
set src [new Agent/UDP] set rcv [new Agent/Null] $ns connect $src $rcv set tcp [new Agent/TCP] set tcpsink [new Agent/TCPSink] $ns connect $tcp $tcpsink
TCP
TCP TCPsink
one-way Tahoe implementation other flavors: TCP/Reno, TCP/NewReno, TCP/Sack1, TCP/Vegas two-way: use FullTCP at both sides
RAP <-> RAP Rate Adaptation Protocol (ratebased AIMD + Slow Start) TFRC <-> TFRCSink TCP Friendly Rate Control protocol (based on TCP throughput-equation)
set ftp [new Application/FTP] $ftp attach-agent $tcp set telnet [new Application/Telnet] set session [new httpSession $ns <numPages> <clientNode>] set cbr [new Application/traffic/cbr]
Telnet
Web
Traffic generator
Computing Routes
Unicast
$ns rtproto <type> <type>: Static, Session, DV, cost, multipath Simulator set EnableMcast_ 1 Simulator set NumberInterfaces_ 1 $ns mrtproto <type> <type>: CtrMcast, DM, dynamicDM, pimDM
Multicast
n1
set tcp [new Agent/TCP] set tcpsink [new Agent/TCPSink] $ns attach-agent $n0 $tcp $ns attach-agent $n1 $tcpsink $ns connect $tcp $tcpsink $ftp attach-agent $tcp $ns at 0.2 "$ftp start" $ns at 1.2 exit" $ns run
$ns duplex-link $n0 $n1 1Mb 10ms DropTail set ftp [new Application/FTP]
Screenshots
Tcl Basics
Variable substitution
Arithmetic Expressions
Operation substitution
Printing
Control Structures
Procedures
NS Models
Transport protocols:
Physical media:
#Open the general trace file set tf [open out.tr w] # Start tracing $ns trace-all $tf
$ns run
n0 n1
UDP
n2
cbr1 UDP
UDP
n3
null0
#Define different colors for data flows #Create links between the nodes $ns color 1 Blue # only one sample line as in ex 1 $ns color 2 Red
# Set orientation of the links $ns duplex-link-op $n0 $n2 orient rightdown #Monitor (Visualize) the queue for the # link between node 2 and node 3 $ns duplex-link-op $n2 $n3 queuePos 0.5
$ns rtproto DV
#Open the nam trace file # as in example 1 #Define a 'finish' procedure # as in example 1 #Create seven nodes in a loop
#Create links between the nodes for {set i 0} {$i < 7} {incr i} { $ns duplex-link $n($i) $n([expr ($i+1)%7]) 1Mb 10ms DropTail }
Ns2 can be accessed from 1101 IPC Lab. Note: Wednesday 14/10/08 at 5:00 PM a practice lab session will be conducted in IPC @ 1101