14
Network Simulator-2 Sandeep singla 1998A2A7540

Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

Embed Size (px)

Citation preview

Page 1: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

Network Simulator-2

Sandeep singla

1998A2A7540

Page 2: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

NS-2

• A discrete event simulator

• Focused on modeling network protocols– Wired, wireless– TCP,UDP,unicast,multicast– Web,telnet,ftp– Routing protocols– Error modeling

Page 3: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

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

Page 4: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

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

Page 5: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

TCL

• The file has the extension .tcl.

• To start the first line is.– Set ns [new simulator].– This will create a simulator object.

Page 6: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

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.

Page 7: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

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

}

Page 8: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

TCL

• The next step is to execute the finish procedure and then start the simulation.– $ns at 5.0 "finish" – $ns run

Page 9: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

Adding Nodes and Links

• To create a network node– Set n0 [$ns node]

Page 10: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

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

Page 11: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

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"

Page 12: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

Routing Alternatives

• Unicast– $ns rtproto <type>– <type>:static,session,DV,cost,multi-path

• Multicast– $ns multicast– $ns mrtproto <type>– <type>:DM,ST,BST,CtrMcast

Page 13: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

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.

Page 14: Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast

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.