The class PagePool/WebTraf is a standalone Web traffic modle that utilizes PagePool framework. However, this class has nothing to do with the HttpApp classes. Because we are only interested in using it to study Web traffic pattern here, and do not want to be bothered with the burden of transmitting HTTP headers, etc. It has the following two major data structures. Details can be found in ns/webcache/webtraf.cc and ns/webcache/webtraf.h, the architecture WebTraf model is also loosely described in [9], Section 2.4, paragraph 3-4 and the appendix A.1.
class WebTrafSession : public TimerHandler {
public:
WebTrafSession(WebTrafPool *mgr, Node *src, int np, int id) : rvInterPage_(NULL),
rvPageSize_(NULL), rvInterObj_(NULL), rvObjSize_(NULL), mgr_(mgr), src_(src),
nPage_(np), curPage_(0), donePage_(0), id_(id), interPageOption_(1) {}
virtual ~WebTrafSession();
// Queried by individual pages/objects
inline RandomVariable*& interPage() { return rvInterPage_; }
inline RandomVariable*& pageSize() { return rvPageSize_; }
inline RandomVariable*& interObj() { return rvInterObj_; }
inline RandomVariable*& objSize() { return rvObjSize_; }
void donePage(void* ClntData); // all the pages within this
// session have been sent
void launchReq(void* ClntData, int obj, int size);
inline int id() const { return id_; }
inline WebTrafPool* mgr() { return mgr_; }
private:
virtual void expire(Event *e = 0); // Lanuch request for a page
virtual void handle(Event *e); // schedule the timer for next page
RandomVariable *rvInterPage_, *rvPageSize_, *rvInterObj_, *rvObjSize_;
WebTrafPool* mgr_;
Node* src_; // One Web client (source of request) per session
nt nPage_; // number of pages per session
int curPage_; // number of pages that have been sent
int id_; // page ID
int interPageOption_;
}
class WebPage : public TimerHandler {
public:
WebPage(int id, WebTrafSession* sess, int nObj, Node* dst) :
id_(id), sess_(sess), nObj_(nObj), curObj_(0),
doneObj_(0), dst_(dst) {}
virtual ~WebPage() {}
inline void start() { // Call expire() and schedule the next one if needed
void doneObject() { // All the objects within this page have been sent
inline int id() const { return id_; }
Node* dst() { return dst_; }
inline int curObj() const { return curObj_; }
inline int doneObj() const { return doneObj_; }
private:
virtual void expire(Event* = 0) { // Launch request for an object
virtual void handle(Event *e) { // schedule the timer for the next object
int id_; // object ID
WebTrafSession* sess_; // the session that requested this page
int nObj_; // number of object in this page
int curObj_ ; // number of object that have been sent
Node* dst_; // server that this page has been requested from
}
Following is a list of related OTcl methods to the WebTraf class.
The example script is available at ns/tcl/ex/web-traffic.tcl (also see ns/tcl/ex/large-scale-web-traffic.tcl for use of a large-scale web traffic simulation)