File: test-suite-webtraf.tcl

package info (click to toggle)
ns2 2.35%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 78,120 kB
  • sloc: cpp: 172,923; tcl: 107,127; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 812; awk: 525; csh: 355
file content (277 lines) | stat: -rw-r--r-- 7,782 bytes parent folder | download | duplicates (8)
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
# -*-	Mode:tcl; tcl-indent-level:8; tab-width:8; indent-tabs-mode:t -*-
#
# Time-stamp: <2000-09-07 12:53:04 haoboy>
#
# Copyright (c) 1995 The Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#	This product includes software developed by the Computer Systems
#	Engineering Group at Lawrence Berkeley Laboratory.
# 4. Neither the name of the University nor of the Laboratory may be used
#    to endorse or promote products derived from this software without
#    specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $Header: /cvsroot/nsnam/ns-2/tcl/test/test-suite-webtraf.tcl,v 1.10 2006/01/24 23:00:08 sallyfloyd Exp $

remove-all-packet-headers       ; # removes all except common
add-packet-header Flags IP TCP  HttpInval ; # hdrs reqd for validation test

# UPDATING GLOBAL DEFAULTS:
Agent/TCP set precisionReduce_ false ;   # default changed on 2006/1/24.
Agent/TCP set rtxcur_init_ 6.0 ;      # Default changed on 2006/01/21
Agent/TCP set updated_rttvar_ false ;  # Variable added on 2006/1/21
Agent/TCP set minrto_ 1
# default changed on 10/14/2004.
Agent/TCP set useHeaders_ false
# The default is being changed to useHeaders_ true.
Agent/TCP set tcpTick_ 0.1
# The default for tcpTick_ is being changed to reflect a changing reality.
Agent/TCP set rfc2988_ false
# The default for rfc2988_ is being changed to true.

Class TestSuite

TestSuite instproc init { name } {
	$self instvar ns_ totalpkt_ testname_
	set testname_ $name
	set ns_ [new Simulator]
	set totalpkt_ 0
}

TestSuite instproc finish args {
	$self instvar traceFile_ ns_
	global quiet
	if { $quiet != "true" } {
		$ns_ flush-trace
		close $traceFile_
	}
	exit 0
}

TestSuite instproc openTrace { stopTime } {
	$self instvar ns_ traceFile_ testname_
	global quiet
	if { $quiet != "true" } {
		set traceFile_ [open $testname_.nam w]
		$ns_ namtrace-all $traceFile_
	}
	$ns_ at $stopTime "$self finish"
}

TestSuite instproc run {} {
	$self instvar ns_
	$ns_ run
}

proc usage {} {
	global argv0
	puts stderr "usage: ns $argv0 <tests> \[<quiet>\]"
	puts stderr "Valid tests are:\t[get-subclasses TestSuite Test/]"
	exit 1
}

proc isProc? {cls prc} {
	if [catch "Object info subclass $cls/$prc" r] {
		global argv0
		puts stderr "$argv0: no such $cls: $prc"
		usage
	}
}

proc get-subclasses {cls pfx} {
	set ret ""
	set l [string length $pfx]

	set c $cls
	while {[llength $c] > 0} {
		set t [lindex $c 0]
		set c [lrange $c 1 end]
		if [string match ${pfx}* $t] {
			lappend ret [string range $t $l end]
		}
		eval lappend c [$t info subclass]
	}
	set ret
}

TestSuite proc runTest {} {
	global argc argv quiet

	set quiet false
	switch $argc {
		1 {
			set test $argv
			isProc? Test $test
			set topo ""
		}
		2 {
			set test [lindex $argv 0]
			isProc? Test $test
			set extra [lindex $argv 1]
			if {$extra == "QUIET"} {
				set quiet true
			}
		}
		default {
			usage
		}
	}
	set t [new Test/$test $test]
	$t run
}

# Create $ns sessions, each of which has $np pages
# server mode flag: $sm
TestSuite instproc create-session { ns np sm } {
	# Polly's dumbbell topology

	$self instvar ns_

	set num_node 12
	for {set i 0} {$i < $num_node} {incr i} {
		set n($i) [$ns_ node]
	}
	$ns_ set src_ [list 2 3 4 5 6]
	$ns_ set dst_ [list 7 8 9 10 11]
	# EDGES (from-node to-node length a b):
	$ns_ duplex-link $n(0) $n(1) 1.5Mb 40ms DropTail
	$ns_ duplex-link $n(0) $n(2) 10Mb 20ms DropTail
	$ns_ duplex-link $n(0) $n(3) 10Mb 20ms DropTail
	$ns_ duplex-link $n(0) $n(4) 10Mb 20ms DropTail
	$ns_ duplex-link $n(0) $n(5) 10Mb 20ms DropTail
	$ns_ duplex-link $n(0) $n(6) 10Mb 20ms DropTail
	$ns_ duplex-link $n(1) $n(7) 10Mb 20ms DropTail
	$ns_ duplex-link $n(1) $n(8) 10Mb 20ms DropTail
	$ns_ duplex-link $n(1) $n(9) 10Mb 20ms DropTail
	$ns_ duplex-link $n(1) $n(10) 10Mb 20ms DropTail
	$ns_ duplex-link $n(1) $n(11) 10Mb 20ms DropTail

	$ns_ duplex-link-op $n(0) $n(1) orient left
	$ns_ duplex-link-op $n(0) $n(2) orient up
	$ns_ duplex-link-op $n(0) $n(3) orient right-up
	$ns_ duplex-link-op $n(0) $n(4) orient right
	$ns_ duplex-link-op $n(0) $n(5) orient right-down
	$ns_ duplex-link-op $n(0) $n(6) orient down
	$ns_ duplex-link-op $n(1) $n(7) orient up
	$ns_ duplex-link-op $n(1) $n(8) orient left-up
	$ns_ duplex-link-op $n(1) $n(9) orient left 
	$ns_ duplex-link-op $n(1) $n(10) orient left-down
	$ns_ duplex-link-op $n(1) $n(11) orient down

	# Set up server and client nodes
	set pool [new PagePool/WebTraf]
	# Set debug to produce detailed output
	$pool set debug_ 1

	$pool set resp_trace_ 0
	$pool set req_trace_ 0
	
	$pool set-num-client [llength [$ns_ set src_]]
	$pool set-num-server [llength [$ns_ set dst_]]

	set i 0
	foreach s [$ns_ set src_] {
		$pool set-client $i $n($s)
		incr i
	}
	set i 0
	foreach s [$ns_ set dst_] {
		$pool set-server $i $n($s)
		incr i
	}

	# Config server mode: 
	# 0: no server processing delay
	# 1: FCFS server scheduling policy
	# 2: STF server scheduling policy
	$pool set-server-mode $sm

	# Session 0 starts from 0.1s, session 1 starts from 0.2s
	$pool set-num-session $ns
	for {set i 0} {$i < $ns} {incr i} {
		set interPage [new RandomVariable/Exponential]
		$interPage set avg_ 1
		set pageSize [new RandomVariable/Constant]
		$pageSize set val_ $np
		set interObj [new RandomVariable/Exponential]
		$interObj set avg_ 0.01
		set objSize [new RandomVariable/ParetoII]
		$objSize set avg_ 10
		$objSize set shape_ 1.2
		$pool create-session $i $np 0.1 $interPage $pageSize \
				$interObj $objSize
		# from webcache/webtraf.cc
	}
}

# These tests only check the page scheduling mechanism of WebTrafPool.

Class Test/1s-1p -superclass TestSuite

Test/1s-1p instproc init args {
	eval $self next $args
	$self openTrace 100.0
	$self create-session 1 1 0
}

Class Test/1s-2p -superclass TestSuite

Test/1s-2p instproc init args {
	eval $self next $args
	$self openTrace 100.0
	$self create-session 1 2 0
}

Class Test/3s-2p -superclass TestSuite

Test/3s-2p instproc init args {
	eval $self next $args
	$self openTrace 100.0
	$self create-session 3 2 0
}

Class Test/fcfs -superclass TestSuite

Test/fcfs instproc init args {
	eval $self next $args
	$self openTrace 100.0
	$self create-session 3 2 1
}

Class Test/stf -superclass TestSuite

Test/stf instproc init args {
	eval $self next $args
	$self openTrace 100.0
	$self create-session 3 2 2
}

TestSuite runTest

### Local Variables:
### mode: tcl
### tcl-indent-level: 8
### tcl-default-application: ns
### End: