Académique Documents
Professionnel Documents
Culture Documents
Network Simulator v2
Todays objective
What is network simulation? Why simulate? What is ns2? How to work in ns2, the basics Example
Very complex Can be as small as a two nodes Can even span up to millions of nodes
Internet Kisi baat se! Cost of failed experiment can be in millions per second
Simulation
No danger of messing things up Can experiment with many radical ideas Verify the workability of a proposed algorithm
NS2
Discrete event simulator Works at packet level Support for many commonly used protocols
Can simulate wired and wireless networks Is primarily Unix based Uses TCL as scripting language Widely used in the research community
Ns2 explained
otcl: Object-oriented support tclcl: C++ and otcl linkage Discrete event scheduler Data components
Ns2 implementation
C++
Difficult to debug
Tcl
Quickly create many different scenarios Time to create and test scenarios is short
Basic tcl
proc test {} { set a 43 set b 27 set c [expr $a + $b] set d [expr [expr $a - $b] * $c] for {set k 0} {$k < 10} {incr k} { puts k = $k } }
Basic Otcl
Class mom mom instproc greet {} { $self instvar age_ puts $age_ years old mom: How are you doing? } Class kid -superclass mom kid instproc greet {} { $self instvar age_ puts $age_ years old kid: Whats up, dude? }
set a [new mom] $a set age_ 45 set b [new kid] $b set age_ 15 $a greet $b greet
Ns 2
Deals with all the layers Create network (physical layer) Create link and queue (data-link layer) Define routing protocol Create transport connection (transport layer) Create traffic (application layer) To test your scenario you can even insert errors
First step
set s1 [$ns node] set s2 [$ns node] set router [$ns node] set d [$ns node] $ns duplex-link $s1 $router 1.5Mb 15ms DropTail $ns duplex-link $s2 $router 1.5Mb 15ms DropTail $ns duplex-link $router $d 2Mb 15ms DropTail $ns queue-limit $s1 $router 50
set tcpSender1 [$ns create-connection TCP $s1 TCPSink $d 0] set tcpSender2 [$ns create-connection TCP $s2 TCPSink $d 1]
set ftp1 [new Application/FTP] $ftp1 attach-agent $tcpSender1 set ftp2 [new Application/FTP] $ftp2 attach-agent $tcpSender2
$ns at 0.0 "$ftp1 start" $ns at 0.0 "$ftp2 start" $ns run
Refrences