cc.h

00001 #include <udt.h>
00002 #include <ccc.h>
00003 
00004 class CTCP: public CCC
00005 {
00006 public:
00007    void init()
00008    {
00009       m_bSlowStart = true;
00010       m_issthresh = 83333;
00011 
00012       m_dPktSndPeriod = 0.0;
00013       m_dCWndSize = 2.0;
00014 
00015       setACKInterval(2);
00016       setRTO(1000000);
00017    }
00018 
00019    virtual void onACK(const int& ack)
00020    {
00021       if (ack == m_iLastACK)
00022       {
00023          if (3 == ++ m_iDupACKCount)
00024             DupACKAction();
00025          else if (m_iDupACKCount > 3)
00026             m_dCWndSize += 1.0;
00027          else
00028             ACKAction();
00029       }
00030       else
00031       {
00032          if (m_iDupACKCount >= 3)
00033             m_dCWndSize = m_issthresh;
00034 
00035          m_iLastACK = ack;
00036          m_iDupACKCount = 1;
00037 
00038          ACKAction();
00039       }
00040    }
00041 
00042    virtual void onTimeout()
00043    {
00044       m_issthresh = getPerfInfo()->pktFlightSize / 2;
00045       if (m_issthresh < 2)
00046          m_issthresh = 2;
00047 
00048       m_bSlowStart = true;
00049       m_dCWndSize = 2.0;
00050    }
00051 
00052 protected:
00053    virtual void ACKAction()
00054    {
00055       if (m_bSlowStart)
00056       {
00057          m_dCWndSize += 1.0;
00058 
00059          if (m_dCWndSize >= m_issthresh)
00060             m_bSlowStart = false;
00061       }
00062       else
00063          m_dCWndSize += 1.0/m_dCWndSize;
00064    }
00065 
00066    virtual void DupACKAction()
00067    {
00068       m_bSlowStart = false;
00069 
00070       m_issthresh = getPerfInfo()->pktFlightSize / 2;
00071       if (m_issthresh < 2)
00072          m_issthresh = 2;
00073 
00074       m_dCWndSize = m_issthresh + 3;
00075    }
00076 
00077 protected:
00078    int m_issthresh;
00079    bool m_bSlowStart;
00080 
00081    int m_iDupACKCount;
00082    int m_iLastACK;
00083 };
00084 
00085 
00086 class CUDPBlast: public CCC
00087 {
00088 public:
00089    CUDPBlast()
00090    {
00091       m_dPktSndPeriod = 1000000; 
00092       m_dCWndSize = 83333.0; 
00093    }
00094 
00095 public:
00096    void setRate(double mbps)
00097    {
00098       m_dPktSndPeriod = (m_iMSS * 8.0) / mbps;
00099    }
00100 };

Generated on 9 Feb 2013 for barchart-udt-core-2.2.2 by  doxygen 1.6.1