| OLD | NEW |
| (Empty) |
| 1 #include <udt.h> | |
| 2 #include <ccc.h> | |
| 3 | |
| 4 class CTCP: public CCC | |
| 5 { | |
| 6 public: | |
| 7 void init() | |
| 8 { | |
| 9 m_bSlowStart = true; | |
| 10 m_issthresh = 83333; | |
| 11 | |
| 12 m_dPktSndPeriod = 0.0; | |
| 13 m_dCWndSize = 2.0; | |
| 14 | |
| 15 setACKInterval(2); | |
| 16 setRTO(1000000); | |
| 17 } | |
| 18 | |
| 19 virtual void onACK(const int& ack) | |
| 20 { | |
| 21 if (ack == m_iLastACK) | |
| 22 { | |
| 23 if (3 == ++ m_iDupACKCount) | |
| 24 DupACKAction(); | |
| 25 else if (m_iDupACKCount > 3) | |
| 26 m_dCWndSize += 1.0; | |
| 27 else | |
| 28 ACKAction(); | |
| 29 } | |
| 30 else | |
| 31 { | |
| 32 if (m_iDupACKCount >= 3) | |
| 33 m_dCWndSize = m_issthresh; | |
| 34 | |
| 35 m_iLastACK = ack; | |
| 36 m_iDupACKCount = 1; | |
| 37 | |
| 38 ACKAction(); | |
| 39 } | |
| 40 } | |
| 41 | |
| 42 virtual void onTimeout() | |
| 43 { | |
| 44 m_issthresh = getPerfInfo()->pktFlightSize / 2; | |
| 45 if (m_issthresh < 2) | |
| 46 m_issthresh = 2; | |
| 47 | |
| 48 m_bSlowStart = true; | |
| 49 m_dCWndSize = 2.0; | |
| 50 } | |
| 51 | |
| 52 protected: | |
| 53 virtual void ACKAction() | |
| 54 { | |
| 55 if (m_bSlowStart) | |
| 56 { | |
| 57 m_dCWndSize += 1.0; | |
| 58 | |
| 59 if (m_dCWndSize >= m_issthresh) | |
| 60 m_bSlowStart = false; | |
| 61 } | |
| 62 else | |
| 63 m_dCWndSize += 1.0/m_dCWndSize; | |
| 64 } | |
| 65 | |
| 66 virtual void DupACKAction() | |
| 67 { | |
| 68 m_bSlowStart = false; | |
| 69 | |
| 70 m_issthresh = getPerfInfo()->pktFlightSize / 2; | |
| 71 if (m_issthresh < 2) | |
| 72 m_issthresh = 2; | |
| 73 | |
| 74 m_dCWndSize = m_issthresh + 3; | |
| 75 } | |
| 76 | |
| 77 protected: | |
| 78 int m_issthresh; | |
| 79 bool m_bSlowStart; | |
| 80 | |
| 81 int m_iDupACKCount; | |
| 82 int m_iLastACK; | |
| 83 }; | |
| 84 | |
| 85 | |
| 86 class CUDPBlast: public CCC | |
| 87 { | |
| 88 public: | |
| 89 CUDPBlast() | |
| 90 { | |
| 91 m_dPktSndPeriod = 1000000; | |
| 92 m_dCWndSize = 83333.0; | |
| 93 } | |
| 94 | |
| 95 public: | |
| 96 void setRate(double mbps) | |
| 97 { | |
| 98 m_dPktSndPeriod = (m_iMSS * 8.0) / mbps; | |
| 99 } | |
| 100 }; | |
| OLD | NEW |