A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tcp-congestion-ops.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2015 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 TCPCONGESTIONOPS_H
20 #define TCPCONGESTIONOPS_H
21 
22 #include "ns3/object.h"
23 #include "ns3/timer.h"
24 #include "ns3/tcp-socket-base.h"
25 
26 namespace ns3 {
27 
43 class TcpCongestionOps : public Object
44 {
45 public:
50  static TypeId GetTypeId (void);
51 
53 
58  TcpCongestionOps (const TcpCongestionOps &other);
59 
60  virtual ~TcpCongestionOps ();
61 
67  virtual std::string GetName () const = 0;
68 
83  virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
84  uint32_t bytesInFlight) = 0;
85 
97  virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked) = 0;
98 
111  virtual void PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked,
112  const Time& rtt)
113  {
114  }
115 
126  const TcpSocketState::TcpCongState_t newState)
127  {
128  }
129 
130  // Present in Linux but not in ns-3 yet:
131  /* call when cwnd event occurs (optional) */
132  // void (*cwnd_event)(struct sock *sk, enum tcp_ca_event ev);
133  /* call when ack arrives (optional) */
134  // void (*in_ack_event)(struct sock *sk, u32 flags);
135  /* new value of cwnd after loss (optional) */
136  // u32 (*undo_cwnd)(struct sock *sk);
137  /* hook for packet ack accounting (optional) */
138  // void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us);
139 
145  virtual Ptr<TcpCongestionOps> Fork () = 0;
146 };
147 
157 {
158 public:
163  static TypeId GetTypeId (void);
164 
165  TcpNewReno ();
166 
171  TcpNewReno (const TcpNewReno& sock);
172 
173  ~TcpNewReno ();
174 
175  std::string GetName () const;
176 
177  virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
178  virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
179  uint32_t bytesInFlight);
180 
181  virtual Ptr<TcpCongestionOps> Fork ();
182 
183 protected:
184  virtual uint32_t SlowStart (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
185  virtual void CongestionAvoidance (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
186 };
187 
188 } // namespace ns3
189 
190 #endif // TCPCONGESTIONOPS_H
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
virtual uint32_t SlowStart(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Tcp NewReno slow start algorithm.
virtual void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Try to increase the cWnd following the NewReno specification.
The NewReno implementation.
virtual std::string GetName() const =0
Get the name of the congestion control algorithm.
virtual Ptr< TcpCongestionOps > Fork()
Copy the congestion control algorithm across socket.
std::string GetName() const
Get the name of the congestion control algorithm.
static TypeId GetTypeId(void)
Get the type ID.
static TypeId GetTypeId(void)
Get the type ID.
virtual uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight)
Get the slow start threshold after a loss event.
TcpCongState_t
Definition of the Congestion state machine.
Congestion control abstract class.
virtual void CongestionStateSet(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState)
Trigger events/calculations specific to a congestion state.
virtual void PktsAcked(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt)
Timing information on received ACK.
virtual uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight)=0
Get the slow start threshold after a loss event.
virtual void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)=0
Congestion avoidance algorithm implementation.
virtual void CongestionAvoidance(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
NewReno congestion avoidance.
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual Ptr< TcpCongestionOps > Fork()=0
Copy the congestion control algorithm across socket.
a unique identifier for an interface.
Definition: type-id.h:58