File: test-suite-packmime.tcl

package info (click to toggle)
ns2 2.35%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 78,796 kB
  • sloc: cpp: 172,923; tcl: 107,130; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 816; awk: 525; csh: 355
file content (374 lines) | stat: -rw-r--r-- 10,995 bytes parent folder | download | duplicates (7)
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# test-suite-PackMime.tcl
#
# Based on ns/tcl/test/test-suite-full.tcl
#
# Modified by Michele Weigle, UNC-Chapel Hill, Dec 2003
#

#*************************************************************************
# Tests to validate PackMime
#
#  1node-http1_0 - one PackMime node running HTTP 1.0
#  1node-http1_1 - one PackMime node running HTTP 1.1
#  2node-http1_1 - two PackMime nodes running HTTP 1.1
#
#*************************************************************************

source misc.tcl

TestSuite instproc finish testname {
	$self instvar ns_
	$ns_ halt
}

Class SkelTopology

Class Topology -superclass SkelTopology

Topology instproc node? num {
    $self instvar node_
    return $node_($num)
}

Class Topology/DB -superclass Topology

#
# PackMime test topology
#
#           s1                      k1
#             \                    /
#  100Mb, 1ms  \    100Mb, 1ms    / 100Mb, 1ms
#               r1 ----------- r2 
#  100Mb, 1ms  /                 \ 100Mb, 1ms
#             /                   \
#          s2                       k2
#
Topology/DB instproc init ns {
    $self instvar node_
    set node_(s1) [$ns node]
    set node_(s2) [$ns node]
    set node_(r1) [$ns DelayBox]
    set node_(r2) [$ns DelayBox]
    set node_(k1) [$ns node]
    set node_(k2) [$ns node]

    $self next
    $ns duplex-link $node_(s1) $node_(r1) 100Mb 1ms DropTail
    $ns duplex-link $node_(s2) $node_(r1) 100Mb 1ms DropTail
    $ns duplex-link $node_(r1) $node_(r2) 100Mb 1ms DropTail
    $ns duplex-link $node_(k1) $node_(r2) 100Mb 1ms DropTail
    $ns duplex-link $node_(k2) $node_(r2) 100Mb 1ms DropTail

    $self instvar lossylink_
    set lossylink_ [$ns link $node_(r1) $node_(r2)]
    set em [new ErrorModule Fid]
    set errmodel [new ErrorModel/Periodic]
    $errmodel unit pkt
    $lossylink_ errormodule $em
    $em insert $errmodel
    $em bind $errmodel 0
    $em default pass
}

TestSuite instproc setup_topo {{all_links 1}} {
    $self instvar ns_ node_ testName_

    # clear output files
    exec rm -f temp.rands

    remove-all-packet-headers
    add-packet-header IP TCP
    $ns_ use-scheduler Heap

    Trace set show_tcphdr_ 1 
    Agent/TCP set minrto_ 1;     # ns-2.27 value

   # setup tracing
    set trace_file [open temp.rands w]
    if ($all_links) {
        $ns_ trace-queue $node_(s1) $node_(r1) $trace_file
        $ns_ trace-queue $node_(r1) $node_(s1) $trace_file
        $ns_ trace-queue $node_(s2) $node_(r1) $trace_file
        $ns_ trace-queue $node_(r1) $node_(s2) $trace_file
    }
    $ns_ trace-queue $node_(r1) $node_(r2) $trace_file
    $ns_ trace-queue $node_(r2) $node_(r1) $trace_file
    if ($all_links) {
        $ns_ trace-queue $node_(k1) $node_(r2) $trace_file
        $ns_ trace-queue $node_(r2) $node_(k1) $trace_file
        $ns_ trace-queue $node_(k2) $node_(r2) $trace_file
        $ns_ trace-queue $node_(r2) $node_(k2) $trace_file
    }

    # create random variables
    set srcd_rng [new RNG];
    set src_delay [new RandomVariable/Uniform];   # delay 20-50 ms
    $src_delay set min_ 20
    $src_delay set max_ 50
    $src_delay use-rng $srcd_rng

    set srcbw_rng [new RNG];
    set src_bw [new RandomVariable/Uniform];      # bw 1-20 Mbps
    $src_bw set min_ 1
    $src_bw set max_ 20
    $src_delay use-rng $srcbw_rng

    set sinkd_rng [new RNG];
    set sink_delay [new RandomVariable/Uniform];   # delay 1-20 ms
    $sink_delay set min_ 1
    $sink_delay set max_ 20
    $sink_delay use-rng $sinkd_rng

    set sinkbw_rng [new RNG];
    set sink_bw [new RandomVariable/Constant];      # bw 100 Mbps
    $sink_bw set val_ 100
    $sink_bw use-rng $sinkbw_rng

    set loss_rng [new RNG];
    set loss_rate [new RandomVariable/Uniform];    # loss 0-1%
    $loss_rate set min_ 0
    $loss_rate set max_ 0.01
    $loss_rate use-rng $loss_rng
    
    # setup rules for DelayBoxes
    $node_(r1) add-rule [$node_(s1) id] [$node_(k1) id] $src_delay \
	    $loss_rate $src_bw
    $node_(r1) add-rule [$node_(s2) id] [$node_(k2) id] $src_delay \
	    $loss_rate $src_bw
    $node_(r2) add-rule [$node_(s1) id] [$node_(k1) id] $sink_delay \
	    $loss_rate $sink_bw
    $node_(r2) add-rule [$node_(s2) id] [$node_(k2) id] $sink_delay \
	    $loss_rate $sink_bw
}

TestSuite instproc setloss {} {
        $self instvar topo_
        $topo_ instvar lossylink_
        set errmodule [$lossylink_ errormodule]
        set errmodel [$errmodule errormodels]
        if { [llength $errmodel] > 1 } {
                puts "droppedfin: confused by >1 err models..abort"
                exit 1
        }
        return $errmodel
}

# Mark the specified packet.
TestSuite instproc mark_pkt { number } {
    $self instvar ns_ lossmodel
    set lossmodel [$self setloss]
    $lossmodel set offset_ $number
    $lossmodel set period_ 10000
    $lossmodel set markecn_ true
}

#################################################################
#
# 1node-http_1_0
#
Class Test/1node-http_1_0 -superclass TestSuite
Test/1node-http_1_0 instproc init topo {
        global defaultRNG
	$self instvar net_ defNet_ test_
        $defaultRNG seed 9999
        set net_ $topo
	set defNet_ DB
	set test_ 1node-http_1_0
	$self next 0
}

Test/1node-http_1_0 instproc run {{PMrate 10} {markpkt 100000} {all_links 1}} {
	$self instvar ns_ node_
        $self setup_topo $all_links

        set PM [new PackMimeHTTP]
        $PM set-server $node_(s1)
        $PM set-client $node_(k1)
        $PM set-rate $PMrate
	$self mark_pkt $markpkt

        $ns_ at 0 "$PM start"
        $ns_ at 5 "$PM stop"

	$ns_ run
}

#
# 1node-http_1_1
#
Class Test/1node-http_1_1 -superclass TestSuite
Test/1node-http_1_1 instproc init topo {
        global defaultRNG
	$self instvar net_ defNet_ test_
        $defaultRNG seed 9999
        set net_ $topo
	set defNet_ DB
	set test_ 1node-http_1_1
	$self next 0
}
Test/1node-http_1_1 instproc run {{PMrate 5} {markpkt 100000} {all_links 1}} {
	$self instvar ns_ node_
        $self setup_topo $all_links

        set PM [new PackMimeHTTP]
        $PM set-server $node_(s1)
        $PM set-client $node_(k1)
        $PM set-rate $PMrate
	$self mark_pkt $markpkt
        $PM set-1.1

        $ns_ at 0 "$PM start"
        $ns_ at 5 "$PM stop"

	$ns_ run
}

#
# 2node-http_1_1
#
Class Test/2node-http_1_1 -superclass TestSuite
Test/2node-http_1_1 instproc init topo {
        global defaultRNG
	$self instvar net_ defNet_ test_
        $defaultRNG seed 9999
        set net_ $topo
	set defNet_ DB
	set test_ 2node-http_1_1
	$self next 0
}
Test/2node-http_1_1 instproc run {{PMrate 5} {markpkt 100000} {all_links 1}} {
	$self instvar ns_ node_
        $self setup_topo $all_links

        set PM [new PackMimeHTTP]
        $PM set-server $node_(s1)
        $PM set-client $node_(k1)
        $PM set-server $node_(s2)
        $PM set-client $node_(k2)
        $PM set-rate $PMrate
	$self mark_pkt $markpkt
        $PM set-1.1
    
        $ns_ at 0 "$PM start"
        $ns_ at 5 "$PM stop"

	$ns_ run
}

####################################################################
#
# To count at ECN-Capable SYN/ACK packets:
# grep "C-----N" temp.rands | grep "ack" | grep "+" | wc -l
# To count at marked ECN-Capable SYN/ACK packets:
# grep "C---E-N" temp.rands | grep "ack" | grep "r" | wc -l
# To count at non-ECN-Capable SYN/ACK packets:
# grep "C------" temp.rands | grep "ack" | grep "+" | wc -l
####################################################################
# 1node-http_1_0_ecn+
# 12 ECN-Capable SYN/ACK packets.
# 1 marked ECN-Capable SYN/ACK packets.
# 0 non-ECN-Capable SYN/ACK packets.
#
Class Test/1node-http_1_0_ecn+ -superclass TestSuite
Test/1node-http_1_0_ecn+ instproc init topo {
        global defaultRNG
	$self instvar net_ defNet_ test_
        $defaultRNG seed 9999
        set net_ $topo
	set defNet_ DB
	set test_ 1node-http_1_0_ecn+
	Agent/TCP set ecn_ 1
	Agent/TCP/FullTcp set ecn_syn_ true
	Agent/TCP/FullTcp set ecn_syn_wait_ 0
	Test/1node-http_1_0_ecn+ instproc run {{PMrate 1} {markpkt 1} {all_links 0}} [Test/1node-http_1_0 info instbody run ]
	$self next 0
}

# ? ECN-Capable SYN/ACK packets.
Class Test/1node-http_1_1_ecn+ -superclass TestSuite
Test/1node-http_1_1_ecn+ instproc init topo {
        global defaultRNG
	$self instvar net_ defNet_ test_
        $defaultRNG seed 9999
        set net_ $topo
	set defNet_ DB
	set test_ 1node-http_1_1_ecn+
	Agent/TCP set ecn_ 1
	Agent/TCP/FullTcp set ecn_syn_ true
	Agent/TCP/FullTcp set ecn_syn_wait_ 0
	Test/1node-http_1_1_ecn+ instproc run {{PMrate 1} {markpkt 1} {all_links 0}} [Test/1node-http_1_1 info instbody run ]
	$self next 0
}

# ? ECN-Capable SYN/ACK packets.
Class Test/2node-http_1_1_ecn+ -superclass TestSuite
Test/2node-http_1_1_ecn+ instproc init topo {
        global defaultRNG
	$self instvar net_ defNet_ test_
        $defaultRNG seed 9999
        set net_ $topo
	set defNet_ DB
	set test_ 2node-http_1_1_ecn+
	Agent/TCP set ecn_ 1
	Agent/TCP/FullTcp set ecn_syn_ true
	Agent/TCP/FullTcp set ecn_syn_wait_ 0
	Test/2node-http_1_1_ecn+ instproc run {{PMrate 1} {markpkt 1} {all_links 0}} [Test/2node-http_1_1 info instbody run ]
	$self next 0
}
####################################################################
# 1node-http_1_0_ecn+B
# 12 ECN-Capable SYN/ACK packets.
# 1 marked ECN-Capable SYN/ACK packets.
# 1 non-ECN-Capable SYN/ACK packets.
# egrep '0.0 4.0|4.0 0.0' temp.rands
#
Class Test/1node-http_1_0_ecn+B -superclass TestSuite
Test/1node-http_1_0_ecn+B instproc init topo {
        global defaultRNG
	$self instvar net_ defNet_ test_
        $defaultRNG seed 9999
        set net_ $topo
	set defNet_ DB
	set test_ 1node-http_1_0_ecn+B
	Agent/TCP set ecn_ 1
	Agent/TCP/FullTcp set ecn_syn_ true
	Agent/TCP/FullTcp set ecn_syn_wait_ 2
	Test/1node-http_1_0_ecn+B instproc run {{PMrate 1} {markpkt 1} {all_links 0}} [Test/1node-http_1_0 info instbody run ]
	$self next 0
}

# ? ECN-Capable SYN/ACK packets.

Class Test/1node-http_1_1_ecn+B -superclass TestSuite
Test/1node-http_1_1_ecn+B instproc init topo {
        global defaultRNG
	$self instvar net_ defNet_ test_
        $defaultRNG seed 9999
        set net_ $topo
	set defNet_ DB
	set test_ 1node-http_1_1_ecn+B
	Agent/TCP set ecn_ 1
	Agent/TCP/FullTcp set ecn_syn_ true
	Agent/TCP/FullTcp set ecn_syn_wait_ 2
	Test/1node-http_1_1_ecn+B instproc run {{PMrate 1} {markpkt 1} {all_links 0}} [Test/1node-http_1_1 info instbody run ]
	$self next 0
}

# ? ECN-Capable SYN/ACK packets.
Class Test/2node-http_1_1_ecn+B -superclass TestSuite
Test/2node-http_1_1_ecn+B instproc init topo {
        global defaultRNG
	$self instvar net_ defNet_ test_
        $defaultRNG seed 9999
        set net_ $topo
	set defNet_ DB
	set test_ 2node-http_1_1_ecn+B
	Agent/TCP set ecn_ 1
	Agent/TCP/FullTcp set ecn_syn_ true
	Agent/TCP/FullTcp set ecn_syn_wait_ 2
	Test/2node-http_1_1_ecn+B instproc run {{PMrate 1} {markpkt 1} {all_links 0}} [Test/2node-http_1_1 info instbody run ]
	$self next 0
}
####################################################################

TestSuite runTest