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.

<strong>and</strong> teardown of connectio<strong>ns</strong>. Only OTcl interface is provided for establishing, tearing down a connection <strong>and</strong> sending d<strong>at</strong><strong>at</strong>hrough a connection.OTcl methodsFollowing is a list of OTcl interfaces rel<strong>at</strong>ed to connection management in Http objects:idget-cnc 〈client〉is-connected 〈server〉send 〈client〉 〈bytes〉 〈callback〉connect 〈client〉 〈TCP〉disconnect 〈client〉return the id of the Http object, which is the id of the node the object is <strong>at</strong>tached to.return the TCP agent associ<strong>at</strong>ed with $client (Http object).return 0 if not connected to $server, 1 otherwise.send $bytes of d<strong>at</strong>a to $client. When it’s done, execute $callback (a OTcl comm<strong>and</strong>).associ<strong>at</strong>e a TCP agent with $client (Http object). Th<strong>at</strong> agent will be used to send packetsto $client.delete the associ<strong>at</strong>ion of a TCP agent with $client. Note th<strong>at</strong> neither the TCP agent nor$client is not deleted, only the associ<strong>at</strong>ion is deleted.Configur<strong>at</strong>ion parameter By default, Http objects use Agent/SimpleTcp as tra<strong>ns</strong>port agents (section 39.1.4). <strong>The</strong>y canalso use Agent/FullTcp agents, which allows Http objects to oper<strong>at</strong>e in a lossy network. Class variable codeTRANSPORT_is used for this purpose. E.g., Http set TRANSPORT_FullTcp tells all Http objects use FullTcp agents.This configur<strong>at</strong>ion should be done before simul<strong>at</strong>ion starts, <strong>and</strong> it should not change during simul<strong>at</strong>ion, because FullTcpagents do not inter-oper<strong>at</strong>e with SimpleTcp agents.39.2.2 Managing web pagesHttp also provides OTcl interfaces to manage a set of pages. <strong>The</strong> real management of pages are h<strong>and</strong>led by class PagePool<strong>and</strong> its subclasses. Because different HTTP objects have different requirements for page management, we allow differentPagePool subclasses to be <strong>at</strong>tached to different subclasses of Http class. Meanwhile, we export a common set of PagePoolinterfaces to OTcl through Http. For example, a browser may use a PagePool only to gener<strong>at</strong>e a request stream, so its PagePoolonly needs to contain a list of URLs. But a cache may want to store page size, last modific<strong>at</strong>ion time of every page i<strong>ns</strong>tead ofa list of URLs. However, this separ<strong>at</strong>ion is not clearcut in the current implement<strong>at</strong>ion.Page URLs are represented in the form of: 〈ServerName〉:〈SequenceNumber〉 where the ServerName is the name ofOTcl object, <strong>and</strong> every page in every server should have a unique SequenceNumber. Page contents are ignored. I<strong>ns</strong>tead,every page contai<strong>ns</strong> several <strong>at</strong>tributes, which are represented in OTcl as a list of the following (〈name〉 〈value〉) pairs: “modtime〈val〉” (page modific<strong>at</strong>ion time), “size 〈val〉” (page size), <strong>and</strong> “age 〈val〉”} <strong>The</strong> ordering of these pairs is not significant.Following is a list of rel<strong>at</strong>ed OTcl methods.set-pagepool 〈pagepool〉enter-page 〈pageid〉 〈<strong>at</strong>tributes〉get-page 〈pageid〉get-modtime 〈pageid〉exist-page 〈pageid〉get-size 〈pageid〉get-cachetime 〈pageid〉set page pooladd a page with id $pageid into pool. $<strong>at</strong>tributes is the <strong>at</strong>tributes of $pageid, as describedabove.return page <strong>at</strong>tributes in the form<strong>at</strong> described above.return the last modific<strong>at</strong>ion time of the page $pageid.return 0 if $pageid doesn’t exist in this Http object, 1 otherwise.return the size of $pageid.return the time when page $pageid is entered into the cache.346

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

Saved successfully!

Ooh no, something went wrong!