Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

RA_Traffic Class Reference

Inheritance diagram for RA_Traffic:

Inheritance graph
[legend]
Collaboration diagram for RA_Traffic:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 RA_Traffic ()
int loadCDF (const char *filename)
int lookup (double u)
virtual double value ()
virtual double interpolate (double u, double x1, double y1, double x2, double y2)
virtual double next_interval (int &)
virtual double interval ()
virtual int on ()
virtual void timeout ()
virtual void recv ()
virtual void recv (int nbytes)
virtual void resume ()
virtual void send (int nbytes)
Process *& target ()
virtual void process_data (int size, AppData *data)
virtual AppDataget_data (int &size, AppData *req_data=0)
virtual void send_data (int size, AppData *data=0)

Protected Member Functions

void init ()
virtual void start ()
virtual void stop ()
virtual int command (int argc, const char *const *argv)

Protected Attributes

double ontime_
double offtime_
double rate_
double interval_
double burstlen_
unsigned int rem_
double minCDF_
double maxCDF_
int interpolation_
int numEntry_
int maxEntry_
CDFentrytable_
RNGrng_
double nextPkttime_
int size_
int running_
TrafficTimer timer_
Agentagent_
int enableRecv_
int enableResume_
Processtarget_

Constructor & Destructor Documentation

RA_Traffic::RA_Traffic  ) 
 

Definition at line 81 of file realaudio.cc.

References RNG::defaultrng(), interpolation_, maxCDF_, maxEntry_, minCDF_, offtime_, ontime_, rate_, rng_, and TrafficGenerator::size_.

00081                        : minCDF_(0), maxCDF_(1), maxEntry_(32), table_(0)
00082 {
00083         bind("minCDF_", &minCDF_);
00084         bind("maxCDF_", &maxCDF_);
00085         bind("interpolation_", &interpolation_);
00086         bind("maxEntry_", &maxEntry_);
00087         bind_time("burst_time_", &ontime_);
00088         bind_time("idle_time_", &offtime_);
00089         bind_bw("rate_", &rate_);
00090         bind("packetSize_", &size_);
00091 
00092         rng_ = RNG::defaultrng();
00093 }

Here is the call graph for this function:


Member Function Documentation

int Application::command int  argc,
const char *const *  argv
[protected, virtual, inherited]
 

Reimplemented from Process.

Reimplemented in MediaApp, QA, EXPOO_Traffic, POO_Traffic, TrafficTrace, HttpUInvalAgent, and TcpApp.

Definition at line 56 of file app.cc.

References Application::agent_, Agent::attachApp(), Process::command(), Application::enableRecv_, Application::enableResume_, Application::send(), Application::start(), and Application::stop().

Referenced by TrafficTrace::command(), TcpApp::command(), POO_Traffic::command(), MediaApp::command(), and EXPOO_Traffic::command().

00057 {
00058         Tcl& tcl = Tcl::instance();
00059 
00060         if (argc == 2) {
00061                 if (strcmp(argv[1], "start") == 0) {
00062                         // enableRecv_ only if recv() exists in Tcl
00063                         tcl.evalf("[%s info class] info instprocs", name_);
00064                         char result[1024];
00065                         sprintf(result, " %s ", tcl.result());
00066                         enableRecv_ = (strstr(result, " recv ") != 0);
00067                         enableResume_ = (strstr(result, " resume ") != 0);
00068                         start();
00069                         return (TCL_OK);
00070                 }
00071                 if (strcmp(argv[1], "stop") == 0) {
00072                         stop();
00073                         return (TCL_OK);
00074                 }
00075                 if (strcmp(argv[1], "agent") == 0) {
00076                         tcl.resultf("%s", agent_->name());
00077                         return (TCL_OK);
00078                 }
00079         }
00080         else if (argc == 3) {
00081                 if (strcmp(argv[1], "attach-agent") == 0) {
00082                         agent_ = (Agent*) TclObject::lookup(argv[2]);
00083                         if (agent_ == 0) {
00084                                 tcl.resultf("no such agent %s", argv[2]);
00085                                 return(TCL_ERROR);
00086                         }
00087                         agent_->attachApp(this);
00088                         return(TCL_OK);
00089                 }
00090                 if (strcmp(argv[1], "send") == 0) {
00091                         send(atoi(argv[2]));
00092                         return(TCL_OK);
00093                 }
00094         }
00095         return (Process::command(argc, argv));
00096 }

Here is the call graph for this function:

AppData * Process::get_data int &  size,
AppData req_data = 0
[virtual, inherited]
 

Reimplemented in MediaApp, QA, HttpApp, HttpUInvalAgent, MediaCache, MediaServer, and TcpApp.

Definition at line 46 of file ns-process.cc.

References abort().

Referenced by QA::check_availability(), MediaApp::get_data(), RapAgent::IpgTimeout(), and QA::output().

00047 {
00048         abort();
00049         /* NOTREACHED */
00050         return NULL; // Make msvc happy 
00051 }

Here is the call graph for this function:

void RA_Traffic::init  )  [protected, virtual]
 

Reimplemented from TrafficGenerator.

Definition at line 95 of file realaudio.cc.

References Application::agent_, burstlen_, interval_, loadCDF(), offtime_, ontime_, PT_REALAUDIO, rate_, rem_, Agent::set_pkttype(), and TrafficGenerator::size_.

00096 {
00097         int res = loadCDF("offtimecdf");
00098 //      int res1 = Ontime_.loadCDF("ontimecdf");
00099         timeval tv;
00100         gettimeofday(&tv, 0);
00101 
00102         if (res < 0)  printf("error:unable to load offtimecdf");
00103 
00104         interval_ = ontime_ ;
00105         burstlen_ = (double) ( rate_ * (ontime_ + offtime_))/ (double)(size_ << 3);
00106         rem_ = 0;
00107         if (agent_)
00108                 agent_->set_pkttype(PT_REALAUDIO);
00109 }

Here is the call graph for this function:

double RA_Traffic::interpolate double  u,
double  x1,
double  y1,
double  x2,
double  y2
[virtual]
 

Definition at line 190 of file realaudio.cc.

References INTER_INTEGRAL, interpolation_, and value().

Referenced by value().

00191 {
00192         double value = y1 + (x - x1) * (y2 - y1) / (x2 - x1);
00193         if (interpolation_ == INTER_INTEGRAL)   // round up
00194                 return ceil(value);
00195         return value;
00196 }

Here is the call graph for this function:

virtual double TrafficGenerator::interval  )  [inline, virtual, inherited]
 

Reimplemented in CBR_PP_Traffic, and CBR_Traffic.

Definition at line 63 of file trafgen.h.

Referenced by SA_Agent::sendpkt().

00063 { return 0; }

int RA_Traffic::loadCDF const char *  filename  ) 
 

Definition at line 150 of file realaudio.cc.

References CDFentry::cdf_, maxEntry_, numEntry_, table_, and CDFentry::val_.

Referenced by init().

00151 {
00152         FILE* fp;
00153         char line[256];
00154         CDFentry* e;
00155 
00156         fp = fopen(filename, "r");
00157         if (fp == 0)
00158                 return 0;
00159 
00160         if (table_ == 0)
00161                 table_ = new CDFentry[maxEntry_];
00162         for (numEntry_=0;  fgets(line, 256, fp);  numEntry_++) {
00163                 if (numEntry_ >= maxEntry_) {   // resize the CDF table
00164                         maxEntry_ *= 2;
00165                         e = new CDFentry[maxEntry_];
00166                         for (int i=numEntry_-1; i >= 0; i--)
00167                                 e[i] = table_[i];
00168                         delete table_;
00169                         table_ = e;
00170                 }
00171                 e = &table_[numEntry_];
00172                 // Use * and l together raises a warning
00173                 sscanf(line, "%lf %*f %lf", &e->val_, &e->cdf_);
00174         }
00175         return numEntry_;
00176 }

int RA_Traffic::lookup double  u  ) 
 

Definition at line 198 of file realaudio.cc.

References CDFentry::cdf_, numEntry_, and table_.

Referenced by value().

00199 {
00200         // always return an index whose value is >= u
00201         int lo, hi, mid;
00202         if (u <= table_[0].cdf_)
00203                 return 0;
00204         for (lo=1, hi=numEntry_-1;  lo < hi; ) {
00205                 mid = (lo + hi) / 2;
00206                 if (u > table_[mid].cdf_)
00207                         lo = mid + 1;
00208                 else hi = mid;
00209         }
00210         return lo;
00211 }

double RA_Traffic::next_interval int &   )  [virtual]
 

Implements TrafficGenerator.

Definition at line 111 of file realaudio.cc.

References burstlen_, offtime_, ontime_, rate_, rem_, TrafficGenerator::size_, and value().

00112 {
00113 //      double t = Ontime_.value() ;
00114         double o = value() ; //off-time is taken from CDF
00115 
00116         double t = ontime_ ; //fixed on-time
00117 //      double o = offtime_ ;
00118 
00119 //      o = o * ran ;
00120 
00121         if (rem_ == 0) {
00122                 /* compute number of packets in next burst */
00123                 rem_ = int(burstlen_ + .5);
00124 
00125                 //recalculate the number of packet sent during ON-period if
00126                 // off-time is mutliple of 1.8s
00127                 if (o > offtime_ ) {
00128                    double b = 
00129                    // (double) ( rate_ * (ontime_ + o))/ (double)(size_ << 3);
00130                    (double) ( rate_ * (t + o))/ (double)(size_ << 3);
00131                    rem_ = int(b);
00132                 }
00133 
00134 //              if (ran > 0.8 ) rem_++ ;
00135 //              if (ran < 0.2 ) rem_-- ;
00136 
00137                 /* make sure we got at least 1 */
00138                 if (rem_<= 0)
00139                         rem_ = 1;       
00140                 /* start of an idle period, compute idle time */
00141                 t += o ;
00142         }       
00143         rem_--;
00144 
00145         size = size_;
00146         return(t);
00147 
00148 }

Here is the call graph for this function:

virtual int TrafficGenerator::on  )  [inline, virtual, inherited]
 

Reimplemented in POO_Traffic.

Definition at line 64 of file trafgen.h.

Referenced by SA_Agent::stoponidle(), and SA_Agent::timeout().

00064 { return 0; }

void Process::process_data int  size,
AppData data
[virtual, inherited]
 

Reimplemented in MediaApp, HttpApp, HttpMInvalCache, HttpUInvalAgent, MediaCache, MediaClient, and TcpApp.

Definition at line 41 of file ns-process.cc.

References abort().

Referenced by HttpUInvalAgent::process_data(), UdpAgent::recv(), RapAgent::recv(), and Process::send_data().

00042 {
00043         abort();
00044 }

Here is the call graph for this function:

void Application::recv int  nbytes  )  [virtual, inherited]
 

Reimplemented in TcpApp.

Definition at line 115 of file app.cc.

References Application::enableRecv_.

Referenced by SimpleTcpAgent::recv(), Agent::recv(), and Agent::recvBytes().

00116 {
00117         if (! enableRecv_)
00118                 return;
00119         Tcl& tcl = Tcl::instance();
00120         tcl.evalf("%s recv %d", name_, nbytes);
00121 }

virtual void TrafficGenerator::recv  )  [inline, virtual, inherited]
 

Definition at line 67 of file trafgen.h.

00067 {}

virtual void TrafficGenerator::resume void   )  [inline, virtual, inherited]
 

Reimplemented from Application.

Definition at line 68 of file trafgen.h.

00068 {}

void Application::send int  nbytes  )  [virtual, inherited]
 

Definition at line 109 of file app.cc.

References Application::agent_, and Agent::sendmsg().

Referenced by Application::command(), TcpApp::send(), and TrafficGenerator::timeout().

00110 {
00111         agent_->sendmsg(nbytes);
00112 }

Here is the call graph for this function:

virtual void Process::send_data int  size,
AppData data = 0
[inline, virtual, inherited]
 

Definition at line 106 of file ns-process.h.

References Process::process_data(), and Process::target_.

Referenced by TcpApp::process_data(), and MediaApp::process_data().

00106                                                             {
00107                 if (target_)
00108                         target_->process_data(size, data);
00109         }

Here is the call graph for this function:

void TrafficGenerator::start  )  [protected, virtual, inherited]
 

Reimplemented from Application.

Reimplemented in CBR_PP_Traffic, and CBR_Traffic.

Definition at line 49 of file trafgen.cc.

References TrafficGenerator::init(), TrafficGenerator::next_interval(), TrafficGenerator::nextPkttime_, TimerHandler::resched(), TrafficGenerator::running_, TrafficGenerator::size_, and TrafficGenerator::timer_.

00050 {
00051         init();
00052         running_ = 1;
00053         nextPkttime_ = next_interval(size_);
00054         timer_.resched(nextPkttime_);
00055         // Enable line below if you want to send immediately upon start
00056         //timeout(); 
00057 }

Here is the call graph for this function:

void TrafficGenerator::stop  )  [protected, virtual, inherited]
 

Reimplemented from Application.

Definition at line 60 of file trafgen.cc.

References TimerHandler::cancel(), TrafficGenerator::running_, and TrafficGenerator::timer_.

00061 {
00062         if (running_)
00063                 timer_.cancel();
00064         running_ = 0;
00065 }

Here is the call graph for this function:

Process*& Process::target  )  [inline, inherited]
 

Definition at line 97 of file ns-process.h.

References Process::target_.

Referenced by QA::check_availability(), Process::command(), HttpApp::command(), MediaApp::get_data(), QA::output(), and TcpApp::process_data().

00097 { return target_; }

void TrafficGenerator::timeout  )  [virtual, inherited]
 

Reimplemented in CBR_PP_Traffic, EXPOO_Traffic, and TrafficTrace.

Definition at line 68 of file trafgen.cc.

References TrafficGenerator::next_interval(), TrafficGenerator::nextPkttime_, TimerHandler::resched(), TrafficGenerator::running_, Application::send(), TrafficGenerator::size_, and TrafficGenerator::timer_.

Referenced by TrafficTimer::expire(), and CBR_Traffic::start().

00069 {
00070         if (! running_)
00071                 return;
00072 
00073         /* send a packet */
00074         send(size_);
00075         /* figure out when to send the next one */
00076         nextPkttime_ = next_interval(size_);
00077         /* schedule it */
00078         if (nextPkttime_ > 0)
00079                 timer_.resched(nextPkttime_);
00080         else
00081                 running_ = 0;
00082 }

Here is the call graph for this function:

double RA_Traffic::value  )  [virtual]
 

Definition at line 178 of file realaudio.cc.

References CDFentry::cdf_, interpolate(), interpolation_, lookup(), maxCDF_, minCDF_, numEntry_, rng_, table_, and RNG::uniform().

Referenced by interpolate(), and next_interval().

00179 {
00180         if (numEntry_ <= 0)
00181                 return 0;
00182         double u = rng_->uniform(minCDF_, maxCDF_);
00183         int mid = lookup(u);
00184         if (mid && interpolation_ && u < table_[mid].cdf_)
00185                 return interpolate(u, table_[mid-1].cdf_, table_[mid-1].val_,
00186                                    table_[mid].cdf_, table_[mid].val_);
00187         return table_[mid].val_;
00188 }

Here is the call graph for this function:


Member Data Documentation

Agent* Application::agent_ [protected, inherited]
 

Definition at line 60 of file app.h.

Referenced by Application::command(), init(), POO_Traffic::init(), EXPOO_Traffic::init(), CBR_Traffic::init(), CBR_PP_Traffic::init(), QA::rap(), MediaApp::rap(), Application::send(), TcpApp::TcpApp(), TrafficTrace::timeout(), TelnetApp::timeout(), EXPOO_Traffic::timeout(), CBR_PP_Traffic::timeout(), and TcpApp::~TcpApp().

double RA_Traffic::burstlen_ [protected]
 

Definition at line 58 of file realaudio.cc.

Referenced by init(), and next_interval().

int Application::enableRecv_ [protected, inherited]
 

Definition at line 61 of file app.h.

Referenced by Application::command(), and Application::recv().

int Application::enableResume_ [protected, inherited]
 

Definition at line 62 of file app.h.

Referenced by Application::command(), and Application::resume().

int RA_Traffic::interpolation_ [protected]
 

Definition at line 62 of file realaudio.cc.

Referenced by interpolate(), RA_Traffic(), and value().

double RA_Traffic::interval_ [protected]
 

Definition at line 57 of file realaudio.cc.

Referenced by init().

double RA_Traffic::maxCDF_ [protected]
 

Definition at line 61 of file realaudio.cc.

Referenced by RA_Traffic(), and value().

int RA_Traffic::maxEntry_ [protected]
 

Definition at line 64 of file realaudio.cc.

Referenced by loadCDF(), and RA_Traffic().

double RA_Traffic::minCDF_ [protected]
 

Definition at line 60 of file realaudio.cc.

Referenced by RA_Traffic(), and value().

double TrafficGenerator::nextPkttime_ [protected, inherited]
 

Definition at line 74 of file trafgen.h.

Referenced by TrafficGenerator::start(), TrafficGenerator::timeout(), TrafficTrace::timeout(), EXPOO_Traffic::timeout(), and CBR_PP_Traffic::timeout().

int RA_Traffic::numEntry_ [protected]
 

Definition at line 63 of file realaudio.cc.

Referenced by loadCDF(), lookup(), and value().

double RA_Traffic::offtime_ [protected]
 

Definition at line 55 of file realaudio.cc.

Referenced by init(), next_interval(), and RA_Traffic().

double RA_Traffic::ontime_ [protected]
 

Definition at line 54 of file realaudio.cc.

Referenced by init(), next_interval(), and RA_Traffic().

double RA_Traffic::rate_ [protected]
 

Definition at line 56 of file realaudio.cc.

Referenced by init(), next_interval(), and RA_Traffic().

unsigned int RA_Traffic::rem_ [protected]
 

Definition at line 59 of file realaudio.cc.

Referenced by init(), and next_interval().

RNG* RA_Traffic::rng_ [protected]
 

Definition at line 66 of file realaudio.cc.

Referenced by RA_Traffic(), and value().

int TrafficGenerator::running_ [protected, inherited]
 

Definition at line 76 of file trafgen.h.

Referenced by TrafficGenerator::start(), CBR_Traffic::start(), CBR_PP_Traffic::start(), TrafficGenerator::stop(), TrafficGenerator::timeout(), TrafficTrace::timeout(), EXPOO_Traffic::timeout(), and CBR_PP_Traffic::timeout().

int TrafficGenerator::size_ [protected, inherited]
 

Definition at line 75 of file trafgen.h.

Referenced by CBR_PP_Traffic::CBR_PP_Traffic(), CBR_Traffic::CBR_Traffic(), EXPOO_Traffic::EXPOO_Traffic(), init(), POO_Traffic::init(), EXPOO_Traffic::init(), CBR_Traffic::init(), CBR_PP_Traffic::init(), next_interval(), POO_Traffic::next_interval(), EXPOO_Traffic::next_interval(), CBR_Traffic::next_interval(), CBR_PP_Traffic::next_interval(), POO_Traffic::POO_Traffic(), RA_Traffic(), TrafficGenerator::start(), TrafficGenerator::timeout(), TrafficTrace::timeout(), EXPOO_Traffic::timeout(), and CBR_PP_Traffic::timeout().

CDFentry* RA_Traffic::table_ [protected]
 

Definition at line 65 of file realaudio.cc.

Referenced by loadCDF(), lookup(), and value().

Process* Process::target_ [protected, inherited]
 

Definition at line 113 of file ns-process.h.

Referenced by HttpUInvalAgent::command(), Process::Process(), HttpUInvalAgent::process_data(), Process::send_data(), and Process::target().

TrafficTimer TrafficGenerator::timer_ [protected, inherited]
 

Definition at line 77 of file trafgen.h.

Referenced by TrafficGenerator::start(), TrafficGenerator::stop(), TrafficGenerator::timeout(), TrafficTrace::timeout(), EXPOO_Traffic::timeout(), and CBR_PP_Traffic::timeout().


The documentation for this class was generated from the following file:
Generated on Tue Apr 20 13:11:29 2004 for NS2.26SourcesOriginal by doxygen 1.3.3