Estimator Class Reference

#include <estimator.h>

Inheritance diagram for Estimator:

NsObject TclObject Handler ExpAvg_Est Null_Est PointSample_Est TimeWindow_Est Collaboration diagram for Estimator:

Collaboration graph
[legend]

Detailed Description

Definition at line 64 of file estimator.h.

Public Member Functions

double avload ()
virtual void change_avload (double incr)
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 ()
 Estimator ()
int isdebug () const
virtual void newflow (double)
double & period ()
virtual void recv (Packet *p, const char *s)
void recv (Packet *, Handler *)
virtual void recvOnly (Packet *)
void setactype (const char *)
void setmeasmod (MeasureMod *)
virtual void start ()
void stop ()
virtual void timeout (int)
void trace (TracedVar *v)

Protected Member Functions

virtual void estimate ()=0
void handle (Event *)
virtual void reset ()

Protected Attributes

char * actype_
TracedDouble avload_
int debug_
int dst_
Estimator_Timer est_timer_
MeasureModmeas_mod_
TracedDouble measload_
double oavload_
double omeasload_
double period_
int src_
Tcl_Channel tchan_


Constructor & Destructor Documentation

Estimator::Estimator  ) 
 

Definition at line 48 of file estimator.cc.

References avload_, dst_, measload_, period_, and src_.

00048                      : meas_mod_(0),avload_(0.0),est_timer_(this), measload_(0.0), tchan_(0), omeasload_(0), oavload_(0)
00049 {
00050     bind("period_",&period_);
00051     bind("src_", &src_);
00052     bind("dst_", &dst_);
00053 
00054     avload_.tracer(this);
00055     avload_.name("\"Estimated Util.\"");
00056     measload_.tracer(this);
00057     measload_.name("\"Measured Util.\"");
00058 }


Member Function Documentation

double Estimator::avload  )  [inline]
 

Definition at line 67 of file estimator.h.

References avload_.

00067 { return double(avload_);};

virtual void Estimator::change_avload double  incr  )  [inline, virtual]
 

Reimplemented in TimeWindow_Est.

Definition at line 69 of file estimator.h.

References avload_.

Referenced by MS_ADC::admit_flow(), HB_ADC::admit_flow(), ACTP_ADC::admit_flow(), ACTO_ADC::admit_flow(), and MS_ADC::rej_action().

00069 { avload_ += incr;}

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

Reimplemented from NsObject.

Definition at line 60 of file estimator.cc.

References avload_, MeasureMod::bitcnt(), NsObject::command(), meas_mod_, period_, and tchan_.

00061 {
00062     Tcl& tcl = Tcl::instance();
00063     if (argc==2) {
00064         if (strcmp(argv[1],"load-est") == 0) {
00065             tcl.resultf("%.3f",double(avload_));
00066             return(TCL_OK);
00067         } else if (strcmp(argv[1],"link-utlzn") == 0) {
00068             tcl.resultf("%.3f",meas_mod_->bitcnt()/period_);
00069             return(TCL_OK);
00070         }
00071     }
00072     if (argc == 3) {
00073         if (strcmp(argv[1], "attach") == 0) {
00074             int mode;
00075             const char* id = argv[2];
00076             tchan_ = Tcl_GetChannel(tcl.interp(), (char*)id, &mode);
00077             if (tchan_ == 0) {
00078                 tcl.resultf("Estimator: trace: can't attach %s for writing", id);
00079                 return (TCL_ERROR);
00080             }
00081             return (TCL_OK);
00082         }
00083         if (strcmp(argv[1], "setbuf") == 0) {
00084             /* some sub classes actually do something here */
00085             return(TCL_OK);
00086         }
00087     }
00088     return NsObject::command(argc,argv);
00089 }

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 }

virtual void Estimator::estimate  )  [protected, pure virtual]
 

Implemented in ExpAvg_Est, Null_Est, PointSample_Est, and TimeWindow_Est.

Referenced by timeout().

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_; }

virtual void Estimator::newflow double   )  [inline, virtual]
 

Definition at line 70 of file estimator.h.

00070 {};

double& Estimator::period  )  [inline]
 

Definition at line 78 of file estimator.h.

References period_.

Referenced by ADC::peak_rate().

00078 { return period_;}

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 Estimator::recv Packet ,
Handler
[inline, virtual]
 

Implements NsObject.

Definition at line 73 of file estimator.h.

00073 {}

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 }

void Estimator::setactype const char *   ) 
 

Definition at line 159 of file estimator.cc.

References actype_.

Referenced by ADC::setest().

00160 {
00161     actype_ = new char[strlen(type)+1];
00162     strcpy(actype_, type);
00163     return;
00164 }

void Estimator::setmeasmod MeasureMod  ) 
 

Definition at line 91 of file estimator.cc.

References meas_mod_.

Referenced by ADC::command().

00092 {
00093     meas_mod_=measmod;
00094 }

void Estimator::start  )  [virtual]
 

Definition at line 96 of file estimator.cc.

References avload_, est_timer_, measload_, period_, and TimerHandler::resched().

Referenced by ADC::command().

00097 {
00098     avload_=0;
00099     measload_ = 0;
00100     est_timer_.resched(period_);
00101 }

Here is the call graph for this function:

void Estimator::stop  ) 
 

Definition at line 103 of file estimator.cc.

References TimerHandler::cancel(), and est_timer_.

00104 {
00105     est_timer_.cancel();
00106 }

Here is the call graph for this function:

void Estimator::timeout int   )  [virtual]
 

Definition at line 108 of file estimator.cc.

References est_timer_, estimate(), period_, and TimerHandler::resched().

Referenced by Estimator_Timer::expire().

00109 {
00110     estimate();
00111     est_timer_.resched(period_);
00112 }

Here is the call graph for this function:

void Estimator::trace TracedVar *  v  ) 
 

Definition at line 119 of file estimator.cc.

References actype_, Scheduler::clock(), dst_, Scheduler::instance(), oavload_, omeasload_, src_, and tchan_.

00120 {
00121     char wrk[500];
00122     double *p, newval;
00123 
00124     /* check for right variable */
00125     if (strcmp(v->name(), "\"Estimated Util.\"") == 0) {
00126         p = &oavload_;
00127     }
00128     else if (strcmp(v->name(), "\"Measured Util.\"") == 0) {
00129         p = &omeasload_;
00130     }
00131     else {
00132         fprintf(stderr, "Estimator: unknown trace var %s\n", v->name());
00133         return;
00134     }
00135 
00136     newval = double(*((TracedDouble*)v));
00137 
00138     if (tchan_) {
00139         int n;
00140         double t = Scheduler::instance().clock();
00141         /* f -t 0.0 -s 1 -a SA -T v -n Num -v 0 -o 0 */
00142         sprintf(wrk, "f -t %g -s %d -a %s:%d-%d -T v -n %s -v %g -o %g",
00143             t, src_, actype_, src_, dst_, v->name(), newval, *p);
00144         n = strlen(wrk);
00145         wrk[n] = '\n';
00146         wrk[n+1] = 0;
00147         (void)Tcl_Write(tchan_, wrk, n+1);
00148         
00149     }
00150 
00151     *p = newval;
00152 
00153     return;
00154 
00155 
00156 
00157 }

Here is the call graph for this function:


Field Documentation

char* Estimator::actype_ [protected]
 

Definition at line 92 of file estimator.h.

Referenced by setactype(), and trace().

TracedDouble Estimator::avload_ [protected]
 

Definition at line 82 of file estimator.h.

Referenced by avload(), TimeWindow_Est::change_avload(), change_avload(), command(), TimeWindow_Est::estimate(), PointSample_Est::estimate(), ExpAvg_Est::estimate(), Estimator(), and start().

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().

int Estimator::dst_ [protected]
 

Definition at line 89 of file estimator.h.

Referenced by Estimator(), and trace().

Estimator_Timer Estimator::est_timer_ [protected]
 

Definition at line 85 of file estimator.h.

Referenced by start(), stop(), and timeout().

MeasureMod* Estimator::meas_mod_ [protected]
 

Definition at line 81 of file estimator.h.

Referenced by command(), TimeWindow_Est::estimate(), PointSample_Est::estimate(), Null_Est::estimate(), ExpAvg_Est::estimate(), and setmeasmod().

TracedDouble Estimator::measload_ [protected]
 

Definition at line 86 of file estimator.h.

Referenced by TimeWindow_Est::estimate(), Null_Est::estimate(), Estimator(), and start().

double Estimator::oavload_ [protected]
 

Definition at line 91 of file estimator.h.

Referenced by trace().

double Estimator::omeasload_ [protected]
 

Definition at line 90 of file estimator.h.

Referenced by trace().

double Estimator::period_ [protected]
 

Definition at line 83 of file estimator.h.

Referenced by command(), TimeWindow_Est::estimate(), PointSample_Est::estimate(), Null_Est::estimate(), ExpAvg_Est::estimate(), Estimator(), period(), start(), and timeout().

int Estimator::src_ [protected]
 

Definition at line 88 of file estimator.h.

Referenced by Estimator(), and trace().

Tcl_Channel Estimator::tchan_ [protected]
 

Definition at line 87 of file estimator.h.

Referenced by command(), and trace().


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