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.

# Assuming $server is a configured Http/Server.set client [new Http/Client $<strong>ns</strong> $node]$client connect $server;# client resides on this node;# connecting client to serverConfiguring request gener<strong>at</strong>ion For every request, Http/Client uses PagePool to gener<strong>at</strong>e a r<strong>and</strong>om page ID, <strong>and</strong> use ar<strong>and</strong>om variable to gener<strong>at</strong>e intervals between two co<strong>ns</strong>ecutive requests: 2$client set-page-gener<strong>at</strong>or $pgp$client set-interval-gener<strong>at</strong>or $ranvar;# <strong>at</strong>tach a configured PagePool;# <strong>at</strong>tach a r<strong>and</strong>om variableHere we assume th<strong>at</strong> PagePools of Http/Client share the same set of pages as PagePools of the server. Usually we simplifyour simul<strong>at</strong>ion by letting all clients <strong>and</strong> servers share the same PagePool, i.e., they have the same set of pages. When there aremultiple servers, or servers’ PagePools are separ<strong>at</strong>ed from those of clients’, care must be taken to make sure th<strong>at</strong> every clientsees the same set of pages as the servers to which they are <strong>at</strong>tached.StartingAfter the above setup, starting requests is very simple:$client start-session $cache $server;# assuming $cache is a configured Http/CacheOTcl interfaces Following is a list of its OTcl methods (in addition to those inherited from Http). This is not a completelist. More details can be found in <strong>ns</strong>/tcl/webcache/http-agent.tcl.send-request 〈server〉 〈type〉 〈pageid〉 〈args〉start-session 〈cache〉 〈server〉start 〈cache〉 〈server〉set-page-gener<strong>at</strong>or 〈pagepool〉set-interval-gener<strong>at</strong>or 〈ranvar〉send a request of page $pageid <strong>and</strong> type $type to $server. <strong>The</strong> only requesttype allowed for a client is GET. $args has a form<strong>at</strong> identical to th<strong>at</strong> of$<strong>at</strong>tributes described in Http::enter-page.start sending requests of a r<strong>and</strong>om page to $server via $cache.before sending requests, popul<strong>at</strong>e $cache with all pages in the client’s Page-Pool. This method is useful when assuming infinite-sized caches <strong>and</strong> wewant to observe behaviors of cache co<strong>ns</strong>istency algorithms in steady st<strong>at</strong>e.<strong>at</strong>tach a PagePool to gener<strong>at</strong>e r<strong>and</strong>om page IDs.<strong>at</strong>tach a r<strong>and</strong>om variable to gener<strong>at</strong>e r<strong>and</strong>om request intervals.39.6 Web serverClass Http/Server models behavior of a HTTP server. Its configur<strong>at</strong>ion is very simple. All th<strong>at</strong> a user needs to do is to cre<strong>at</strong>ea server, <strong>at</strong>tach a PagePool <strong>and</strong> wait:set server [new Http/Server $<strong>ns</strong> $node]$server set-page-gener<strong>at</strong>or $pgp;# <strong>at</strong>tach $server to $node;# <strong>at</strong>tach a page pool2 Some PagePool, e.g., PagePool/M<strong>at</strong>h, has only one page <strong>and</strong> therefore it always retur<strong>ns</strong> the same page. Some other PagePool, e.g. PagePool/Trace, hasmultiple pages <strong>and</strong> needs a r<strong>and</strong>om variable to pick out a r<strong>and</strong>om page.353

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

Saved successfully!

Ooh no, something went wrong!