/usr/include/ns3.27/ns3/tcp-ledbat.h is in libns3-dev 3.27+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2016 NITK Surathkal
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Ankit Deepak <adadeepak8@gmail.com>
*
*/
#ifndef TCP_LEDBAT_H
#define TCP_LEDBAT_H
#include <vector>
#include "ns3/tcp-congestion-ops.h"
#include "ns3/event-id.h"
namespace ns3 {
/**
* \ingroup congestionOps
*
* \brief An implementation of LEDBAT
*/
class TcpLedbat : public TcpNewReno
{
private:
/**
* \brief The slowstart types
*/
enum SlowStartType
{
DO_NOT_SLOWSTART, //!< Do not Slow Start
DO_SLOWSTART, //!< Do NewReno Slow Start
};
/**
* \brief The state of LEDBAT. If LEDBAT is not in VALID_OWD state, it falls to
* default congestion ops.
*/
enum State
{
LEDBAT_VALID_OWD = (1 << 1), //!< If valid timestamps are present
LEDBAT_CAN_SS = (1 << 3) //!< If LEDBAT allows Slow Start
};
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
/**
* Create an unbound tcp socket.
*/
TcpLedbat (void);
/**
* \brief Copy constructor
* \param sock the object to copy
*/
TcpLedbat (const TcpLedbat& sock);
/**
* \brief Destructor
*/
virtual ~TcpLedbat (void);
/**
* \brief Get the name of the TCP flavour
*
* \return The name of the TCP
*/
virtual std::string GetName () const;
/**
* \brief Get information from the acked packet
*
* \param tcb internal congestion state
* \param segmentsAcked count of segments ACKed
* \param rtt The estimated rtt
*/
virtual void PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked,
const Time& rtt);
/**
* \brief Get the slow start threshold
*
* \param tcb internal congestion state
* \param bytesInFlight bytes in flight
*
* \return The slow start threshold
*/
virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
uint32_t bytesInFlight);
virtual Ptr<TcpCongestionOps> Fork ();
/**
* \brief Adjust cwnd following LEDBAT algorithm
*
* \param tcb internal congestion state
* \param segmentsAcked count of segments ACKed
*/
virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
/**
* \brief Change the Slow Start Capability
*
* \param doSS Slow Start Option
*/
void SetDoSs (SlowStartType doSS);
protected:
/**
* \brief Reduce Congestion
*
* \param tcb internal congestion state
* \param segmentsAcked count of segments ACKed
*/
virtual void CongestionAvoidance (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
private:
/**
*\brief Buffer structure to store delays
*/
struct OwdCircBuf
{
std::vector<uint32_t> buffer; //!< Vector to store the delay
uint32_t min; //!< The index of minimum value
};
/**
* \brief Initialise a new buffer
*
* \param buffer The buffer to be initialised
*/
void InitCircBuf (struct OwdCircBuf &buffer);
/// Filter function used by LEDBAT for current delay
typedef uint32_t (*FilterFunction)(struct OwdCircBuf &);
/**
* \brief Return the minimum delay of the buffer
*
* \param b The buffer
* \return The minimum delay
*/
static uint32_t MinCircBuf (struct OwdCircBuf &b);
/**
* \brief Return the value of current delay
*
* \param filter The filter function
* \return The current delay
*/
uint32_t CurrentDelay (FilterFunction filter);
/**
* \brief Return the value of base delay
*
* \return The base delay
*/
uint32_t BaseDelay ();
/**
* \brief Add new delay to the buffers
*
* \param cb The buffer
* \param owd The new delay
* \param maxlen The maximum permitted length
*/
void AddDelay (struct OwdCircBuf &cb, uint32_t owd, uint32_t maxlen);
/**
* \brief Update the base delay buffer
*
* \param owd The delay
*/
void UpdateBaseDelay (uint32_t owd);
Time m_target; //!< Target Queue Delay
double m_gain; //!< GAIN value from RFC
SlowStartType m_doSs; //!< Permissible Slow Start State
uint32_t m_baseHistoLen; //!< Length of base delay history buffer
uint32_t m_noiseFilterLen; //!< Length of current delay buffer
uint64_t m_lastRollover; //!< Timestamp of last added delay
int32_t m_sndCwndCnt; //!< The congestion window addition parameter
struct OwdCircBuf m_baseHistory; //!< Buffer to store the base delay
struct OwdCircBuf m_noiseFilter; //!< Buffer to store the current delay
uint32_t m_flag; //!< LEDBAT Flag
};
} // namespace ns3
#endif /* TCP_LEDBAT_H */
|