1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 /* 3 * Copyright (c) 2016 NITK Surathkal 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 * Authors: Charitha Sangaraju <charitha29193@gmail.com> 19 * Nandita G <gm.nandita@gmail.com> 20 * Mohit P. Tahiliani <tahiliani@nitk.edu.in> 21 * 22 */ 23 24 #ifndef TCPLP_H 25 #define TCPLP_H 26 27 #include "tcp-congestion-ops.h" 28 29 #include "ns3/traced-value.h" 30 31 namespace ns3 { 32 33 class TcpSocketState; 34 35 class TcpLp : public TcpNewReno 36 { 37 public: 38 /** 39 * \brief Get the type ID. 40 * 41 * \return the object TypeId 42 */ 43 static TypeId GetTypeId (void); 44 45 /** 46 * \brief Creates an unbound tcp socket. 47 * 48 */ 49 TcpLp (void); 50 51 /** 52 * \brief Copy constructor 53 * 54 * \param sock the object to copy 55 */ 56 TcpLp (const TcpLp& sock); 57 58 virtual ~TcpLp (void); 59 60 /** 61 * \brief Timing information on received ACK 62 * 63 * The function is called every time an ACK is received. 64 * It determines the state of TcpLp and adjusts the congestion window accordingly. 65 * 66 * \param tcb internal congestion state 67 * \param segmentsAcked count of segments acked 68 * \param rtt last rtt 69 */ 70 virtual void PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked, 71 const Time& rtt); 72 73 virtual std::string GetName () const; 74 75 virtual Ptr<TcpCongestionOps> Fork (); 76 77 protected: 78 /** 79 * \brief Invokes Congestion Avoidance of TcpNewReno if TcpLp is not within inference. 80 * 81 * \param tcb internal congestion state 82 * \param segmentsAcked count of segments acked 83 */ 84 virtual void CongestionAvoidance (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked); 85 86 private: 87 /** 88 * \brief Describes the state of TcpLp. 89 * 90 */ 91 enum State 92 { 93 LP_VALID_OWD = (1 << 1), /**< Calculated One-Way Delay is valid */ 94 LP_WITHIN_THR = (1 << 3), /**< TcpLp is within Threshold */ 95 LP_WITHIN_INF = (1 << 4), /**< TcpLp is within Inference */ 96 }; 97 98 uint32_t m_flag; //!<TcpLp state flag 99 uint32_t m_sOwd; //!<Smoothed One-Way Delay 100 uint32_t m_owdMin; //!<Minimum One-Way Delay 101 uint32_t m_owdMax; //!<Maximum One-Way Delay 102 uint32_t m_owdMaxRsv; //!<Reserved Maximum One-Way Delay 103 Time m_lastDrop; //!<Last time when cwnd was reduced 104 Time m_inference; //!<Current inference period 105 106 private: 107 /** 108 * \brief Calculates One-Way Delay using Sender and Receiver timestamps. 109 * 110 * \param tcb internal congestion state 111 * \return One-Way Delay 112 */ 113 uint32_t OwdCalculator (Ptr<TcpSocketState> tcb); 114 115 /** 116 * \brief Estimates minimum and maximum One-Way Delays and calculates the smoothed One-Way Delay. 117 * 118 * \param tcb internal congestion state 119 */ 120 void RttSample (Ptr<TcpSocketState> tcb); 121 }; 122 123 } // namespace ns3 124 125 #endif // TCPLP_H 126