Tuesday, November 6, 2018

Study and installation of Network Simulator. Modify the same example such that node n0 sends data to n1 - Computer Networks | TCL

#Save File as .tcl
#OS - Linux
#File Execution - Any Linux Terminal

#Step:1 - Take New Simulator, Open it and how to execute
set ns [new Simulator] 
set nf [open out.nam w]
$ns namtrace-all $nf
 
proc finish {} {
            global ns nf
            $ns flush-trace
            close $nf
            exec nam out.nam &
            exit 0
}

#step:2 - Two Nodes, one link
set n0 [$ns node]
set n1 [$ns node]
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
 
#step 3 - Sending Data
#Create a UDP agent and attach it to node n0
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
 
# Create a CBR traffic source and attach it to udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
 
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"
 
$ns at 5.0 "finish"
$ns run

Creating a node and Agent to send Data

Sending Data from node 0 to node 1

No comments:

Post a Comment