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.

Chapter 39Web cache as an applic<strong>at</strong>ionAll applic<strong>at</strong>io<strong>ns</strong> described above are “virtual” applic<strong>at</strong>io<strong>ns</strong>, in the se<strong>ns</strong>e th<strong>at</strong> they do not actually tra<strong>ns</strong>fer their own d<strong>at</strong>ain the simul<strong>at</strong>or; all th<strong>at</strong> m<strong>at</strong>ter is the size <strong>and</strong> the time when d<strong>at</strong>a are tra<strong>ns</strong>ferred. Sometimes we may want applic<strong>at</strong>io<strong>ns</strong>to tra<strong>ns</strong>fer their own d<strong>at</strong>a in simul<strong>at</strong>io<strong>ns</strong>. One such example is web caching, where we want HTTP servers to send HTTPheaders to caches <strong>and</strong> clients. <strong>The</strong>se headers contain page modific<strong>at</strong>ion time inform<strong>at</strong>ion <strong>and</strong> other caching directives, whichare important for some cache co<strong>ns</strong>istency algorithms.In the following, we first describe general issues regarding tra<strong>ns</strong>mitting applic<strong>at</strong>ion-level d<strong>at</strong>a in <strong>ns</strong>, then we discuss specialissues, as well as APIs, rel<strong>at</strong>ed to tra<strong>ns</strong>mitting applic<strong>at</strong>ion d<strong>at</strong>a using TCP as tra<strong>ns</strong>port. We will then proceed to discuss theinternal design of HTTP client, server, <strong>and</strong> proxy cache.39.1 Using applic<strong>at</strong>ion-level d<strong>at</strong>a in <strong>ns</strong>In order to tra<strong>ns</strong>mit applic<strong>at</strong>ion-level d<strong>at</strong>a in <strong>ns</strong>, we provide a uniform structure to pass d<strong>at</strong>a among applic<strong>at</strong>io<strong>ns</strong>, <strong>and</strong> topass d<strong>at</strong>a from applic<strong>at</strong>io<strong>ns</strong> to tra<strong>ns</strong>port agents (Figure 39.1). It has three major components: a represent<strong>at</strong>ion of a uniformapplic<strong>at</strong>ion-level d<strong>at</strong>a unit (ADU), a common interface to pass d<strong>at</strong>a between applic<strong>at</strong>io<strong>ns</strong>, <strong>and</strong> two mechanisms to pass d<strong>at</strong>abetween applic<strong>at</strong>io<strong>ns</strong> <strong>and</strong> tra<strong>ns</strong>port agents.39.1.1 ADU<strong>The</strong> functionality of an ADU is similar to th<strong>at</strong> of a Packet. It needs to pack user d<strong>at</strong>a into an array, which is then included inthe user d<strong>at</strong>a area of an <strong>ns</strong>packet by an Agent (this is not supported by current Agents. User must derive new agents to acceptuser d<strong>at</strong>a from applic<strong>at</strong>io<strong>ns</strong>, or use an wrapper like TcpApp. We’ll discuss this l<strong>at</strong>er).Compared with Packet, ADU provides this functionality in a different way. In Packet, a common area is alloc<strong>at</strong>ed for allpacket headers; an offset is used to access different headers in this area. In ADU this is not applicable, because some ADUalloc<strong>at</strong>es their space dynamically according the the availability of user d<strong>at</strong>a. For example, if we want to deliver an OTclscript between applic<strong>at</strong>io<strong>ns</strong>, the size of the script is undetermined beforeh<strong>and</strong>. <strong>The</strong>refore, we choose a less efficient but moreflexible method. Each ADU defines its own d<strong>at</strong>a members, <strong>and</strong> provides methods to serialize them (i.e., pack d<strong>at</strong>a into anarray <strong>and</strong> extract them from an array). For example, in the abstract base class of all ADU, AppD<strong>at</strong>a, we have:class AppD<strong>at</strong>a {341

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

Saved successfully!

Ooh no, something went wrong!