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.

39.2.3 DebuggingHttpApp provides two debugging methods. log registers a file h<strong>and</strong>le as the trace file for all HttpApp-specific traces. Itstrace form<strong>at</strong> is described in section 39.9. evTrace logs a particular event into trace file. It conc<strong>at</strong>en<strong>at</strong>es time <strong>and</strong> the id ofthe HttpApp to the given string, <strong>and</strong> writes it out. Details can be found in <strong>ns</strong>/webcache/http.cc.39.3 Representing web pagesWe represent web pages as the abstract class Page. It is defined as follows:class Page {public:Page(int size) : size_(size) {}int size() co<strong>ns</strong>t { return size_; }int& id() { return id_; }virtual WebPageType type() co<strong>ns</strong>t = 0;protected:int size_;int id_;};It represents the basic properties of a web page: size <strong>and</strong> URL. Upon it we derive two classes of web pages: ServerPage <strong>and</strong>ClientPage. <strong>The</strong> former contai<strong>ns</strong> a list of page modific<strong>at</strong>ion times, <strong>and</strong> is supposed to by used by servers. It was originallydesigned to work with a special web server trace; currently it is not widely used in <strong>ns</strong>. <strong>The</strong> l<strong>at</strong>ter, ClientPage, is the defaultweb page for all page pools below.A ClientPage has the following major properties (we omit some variables used by web cache with invalid<strong>at</strong>ion, which has toomany details to be covered here):• HttpApp* server_ - Pointer to the original server of this page.• double age_ - Lifetime of the page.• int st<strong>at</strong>us_ - St<strong>at</strong>us of the page. Its contents are explained below.<strong>The</strong> st<strong>at</strong>us (32-bit) of a ClientPage is separ<strong>at</strong>ed into two 16-bit parts. <strong>The</strong> first part (with mask 0x00FF) is used to store pagest<strong>at</strong>us, the second part (with mask 0xFF00) is used to store expected page actio<strong>ns</strong> to be performed by cache. Available pagest<strong>at</strong>us are (again, we omit those closely rel<strong>at</strong>ed to web cache invalid<strong>at</strong>ion):HTTP_VALID_PAGEHTTP_UNCACHEABLEPage is valid.Page is uncacheable. This option can be used to simul<strong>at</strong>e CGI pages or dynamic server pages.CilentPage has the following major C++ methods:• type() - Retur<strong>ns</strong> the type of the page. Assuming pages of the same type should have identical oper<strong>at</strong>io<strong>ns</strong>, we letall ClientPage to be of type “HTML”. If l<strong>at</strong>er on other types of web pages are needed, a class may be derived fromClientPage (or Page) with the desired type.347

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

Saved successfully!

Ooh no, something went wrong!