TraceFile Class Reference

Inheritance diagram for TraceFile:

NsObject TclObject Handler Collaboration diagram for TraceFile:

Collaboration graph
[legend]

Detailed Description

Definition at line 83 of file traffictrace.cc.

Public Member Functions

int command (int argc, const char *const *argv)
virtual void debug (const char *fmt,...)
virtual int delay_bind_dispatch (const char *varName, const char *localName, TclObject *tracer)
virtual void delay_bind_init_all ()
void get_next (int &, struct tracerec &)
int isdebug () const
virtual void recv (Packet *p, const char *s)
virtual void recvOnly (Packet *)
int setup ()
 TraceFile ()

Protected Member Functions

void handle (Event *)
virtual void reset ()

Protected Attributes

int debug_

Private Member Functions

void recv (Packet *, Handler *)

Private Attributes

char * name_
int nrec_
int status_
tracerectrace_


Constructor & Destructor Documentation

TraceFile::TraceFile  ) 
 

Definition at line 125 of file traffictrace.cc.

00125                      : status_(0)
00126 {
00127 }


Member Function Documentation

int TraceFile::command int  argc,
const char *const *  argv
[virtual]
 

Reimplemented from NsObject.

Definition at line 129 of file traffictrace.cc.

References NsObject::command(), and name_.

00130 {
00131 
00132     if (argc == 3) {
00133         if (strcmp(argv[1], "filename") == 0) {
00134             name_ = new char[strlen(argv[2])+1];
00135             strcpy(name_, argv[2]);
00136             return(TCL_OK);
00137         }
00138     }
00139     return (NsObject::command(argc, argv));
00140 }

Here is the call graph for this function:

void NsObject::debug const char *  fmt,
  ...
[virtual, inherited]
 

Definition at line 102 of file object.cc.

References NsObject::debug_.

00103 {
00104     if (!debug_)
00105         return;
00106     va_list ap;
00107     va_start(ap, fmt);
00108     vprintf(fmt, ap);
00109 }

int NsObject::delay_bind_dispatch const char *  varName,
const char *  localName,
TclObject tracer
[virtual, inherited]
 

Reimplemented in BayFullTcpAgent, Agent, MPLSAddressClassifier, LDPAgent, HbAfterRtoSctpAgent, MfrHbAfterRtoSctpAgent, MfrTimestampSctpAgent, MultipleFastRtxSctpAgent, NewRenoSctpAgent, TimestampSctpAgent, SctpAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, VegasTcpAgent, XcpAgent, and XcpSink.

Definition at line 63 of file object.cc.

References NsObject::debug_.

Referenced by MPLSAddressClassifier::delay_bind_dispatch(), and Agent::delay_bind_dispatch().

00064 {
00065     if (delay_bind_bool(varName, localName, "debug_", &debug_, tracer)) 
00066         return TCL_OK;
00067     return TclObject::delay_bind_dispatch(varName, localName, tracer);
00068 }

void NsObject::delay_bind_init_all  )  [virtual, inherited]
 

Reimplemented in BayFullTcpAgent, Agent, MPLSAddressClassifier, LDPAgent, HbAfterRtoSctpAgent, MfrHbAfterRtoSctpAgent, MfrTimestampSctpAgent, MultipleFastRtxSctpAgent, NewRenoSctpAgent, TimestampSctpAgent, SctpAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, VegasTcpAgent, XcpAgent, and XcpSink.

Definition at line 57 of file object.cc.

Referenced by MPLSAddressClassifier::delay_bind_init_all(), and Agent::delay_bind_init_all().

00058 {
00059     delay_bind_init_one("debug_");
00060 }

void TraceFile::get_next int &  ,
struct tracerec
 

Definition at line 142 of file traffictrace.cc.

References nrec_, trace_, tracerec::trec_size, and tracerec::trec_time.

Referenced by TrafficTrace::next_interval().

00143 {
00144     t.trec_time = trace_[ndx].trec_time;
00145     t.trec_size = trace_[ndx].trec_size;
00146 
00147     if (++ndx == nrec_)
00148         ndx = 0;
00149 
00150 }

void NsObject::handle Event  )  [protected, virtual, inherited]
 

Implements Handler.

Reimplemented in LinkDelay, LL, AckRecons, and Snoop.

Definition at line 91 of file object.cc.

References NsObject::recv().

00092 {
00093     recv((Packet*)e);
00094 }

Here is the call graph for this function:

int NsObject::isdebug  )  const [inline, inherited]
 

Definition at line 61 of file object.h.

References NsObject::debug_.

00061 { return debug_; }

void NsObject::recv Packet p,
const char *  s
[virtual, inherited]
 

Reimplemented in CMUTrace.

Definition at line 96 of file object.cc.

References Packet::free().

00097 {
00098     Packet::free(p);
00099 }

Here is the call graph for this function:

void TraceFile::recv Packet ,
Handler
[private, virtual]
 

Implements NsObject.

Definition at line 205 of file traffictrace.cc.

References abort().

00206 {
00207         /* shouldn't get here */
00208         abort();
00209 }

Here is the call graph for this function:

virtual void NsObject::recvOnly Packet  )  [inline, virtual, inherited]
 

Reimplemented in Agent, and Trace.

Definition at line 56 of file object.h.

Referenced by Trace::recvOnly().

00056 {};

void NsObject::reset  )  [protected, virtual, inherited]
 

Reimplemented in BayFullTcpAgent, HashClassifier, IvsSource, dsREDQueue, DiffusionRate, SinkAgent, DiffusionAgent, FloodingAgent, OmniMcastAgent, LinkDelay, CBQueue, DropTail, ErrorModel, PIQueue, Queue< T >, RedPDQueue, REDQueue, REMQueue, RIOQueue, Snoop, FackTcpAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, Sack1TcpAgent, TcpSink, DelAckSink, TcpAgent, VegasTcpAgent, toraAgent, Queue< T >, and XcpSink.

Definition at line 70 of file object.cc.

Referenced by NsObject::command().

00071 {
00072 }

int TraceFile::setup  ) 
 

Definition at line 152 of file traffictrace.cc.

References name_, nrec_, status_, trace_, tracerec::trec_size, and tracerec::trec_time.

Referenced by TrafficTrace::init().

00153 {
00154     tracerec* t;
00155     struct stat buf;
00156     int i;
00157     FILE *fp;
00158 
00159     /* only open/read the file once (could be shared by multiple
00160      * SourceModel's
00161      */
00162     if (! status_) {
00163         status_ = 1;
00164 
00165         if (stat(name_, (struct stat *)&buf)) {
00166             printf("could not stat %s\n", name_);
00167             return -1;
00168         }
00169 
00170         nrec_ = buf.st_size/sizeof(tracerec);
00171         unsigned nrecplus = nrec_ * sizeof(tracerec);
00172         unsigned bufst = buf.st_size;
00173 
00174         //  if ((unsigned)(nrec_ * sizeof(tracerec)) != buf.st_size) {
00175         if (nrecplus != bufst) {
00176             printf("bad file size in %s\n", name_);
00177             return -1;
00178         }
00179 
00180         trace_ = new struct tracerec[nrec_];
00181 
00182         if ((fp = fopen(name_, "rb")) == NULL) {
00183             printf("can't open file %s\n", name_);
00184             return -1;
00185         }
00186 
00187         for (i = 0, t = trace_; i < nrec_; i++, t++)
00188             if (fread((char *)t, sizeof(tracerec), 1, fp) != 1) {
00189                 printf("read failed\n");
00190                 return -1 ;
00191             }
00192             else {
00193         
00194                 t->trec_time = ntohl(t->trec_time);
00195                 t->trec_size = ntohl(t->trec_size);
00196             }
00197 
00198     }
00199 
00200     /* pick a random starting place in the trace file */
00201     return (int(Random::uniform((double)nrec_)+.5));
00202 
00203 }


Field Documentation

int NsObject::debug_ [protected, inherited]
 

Reimplemented in FECModel, FloodAgent, and LandmarkAgent.

Definition at line 66 of file object.h.

Referenced by REDQueue::command(), RedPDQueue::command(), PushbackQueue::command(), NsObject::debug(), NsObject::delay_bind_dispatch(), PushbackQueue::enque(), NsObject::isdebug(), NsObject::NsObject(), TfrcAgent::recv(), PushbackQueue::reportDrop(), SctpAgent::Reset(), REDQueue::reset(), DropTail::shrink_queue(), and Delayer::try_send().

char* TraceFile::name_ [private]
 

Definition at line 94 of file traffictrace.cc.

Referenced by command(), and setup().

int TraceFile::nrec_ [private]
 

Definition at line 95 of file traffictrace.cc.

Referenced by get_next(), and setup().

int TraceFile::status_ [private]
 

Definition at line 93 of file traffictrace.cc.

Referenced by setup().

struct tracerec* TraceFile::trace_ [private]
 

Definition at line 96 of file traffictrace.cc.

Referenced by get_next(), and setup().


The documentation for this class was generated from the following file:
Generated on Tue Mar 6 17:34:51 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6