00001 #ifndef ns_rate_estimator_h 00002 #define ns_rate_estimator_h 00003 00004 #include "packet.h" 00005 00006 //copied over from csfq.cc (Stoica) 00007 class RateEstimator { 00008 public: 00009 double k_; /* averaging interval for rate estimation in seconds*/ 00010 double estRate_; /* current flow's estimated rate in bps */ 00011 double bytesArr_; 00012 00013 RateEstimator(); 00014 RateEstimator(double estimate); 00015 void estimateRate(Packet *p); 00016 void reset(); 00017 00018 protected: 00019 int temp_size_; /* keep track of packets that arrive at the same time */ 00020 double prevTime_; /* time of last packet arrival */ 00021 double reset_time_; 00022 }; 00023 00024 00025 #endif