Network simulator tool (ns2)
Network Simulator Tool NS-2 provides substantial support for simulation of TCP, routing, and multicast protocols over wired and wireless (local and satellite) networks.In which physical activites are translated into events and events are queued and processed in the order of their scheduled occurrences.
Procedures used to define program in ns2:
- Creating event scheduler
- Turn on tracing
- Create network
- Find out routes and setup routing (rtproto)
- Develop transport connections (Agents)
- Create traffic (Applications)
- Monitoring.
Sample NS2 Programs
#Create a Simulator set ns [new Simulator] # Create a trace file set extrace [open out.tr w] $ns trace-all $mytrace # Create a NAM trace file set exNAM [open out.nam w] $ns namtrace-all $exNAM # Define a procedure finish proc finish { } { global ns extrace exNAM $ns flush-trace close $extrace close $exNAM exec nam out.nam & exit 0 } # Create Nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] # Connect Nodes with Links $ns duplex-link $n0 $n2 100Mb 5ms DropTail $ns duplex-link $n1 $n2 100Mb 5ms DropTail $ns duplex-link $n2 $n4 54Mb 10ms DropTail $ns duplex-link $n2 $n3 54Mb 10ms DropTail $ns simplex-link $n3 $n4 10Mb 15ms DropTail $ns queue-limit $n2 $n3 40
creating Nodes in Network Simulator Tool NS2
for {set i 0} {$i < $val(nn) } {incr i} { set node_($i) [$ns node] $node_($i) random-motion 0 }
Journal Support for Ns2 Projects: Network Simulator Tool NS-2