/* -*- c++ -*- rcp-tap.h Received-Based TCP (Sender Side) Two agents: RcpAgent (receiver side) and RcpTap (sender side) */ #ifndef __rcptap_h__ #define __rcptap_h__ #include "tcp.h" //sale >>> #include "timer-handler.h" //# include "ping.h" //sale <<< //sale >>> #include "ping.h" //#include "agent.h" //#include "tclcl.h" //#include "packet.h" //#include "address.h" //#include "ip.h" //sale <<< /* * The following definitions can be put in tcp.h */ #define REPN (NSA*2) // 3 blocks #define TCP_REASON_REQOVER 0x04 // output() //sale >>> //from tfrc.h /* packet status */ #define UNKNOWN 0 #define RCVD 1 #define LOST 2 #define NOLOSS 3 #define ECNLOST 4 #define ECNNOLOSS 5 #define DEFAULT_NUMSAMPLES 8 #define WALI 1 #define EWMA 2 #define RBPH 3 #define EBPH 4 //sale <<< #ifdef NDEBUG #undef NDEBUG #endif //sale >>> class RcpTap; //class MyPingAgent : public PingAgent { //public: // MyPingAgent(RcpTap *a) : PingAgent() { a_ = a; } // virtual int command(int argc, const char*const* argv); // virtual void recv(Packet*, Handler*); //protected: // RcpTap *a_; //}; class RcpTapTimer : public TimerHandler { public: RcpTapTimer(RcpTap *a) : TimerHandler() { a_ = a; } virtual void expire(Event *e); protected: RcpTap *a_; }; //sale <<< class RcpTap : public Agent { //sale >>> friend RcpTapTimer; // friend MyPingAgent; //sale <<< public: RcpTap(); virtual int command(int argc, const char*const* argv); virtual void recv(Packet *pkt, Handler *); virtual void sendmsg(int nbytes, const char *flags = 0); virtual void advanceby(int delta); // MyPingAgent ping_; protected: virtual void reset(); virtual void delay_bind_init_all(); virtual int delay_bind_dispatch(const char *, const char *, TclObject *); int headersize(); void output(int seqno, int reason=0); TracedInt curseq_; /* highest seqno produced by app */ TracedInt maxseq_; /* highest seqno sent so far */ TracedInt o_seqno_; /* output seqno of the packet */ TracedInt r_seqno_; /* received seqno of the packet */ TracedInt nreqpack_; /* number of req packets received */ TracedInt ndatapack_; /* number of data packets sent */ TracedInt ndatabytes_; /* number of data bytes sent */ TracedInt nrexmitpack_; /* number of retransmited packets */ TracedInt nrexmitbytes_; /* number of retransmited bytes */ TracedDouble TCP_rate_; /* actually RCP rate */ TracedDouble est_loss_; /* loss estimated by TFRC algorithm */ TracedDouble TFRC_rate_; /* rate computed by TFRC algorithm */ TracedDouble ploss_; /* total Ploss */ TracedDouble EQ_rate_; /* rate computed by Equation, based on average rtt and average ploss */ TracedDouble ratio_TCP_TFRC_; /* ratio among TCP and TFRC */ TracedDouble ratio_TCP_EQ_; /* ratio among TCP and EQ */ //sale >>> int Maxseq_sale_; /*for WALI computation only*/ //sale <<< int syn_; /* 1 for modeling SYN/ACK exchange */ int useHeaders_; /* boolean: add TCP/IP header size */ int tcpip_base_hdr_size_; /* size of base TCP/IP header */ int ts_option_size_; /* header bytes in a ts option */ int ts_option_; /* use RFC1323-like timestamps? */ int closed_; /* whether the connection has closed */ double ts_peer_; /* the most recent timestamp the peer sent */ int rpq_[REPN],repnxt_; /* for repetitive request (redundancy) */ #define rep_(i) rpq_[(i) % REPN] Agent *peer_; /* XXX: ask peer to start pulling */ //sale >>> void compute_thr(int ind); double sum_bytes; /*number of bytes sent so far*/ double time_last; /*time when the last throughput computation was done*/ double rate_last; /*rate computed when the last throughput computation was done*/ //sale <<< //sale >>> int loss_int_used; //loss interval used -> 1 //from tfrc-sink.h //void sendpkt(double); // void nextpkt(double); double adjust_history(double); double est_loss(); double est_thput(); // int command(int argc, const char*const* argv); void print_loss(int sample, double ave_interval); void print_loss_all(int *sample); // algo specific double est_loss_WALI(); void shift_array(int *a, int sz, int defval) ; void shift_array(double *a, int sz, double defval) ; void multiply_array(double *a, int sz, double multiplier); void init_WALI(); double weighted_average(int start, int end, double factor, double *m, double *w, int *sample); double est_loss_EWMA () ; double est_loss_RBPH () ; double est_loss_EBPH() ; //comman variables RcpTapTimer timer_; // int psize_; // size of received packet double rtt_; // rtt value reported by sender double rtt_sum_; //sum of rtts by now double rtt_num_; //number of rtt_samples double tzero_; // timeout value reported by sender int smooth_; // for the smoother method for incorporating // incorporating new loss intervals // int UrgentFlag ; // send loss report immediately int total_received_; // total # of pkts rcvd by rcvr int bval_; // value of B used in the formula double last_report_sent; // when was last feedback sent double NumFeedback_; // how many feedbacks per rtt int rcvd_since_last_report; // # of packets rcvd since last report // int losses_since_last_report; // # of losses since last report int printLoss_; // to print estimated loss rates // int maxseq; // max seq number seen - we use maxseq_ from RCP // these assist in keep track of incming packets and calculate flost_ // double last_timestamp_, last_arrival_; int hsz; char *lossvec_; double *rtvec_; double *tsvec_; // int lastloss_round_id ; int round_id ; double lastloss; // when last loss occured // WALI specific int numsamples ; int *sample; double *weights ; double *mult ; double mult_factor_; // most recent multiple of mult array int sample_count ; int last_sample ; int init_WALI_flag; // these are for "faking" history after slow start int loss_seen_yet; // have we seen the first loss yet? int adjust_history_after_ss; // fake history after slow start? (0/1) int false_sample; // by how much? int algo; // algo for loss estimation int discount ; // emphasize most recent loss interval // when it is very large // EWMA double history ; double avg_loss_int ; int loss_int ; // RBPH, EBPH double sendrate ; int minlc ; //sale <<< }; #endif/*__rcptap_h__*/