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 #ifndef TCPHYBLA_H
20 #define TCPHYBLA_H
21 
22 #include "tcp-congestion-ops.h"
23 #include "ns3/traced-value.h"
24 
25 namespace ns3 {
26 
27 class TcpSocketState;
28 
29 /**
30  * \ingroup congestionOps
31  *
32  * \brief Implementation of the TCP Hybla algorithm
33  *
34  * The key idea behind TCP Hybla is to obtain for long RTT connections the same
35  * instantaneous transmission rate of a reference TCP connection with lower RTT.
36  * With analytical steps, it is shown that this goal can be achieved by
37  * modifying the time scale, in order for the throughput to be independent from
38  * the RTT. This independence is obtained through the use of a coefficient rho.
39  *
40  * This coefficient is used to calculate both the slow start threshold
41  * and the congestion window when in slow start and in congestion avoidance,
42  * respectively.
43  *
44  * More information: http://dl.acm.org/citation.cfm?id=2756518
45  */
46 class TcpHybla : public TcpNewReno
47 {
48 public:
49   /**
50    * \brief Get the type ID.
51    * \return the object TypeId
52    */
53   static TypeId GetTypeId (void);
54 
55   /**
56    * Create an unbound tcp socket.
57    */
58   TcpHybla (void);
59 
60   /**
61    * \brief Copy constructor
62    * \param sock the object to copy
63    */
64   TcpHybla (const TcpHybla& sock);
65 
66   virtual ~TcpHybla (void) override;
67 
68   // Inherited
69   virtual void PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked,
70                           const Time& rtt) override;
71   virtual std::string GetName () const override;
72   virtual Ptr<TcpCongestionOps> Fork () override;
73 
74 protected:
75   virtual uint32_t SlowStart (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked) override;
76   virtual void CongestionAvoidance (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked) override;
77 
78 private:
79   TracedValue<double> m_rho;         //!< Rho parameter
80   Time                m_rRtt;        //!< Reference RTT
81   double              m_cWndCnt;     //!< cWnd integer-to-float counter
82 
83 private:
84   /**
85    * \brief Recalculate algorithm parameters
86    * \param tcb the socket state.
87    */
88   void RecalcParam (const Ptr<TcpSocketState> &tcb);
89 };
90 
91 } // namespace ns3
92 
93 #endif // TCPHYBLA_H
94