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 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
|
#
# Copyright (c) Xerox Corporation 1998. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Linking this file statically or dynamically with other modules is making
# a combined work based on this file. Thus, the terms and conditions of
# the GNU General Public License cover the whole combination.
#
# In addition, as a special exception, the copyright holders of this file
# give you permission to combine this file with free software programs or
# libraries that are released under the GNU LGPL and with code included in
# the standard release of ns-2 under the Apache 2.0 license or under
# otherwise-compatible licenses with advertising requirements (or modified
# versions of such code, with unchanged license). You may copy and
# distribute such a system following the terms of the GNU GPL for this
# file and the licenses of the other code concerned, provided that you
# include the source code of that other code when and as the GNU GPL
# requires distribution of source code.
#
# Note that people who make modified versions of this file are not
# obligated to grant this special exception for their modified versions;
# it is their choice whether to do so. The GNU General Public License
# gives permission to release a modified version without this exception;
# this exception also makes it possible to release a modified version
# which carries forward this exception.
#
# $Header: /cvsroot/nsnam/ns-2/tcl/test/test-suite-intserv.tcl,v 1.10 2005/08/26 05:05:30 tomh Exp $
#
#
# This test suite runs validation tests for the measurement based
# admission control algorithms that are part of the simple
# integrated services support in ns. The integrated services support
# includes a simple signalling protocol and a scheduler that provides
# a service like controlled-load by giving priority to real-time over
# best-effort traffic.
#
# Five admission control algorithms are tested:
# 1. Measured Sum (MS)
# 2. Hoeffding Bounds (HB)
# 3. Acceptance Region Tangent at Peak (ACTP)
# 4. Acceptance Region Tangent at Origin (ACTO)
# 5. Parameter Based (Param)
#
# The first four are measurement-based, the last is parameter-based.
#
# The measurement-based algorithms each use an estimation algorithm.
# Time window for Measured Sum, exponential averaging for Hoeffding
# Bounds and Point Sample for the Acceptance region algorithms.
# See the paper "Comparison of Measurement-based Admission Control Algorithms
# for Controlled-Load Service", Sugih Jamin, Scott Shenker and Peter
# Danzig, in the Proceedings of IEEE Infocom '97, and references therein
# for a further description of these algorithms.
# To run a test:
# ns test-suite-intserv.tcl ALG
# where ALG is one of MS, HB, ACTP, ACTO, Param
#remove-all-packet-headers ; # removes all except common
#add-packet-header Flags IP TCP ; # hdrs reqd for validation test
# FOR UPDATING GLOBAL DEFAULTS:
set meastime 100
set simtime 300
Class TestSuite
TestSuite proc setinstance {T} {
TestSuite set T $T
}
TestSuite proc getinstance {} {
TestSuite set T
}
TestSuite instproc init {} {
$self instvar ns_ net_ test_ node_ testName_ adc_ est_
$self instvar param_ r_ hvar_ fvar_ srcno_ qmon_ f_ flow_ totflows_
$self defaults
set ns_ [new Simulator]
# next line no longer needed with 32-bit addressing, Nov '99.
# $ns_ expand-port-field-bits 16
TestSuite setinstance $self
set net_ 2Node
set topo_ [new Topology/$net_ $ns_]
foreach i [$topo_ array names node_] {
# This would be cool, but lets try to be compatible
# with test-suite.tcl as far as possible.
#
# $self instvar $i
# set $i [$topo_ node? $i]
#
set node_($i) [$topo_ node? $i]
}
# create the link
$ns_ duplex-intserv-link $node_(0) $node_(1) $param_(bw) $param_(dly) SimpleIntServ SALink $adc_ $est_ CL
# set up queue monitor
set f_ [open temp.rands w]
set qmon_ [$ns_ monitor-queue $node_(0) $node_(1) $f_]
set l01 [$ns_ link $node_(0) $node_(1)]
$l01 set qBytesEstimate_ 0
$l01 set qPktsEstimate_ 0
$l01 set sampleInterval_ 0
#$ns_ at $param_(meastime) "$l01 trace-util [expr $param_(ptime)*$param_(S)] $f_"
# create the receiver
set r_ [new Agent/SAack]
$ns_ attach-agent $node_(1) $r_
set hvar_ [new RandomVariable/Exponential]
$hvar_ set avg_ $param_(hold)
set fvar_ [new RandomVariable/Exponential]
$fvar_ set avg_ $param_(fint)
set srcno_ 1
# schedule the first flow
set starttime [expr $srcno_ + double([ns-random] % 10000000) / 1e7]
$ns_ at $starttime "$self sched-source $node_(0)"
$ns_ at $param_(meastime) "$qmon_ set bdepartures_ 0;$qmon_ set bdrops_ 0"
$ns_ at $param_(simtime) "$self finish $f_"
$self set flows_ 0
$self set totflows_ 0
}
TestSuite instproc flowadmit {} {
$self instvar flows_ totflows_
incr flows_
incr totflows_
}
TestSuite instproc flowdepart {} {
$self instvar flows_
incr flows_ -1
}
TestSuite instproc defaults {} {
global simtime meastime
$self instvar param_
set param_(psize) 125
set param_(bw) 10e6
set param_(ptime) [expr $param_(psize)*8.0/$param_(bw)]
set param_(dly) 1ms
set param_(S) 5e3
set param_(hold) 300
set param_(fint) .4
set param_(simtime) $simtime
set param_(meastime) $meastime
set param_(trace_flow) 0
Queue/SimpleIntServ set qlimit1_ 160
Queue/SimpleIntServ set qlimit0_ 0
ADC set backoff_ true
Est set period_ [expr $param_(S) * $param_(ptime)]
}
TestSuite instproc run {} {
$self instvar ns_
$ns_ run
}
TestSuite instproc create-source {node starttime i} {
$self instvar ns_ r_ hvar_
set a [new Agent/SA]
$ns_ attach-agent $node $a
$a set fid_ $i
$ns_ connect $a $r_
set exp1 [new Application/Traffic/Exponential]
$exp1 set packetSize_ 125
$exp1 set burst_time_ [expr 20.0/64]
$exp1 set idle_time_ 325ms
$exp1 set rate_ 64k
#set up (r,b)
$a set rate_ 64k
$a set bucket_ 1
$a attach-traffic $exp1
$a set lifetime_ [$hvar_ value]
$ns_ at $starttime "$a start"
$a instvar trafgen_
set trafgen_ $exp1
}
TestSuite instproc sched-source {node} {
$self instvar srcno_ ns_ fvar_ param_ f_
$self create-source $node [$ns_ now] $srcno_
if { $param_(trace_flow) } {
puts $f_ "Flow $srcno started @ [$ns now]"
}
incr srcno_
#generate another startime
set starttime [expr [$ns_ now]+[$fvar_ value]]
$ns_ at $starttime "$self sched-source $node"
}
TestSuite proc runTest {} {
global argc argv quiet
set test [lindex $argv 0]
set t [new Test/$test]
$t show-simtime
$t run
}
TestSuite instproc show-simtime {} {
global tcl_precision
$self instvar ns_ qmon_ param_ f_ flows_ totflows_
$qmon_ instvar bdepartures_ pdrops_ pdepartures_
if {$pdepartures_ != 0} {
set d [expr $pdrops_*1.0/($pdrops_+$pdepartures_)]
} else {
set d 0
}
if { [$ns_ now] < $param_(meastime) } {
set time [$ns_ now]
} else {
set time [expr [$ns_ now] - $param_(meastime)]
}
if { $time == 0 } {
set thput 0
} else {
set thput [expr $bdepartures_ * 8.0 / ($param_(bw) * $time)]
}
set oprecision [set tcl_precision]
set tcl_precision 6
puts $f_ "[$ns_ now] $thput $d"
puts $f_ "Flows: $flows_ $totflows_"
set tcl_precision $oprecision
$ns_ at [expr [$ns_ now] + 10.0] "$self show-simtime"
}
TestSuite instproc finish { file } {
global tcl_precision
$self instvar qmon_ param_ f_
$qmon_ instvar pdrops_ pdepartures_ bdepartures_
set utlzn [expr $bdepartures_*8.0/($param_(bw)*($param_(simtime)-$param_(meastime)))]
set d [expr $pdrops_*1.0/($pdrops_+ $pdepartures_)]
set oprecision [set tcl_precision]
set tcl_precision 6
puts $f_ "Drops : $d Utilization : $utlzn"
set tcl_precision $oprecision
close $file
exec rm -f $file
exit 0
}
Class Test/MS -superclass TestSuite
Test/MS instproc init {} {
$self instvar adc_ est_
set adc_ MS
set est_ TimeWindow
$self next
}
Test/MS instproc defaults {} {
$self next
ADC/MS set backoff_ false
ADC/MS set utilization_ 1.02
Est/TimeWindow set T_ 3
}
Class Test/HB -superclass TestSuite
Test/HB instproc init {} {
$self instvar adc_ est_
set adc_ HB
set est_ ExpAvg
$self next
}
Test/HB instproc defaults {} {
$self next
ADC/HB set epsilon_ 0.999
Est/ExpAvg set w_ 0.0625
}
Class Test/ACTP -superclass TestSuite
Test/ACTP instproc init {} {
$self instvar adc_ est_
set adc_ ACTP
set est_ PointSample
$self next
}
Test/ACTP instproc defaults {} {
$self next
$self instvar param_
ADC/ACTP set s_ [expr 2e-7]
set param_(S) 2.5e4
Est set period_ [expr $param_(S) * $param_(ptime)]
}
Class Test/ACTO -superclass TestSuite
Test/ACTO instproc init {} {
$self instvar adc_ est_
set adc_ ACTO
set est_ PointSample
$self next
}
Test/ACTO instproc defaults {} {
$self next
$self instvar param_
ADC/ACTO set s_ [expr 8e-8]
set param_(S) 2.5e4
Est set period_ [expr $param_(S) * $param_(ptime)]
}
Class Test/Param -superclass TestSuite
Test/Param instproc init {} {
$self instvar adc_ est_
set adc_ Param
set est_ Null
$self next
}
Test/Param instproc defaults {} {
$self next
ADC/Param set utilization_ 2.05
}
Class SkelTopology
SkelTopology instproc init ns {
$self next
}
SkelTopology instproc node? n {
$self instvar node_
if [info exists node_($n)] {
set ret $node_($n)
} else {
set ret ""
}
set ret
}
Class Topology/2Node -superclass SkelTopology
Topology/2Node instproc init ns {
$self next $ns
$self instvar node_
set node_(0) [$ns node]
set node_(1) [$ns node]
}
#new Test/$TestName
Agent/SA instproc sched-stop { decision } {
global hold simtime trace_flow
$self instvar node_ lifetime_
set T [TestSuite getinstance]
$T instvar ns_ param_ flows_ totflows_ f_
if { $decision == 1 } {
set leavetime [expr [$ns_ now] + $lifetime_]
$T flowadmit
$ns_ at [expr [$ns_ now] + $lifetime_] "$self stop;\
if { $param_(trace_flow) } { \
puts $f_ \"Flow [$self set fid_] left @ $leavetime\" \
}; \
$ns_ detach-agent $node_ $self; \
delete [$self set trafgen_]; delete $self; $T flowdepart"
} else {
set leavetime [$ns_ now]
$ns_ at-now "if { $param_(trace_flow) } { \
puts $f_ \"Flow [$self set fid_] left @ $leavetime\"\
}; \
$ns_ detach-agent $node_ $self; \
delete [$self set trafgen_]; delete $self"
}
}
TestSuite runTest
|