• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/tutorial_nsbyexample/mm-app.h

00001 //
00002 // Author:    Jae Chung
00003 // File:      mm-app.h
00004 // Written:   07/17/99 (for ns-2.1b4a)
00005 // Modifed:   10/14/01 (for ns-2.1b8a)
00006 // 
00007 
00008 #include "timer-handler.h"
00009 #include "packet.h"
00010 #include "app.h"
00011 #include "udp-mm.h"
00012 
00013 // This is used for receiver's received packet accounting
00014 struct pkt_accounting { 
00015         int last_seq;   // sequence number of last received MM pkt
00016         int last_scale; // rate (0-4) of last acked
00017         int lost_pkts;  // number of lost pkts since last ack
00018         int recv_pkts;  // number of received pkts since last ack
00019         double rtt;     // round trip time
00020 };
00021 
00022 
00023 class MmApp;
00024 
00025 
00026 // Sender uses this timer to 
00027 // schedule next app data packet transmission time
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 // Reciver uses this timer to schedule
00038 // next ack packet transmission time
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 // Mulitmedia Application Class Definition
00049 class MmApp : public Application {
00050  public:
00051         MmApp();
00052         void send_mm_pkt();  // called by SendTimer:expire (Sender)
00053         void send_ack_pkt(); // called by AckTimer:expire (Receiver)
00054  protected:
00055         int command(int argc, const char*const* argv);
00056         void start();       // Start sending data packets (Sender)
00057         void stop();        // Stop sending data packets (Sender)
00058  private:
00059         void init();
00060         inline double next_snd_time();                          // (Sender)
00061         virtual void recv_msg(int nbytes, const char *msg = 0); // (Sender/Receiver)
00062         void set_scale(const hdr_mm *mh_buf);                   // (Sender)
00063         void adjust_scale(void);                                // (Receiver)
00064         void account_recv_pkt(const hdr_mm *mh_buf);            // (Receiver)
00065         void init_recv_pkt_accounting();                        // (Receiver)
00066 
00067         double rate[5];        // Transmission rates associated to scale values
00068         double interval_;      // Application data packet transmission interval
00069         int pktsize_;          // Application data packet size
00070         int random_;           // If 1 add randomness to the interval
00071         int running_;          // If 1 application is running
00072         int seq_;              // Application data packet sequence number
00073         int scale_;            // Media scale parameter
00074         pkt_accounting p_accnt;
00075         SendTimer snd_timer_;  // SendTimer
00076         AckTimer  ack_timer_;  // AckTimer
00077 };
00078 
00079 
00080 

Generated on Tue Aug 10 2010 16:16:08 for ns-2.33 by  doxygen 1.7.1