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.

Chapter 38Applic<strong>at</strong>io<strong>ns</strong> <strong>and</strong> tra<strong>ns</strong>port agent APIApplic<strong>at</strong>io<strong>ns</strong> sit on top of tra<strong>ns</strong>port agents in <strong>ns</strong>. <strong>The</strong>re are two basic types of applic<strong>at</strong>io<strong>ns</strong>: traffic gener<strong>at</strong>ors <strong>and</strong> simul<strong>at</strong>ed applic<strong>at</strong>io<strong>ns</strong>.Figure 38.1 illustr<strong>at</strong>es two examples of how applic<strong>at</strong>io<strong>ns</strong> are composed <strong>and</strong> <strong>at</strong>tached to tra<strong>ns</strong>port agents. Tra<strong>ns</strong>portagents are described in Part V (Tra<strong>ns</strong>port).This chapter first describes the base class Applic<strong>at</strong>ion. Next, the tra<strong>ns</strong>port API, through which applic<strong>at</strong>io<strong>ns</strong> requestservices from underlying tra<strong>ns</strong>port agents, is described. Finally, the current implement<strong>at</strong>io<strong>ns</strong> of traffic gener<strong>at</strong>ors <strong>and</strong> sourcesare explained.38.1 <strong>The</strong> class Applic<strong>at</strong>ionApplic<strong>at</strong>ion is a C++ class defined as follows:class Applic<strong>at</strong>ion : public TclObject {public:Applic<strong>at</strong>ion();virtual void send(int nbytes);virtual void recv(int nbytes);virtual void resume();protected:int comm<strong>and</strong>(int argc, co<strong>ns</strong>t char*co<strong>ns</strong>t* argv);virtual void start();virtual void stop();Agent *agent_;int enableRecv_;// call OTcl recv or notint enableResume_;// call OTcl resume or not};Although objects of class Applic<strong>at</strong>ion are not meant to be i<strong>ns</strong>tanti<strong>at</strong>ed, we do not make it an abstract base classso th<strong>at</strong> it is visible from OTcl level. <strong>The</strong> class provides basic prototypes for applic<strong>at</strong>ion behavior (send(), recv(),resume(), start(), stop()), a pointer to the tra<strong>ns</strong>port agent to which it is connected, <strong>and</strong> flags th<strong>at</strong> indic<strong>at</strong>e whethera OTcl-level upcall should be made for recv() <strong>and</strong> resume() events.331

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

Saved successfully!

Ooh no, something went wrong!