12.07.2015 Views

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

set tmp [new R<strong>and</strong>omVariable/Exponential]$tmp set avg_ 5$pgp ranvar-age $tmp;## Page age gener<strong>at</strong>or;## average page age;## Cre<strong>at</strong>e a server <strong>and</strong> link it to the cen-;## Cre<strong>at</strong>e a cache;## Cre<strong>at</strong>e a client;## Poisson process as request sequence;## average request interval;## simul<strong>at</strong>ion start time;## simul<strong>at</strong>ion end timeset server [new Http/Server $<strong>ns</strong> $node(s)]tral page pool$server set-page-gener<strong>at</strong>or $pgp$server log $logset cache [new Http/Cache $<strong>ns</strong> $node(e)]$cache log $logset client [new Http/Client $<strong>ns</strong> $node(c)]set tmp [new R<strong>and</strong>omVariable/Exponential]$tmp set avg_ 5$client set-interval-gener<strong>at</strong>or $tmp$client set-page-gener<strong>at</strong>or $pgp$client log $logset startTime 1set finishTime 50$<strong>ns</strong> <strong>at</strong> $startTime "start-connection"$<strong>ns</strong> <strong>at</strong> $finishTime "finish"<strong>The</strong>n we define a procedure which will be called after simul<strong>at</strong>ion starts. <strong>The</strong> procedure will setup connectio<strong>ns</strong> among all Httpobjects.proc start-connection {} {global <strong>ns</strong> server cache client$client connect $cache$cache connect $server$client start-session $cache $server}At the end, the usual closing:proc finish {} {global <strong>ns</strong> log$<strong>ns</strong> flush-traceflush $logclose $logexit 0}$<strong>ns</strong> runThis script is also available <strong>at</strong> <strong>ns</strong>/tcl/ex/simple-webcache.tcl. Examining its output http.log, one will find th<strong>at</strong> the resultof the abse<strong>ns</strong>e cache co<strong>ns</strong>istency algorithm results in a lot of stale hits. This can be easily remedied by replacing “newHttp/Cache” line with: set cache [new Http/Cache/TTL $<strong>ns</strong> $node(e)]. For more complic<strong>at</strong>ed cache co<strong>ns</strong>istencyalgorithm examples, see <strong>ns</strong>/tcl/test/test-suite-webcache.tcl.356

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!