⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test-suite-webcache.tcl

📁 NS-2.28的802.11e协议扩展源代码
💻 TCL
📖 第 1 页 / 共 4 页
字号:
	$mh_ switch-treetype $grp2	$server_(0) set-parent-cache $cache_(0)}Test/Mcast-PB instproc collect-stat {} {	$self instvar topo_ client_ server_ cache_ secondCaches_	set bw [$topo_ mon-stat]	set sn 0	set gn 0	set st(max) 0	set st(min) 98765432	set st(avg) 0	set rt(max) 0	set rt(min) 98765432	set rt(avg) 0	foreach c [array names client_] {		set gn [expr $gn + [$client_($c) stat req-num]]		set sn [expr $sn + [$client_($c) stat stale-num]]		set st(avg) [expr $st(avg) + [$client_($c) stat stale-time]]		set tmp [$client_($c) stat st-min]		if { $tmp < $st(min) } { set st(min) $tmp }		set tmp [$client_($c) stat st-max]		if { $tmp > $st(max) } { set st(max) $tmp }		set rt(avg) [expr $rt(avg) + [$client_($c) stat rep-time]]		set tmp [$client_($c) stat rt-max]		if { $tmp > $rt(max) } { set rt(max) $tmp }		set tmp [$client_($c) stat rt-min]		if { $tmp < $rt(min) } { set rt(min) $tmp }	}	if {$st(max) < $st(min)} {		set st(max) 0		set st(min) 0	}	if {$rt(max) < $rt(min)} {		set rt(max) 0		set rt(min) 0	}	set sr [expr double($sn) / $gn * 100]	if [catch {set st(avg) [expr double($st(avg)) / $sn]}] {		set st(avg) 0	;# No stale hits	} 	set rt(avg) [expr double($rt(avg)) / $gn]	set ims 0	foreach c [array names cache_] {		set ims [expr $ims + [$cache_($c) stat ims-num]]	}	set res [list sr $sr sh [$server_(0) stat hit-num] th [$cache_($secondCaches_) stat hit-num] st $st(avg) st-max $st(max) st-min $st(min) rt $rt(avg) rt-max $rt(max) rt-min $rt(min) mn [$server_(0) stat mod-num] ims-num $ims]	return [concat $bw $res]}Test/Mcast-PB instproc output-stat { args } {	eval array set d $args	global opts 	# XXX Don't have statistics for total bandwidth. :(	#puts "$opts(hb-interval) Bandwidth*Hop -1 Stale $d(sr) AverageRepTime $d(rt) BottleneckBW $d(btnk_bw) ServerBW $d(svr_bw) StaleTime $d(st)"}Test/Mcast-PB instproc finish {} {	global opts	if $opts(quiet) {		$self output-stat [$self collect-stat]	}	$self next}## Same as mcast-PB, except using Inval/Mcast/Perc cache# Class Test/Mcast-PBP -superclass Test/Mcast-PBTest/Mcast-PBP instproc init {} {	$self next	$self set-cache-type /Inval/Mcast/Perc}## Same as mcast-PB, except enabled selective push of updates#Class Test/Mcast-PBU -superclass Test/Mcast-PBTest/Mcast-PBU instproc create-members {} {	$self next	$self instvar cache_ server_	foreach n [array names cache_] {		$cache_($n) set enable_upd_ 1	}	foreach n [array names server_] {		$server_($n) set enable_upd_ 1	}}## Mcast invalidation + selective push + mandatory push#Class Test/Mcast-PBU-MP -superclass Test/Mcast-PBUTest/Mcast-PBU-MP instproc create-members {} {	$self next	$self instvar client_ ns_ server_	$ns_ at 100.0 "$client_(1) request-mpush $server_(0):0"	$ns_ at 500.0 "$client_(1) stop-mpush $server_(0):0"}## Testing TTL using a bottleneck topology#Class Test/ttl-PB -superclass Test/Mcast-PBTest/ttl-PB instproc init {} {	global opts	set opts(ttl) 0.1	$self next	$self set-cache-type /TTL	$self set-server-type ""	$self set-client-type ""}Test/ttl-PB instproc create-members {} {	$self next	global opts	$self instvar cache_	foreach n [array names cache_] {		$cache_($n) set-thresh $opts(ttl)	}}Test/ttl-PB instproc set-groups {} {	# We do not set any mcast groups}Test/ttl-PB instproc connect-server {} {	$self instvar server_ cache_	$cache_(0) connect $server_(0)}Test/ttl-PB instproc output-stat { args } {	eval array set d $args	global opts 	# XXX Don't have statistics for total bandwidth. :(	#puts "$opts(ttl) Bandwidth*Hop -1 Stale $d(sr) AverageRepTime $d(rt) BottleneckBW $d(btnk_bw) ServerBW $d(svr_bw) StaleTime $d(st)"}## Testing Omniscient TTL using a bottleneck topology#Class Test/ottl-PB -superclass {Test/ttl-PB Test/Mcast-PB}Test/ottl-PB instproc init {} {	$self next	$self set-cache-type /TTL/Omniscient	$self set-server-type ""	$self set-client-type ""}Test/ottl-PB instproc output-stat { args } {	eval array set d $args	# XXX Don't have statistics for total bandwidth. :(	#puts "Bandwidth*Hop -1 Stale $d(sr) AverageRepTime $d(rt) BottleneckBW $d(btnk_bw) ServerBW $d(svr_bw) StaleTime $d(st)"}## All the above tests with real traces#Class Test/Mcast-PBtr -superclass Test/Mcast-PBTest/Mcast-PBtr instproc init {} {	$self inherit-set pagepoolType_ "ProxyTrace"	$self next	Http set TRANSPORT_ FullTcp}Test/Mcast-PBtr instproc populate-cache {} {	# Populate servers and caches with pages.	# Do not use Http/Client::populate{}!	$self instvar pgp_ cache_ server_ secondCaches_ startTime_ ns_	set n $secondCaches_	for {set i 0} {$i < [$pgp_ get-poolsize]} {incr i} {		set pageid $server_(0):$i		$server_(0) gen-page $pageid		#set pageinfo [$server_(0) get-page $pageid]		#for {set j 0} {$j < $secondCaches_} {incr j} {		#	eval $cache_($j) enter-page $pageid $pageinfo		#}		#eval $cache_($secondCaches_) enter-page $pageid $pageinfo#		if {$i % 1000 == 0} {#			puts "$i pages populated"#		}	}}Test/Mcast-PBtr instproc start-connection {} {	$self next	$self populate-cache}Test/Mcast-PBtr instproc start-requests {} {	$self instvar client_ cache_ server_ secondCaches_		for {set i 0} {$i < $secondCaches_} {incr i} {		# Use start-session{} to avoid populating cache		$client_($i) start-session $cache_($i) $server_(0)	}		$self instvar topo_ ns_	$topo_ start-monitor $ns_}Test/Mcast-PBtr instproc set-pagepool {} {	$self instvar startTime_ finishTime_ pgp_ ns_ pagepoolType_	global opts	if {![info exists opts(xtrace-req)] || ![info exists opts(xtrace-page)]} {		error "Must supply request logs and page logs of proxy traces"	}	set pgp_ [new PagePool/$pagepoolType_]	$pgp_ set-reqfile $opts(xtrace-req)	$pgp_ set-pagefile $opts(xtrace-page)	$pgp_ bimodal-ratio 0.1	$pgp_ set-client-num $opts(num-2nd-cache)	# XXX Do *NOT* set start time of page generators. It'll be set	# after the cache population phase	# Estimate a finish time	set opts(duration) [$pgp_ get-duration]	set finishTime_ [expr $opts(duration) + $startTime_]	#puts "Duration changed to $opts(duration), finish at $finishTime_"	$self instvar ageRNG_	if ![info exists ageRNG_] {		set ageRNG_ [new RNG]		$ageRNG_ seed $opts(ns-random-seed)	}	# Dynamic page, with page modification 	set tmp [new RandomVariable/Uniform]	$tmp use-rng $ageRNG_	$tmp set min_ [expr $opts(avg-page-age)*0.001]	$tmp set max_ [expr $opts(avg-page-age)*1.999]	$pgp_ ranvar-dp $tmp	# Static page	set tmp [new RandomVariable/Uniform]	$tmp use-rng $ageRNG_	$tmp set min_ [expr $finishTime_ * 1.1]	$tmp set max_ [expr $finishTime_ * 1.2]	$pgp_ ranvar-sp $tmp}# Set every client's request generator to pgp_Test/Mcast-PBtr instproc set-req-generator { client } {	$self instvar pgp_	$client set-page-generator $pgp_}Class Test/Mcast-PBPtr -superclass {Test/Mcast-PBP Test/Mcast-PBtr}Class Test/Mcast-PBUtr -superclass {Test/Mcast-PBU Test/Mcast-PBtr}Class Test/ttl-PBtr -superclass {Test/ttl-PB Test/Mcast-PBtr}Class Test/ottl-PBtr -superclass {Test/ottl-PB Test/Mcast-PBtr}#----------------------------------------------------------------------# Test group 2## Same as test group 1, except using compound pages## Mcast-PB with compound pages#----------------------------------------------------------------------Class Test/mmcast-PB -superclass Test/Mcast-PBTest/mmcast-PB instproc init {} {	$self next	$self set-cache-type /Inval/Mcast/Perc	$self set-server-type /Inval/MYuc	$self set-client-type /Compound}Test/mmcast-PB instproc set-pagepool {} {	$self instvar startTime_ finishTime_ pgp_	global opts	# Use PagePool/Math, which means a single page	set pgp_ [new PagePool/CompMath]	# Size generator	$pgp_ set main_size_ $opts(avg-page-size)	$pgp_ set comp_size_ $opts(comp-page-size)	# Age generator	$self instvar ageRNG_	if ![info exists ageRNG_] {		set ageRNG_ [new RNG]		$ageRNG_ seed $opts(ns-random-seed)	}	set tmp [new RandomVariable/Exponential]	$tmp use-rng $ageRNG_	$tmp set avg_ $opts(avg-page-age)	$pgp_ ranvar-main-age $tmp	# Compound age generator	$self instvar compAgeRNG_	if ![info exists compAgeRNG_] {		set compAgeRNG_ [new RNG]		$compAgeRNG_ seed $opts(ns-random-seed)	}	set tmp [new RandomVariable/Uniform]	$tmp use-rng $compAgeRNG_	$tmp set min_ [expr $opts(avg-comp-page-age) * 0.9]	$tmp set max_ [expr $opts(avg-comp-page-age) * 1.1]	$pgp_ ranvar-obj-age $tmp	$pgp_ set num_pages_ [expr $opts(num-comp-pages) + 1]	$pgp_ set start_time_ $startTime_	set finishTime_ [expr $startTime_ + $opts(duration)]#	puts "Start at $startTime_, stop at $finishTime_"}## selective push + inval#Class Test/mmcast-PBU -superclass {Test/Mcast-PBU Test/mmcast-PB}## TTL with compound page#Class Test/mttl-PB -superclass {Test/ttl-PB Test/mmcast-PB}Test/mttl-PB instproc init {} {	$self next	$self set-cache-type /TTL	$self set-server-type /Compound	$self set-client-type /Compound}## Omniscient TTL + compound page#Class Test/mottl-PB -superclass {Test/ottl-PB Test/mmcast-PB}Test/mottl-PB instproc init {} {	$self next	$self set-cache-type /TTL/Omniscient	$self set-server-type /Compound	$self set-client-type /Compound}#----------------------------------------------------------------------# Test group 3## Comparison of direct request+invalidation vs ttl+direct request## Topology is derived from the BottleNeck topology. It adds additional# direct links from every leaf cache to the web server. This link is# used to model the "short path" from leaf caches to the server.#----------------------------------------------------------------------Class Test-dreq -superclass Test-CacheTest-dreq instproc init {} {	$self set-defnet cache5	$self next	$self instvar secondCaches_	global opts	set secondCaches_ $opts(num-2nd-cache)}Test-dreq instproc start-requests {} {	$self instvar client_ server_ cache_ secondCaches_	for {set i 0} {$i < $secondCaches_} {incr i} {		$client_($i) start $cache_($i) $server_(0)	}}Test-dreq instproc set-connections {} {	$self instvar client_ server_ cache_ secondCaches_ ns_	for {set i 0} {$i < $secondCaches_} {incr i} {		$client_($i) connect $cache_($i)	}}Test-dreq instproc collect-stat {} {	$self instvar topo_ client_ secondCaches_	$topo_ instvar qmon_	set svr_bw 0	for {set i 0} {$i < $secondCaches_} {incr i} {		set svr_bw [expr [$qmon_(svr_f$i) set bdepartures_] + \			$svr_bw + [$qmon_(svr_t$i) set bdepartures_]]	}	set btnk_bw [expr [$qmon_(btnk_f) set bdepartures_] + \			[$qmon_(btnk_t) set bdepartures_]]	set sn 0	set gn 0	set st 0	set rt 0	foreach c [array names client_] {		set gn [expr $gn + [$client_($c) stat req-num]]		set sn [expr $sn + [$client_($c) stat stale-num]]		set st [expr $st + [$client_($c) stat stale-time]]		set rt [expr $rt + [$client_($c) stat rep-time]]	}	set sr [expr double($sn) / $gn * 100]	if [catch {set st [expr double($st) / $sn]}] {		set st 0	;# No stale hits	}	set rt [expr double($rt) / $gn]	return [list svr_bw $svr_bw btnk_bw $btnk_bw sr $sr st $st rt $rt]}Test-dreq instproc finish {} {	$self output-stat [$self collect-stat]	$self next}Class Test/mcast-dreq -superclass Test-dreqTest/mcast-dreq instproc init {} {	$self next	$self set-cache-type /Inval/Mcast/Perc	$self set-server-type /Inval/Yuc	$self set-client-type ""}Test/mcast-dreq instproc output-stat { args } {	eval array set d $args	global opts 	# XXX Don't have statistics for total bandwidth. :(	#puts "$opts(hb-interval) Bandwidth*Hop -1 Stale $d(sr) AverageRepTime $d(rt) BottleneckBW $d(btnk_bw) ServerBW $d(svr_bw) StaleTime $d(st)"}Test/mcast-dreq instproc set-connections {} {	$self next ;# connecting clients	$self instvar server_ cache_ secondCaches_ 	set n $secondCaches_	for {set i 0} {$i < $secondCaches_} {incr i} {		$cache_($i) connect $cache_($n)		$cache_($i) set-parent $cache_($n)		if $i {			# Let all leaf caches connect to server			$cache_($i) connect $server_(0)		}	}	$cache_($n) connect $server_(0)	$server_(0) connect $cache_(0)}Test/mcast-dreq instproc set-groups {} {	$self instvar cache_ server_ secondCaches_ mh_	set n $secondCaches_	set grp1 [Node allocaddr]	set grp2 [Node allocaddr]	$cache_($n) init-inval-group $grp1	$cache_($n) init-update-group $grp2	for {set i 0} {$i < $n} {incr i} {		$cache_($i) join-inval-group $grp1		$cache_($i) join-update-group $grp2		# Every leaf cache uses direct request		$cache_($i) set direct_request_ 1	}	$mh_ switch-treetype $grp1	$mh_ switch-treetype $grp2	$server_(0) set-parent-cache $cache_(0)}#----------------------------------------------------------------------# Options #----------------------------------------------------------------------global raw_opt_infoset raw_opt_info {	# Random number seed; default is 0, so ns will give a 	# diff. one on each invocation.	# XXX Get a "good" seed from predef_seeds[] in rng.cc	ns-random-seed 188312339			# Animation options; complete traces are useful	# for nam only, so do those only when a tracefile	# is being used for nam	nam-trace-all 1	enable-log 0	# Tests to be used	prot	duration 500		    	# Trace file used for PagePool	page-file 		# TTL threshold	ttl 0.1		# Cache type	cache 	# server type	server 		# Packet size configurations	cache-ims-size	50	cache-ref-size	50	server-inv-size	43	client-req-size 43		# request intervals	min-req-interval 50	max-req-interval 70	avg-req-interval 60	min-page-size 100	max-page-size 50000	avg-page-size 1024	min-page-age  50	max-page-age  70	avg-page-age  60	# compound page size: 50K	comp-page-size 51200	avg-comp-page-age 40000	num-comp-pages 1	# If we use only one page	single-page 1	hb-interval 30	upd-interval 5	# Number of second level caches. Needed by Topology/BottleNeck	num-2nd-cache 5	scheduler-type Calendar	# Proxy trace files: requests and pages	xtrace-req webtrace-reqlog	xtrace-page webtrace-pglog}#----------------------------------------------------------------------# Execution starts...#----------------------------------------------------------------------run

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -