00001
00002
00003
00004
00005
00006
00007
00008 #include "timer-handler.h"
00009 #include "packet.h"
00010 #include "app.h"
00011 #include "udp-mm.h"
00012
00013
00014 struct pkt_accounting {
00015 int last_seq;
00016 int last_scale;
00017 int lost_pkts;
00018 int recv_pkts;
00019 double rtt;
00020 };
00021
00022
00023 class MmApp;
00024
00025
00026
00027
00028 class SendTimer : public TimerHandler {
00029 public:
00030 SendTimer(MmApp* t) : TimerHandler(), t_(t) {}
00031 inline virtual void expire(Event*);
00032 protected:
00033 MmApp* t_;
00034 };
00035
00036
00037
00038
00039 class AckTimer : public TimerHandler {
00040 public:
00041 AckTimer(MmApp* t) : TimerHandler(), t_(t) {}
00042 inline virtual void expire(Event*);
00043 protected:
00044 MmApp* t_;
00045 };
00046
00047
00048
00049 class MmApp : public Application {
00050 public:
00051 MmApp();
00052 void send_mm_pkt();
00053 void send_ack_pkt();
00054 protected:
00055 int command(int argc, const char*const* argv);
00056 void start();
00057 void stop();
00058 private:
00059 void init();
00060 inline double next_snd_time();
00061 virtual void recv_msg(int nbytes, const char *msg = 0);
00062 void set_scale(const hdr_mm *mh_buf);
00063 void adjust_scale(void);
00064 void account_recv_pkt(const hdr_mm *mh_buf);
00065 void init_recv_pkt_accounting();
00066
00067 double rate[5];
00068 double interval_;
00069 int pktsize_;
00070 int random_;
00071 int running_;
00072 int seq_;
00073 int scale_;
00074 pkt_accounting p_accnt;
00075 SendTimer snd_timer_;
00076 AckTimer ack_timer_;
00077 };
00078
00079
00080