OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2014 Natale Patriciello <natale.patriciello@gmail.com> |
| 4 * |
| 5 * This program is free software; you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 2 as |
| 7 * published by the Free Software Foundation; |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software |
| 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 * |
| 18 */ |
| 19 |
| 20 #ifndef TCPBIC_H |
| 21 #define TCPBIC_H |
| 22 |
| 23 #include "ns3/tcp-socket-base.h" |
| 24 #include "ns3/timer.h" |
| 25 |
| 26 namespace ns3 { |
| 27 |
| 28 /** \brief BIC congestion control algorithm |
| 29 * |
| 30 * In TCP Bic the congestion control problem is viewed as a search |
| 31 * problem. Taking as a starting point the current window value |
| 32 * and as a target point the last maximum window value |
| 33 * (i.e. the cWnd value just before the loss event) a binary search |
| 34 * technique can be used to update the cWnd value at the midpoint between |
| 35 * the two, directly or using an additive increase strategy if the distance from |
| 36 * the current window is too large. |
| 37 * |
| 38 * This way, assuming a no-loss period, the congestion window logarithmically |
| 39 * approaches the maximum value of cWnd until the difference between it and cWnd |
| 40 * falls below a preset threshold. After reaching such a value (or the maximum |
| 41 * window is unknown, i.e. the binary search does not start at all) the algorith
m |
| 42 * switches to probing the new maximum window with a 'slow start' strategy. |
| 43 * |
| 44 * If a loss occur in either these phases, the current window (before the loss) |
| 45 * can be treated as the new maximum, and the reduced (with a multiplicative |
| 46 * decrease factor Beta) window size can be used as the new minimum. |
| 47 * |
| 48 * To maintain the performance of TCP Bic as close as possible with the Linux |
| 49 * implementation, and at the same time maintain the friendliness with other TCP |
| 50 * flavors, the cWnd is increased only after a certain number of ACKs |
| 51 * are received, following RFC 6356. After the slow start phase, and after each |
| 52 * new ACK, a value is calculated by the method Update. This number |
| 53 * (m_cnt in the code) represents the ACK packets that should be received |
| 54 * before increasing the cWnd by one segment. After a trivial check on the |
| 55 * arrived ACKs (represented by m_cWndCnt in the code), the |
| 56 * cWnd can be increased and m_cWndCnt can be set to zero, or |
| 57 * otherwise m_cWndCnt can be increased by one and the |
| 58 * cWnd can be left untouched. |
| 59 * |
| 60 * The binary search on the cWnd size space is done by varying the returned |
| 61 * cnt, depending on the internal state of the class (e.g. the last maximum |
| 62 * and the current cWnd size). |
| 63 * |
| 64 * The reference paper for BIC can be found in: |
| 65 * http://an.kaist.ac.kr/courses/2006/cs540/reading/bic-tcp.pdf |
| 66 * |
| 67 * This model has a number of configurable parameters that are exposed as |
| 68 * attributes of the TcpBic TypeId. This model also exports trace sources, |
| 69 * for tracking the congestion window, slow start threshold, and the internat |
| 70 * state of the protocol. |
| 71 * |
| 72 * More information on this implementation: http://dl.acm.org/citation.cfm?id=27
56518 |
| 73 */ |
| 74 class TcpBic : public TcpSocketBase |
| 75 { |
| 76 public: |
| 77 /** |
| 78 * \brief Get the type ID. |
| 79 * \return the object TypeId |
| 80 */ |
| 81 static TypeId GetTypeId (void); |
| 82 |
| 83 /** |
| 84 * \brief State of the congestion control machine: open or loss |
| 85 */ |
| 86 enum BicState |
| 87 { |
| 88 OPEN = 0x1, //!< Open state |
| 89 LOSS = 0x2 //!< Loss state |
| 90 }; |
| 91 |
| 92 /** |
| 93 * \brief Constructor |
| 94 */ |
| 95 TcpBic (); |
| 96 |
| 97 // From TcpSocketBase |
| 98 virtual int Connect (const Address &address); |
| 99 virtual int Listen (void); |
| 100 |
| 101 protected: |
| 102 virtual uint32_t Window (void); // Return the max possible number of unacked
bytes |
| 103 virtual Ptr<TcpSocketBase> Fork (void); // Call CopyObject<TcpNewReno> to cl
one me |
| 104 virtual void NewAck (SequenceNumber32 const& seq); |
| 105 virtual void DupAck (const TcpHeader& t, uint32_t count); // Halving cwnd a
nd reset nextTxSequence |
| 106 virtual void Retransmit (void); // Exit fast recovery upon retransmit timeou
t |
| 107 |
| 108 // Implementing ns3::TcpSocket -- Attribute get/set |
| 109 virtual void SetInitialSSThresh (uint32_t threshold); |
| 110 virtual uint32_t GetInitialSSThresh (void) const; |
| 111 virtual void SetInitialCwnd (uint32_t cwnd); |
| 112 virtual uint32_t GetInitialCwnd (void) const; |
| 113 virtual void ScaleSsThresh (uint8_t scaleFactor); |
| 114 |
| 115 private: |
| 116 uint32_t m_initialCwnd; //!< Initial cWnd |
| 117 |
| 118 // User parameters |
| 119 bool m_fastConvergence; //!< Enable or disable fast convergence algorithm |
| 120 double m_beta; //!< Beta for cubic multiplicative increase |
| 121 uint32_t m_maxIncr; //!< Maximum window increment |
| 122 uint32_t m_lowWnd; //!< Lower bound on congestion window |
| 123 int m_smoothPart; //!< Number of RTT needed to reach Wmax from Wmax
-B |
| 124 |
| 125 // Bic parameters |
| 126 uint32_t m_cWndCnt; //!< cWnd integer-to-float counter |
| 127 uint32_t m_lastMaxCwnd; //!< Last maximum cWnd |
| 128 uint32_t m_lastCwnd; //!< Last cWnd |
| 129 Time m_epochStart; //!< Beginning of an epoch |
| 130 |
| 131 TracedValue<uint32_t> m_cWnd; //!< Congestion window |
| 132 TracedValue<uint32_t> m_ssThresh; //!< Slow start threshold |
| 133 TracedValue<uint8_t> m_bicState; //!< Bic state |
| 134 |
| 135 uint8_t m_b; //!< Binary search coefficient |
| 136 uint32_t m_retxThresh; //!< Fast Retransmit threshold |
| 137 |
| 138 private: |
| 139 /** |
| 140 * \brief Reset BIC parameters |
| 141 */ |
| 142 void Reset (void); |
| 143 |
| 144 /** |
| 145 * \brief Initialize the algorithm |
| 146 */ |
| 147 void Init (void); |
| 148 |
| 149 /** |
| 150 * \brief The congestion avoidance algorithm of BIC is implemented here |
| 151 */ |
| 152 void CongAvoid (void); |
| 153 |
| 154 /** |
| 155 * \brief Bic window update after a new ack received |
| 156 */ |
| 157 uint32_t Update (void); |
| 158 |
| 159 /** |
| 160 * \brief Window update after a loss |
| 161 */ |
| 162 void RecalcSsthresh (void); |
| 163 }; |
| 164 |
| 165 } // namespace ns3 |
| 166 #endif // TCPBIC_H |
OLD | NEW |