Debian Codegraph @

tcl/ex/asym/asym-test-2.tcl

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!../../../../ns
2 #source ../../../lan/ns-lan.tcl
3 source ../../../ex/asym/util.tcl
4
5 # set up simulation
6
7 set ns [new Simulator]
8
9 set n0 [$ns node]
10 set n1 [$ns node]
11 set n2 [$ns node]
12 set n3 [$ns node]
13
14 set f [open out.tr w]
15 $ns trace-all $f
16
17 set tcptrace [open tcp.tr w]
18 set sinktrace [open sink.tr w]
19 set redtrace [open red.tr w]
20 set graph 0
21 set connGraphFlag("") 0
22 set maxdelack 25
23 set maxburst 3
24 set upwin 0
25 set tcpTick 0.1
26 set ackSize 40
27 set rbw 28.8Kb
28 set rqsize 10
29 set qsize 10
30 set rgw "DropTail"
31 set nonfifo 0
32 set acksfirst false
33 set filteracks false
34 set replace_head false
35 set midtime 0
36
37 proc printUsage {} {
38 puts "Usage: "
39 exit
40 }
41
42 proc finish {ns traceall tcptrace graph connGraphFlag midtime} {
43 upvar $connGraphFlag graphFlag
44
45 $ns flush-trace
46 close $traceall
47 flush $tcptrace
48 close $tcptrace
49 plotgraph $graph $graphFlag $midtime
50 exit 0
51 }
52
53 # read user options and act accordingly
54 set count 0
55 while {$count < $argc} {
56 set arg [lindex $argv $count]
57 incr count 2
58 switch -exact '$arg' {
59 '-graph' {
60 set graph 1
61 incr count -1
62 continue
63 }
64 '-mda' {
65 set maxdelack [lindex $argv [expr $count-1]]
66 continue
67 }
68 '-acksz' {
69 set ackSize [lindex $argv [expr $count-1]]
70 continue
71 }
72 '-mb' {
73 set maxburst [lindex $argv [expr $count-1]]
74 continue
75 }
76 '-upwin' {
77 set upwin [lindex $argv [expr $count-1]]
78 continue
79 }
80 '-tk' {
81 set tcpTick [lindex $argv [expr $count-1]]
82 continue
83 }
84 '-rbw' {
85 set rbw [lindex $argv [expr $count-1]]
86 continue
87 }
88 '-rq' {
89 set rqsize [lindex $argv [expr $count-1]]
90 continue
91 }
92 '-q' {
93 set qsize [lindex $argv [expr $count-1]]
94 Queue set limit_ $qsize
95 continue
96 }
97 '-nonfifo' {
98 set nonfifo 1
99 incr count -1
100 continue
101 }
102 '-noecn' {
103 Agent/TCP set disable_ecn_ 1
104 incr count -1
105 continue
106 }
107 '-red' {
108 set rgw "RED"
109 incr count -1
110 continue
111 }
112 '-acksfirst' {
113 set acksfirst true
114 incr count -1
115 continue
116 }
117 '-filteracks' {
118 set filteracks true
119 incr count -1
120 continue
121 }
122 '-replace_head' {
123 set replace_head true
124 incr count -1
125 continue
126 }
127 '-mid' {
128 set midtime [lindex $argv [expr $count-1]]
129 continue
130 }
131 default {
132 incr count -2
133 }
134 }
135 switch -exact '$arg' {
136 '-dn' {
137 set direction "down"
138 }
139 '-up' {
140 set direction "up"
141 }
142 default {
143 puts "arg $arg"
144 printUsage
145 exit
146 }
147 }
148 incr count 1
149 set arg [lindex $argv $count]
150 switch -exact '$arg' {
151 '-asym' {
152 set type "asym"
153 }
154 '-asymsrc' {
155 set type "asymsrc"
156 }
157 '-reno' {
158 set type "reno"
159 }
160 default {
161 puts "arg $arg"
162 printUsage
163 exit
164 }
165 }
166 incr count 1
167 set arg [lindex $argv $count]
168 set startTime $arg
169 incr count 1
170
171 set connGraph 0
172 set arg [lindex $argv $count]
173 if { $arg == "-graph" } {
174 set connGraph 1
175 incr count 1
176 }
177
178 if { $direction == "down" } {
179 set src $n0
180 set dst $n3
181 } elseif { $direction == "up" } {
182 set src $n3
183 set dst $n0
184 } else {
185 }
186
187 if { $type == "asym" } {
188 set tcp [createTcpSource "TCP/Reno/Asym" $maxburst $tcpTick]
189 set sink [createTcpSink "TCPSink/Asym" $sinktrace $ackSize $maxdelack]
190 } elseif { $type == "asymsrc" } {
191 set tcp [createTcpSource "TCP/Reno/Asym" $maxburst $tcpTick]
192 set sink [createTcpSink "TCPSink" $sinktrace $ackSize]
193 } elseif { $type == "reno" } {
194 set tcp [createTcpSource "TCP/Reno" $tcpTick]
195 set sink [createTcpSink "TCPSink" $sinktrace $ackSize]
196 }
197
198 if { $direction == "up" && $upwin != 0 } {
199 $tcp set window_ $upwin
200 }
201 set ftp [createFtp $ns $src $tcp $dst $sink]
202 setupTcpTracing $tcp $tcptrace
203 setupGraphing $tcp $connGraph connGraphFlag
204 $ns at $startTime "$ftp start"
205 }
206
207 # topology
208 #
209 # 10Mb, 1ms 10Mb, 5ms 10Mb, 1ms
210 # n0 ------------ n1 ------------ n2 ------------ n3
211 # 28.8Kb, 50ms
212 #
213 $ns duplex-link $n0 $n1 10Mb 1ms DropTail
214 $ns simplex-link $n1 $n2 10Mb 5ms DropTail
215 $ns simplex-link $n2 $n1 $rbw 50ms $rgw
216 $ns duplex-link $n2 $n3 10Mb 1ms DropTail
217
218 # configure reverse bottleneck queue
219 configQueue $ns $n2 $n1 $rgw $redtrace $rqsize $nonfifo $acksfirst $filteracks $replace_head
220
221 # end simulation
222 $ns at 30.0 "finish $ns $f $tcptrace $graph connGraphFlag $midtime"
223
224 $ns run