-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-program.tcl
325 lines (260 loc) · 9.47 KB
/
test-program.tcl
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
source /home/gwm/gao/ns-allinone-2.35/ns-2.35/test/ReadFile.tcl; #author by
set pathNum 4
set lineRateDown 1Gb
set lineRateUp 1Gb
set packetSize 1460
set RTT 0.0001
set K 65
set startSwitchID 0
set longfno 0
set shortfno 30
set N 8
set B 250
set simulationTime 1.0
set startMeasurementTime 1
set stopMeasurementTime 2
set flowClassifyTime 0.001
set sourceAlg DC-TCP-Sack
set switchAlg RED
set DCTCP_g_ 0.0625
set ackRatio 1
set packetSize 1460
set traceSamplingInterval 0.0001
set throughputSamplingInterval 0.01
set enableNAM 0
set ns [new Simulator]
Node set multiPath_ 1
Classifier/MultiPath set perflow_ 1
Classifier/MultiPath set checkpathid_ 1
Agent/TCP set ecn_ 1
Agent/TCP set old_ecn_ 1
Agent/TCP set packetSize_ $packetSize
Agent/TCP/FullTcp set segsize_ $packetSize
Agent/TCP set window_ 1256
Agent/TCP set slow_start_restart_ false
Agent/TCP set tcpTick_ 0.01
Agent/TCP set minrto_ 0.01 ; # minRTO = 200ms
Agent/TCP set windowOption_ 0
#if {[string compare $sourceAlg "DC-TCP-Sack"] == 0} {
Agent/TCP set dctcp_ true
Agent/TCP set dctcp_g_ $DCTCP_g_;
#}
Agent/TCP/FullTcp set segsperack_ $ackRatio;
Agent/TCP/FullTcp set spa_thresh_ 3000;
Agent/TCP/FullTcp set interval_ 0.04 ; #delayed ACK interval = 40ms
Queue set limit_ 1000
Queue/RED set bytes_ false
Queue/RED set queue_in_bytes_ true
Queue/RED set mean_pktsize_ $packetSize
Queue/RED set setbit_ true
Queue/RED set gentle_ false
Queue/RED set q_weight_ 1.0
Queue/RED set mark_p_ 1.0
Queue/RED set thresh_ [expr $K]
Queue/RED set maxthresh_ [expr $K]
DelayLink set avoidReordering_ true
set f [open ps.tr w]
$ns trace-all $f
set nf [open ps.nam w]
$ns namtrace-all $nf
set now [$ns now]
set now [format "%.6f" $now];
set linkIDTrace [open linkIDTrace.tr w]
set simpleLinkTrace [open simpleLinkTrace.tr w]
set storedStartSwitchIDFile [open storedStartSwitchID.tr w]
puts $storedStartSwitchIDFile "startSwitchID $startSwitchID pathnum $pathNum $now"
close $storedStartSwitchIDFile
$ns color 1 Red
$ns color 2 Yellow
$ns color 3 Green
#node
for {set i 0} {$i<[expr $pathNum+2]} {incr i} {
set n($i) [$ns node]
}
for {set i 1000} {$i<[expr $shortfno+1000]} {incr i} {
set n($i) [$ns node]
}
for {set i 2000} {$i<[expr $longfno+2000]} {incr i} {
set n($i) [$ns node]
}
for {set i 3000} {$i<[expr $shortfno+3000]} {incr i} {
set n($i) [$ns node]
}
for {set i 4000} {$i<[expr $longfno+4000]} {incr i} {
set n($i) [$ns node]
}
#link
for {set i 1000} {$i<[expr $shortfno+1000]} {incr i} {
$ns simplex-link $n($i) $n(0) $lineRateUp [expr $RTT/8] DropTail
$ns simplex-link $n(0) $n($i) $lineRateUp [expr $RTT/8] RED
$ns queue-limit $n($i) $n(0) 2000
}
for {set i 2000} {$i<[expr $longfno+2000]} {incr i} {
$ns simplex-link $n($i) $n(0) $lineRateUp [expr $RTT/8] DropTail
$ns simplex-link $n(0) $n($i) $lineRateUp [expr $RTT/8] RED
$ns queue-limit $n($i) $n(0) 2000
}
for {set i 1} {$i<[expr $pathNum+1]} {incr i} {
$ns duplex-link $n(0) $n($i) $lineRateDown [expr $RTT/8] RED
$ns queue-limit $n(0) $n($i) 256
}
#$ns simplex-link $n(0) $n(2) $lineRateDown [expr $RTT/8+0.000276] RED
#$ns simplex-link $n(2) $n(0) $lineRateDown [expr $RTT/8] RED
#$ns queue-limit $n(0) $n(2) 256
#$ns simplex-link $n(0) $n(3) $lineRateDown [expr $RTT/8+0.000240] RED
#$ns simplex-link $n(3) $n(0) $lineRateDown [expr $RTT/8] RED
#$ns queue-limit $n(0) $n(3) 256
#$ns simplex-link $n(0) $n(4) $lineRateDown [expr $RTT/8+0.000240] RED
#$ns simplex-link $n(4) $n(0) $lineRateDown [expr $RTT/8] RED
#$ns queue-limit $n(0) $n(4) 256
#$ns simplex-link $n(0) $n(5) $lineRateDown [expr $RTT/8+0.000240] RED
#$ns simplex-link $n(5) $n(0) $lineRateDown [expr $RTT/8] RED
#$ns queue-limit $n(0) $n(5) 256
#$ns simplex-link $n(0) $n(6) $lineRateDown [expr $RTT/8+0.000240] RED
#$ns simplex-link $n(6) $n(0) $lineRateDown [expr $RTT/8] RED
#$ns queue-limit $n(0) $n(6) 256
#$ns simplex-link $n(0) $n(7) $lineRateDown [expr $RTT/8+0.000240] RED
#$ns simplex-link $n(7) $n(0) $lineRateDown [expr $RTT/8] RED
#$ns queue-limit $n(0) $n(7) 256
#$ns simplex-link $n(0) $n(8) $lineRateDown [expr $RTT/8+0.000240] RED
#$ns simplex-link $n(8) $n(0) $lineRateDown [expr $RTT/8] RED
#$ns queue-limit $n(0) $n(8) 256
#$ns duplex-link $n(0) $n(8) 1Gb [expr $RTT/8] RED
#$ns queue-limit $n(0) $n(8) 256
for {set i 1} {$i<[expr $pathNum+1]} {incr i} {
$ns duplex-link $n($i) $n([expr $pathNum+1]) $lineRateDown [expr $RTT/8] RED
$ns queue-limit $n($i) $n([expr $pathNum+1]) 256
}
#$ns simplex-link $n(10) $n(11) $lineRateDown [expr $RTT/8+2*$RTT] RED
#$ns simplex-link $n(11) $n(10) $lineRateDown [expr $RTT/8] RED
#$ns queue-limit $n(10) $n(11) 256
#$ns duplex-link $n(8) $n(9) $lineRateDown [expr $RTT/8] RED
#$ns queue-limit $n(8) $n(9) 256
for {set i 3000} {$i<[expr $shortfno+3000]} {incr i} {
$ns simplex-link $n([expr $pathNum+1]) $n($i) $lineRateUp [expr $RTT/8] RED
$ns simplex-link $n($i) $n([expr $pathNum+1]) $lineRateUp [expr $RTT/8] DropTail
$ns queue-limit $n([expr $pathNum+1]) $n($i) 256
$ns queue-limit $n($i) $n([expr $pathNum+1]) 256
}
for {set i 4000} {$i<[expr $longfno+4000]} {incr i} {
$ns simplex-link $n([expr $pathNum+1]) $n($i) $lineRateUp [expr $RTT/8] RED
$ns simplex-link $n($i) $n([expr $pathNum+1]) $lineRateUp [expr $RTT/8] DropTail
$ns queue-limit $n([expr $pathNum+1]) $n($i) 256
$ns queue-limit $n($i) $n([expr $pathNum+1]) 256
}
#tcp agent
#for {set i 0} {$i<$shortfno} {incr i} {
#set tcp($i) [new Agent/TCP/FullTcp/Newreno]
# set shortnode [expr $i+1000]
# $ns attach-agent $n($shortnode) $tcp($i)
# $tcp($i) set fid_ $i
#}
#for {set i $shortfno} {$i < [expr $shortfno + $longfno] } {incr i} {
#set tcp($i) [new Agent/TCP/FullTcp/Newreno]
# set longnode [expr $i - $shortfno + 2000]
# $ns attach-agent $n($longnode) $tcp($i)
# $tcp($i) set fid_ $i
#}
for {set i 0} {$i < $shortfno } {incr i} {
if {[string compare $sourceAlg "Newreno"] == 0 || [string compare $sourceAlg "DC-TCP-Newreno"] == 0} {
set tcp($i) [new Agent/TCP/FullTcp/Newreno]
set shortnode [expr $i +1000]
$ns attach-agent $n($shortnode) $tcp($i)
$tcp($i) set fid_ $i
}
if {[string compare $sourceAlg "Sack"] == 0 || [string compare $sourceAlg "DC-TCP-Sack"] == 0} {
set tcp($i) [new Agent/TCP/FullTcp/Sack]
set shortnode [expr $i +1000]
$ns attach-agent $n($shortnode) $tcp($i)
$tcp($i) set fid_ $i
}
}
for {set i $shortfno} {$i < [expr $longfno+$shortfno] } {incr i} {
if {[string compare $sourceAlg "Newreno"] == 0 || [string compare $sourceAlg "DC-TCP-Newreno"] == 0} {
set tcp($i) [new Agent/TCP/FullTcp/Newreno]
set longnode [expr $i - $shortfno + 2000]
$ns attach-agent $n($longnode) $tcp($i)
$tcp($i) set fid_ $i+1000
}
if {[string compare $sourceAlg "Sack"] == 0 || [string compare $sourceAlg "DC-TCP-Sack"] == 0} {
set tcp($i) [new Agent/TCP/FullTcp/Sack]
set longnode [expr $i - $shortfno + 2000]
$ns attach-agent $n($longnode) $tcp($i)
$tcp($i) set fid_ $i+1000
}
}
$ns rtproto DV
Agent/rtProto/DV set advertInterval 16
#sink agent
#for {set i 0} {$i<$longfno} {incr i} {
# set sinkno [expr $i+3000]
# set sink($i) [new Agent/TCP/FullTcp/Newreno]
# $sink($i) listen
# $ns attach-agent $n($sinkno) $sink($i)
# $ns connect $tcp($i) $sink($i)
#}
#for {set i $shortfno} {$i < [expr $shortfno + $longfno] } {incr i} {
# set sinkno [expr $i - $shortfno + 4000]
# set sink($i) [new Agent/TCP/FullTcp/Newreno]
# $sink($i) listen
# $ns attach-agent $n($sinkno) $sink($i)
# $ns connect $tcp($i) $sink($i)
#}
for {set i 0} {$i < $shortfno } {incr i} {
if {[string compare $sourceAlg "Newreno"] == 0 || [string compare $sourceAlg "DC-TCP-Newreno"] == 0} {
#set sink($i) [new Agent/TCPSink]
set sink($i) [new Agent/TCP/FullTcp/Newreno]
$sink($i) listen
set sinkno [expr $i+3000]
$ns attach-agent $n($sinkno) $sink($i)
$ns connect $tcp($i) $sink($i)
}
if {[string compare $sourceAlg "Sack"] == 0 || [string compare $sourceAlg "DC-TCP-Sack"] == 0} {
set sink($i) [new Agent/TCP/FullTcp/Sack]
set sinkno [expr $i+3000]
$ns attach-agent $n($sinkno) $sink($i)
$ns connect $tcp($i) $sink($i)
$sink($i) listen
}
}
for {set i $shortfno} {$i < [expr $longfno+$shortfno] } {incr i} {
if {[string compare $sourceAlg "Newreno"] == 0 || [string compare $sourceAlg "DC-TCP-Newreno"] == 0} {
#set sink($i) [new Agent/TCPSink]
set sink($i) [new Agent/TCP/FullTcp/Newreno]
$sink($i) listen
set sinkno [expr $i - $shortfno + 4000]
$ns attach-agent $n($sinkno) $sink($i)
$ns connect $tcp($i) $sink($i)
}
if {[string compare $sourceAlg "Sack"] == 0 || [string compare $sourceAlg "DC-TCP-Sack"] == 0} {
set sink($i) [new Agent/TCP/FullTcp/Sack]
set sinkno [expr $i - $shortfno + 4000]
$ns attach-agent $n($sinkno) $sink($i)
$ns connect $tcp($i) $sink($i)
$sink($i) listen
}
}
for {set i 0} {$i<$shortfno} {incr i} {
set ftp($i) [$tcp($i) attach-app FTP]
# $ns at 0.1 "$ftp($i) send [expr 1460*100]"
set fs [$flows($i) getFS]; #author by
set ft [$flows($i) getAT];
$ns at $ft "$ftp($i) send [expr $fs*1460]"; #author by
#puts $ft;
#puts $fs;
#puts [expr 1460*50];
}
for {set i $shortfno} {$i < [expr $shortfno + $longfno ] } {incr i} {
set ftp($i) [$tcp($i) attach-app FTP]
$ns at 0.1 "$ftp($i) send [expr 1460*1000]"
}
proc finish {} {
global ns f nf
$ns flush-trace
close $f
close $nf
#exec nam ps.nam &
exit 0
}
$ns at 1.0 "finish"
$ns run