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.

send_d<strong>at</strong>a(ADU)Applic<strong>at</strong>ion(HttpApp, ...)process_d<strong>at</strong>a(ADU)Applic<strong>at</strong>ion(HttpApp, ...)Agent Wrapper(TcpApp, ...)send_d<strong>at</strong>a(ADU)process_d<strong>at</strong>a(ADU)send(bytes)recv(bytes)Agents supporting user d<strong>at</strong>a(HttpInvalAgent, ...)Agent (TCP, ...)packetspacketsFigure 39.1: Examples of applic<strong>at</strong>ion-level d<strong>at</strong>a flowpriv<strong>at</strong>e:AppD<strong>at</strong>aType type_; // ADU typepublic:struct hdr {AppD<strong>at</strong>aType type_;};public:AppD<strong>at</strong>a(char* b) {assert(b != NULL);type_ = ((hdr *)b)->type_;}virtual void pack(char* buf) co<strong>ns</strong>t;}Here pack(char* buf) is used to write an AppD<strong>at</strong>a object into an array, <strong>and</strong> AppD<strong>at</strong>a(char* b) is used to build anew AppD<strong>at</strong>a from a “serialized” copy of the object in an array.When deriving new ADU from the base class, users may add more d<strong>at</strong>a, but <strong>at</strong> the same time a new pack(char *b) <strong>and</strong>a new co<strong>ns</strong>tructor should be provided to write <strong>and</strong> read those new d<strong>at</strong>a members from an array. For an example as how toderive from an ADU, look <strong>at</strong> <strong>ns</strong>/webcache/http-aux.h.39.1.2 Passing d<strong>at</strong>a between applic<strong>at</strong>io<strong>ns</strong><strong>The</strong> base class of Applic<strong>at</strong>ion, Process, allows applic<strong>at</strong>io<strong>ns</strong> to pass d<strong>at</strong>a or request d<strong>at</strong>a between each other. It is defined asfollows:class Process {public:Process() : target_(0) {}inline Process*& target() { return target_; }342

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

Saved successfully!

Ooh no, something went wrong!