Upload
leslie-leonard
View
217
Download
0
Embed Size (px)
Citation preview
Network Simulator-2
Sandeep singla
1998A2A7540
NS-2
• A discrete event simulator
• Focused on modeling network protocols– Wired, wireless– TCP,UDP,unicast,multicast– Web,telnet,ftp– Routing protocols– Error modeling
Ns components
• Ns, the simulator itself• Nam, Network animator
– Visualize the ns output– GUI input the simple scenarios
• Preprocessing– Traffic and topology generator
• Post processing– Simple trace analysis,often in TCL
Languages
• Uses two languages– C++ for packet processing
• Fast to run,detailed,complete control
– TCL for control• Simulation setups,configuration,occasional events
• Fast to write and change
TCL
• The file has the extension .tcl.
• To start the first line is.– Set ns [new simulator].– This will create a simulator object.
TCL
• Next a file is opened for dumping all the trace data to be used by nam (network animator).– Set nf [open out.Nam w].– $Ns namtrace-all $nf.
TCL
• The next step is to add a finish procedure to close the trace file and start the nam.– Proc finish {} {
Global ns nf$Ns flush-traceClose $nfExec nam out.Nam &Exit 0
}
TCL
• The next step is to execute the finish procedure and then start the simulation.– $ns at 5.0 "finish" – $ns run
Adding Nodes and Links
• To create a network node– Set n0 [$ns node]
Adding Nodes and Links
• To create a link between two nodes– $Ns duplex-link $n0 $n1 1mb 10ms DropTail– Specifies bandwidth,delay,and queue type
• Drop tail,RED,CBQ,FQ,SFQ,DRR
Adding Nodes and Links
• To send data– Set udp0 [new agent/UDP]
$Ns attach-agent $n0 $udp0 Set cbr0 [new application/traffic/CBR] Set null0 [new agent/null] $Ns attach-agent $n1 $null0 $Ns connect $udp0 $null0 $Ns at 0.5 "$cbr0 start" $Ns at 4.5 "$cbr0 stop"
Routing Alternatives
• Unicast– $ns rtproto <type>– <type>:static,session,DV,cost,multi-path
• Multicast– $ns multicast– $ns mrtproto <type>– <type>:DM,ST,BST,CtrMcast
What More Can Be Done..
• Ns-2 offers a simulation of a variety of protocols ex: various routing protocols, various multicast and broadcast protocols.
• All the links can be monitored and graphs can be created of the traffic pattern using a tool that comes along with the ns-2 package- x graph.
What More Can Be Done..
• Wireless networks can be simulated using ns-2 and various tools have been provided for this purpose.
• The various network failures scenarios can also be simulated, for example failure of a link or a node.