12.07.2015 Views

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

$<strong>ns</strong> <strong>at</strong>tach-agent $n_sink $sink# make the connection$<strong>ns</strong> connect $src $sink$sink listen# cre<strong>at</strong>e r<strong>and</strong>om variablesset recvr_delay [new R<strong>and</strong>omVariable/Uniform];$recvr_delay set min_ 1$recvr_delay set max_ 20set sender_delay [new R<strong>and</strong>omVariable/Uniform];$sender_delay set min_ 20$sender_delay set max_ 100set recvr_bw [new R<strong>and</strong>omVariable/Co<strong>ns</strong>tant];$recvr_bw set val_ 100set sender_bw [new R<strong>and</strong>omVariable/Uniform];$sender_bw set min_ 1$sender_bw set max_ 20set loss_r<strong>at</strong>e [new R<strong>and</strong>omVariable/Uniform];$loss_r<strong>at</strong>e set min_ 0$loss_r<strong>at</strong>e set max_ 0.01# delay 1-20 ms# delay 20-100 ms# bw 100 Mbps# bw 1-20 Mbps# loss 0-1% loss# setup rules for DelayBoxes$db(0) add-rule [$n_src id] [$n_sink id] $recvr_delay $loss_r<strong>at</strong>e $recvr_bw$db(1) add-rule [$n_src id] [$n_sink id] $sender_delay $loss_r<strong>at</strong>e $sender_bw# output delays to files$db(0) set-delay-file "db0.out"$db(1) set-delay-file "db1.out"# schedule traffic$<strong>ns</strong> <strong>at</strong> 0.5 "$src advance 10000"$<strong>ns</strong> <strong>at</strong> 1000.0 "$db(0) close-delay-file; $db(1) close-delay-file; exit 0"# start the simul<strong>at</strong>ion$<strong>ns</strong> run22.3 Comm<strong>and</strong>s <strong>at</strong> a Glance<strong>The</strong> following comm<strong>and</strong>s on the DelayBox class can be accessed from OTcl:[$<strong>ns</strong> DelayBox]Cre<strong>at</strong>es a new DelayBox node.$delaybox add-rule [] []Add a rule to the rule table, specifying delay, loss r<strong>at</strong>e, <strong>and</strong> bottleneck link speed R<strong>and</strong>omVariables for packets flowing fromsrcNode to dstNode. Delay is required, but loss r<strong>at</strong>e <strong>and</strong> link speed are optional.$delaybox list-rulesList all rules in the rule table210

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!