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...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

TclObjectProcessApplic<strong>at</strong>ionHttpApp, ...Applic<strong>at</strong>ion/TcpAppApplic<strong>at</strong>ion/FTPApplic<strong>at</strong>ion/TelnetApplic<strong>at</strong>ion/Traffic/*Figure 39.2: Hierarchy of classes rel<strong>at</strong>ed to applic<strong>at</strong>ion-level d<strong>at</strong>a h<strong>and</strong>lingNow we let $app1 be sender <strong>and</strong> $app2 be receiver:$<strong>ns</strong> <strong>at</strong> 1.0 "$app1 send 100 \"$app2 app-recv 100\""Where app-recv is defined as:Applic<strong>at</strong>ion/TcpApp i<strong>ns</strong>tproc app-recv { size } {global <strong>ns</strong>puts "[$<strong>ns</strong> now] app2 receives d<strong>at</strong>a $size from app1"}39.1.5 Class hierarchy rel<strong>at</strong>ed to user d<strong>at</strong>a h<strong>and</strong>lingWe conclude this section by providing a hierarchy of classes involved in this section (Figure 39.2).39.2 Overview of web cache classes<strong>The</strong>re are three major classes rel<strong>at</strong>ed to web cache, as it is in the real world: client (browser), server, <strong>and</strong> cache. Becausethey share a common fe<strong>at</strong>ure, i.e., the HTTP protocol, they are derived from the same base class Http (Name of OTclclass, it’s called HttpApp in C++). For the following reaso<strong>ns</strong>, it’s not a real Applic<strong>at</strong>ion. First, an HTTP object (i.e.,client/cache/server) may want to maintain multiple concurrent HTTP connectio<strong>ns</strong>, but an Applic<strong>at</strong>ion contai<strong>ns</strong> only oneagent_. Also, an HTTP object needs to tra<strong>ns</strong>mit real d<strong>at</strong>a (e.g., HTTP header) <strong>and</strong> th<strong>at</strong>’s provided by TcpApp i<strong>ns</strong>tead ofany Agent. <strong>The</strong>refore, we choose to use a st<strong>and</strong>alone class derived from TclObject for common fe<strong>at</strong>ures of all HTTP objects,which are managing HTTP connectio<strong>ns</strong> <strong>and</strong> a set of pages. In the rest of the section, we’ll discuss these functionalities ofHttp. In the next three sectio<strong>ns</strong>, we’ll in turn describe HTTP client, cache <strong>and</strong> server.39.2.1 Managing HTTP connectio<strong>ns</strong>Every HTTP connection is embodied as a TcpApp object. Http maintai<strong>ns</strong> a hash of TcpApp objects, which are all of itsactive connectio<strong>ns</strong>. It assumes th<strong>at</strong> to any other Http, it has only one HTTP connection. It also allows dynamic establishment345

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

Saved successfully!

Ooh no, something went wrong!