Created
September 11, 2012 08:45
-
-
Save batako/3696983 to your computer and use it in GitHub Desktop.
NS-2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set ns [new Simulator] | |
set f [open out.tr w] | |
$ns trace-all $f | |
set nf [open out.nam w] | |
$ns namtrace-all $nf | |
set n0 [$ns node] | |
set n1 [$ns node] | |
$ns duplex-link $n0 $n1 5Mb 2ms DropTail | |
set udp0 [new Agent/UDP] | |
$ns attach-agent $n0 $udp0 | |
set cbr0 [new Application/Traffic/CBR] | |
$cbr0 attach-agent $udp0 | |
set null0 [new Agent/Null] | |
$ns attach-agent $n1 $null0 | |
$ns connect $udp0 $null0 | |
$ns at 1.0 "$cbr0 start" | |
$ns at 3.0 "finish" | |
proc finish {} { | |
global ns f nf | |
$ns flush-trace | |
close $f | |
close $nf | |
puts "running nam..." | |
exec nam out.nam & | |
exit 0 | |
} | |
$ns run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ns simple.tcl