/usr/share/doc/nam/examples/iecdemos/tcp-common.tcl is in nam-examples 1.15-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | # begin common code
set ftime_ 1.5
proc finish {} {
global ns nf ofile
$ns flush-trace
close $nf
puts "filtering..."
exec tclsh ../bin/namfilter.tcl ${ofile}.nam
exec rm -f ${ofile}.de
exec make_dropevents ${ofile}.tr > ${ofile}.de
puts "running nam..."
exec nam ${ofile}.nam &
exit 0
}
set ns [new Simulator]
set f [open ${ofile}.tr w]
$ns trace-all $f
set nf [open ${ofile}.nam w]
$ns namtrace-all $nf
# define color index
$ns color 0 red
$ns color 1 blue
$ns color 2 chocolate
$ns color 3 red
$ns color 4 brown
$ns color 5 tan
$ns color 6 gold
$ns color 7 black
# define nodes
set n0 [$ns node]
$n0 color blue
$n0 shape circle
set n1 [$ns node]
$n1 color blue
$n1 shape circle
set n2 [$ns node]
$n2 color blue
$n2 shape circle
set n3 [$ns node]
$n3 color blue
$n3 shape circle
set router [$ns node]
$router color red
$router shape hexagon
set r2 [$ns node]
$r2 color blue
$r2 shape hexagon
$ns at 0.0 "$n2 label \" link(${L1rate},${L1del}) typ\""
$ns at 0.0 "$r2 label \"/---(${L2rate},${L2del}) \""
$ns at 0.0 "$router label \" Q(${L2qlim},${L2type})\""
# define topology
$ns duplex-link $n0 $router $L1rate $L1del $L1type
$ns duplex-link $n2 $router $L1rate $L1del $L1type
$ns duplex-link $router $r2 $L2rate $L2del $L2type
$ns duplex-link $r2 $n1 $L1rate $L1del $L1type
$ns duplex-link $r2 $n3 $L1rate $L1del $L1type
# and orientation
$ns duplex-link-op $n0 $router orient right-down
$ns duplex-link-op $r2 $n1 orient right-up
$ns duplex-link-op $n2 $router orient right-up
$ns duplex-link-op $r2 $n3 orient right-down
$ns duplex-link-op $router $r2 orient right
# queue limitations and nam trace info
$ns queue-limit $router $r2 $L2qlim
$ns simplex-link-op $router $r2 queuePos 0.4
Agent/TCP set nam_tracevar_ true
set tcp [new $tcptype]
$ns attach-agent $n0 $tcp
if [info exists sinktype] {
set sink [new $sinktype]
} else {
set sink [new Agent/TCPSink]
}
# just turn these on always, to mark cong action pkts
$sink set ecn_ true
$tcp set ecn_ true
if [info exists ecn] {
puts "using ECN in router"
[[$ns link $router $r2] queue] set setbit_ true
}
if [info exists blimit] {
puts "setting DRR limit to $blimit"
[[$ns link $router $r2] queue] set blimit_ $blimit
}
$ns attach-agent $n1 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
#$ns add-agent-trace $tcp tcp
#$ns monitor-agent-trace $tcp
#$tcp tracevar cwnd_
set udp [new Agent/UDP]
$udp set fid_ 1
$ns attach-agent $n2 $udp
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 1000
$cbr set interval_ 0.02
if [info exists cbrrate] {
$cbr set interval_ $cbrrate
}
$cbr attach-agent $udp
set na [new Agent/Null]
$ns attach-agent $n3 $na
$ns connect $udp $na
$ns at 0.0 "$ns set-animation-rate 2ms"
$ns at $ftpstart "$ftp start"
$ns at $cbrstart "$cbr start"
if [info exists endtime] {
set ftime_ $endtime
}
$ns at 0.0 "$ns trace-annotate \"$ofile agent starting\""
$ns at $ftpstart "$ns trace-annotate \"FTP starts at $ftpstart\""
$ns at $cbrstart "$ns trace-annotate \"CBR starts at $cbrstart\""
$ns at [expr $ftime_ + .49] "$ns trace-annotate \"FTP stops\""
$ns at [expr $ftime_ + 0.5] "$ns detach-agent $n0 $tcp ; $ns detach-agent $n1 $sink"
$ns at [expr $ftime_ + 0.55] "finish"
source $ofile.de
# end common code
|