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

TraceFile Class Reference

Inheritance diagram for TraceFile:

Inheritance graph
[legend]
Collaboration diagram for TraceFile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

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

Protected Member Functions

virtual void reset ()
void handle (Event *)

Protected Attributes

int debug_

Private Member Functions

void recv (Packet *, Handler *)

Private Attributes

int status_
char * name_
int nrec_
tracerectrace_

Constructor & Destructor Documentation

TraceFile::TraceFile  ) 
 

Definition at line 102 of file traffictrace.cc.

00102                      : status_(0)
00103 {
00104 }


Member Function Documentation

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

Reimplemented from NsObject.

Definition at line 106 of file traffictrace.cc.

References NsObject::command(), and name_.

00107 {
00108 
00109         if (argc == 3) {
00110                 if (strcmp(argv[1], "filename") == 0) {
00111                         name_ = new char[strlen(argv[2])+1];
00112                         strcpy(name_, argv[2]);
00113                         return(TCL_OK);
00114                 }
00115         }
00116         return (NsObject::command(argc, argv));
00117 }

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, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, and VegasTcpAgent.

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, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, and VegasTcpAgent.

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 119 of file traffictrace.cc.

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

Referenced by TrafficTrace::next_interval().

00120 {
00121         t.trec_time = trace_[ndx].trec_time;
00122         t.trec_size = trace_[ndx].trec_size;
00123 
00124         if (++ndx == nrec_)
00125                 ndx = 0;
00126 
00127 }

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 182 of file traffictrace.cc.

References abort().

00183 {
00184         /* shouldn't get here */
00185         abort();
00186 }

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, and Queue< T >.

Definition at line 70 of file object.cc.

Referenced by NsObject::command().

00071 {
00072 }

int TraceFile::setup  ) 
 

Definition at line 129 of file traffictrace.cc.

References name_, nrec_, status_, trace_, and Random::uniform().

Referenced by TrafficTrace::init().

00130 {
00131         tracerec* t;
00132         struct stat buf;
00133         int i;
00134         FILE *fp;
00135 
00136         /* only open/read the file once (could be shared by multiple
00137          * SourceModel's
00138          */
00139         if (! status_) {
00140                 status_ = 1;
00141 
00142                 if (stat(name_, (struct stat *)&buf)) {
00143                         printf("could not stat %s\n", name_);
00144                         return -1;
00145                 }
00146 
00147                 nrec_ = buf.st_size/sizeof(tracerec);
00148                 unsigned nrecplus = nrec_ * sizeof(tracerec);
00149                 unsigned bufst = buf.st_size;
00150 
00151                 //      if ((unsigned)(nrec_ * sizeof(tracerec)) != buf.st_size) {
00152                 if (nrecplus != bufst) {
00153                         printf("bad file size in %s\n", name_);
00154                         return -1;
00155                 }
00156 
00157                 trace_ = new struct tracerec[nrec_];
00158 
00159                 if ((fp = fopen(name_, "rb")) == NULL) {
00160                         printf("can't open file %s\n", name_);
00161                         return -1;
00162                 }
00163 
00164                 for (i = 0, t = trace_; i < nrec_; i++, t++)
00165                         if (fread((char *)t, sizeof(tracerec), 1, fp) != 1) {
00166                                 printf("read failed\n");
00167                                 return -1 ;
00168                         }
00169                         else {
00170                 
00171                                 t->trec_time = ntohl(t->trec_time);
00172                                 t->trec_size = ntohl(t->trec_size);
00173                         }
00174 
00175         }
00176 
00177         /* pick a random starting place in the trace file */
00178         return (int(Random::uniform((double)nrec_)+.5));
00179 
00180 }

Here is the call graph for this function:


Member Data 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(), RedPDQueue::enque(), PushbackQueue::enque(), NsObject::isdebug(), NsObject::NsObject(), TfrcAgent::recv(), PushbackQueue::reportDrop(), and REDQueue::reset().

char* TraceFile::name_ [private]
 

Definition at line 71 of file traffictrace.cc.

Referenced by command(), and setup().

int TraceFile::nrec_ [private]
 

Definition at line 72 of file traffictrace.cc.

Referenced by get_next(), and setup().

int TraceFile::status_ [private]
 

Definition at line 70 of file traffictrace.cc.

Referenced by setup().

struct tracerec* TraceFile::trace_ [private]
 

Definition at line 73 of file traffictrace.cc.

Referenced by get_next(), and setup().


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