📄 test-suite-webcache.tcl
字号:
$client_(0) connect $cache_ $client_(1) connect $cache_ $client_(2) connect $cache_ $cache_ connect $server_ $cache_ set-parent $server_ $self start-request}Test/http3 instproc start-request {} { $self instvar client_ ns_ cache_ server_ $client_(0) send-request $cache_ GET $server_:0 set tmp [expr [$ns_ now] + 1] $ns_ at $tmp "$client_(1) send-request $cache_ GET $server_:1" set tmp [expr $tmp + 1] $ns_ at $tmp "$client_(2) send-request $cache_ GET $server_:0" set tmp [expr $tmp + 2] $ns_ at $tmp "$self start-request"}Test/http3 instproc finish-connection {} { $self instvar client_ server_ cache_ $client_(0) disconnect $cache_ $client_(1) disconnect $cache_ $client_(2) disconnect $cache_ $cache_ disconnect $server_}Class Test/http3f -superclass Test/http3Test/http3f instproc init args { eval $self next $args Http set TRANSPORT_ FullTcp}## Testing cache with TTL invalidation#Class Test/http4 -superclass TestTest/http4 instproc init {} { $self set-defnet 5node $self next $self instvar ns_ startTime_ finishTime_ set startTime_ 1 set finishTime_ 40 Http set TRANSPORT_ SimpleTcp}Test/http4 instproc set-routing {} { $self instvar ns_ $ns_ rtproto Session}Test/http4 instproc set-topology {} { $self instvar node_ ns_ for {set i 0} {$i < 5} {incr i} { set node_($i) [$ns_ node] } $ns_ duplex-link $node_(3) $node_(4) 1Mb 50ms DropTail $ns_ duplex-link $node_(0) $node_(3) 1Mb 50ms DropTail $ns_ duplex-link $node_(1) $node_(3) 1Mb 50ms DropTail $ns_ duplex-link $node_(2) $node_(3) 1Mb 50ms DropTail}Test/http4 instproc set-members {} { $self instvar ns_ startTime_ client_ cache_ server_ node_ test_ set client_(0) [new Http/Client $ns_ $node_(0)] set client_(1) [new Http/Client $ns_ $node_(1)] set client_(2) [new Http/Client $ns_ $node_(2)] set cache_ [new Http/Cache/TTL $ns_ $node_(3)] set server_ [new Http/Server $ns_ $node_(4)] $ns_ at $startTime_ "$self start-connection" $ns_ at 10 "$self finish-connection"}Test/http4 instproc start-requests {} { $self instvar client_ server_ cache_ ns_ $client_(0) send-request $cache_ GET $server_:0 set tmp [expr [$ns_ now] + 1] $ns_ at $tmp "$client_(1) send-request $cache_ GET $server_:1" incr tmp $ns_ at $tmp "$client_(2) send-request $cache_ GET $server_:0" incr tmp 3 $ns_ at $tmp "$self start-requests"}# Connect TCP source and destination after simulator startsTest/http4 instproc start-connection {} { $self instvar ns_ client_ server_ cache_ node_ $client_(0) connect $cache_ $client_(1) connect $cache_ $client_(2) connect $cache_ $cache_ connect $server_ $cache_ set-parent $server_ $self start-requests}Test/http4 instproc finish-connection {} { $self instvar client_ server_ cache_ $client_(0) disconnect $cache_ $client_(1) disconnect $cache_ $client_(2) disconnect $cache_ $cache_ disconnect $server_}Class Test/http4f -superclass Test/http4Test/http4f instproc init args { eval $self next $args Http set TRANSPORT_ FullTcp}## Testing PagePool#Class Test/PagePool -superclass TestTest/PagePool instproc init {} { $self instvar pgp_ global opts set opts(page-file) pages set pgp_ [new PagePool/Trace $opts(page-file)] set max [$pgp_ get-poolsize] set tmp [new RandomVariable/Uniform] $tmp set min_ 0 $tmp set max_ [expr $max - 1] $pgp_ ranvar $tmp}Test/PagePool instproc test-enumerate {} { $self instvar pgp_ log_ set max [$pgp_ get-poolsize] for {set i 0} {$i < $max} {incr i} { puts -nonewline $log_ "Page $i: " puts -nonewline $log_ "size [$pgp_ gen-size $i] " set mtime [$pgp_ gen-modtime $i -1] puts -nonewline $log_ "ctime $mtime " set tmp [$pgp_ gen-modtime $i $mtime] while {$tmp != $mtime} { puts -nonewline $log_ "mtime $tmp " set mtime $tmp set tmp [$pgp_ gen-modtime $i $mtime] } puts $log_ "" }}Test/PagePool instproc test-getpageid {} { $self instvar pgp_ log_ set max [$pgp_ get-poolsize] for {set i 0} {$i < $max} {incr i} { set id [$pgp_ gen-pageid 0] puts -nonewline $log_ "Page $id: " puts -nonewline $log_ "size [$pgp_ gen-size $id] " set mtime [$pgp_ gen-modtime $id -1] puts -nonewline $log_ "ctime $mtime " set tmp [$pgp_ gen-modtime $id $mtime] while {$tmp != $mtime} { puts -nonewline $log_ "mtime $tmp " set mtime $tmp set tmp [$pgp_ gen-modtime $id $mtime] } puts $log_ "" }}Test/PagePool instproc run {} { $self instvar log_ set log_ [open "temp.rands" w] $self test-getpageid $self test-enumerate close $log_}#----------------------------------------------------------------------# Testing simplest case for heartbeat message: 1 client+1 cache+1 server#----------------------------------------------------------------------# Multicast invalidation + server invalidationClass Test/cache0-inv -superclass Test-CacheTest/cache0-inv instproc init {} { $self set-defnet cache0 $self next $self set-server-type /Inval/Yuc $self set-cache-type /Inval/Mcast $self set-client-type "" Http set TRANSPORT_ SimpleTcp}Test/cache0-inv instproc set-connections {} { $self instvar client_ server_ cache_ # XXX Should always let server connects to cache first, then requests $client_(0) connect $cache_(0) $server_(0) connect $cache_(0) $server_(0) set-parent-cache $cache_(0)}Test/cache0-inv instproc start-requests {} { $self instvar client_ cache_ server_ ns_ $client_(0) start $cache_(0) $server_(0)}# Mcast invalClass Test/cache0f-inv -superclass Test/cache0-invTest/cache0f-inv instproc init args { eval $self next $args Http set TRANSPORT_ FullTcp}# Push + mcast invalClass Test/cache0-push -superclass Test/cache0-invTest/cache0-push instproc create-members {} { $self next $self instvar cache_ server_ $server_(0) set enable_upd_ 1 $cache_(0) set enable_upd_ 1}Class Test/cache0f-push -superclass {Test/cache0-push Test/cache0f-inv}# TTL Class Test/cache0-ttl -superclass Test/cache0-invTest/cache0-ttl instproc init args { eval $self next $args $self set-server-type "" $self set-cache-type /TTL $self set-client-type ""}Test/cache0-ttl instproc set-connections {} { $self instvar client_ server_ cache_ # XXX Should always let server connects to cache first, then requests $client_(0) connect $cache_(0) $cache_(0) connect $server_(0) $server_(0) set-parent-cache $cache_(0)}Class Test/cache0f-ttl -superclass {Test/cache0f-inv Test/cache0-ttl}# Omniscient TTLClass Test/cache0-ottl -superclass Test/cache0-ttlTest/cache0-ottl instproc init args { eval $self next $args $self set-cache-type /TTL/Omniscient}Class Test/cache0f-ottl -superclass {Test/cache0-ottl Test/cache0f-ttl}#----------------------------------------------------------------------# Two hierarchies #1: server0 -> root cache 0#----------------------------------------------------------------------Class Test/TLC1 -superclass Test-CacheTest/TLC1 instproc init {} { # Do our own initialization global opts set opts(duration) 500 set opts(avg-page-age) 60 set opts(avg-req-interval) 6 set opts(hb-interval) 6 $self set-defnet cache2 $self next $self set-cache-type /Inval/Mcast $self set-server-type /Inval/Yuc $self set-client-type "" Http set TRANSPORT_ SimpleTcp}Test/TLC1 instproc start-requests {} { $self instvar client_ cache_ server_ $client_(0) start $cache_(2) $server_(0) $client_(1) start $cache_(6) $server_(0) $client_(2) start $cache_(4) $server_(0) $client_(3) start $cache_(1) $server_(0)}Test/TLC1 instproc set-connections {} { $self instvar client_ cache_ server_ $client_(0) connect $cache_(2) $client_(1) connect $cache_(6) $client_(2) connect $cache_(4) $client_(3) connect $cache_(1) $cache_(2) connect $cache_(0) $cache_(2) set-parent $cache_(0) $cache_(3) connect $cache_(0) $cache_(3) set-parent $cache_(0) $cache_(6) connect $cache_(2) $cache_(6) set-parent $cache_(2) $cache_(4) connect $cache_(1) $cache_(4) set-parent $cache_(1) $cache_(5) connect $cache_(1) $cache_(5) set-parent $cache_(1) # XXX # We also need TCP connections between TLCs, but the order in which # they are connected is tricky. I.e., the cache that first sends # out a packet should connect first. But how do we know which cache # would send out a packet first??? $cache_(1) connect $cache_(0)}Test/TLC1 instproc set-groups {} { $self instvar client_ cache_ server_ mh_ # TBA group setup stuff... set grp [Node allocaddr] $cache_(0) join-tlc-group $grp $cache_(1) join-tlc-group $grp $mh_ switch-treetype $grp set grp [Node allocaddr] $cache_(0) init-inval-group $grp $cache_(2) join-inval-group $grp $cache_(3) join-inval-group $grp $mh_ switch-treetype $grp set grp [Node allocaddr] $cache_(1) init-inval-group $grp $cache_(4) join-inval-group $grp $cache_(5) join-inval-group $grp $mh_ switch-treetype $grp set grp [Node allocaddr] $cache_(2) init-inval-group $grp $cache_(6) join-inval-group $grp $mh_ switch-treetype $grp # XXX Must let the server to initialize connection, because it's # going to send out the first packet $cache_(1) connect $server_(0) $server_(0) connect $cache_(0) # XXX Must do this at the end. It'll trigger a lot of JOINs. $server_(0) set-parent-cache $cache_(0) # XXX Must do this when using multiple hierarchies $server_(0) set-tlc $cache_(0)}Class Test/TLC1f -superclass Test/TLC1Test/TLC1f instproc init {} { $self next Http set TRANSPORT_ FullTcp}## Two hierarchies with direct request#Class Test/TLC1-dreq -superclass Test/TLC1Test/TLC1-dreq instproc init {} { $self next $self set-cache-type /Inval/Mcast/Perc}# Set up direct connections from leaf caches (i.e., all caches who # may connect to a browser) to the serverTest/TLC1-dreq instproc set-connections {} { $self next $self instvar cache_ server_ $cache_(1) connect $server_(0) $cache_(2) connect $server_(0) $cache_(4) connect $server_(0) $cache_(6) connect $server_(0) $cache_(1) set direct_request_ 1 $cache_(2) set direct_request_ 1 $cache_(4) set direct_request_ 1 $cache_(6) set direct_request_ 1}#----------------------------------------------------------------------# Testing server/cache liveness messages and failure recovery#----------------------------------------------------------------------Class Test/Liveness -superclass Test-CacheTest/Liveness instproc init {} { # Set default initialization values global opts set opts(duration) 1200 ;# Link heals at time 1000. set opts(avg-page-age) 60 set opts(avg-req-interval) 60 set opts(hb-interval) 30 $self set-defnet cache4d $self next $self set-cache-type /Inval/Mcast $self set-server-type /Inval/Yuc $self set-client-type "" # Must use FullTcp, because we'll have packet loss, etc. Http set TRANSPORT_ FullTcp}Test/Liveness instproc start-requests {} { $self instvar client_ cache_ server_ ns_ $client_(0) start $cache_(3) $server_(0) $client_(1) start $cache_(4) $server_(0) $client_(2) start $cache_(5) $server_(0) $client_(3) start $cache_(6) $server_(0)# puts "At [$ns_ now], request starts"}Test/Liveness instproc set-connections {} { $self instvar ns_ client_ server_ cache_ # Enable dynamics somewhere $client_(0) connect $cache_(3) $client_(1) connect $cache_(4) $client_(2) connect $cache_(5) $client_(3) connect $cache_(6) $cache_(1) connect $cache_(0) $cache_(2) connect $cache_(0) $cache_(3) connect $cache_(1) $cache_(4) connect $cache_(1) $cache_(5) connect $cache_(2) $cache_(6) connect $cache_(2) $cache_(1) set-parent $cache_(0) $cache_(2) set-parent $cache_(0) $cache_(3) set-parent $cache_(1) $cache_(4) set-parent $cache_(1) $cache_(5) set-parent $cache_(2) $cache_(6) set-parent $cache_(2) # All TLCs have connection to server $cache_(0) connect $server_(0) # Parent cache of the server is e3 $server_(0) connect $cache_(3)}Test/Liveness instproc set-groups {} { $self instvar cache_ mh_ server_ set grp [Node allocaddr] $cache_(0) init-inval-group $grp $cache_(1) join-inval-group $grp $cache_(2) join-inval-group $grp $mh_ switch-treetype $grp set grp [Node allocaddr] $cache_(1) init-inval-group $grp $cache_(3) join-inval-group $grp $cache_(4) join-inval-group $grp $mh_ switch-treetype $grp set grp [Node allocaddr] $cache_(2) init-inval-group $grp $cache_(5) join-inval-group $grp $cache_(6) join-inval-group $grp $mh_ switch-treetype $grp $server_(0) set-parent-cache $cache_(3)}#----------------------------------------------------------------------# Test Group 1: ## Poisson page mods and Poisson requests, one bottleneck link, 2-level # cache hierarchy with a single TLC. No loss.## Comparing Invalidation, TTL and OTTL.## Testing Mcast+Yucd using a bottleneck topology#----------------------------------------------------------------------Class Test/Mcast-PB -superclass Test-CacheTest/Mcast-PB instproc init {} { # Our own initializations global opts set opts(duration) 200 set opts(avg-page-age) 10 set opts(avg-req-interval) 6 set opts(hb-interval) 6 set opts(num-2nd-cache) 5 $self set-defnet BottleNeck $self next $self instvar secondCaches_ set secondCaches_ $opts(num-2nd-cache) $self set-cache-type /Inval/Mcast $self set-server-type /Inval/Yuc $self set-client-type ""}Test/Mcast-PB instproc start-requests {} { $self instvar client_ cache_ server_ secondCaches_ set n $secondCaches_ for {set i 0} {$i < $n} {incr i} { $client_($i) start $cache_($i) $server_(0) } $self instvar pgp_ topo_ ns_ # Because Test/Cache::init{} already did set-pagepool{}, now we # know how many pages we have. Estimate the cache population time # by NumPages*1+10, then start bandwidth monitoring after # the caches are populated with pages $ns_ at [expr [$ns_ now] + [$pgp_ get-poolsize] + 10] \ "$topo_ start-monitor $ns_"}Test/Mcast-PB instproc set-connections {} { $self instvar ns_ client_ server_ cache_ secondCaches_ set n $secondCaches_ for {set i 0} {$i < $n} {incr i} { $client_($i) connect $cache_($i) $cache_($i) connect $cache_($n) $cache_($i) set-parent $cache_($n) } $cache_($n) connect $server_(0) $self connect-server}Test/Mcast-PB instproc connect-server {} { $self instvar server_ cache_ $server_(0) connect $cache_(0)}Test/Mcast-PB 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 } $mh_ switch-treetype $grp1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -