File: isigen.tcl

package info (click to toggle)
ns2 2.35%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,864 kB
  • sloc: cpp: 172,923; tcl: 107,130; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 818; awk: 525; csh: 355
file content (316 lines) | stat: -rw-r--r-- 9,456 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
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
# Copyright (C) 2001 by USC/ISI
# All rights reserved.                                            
#                                                                
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation, advertising
# materials, and other materials related to such distribution and use
# acknowledge that the software was developed by the University of
# Southern California, Information Sciences Institute.  The name of the
# University may not be used to endorse or promote products derived from
# this software without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
# 
# An example script that simulates ISI web traffic. 
#
# Some attributes:
# 1. Topology: ~1100 nodes, 960 web clients, 40 web servers
#                           100 ftp clients, 10 ftp servers
# 2. Traffic: approximately 1,700,000 packets, heavy-tailed connection 
#             sizes, throughout 3600 second simulation time
# 3. Simulation scale: ~33 MB memory, ~1 hrs running on Red Hat Linux 7.0
#              Pentium II Xeon 450 MHz PC with 1GB physical memory
#
# Created by Kun-chan Lan (kclang@isi.edu)

global num_node n verbose num_ftp_client num_nonisi_web_client num_isi_server 
set verbose 1
set enableWEB 1
set enableFTP 0

source isitopo.tcl

# Basic ns setup
set ns [new Simulator]

$ns rtproto Manual

create_topology

#trace files setup (isi: inbound traffic  www: all traffic)
$ns trace-queue $n(9) $n(1) [open isi.in w]
$ns trace-queue $n(1) $n(9) [open isi.out w]
$ns trace-queue $n(9) $n([expr $num_node - 1]) [open www.out w]
$ns trace-queue $n([expr $num_node - 1]) $n(9) [open www.in w]

set stopTime 3600.1

set stopTimeW $stopTime
set stopTimeF $stopTime


# Number of Sessions
set numSessionI 3000
set numSessionO 1500

# Random seed at every run
global defaultRNG
$defaultRNG seed 0

if {$enableWEB ==  1} {

#setup Web model

# Create page poolWWW
set poolWWW [new PagePool/EmpWebTraf]

# Setup web servers and clients
$poolWWW set-num-client [llength [$ns set srcW_]]
$poolWWW set-num-server [llength [$ns set dstW_]]

$poolWWW set-num-remote-client $num_nonisi_web_client
$poolWWW set-num-server-lan $num_isi_server

set i 0
foreach s [$ns set srcW_] {
	$poolWWW set-client $i $n($s)
	incr i
}
set i 0
foreach s [$ns set dstW_] {
	$poolWWW set-server $i $n($s)
	incr i
}



# Inter-session Interval
set WWWinterSessionO [new RandomVariable/Empirical]
$WWWinterSessionO loadCDF cdf/2pm.dump.www.out.sess.inter.cdf
set WWWinterSessionI [new RandomVariable/Empirical]
$WWWinterSessionI loadCDF cdf/2pm.dump.www.in.sess.inter.cdf
#set WWWinterSessionO [new RandomVariable/Exponential]
#$WWWinterSessionO set avg_ 13.6
#set WWWinterSessionI [new RandomVariable/Exponential]
#$WWWinterSessionI set avg_ 1.6

## Number of Pages per Session
set WWWsessionSizeO [new RandomVariable/Empirical]
$WWWsessionSizeO loadCDF cdf/2pm.dump.www.out.pagecnt.cdf
set WWWsessionSizeI [new RandomVariable/Empirical]
$WWWsessionSizeI loadCDF cdf/2pm.dump.www.in.pagecnt.cdf



# Create sessions
$poolWWW set-num-session [expr $numSessionI + $numSessionO]

puts "creating WWW outbound session"

set interPage [new RandomVariable/Empirical]
$interPage loadCDF cdf/2pm.dump.www.out.idle.cdf

set pageSize [new RandomVariable/Constant]
$pageSize set val_ 1
set interObj [new RandomVariable/Empirical]
$interObj loadCDF cdf/2pm.dump.www.out.obj.cdf  

set objSize [new RandomVariable/Empirical]
$objSize loadCDF cdf/2pm.dump.www.out.pagesize.cdf
set reqSize [new RandomVariable/Empirical]
$reqSize loadCDF cdf/2pm.dump.www.out.req.cdf

set persistSel [new RandomVariable/Empirical]
$persistSel loadCDF cdf/persist.cdf
set serverSel [new RandomVariable/Empirical]
$serverSel loadCDF cdf/2pm.dump.outbound.server.cdf

set windowS [new RandomVariable/Empirical]
$windowS loadCDF cdf/2pm.dump.www.outbound.wins.cdf
set windowC [new RandomVariable/Empirical]
$windowC loadCDF cdf/2pm.dump.www.outbound.winc.cdf

set mtu [new RandomVariable/Empirical]
$mtu loadCDF cdf/mtu.cdf

set launchTime 0
for {set i 0} {$i < $numSessionO} {incr i} {
        if {$launchTime <=  $stopTimeW} {
	   set numPage [$WWWsessionSizeO value]
	   puts "Session Outbound $i has $numPage pages $launchTime"

	   $poolWWW create-session  $i  \
	                $numPage [expr $launchTime + 0.1] \
			$interPage $pageSize $interObj $objSize \
                        $reqSize $persistSel $serverSel $windowS $windowC $mtu 1

	   set launchTime [expr $launchTime + [$WWWinterSessionO value]]
	}
}

puts "creating WWW inbound session"

set interPage [new RandomVariable/Empirical]
$interPage loadCDF cdf/2pm.dump.www.in.idle.cdf

set pageSize [new RandomVariable/Constant]
$pageSize set val_ 1
set interObj [new RandomVariable/Empirical]
$interObj loadCDF cdf/2pm.dump.www.in.obj.cdf  

set objSize [new RandomVariable/Empirical]
$objSize loadCDF cdf/2pm.dump.www.in.pagesize.cdf
set reqSize [new RandomVariable/Empirical]
$reqSize loadCDF cdf/2pm.dump.www.in.req.cdf

set persistSel [new RandomVariable/Empirical]
$persistSel loadCDF cdf/persist.cdf
set serverSel [new RandomVariable/Empirical]
$serverSel loadCDF cdf/2pm.dump.www.inbound.server.cdf

set windowS [new RandomVariable/Empirical]
$windowS loadCDF cdf/2pm.dump.www.inbound.wins.cdf
set windowC [new RandomVariable/Empirical]
$windowC loadCDF cdf/2pm.dump.www.inbound.winc.cdf

set mtu [new RandomVariable/Empirical]
$mtu loadCDF cdf/mtu.cdf

set launchTime 0
for {set i 0} {$i < $numSessionI} {incr i} {
        if {$launchTime <=  $stopTimeW} {
	   set numPage [$WWWsessionSizeI value]
	   puts "Session Inbound $i has $numPage pages $launchTime"

	   $poolWWW create-session [expr $i + $numSessionO] \
	                $numPage [expr $launchTime + 0.1] \
			$interPage $pageSize $interObj $objSize \
                        $reqSize $persistSel $serverSel $windowS $windowC $mtu 0

	   set launchTime [expr $launchTime + [$WWWinterSessionI value]]
        }
}

}


if {$enableFTP ==  1} {

# setup FTP model

# Create page pool
set poolFTP [new PagePool/EmpFtpTraf]

# Setup FTP servers and clients
$poolFTP set-num-client [llength [$ns set srcF_]]
$poolFTP set-num-server [llength [$ns set dstF_]]

$poolFTP set-num-remote-client $num_ftp_client
$poolFTP set-num-server-lan $num_isi_server

set i 0
foreach s [$ns set srcF_] {
        $poolFTP set-client $i $n($s)
        incr i
}
set i 0
foreach s [$ns set dstF_] {
        $poolFTP set-server $i $n($s)
	incr i
}

# Inter-session Interval
set FTPinterSessionO [new RandomVariable/Empirical]
$FTPinterSessionO loadCDF cdf/2pm.dump.ftp.outbound.sess.inter.cdf
set FTPinterSessionI [new RandomVariable/Empirical]
$FTPinterSessionI loadCDF cdf/2pm.dump.ftp.inbound.sess.inter.cdf

## Number of File per Session
set FTPsessionSizeO [new RandomVariable/Empirical]
$FTPsessionSizeO loadCDF cdf/2pm.dump.ftp.outbound.fileno.cdf
set FTPsessionSizeI [new RandomVariable/Empirical]
$FTPsessionSizeI loadCDF cdf/2pm.dump.ftp.inbound.fileno.cdf

$poolFTP set-num-session [expr $numSessionI + $numSessionO]

puts "creating FTP outbound session"

set interFile [new RandomVariable/Empirical]
$interFile loadCDF cdf/2pm.dump.ftp.outbound.file.inter.cdf

set fileSize [new RandomVariable/Empirical]
$fileSize loadCDF cdf/2pm.dump.ftp.outbound.size.cdf

set serverSel [new RandomVariable/Empirical]
$serverSel loadCDF cdf/2pm.dump.outbound.server.cdf

set windowS [new RandomVariable/Empirical]
$windowS loadCDF cdf/2pm.dump.ftp.outbound.wins.cdf
set windowC [new RandomVariable/Empirical]
$windowC loadCDF cdf/2pm.dump.ftp.outbound.winc.cdf

set launchTime 0
for {set i 0} {$i < $numSessionO} {incr i} {
        if {$launchTime <=  $stopTimeF} {

	   	set numFile [$FTPsessionSizeO value]
           	puts "Session Outbound $i has $numFile files $launchTime"

       		$poolFTP create-session  $i  \
                         $numFile [expr $launchTime + 0.1] \
		         $interFile $fileSize $serverSel $windowS $windowC 1
           	set launchTime [expr $launchTime + [$FTPinterSessionO value]]
        }
}


puts "creating FTP inbound session"

set interFile [new RandomVariable/Empirical]
$interFile loadCDF cdf/2pm.dump.ftp.inbound.file.inter.cdf

set fileSize [new RandomVariable/Empirical]
$fileSize loadCDF cdf/2pm.dump.ftp.inbound.size.cdf

set serverSel [new RandomVariable/Empirical]
$serverSel loadCDF cdf/2pm.dump.ftp.inbound.server.cdf

set windowS [new RandomVariable/Empirical]
$windowS loadCDF cdf/2pm.dump.ftp.inbound.wins.cdf
set windowC [new RandomVariable/Empirical]
$windowC loadCDF cdf/2pm.dump.ftp.inbound.winc.cdf


set launchTime 0
for {set i 0} {$i < $numSessionI} {incr i} {
        if {$launchTime <=  $stopTimeF} {

	   	set numFile [$FTPsessionSizeI value]
		puts "Session Inbound $i has $numFile files $launchTime"

		$poolFTP create-session [expr $i + $numSessionO] \
                         $numFile [expr $launchTime + 0.1] \
                         $interFile $fileSize $serverSel $windowS $windowC 0

	        set launchTime [expr $launchTime + [$FTPinterSessionI value]]
         }
}

}

## Start the simulation
$ns at $stopTime "finish"

proc finish {} {
	global ns gf 
	$ns flush-trace

	exit 0
}

puts "ns started"
$ns run