Skip to content

Instantly share code, notes, and snippets.

@batako
Created September 11, 2012 08:45
Show Gist options
  • Select an option

  • Save batako/3696983 to your computer and use it in GitHub Desktop.

Select an option

Save batako/3696983 to your computer and use it in GitHub Desktop.
NS-2
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
@batako
Copy link
Copy Markdown
Author

batako commented Sep 11, 2012

ns simple.tcl

@batako
Copy link
Copy Markdown
Author

batako commented Sep 11, 2012

ns simple.tcl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment