A Discrete-Event Network Simulator
API
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 "tcp-rate-ops.h"
23 #include "tcp-socket-state.h"
24 
25 namespace ns3 {
26 
51 class TcpCongestionOps : public Object
52 {
53 public:
58  static TypeId GetTypeId (void);
59 
61 
66  TcpCongestionOps (const TcpCongestionOps &other);
67 
68  virtual ~TcpCongestionOps ();
69 
75  virtual std::string GetName () const = 0;
76 
82  virtual void Init (Ptr<TcpSocketState> tcb)
83  {
84  NS_UNUSED (tcb);
85  }
86 
101  virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
102  uint32_t bytesInFlight) = 0;
103 
115  virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
116 
129  virtual void PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked,
130  const Time& rtt);
131 
148  virtual void CongestionStateSet (Ptr<TcpSocketState> tcb,
149  const TcpSocketState::TcpCongState_t newState);
150 
160  virtual void CwndEvent (Ptr<TcpSocketState> tcb,
161  const TcpSocketState::TcpCAEvent_t event);
162 
175  virtual bool HasCongControl () const;
176 
187  virtual void CongControl (Ptr<TcpSocketState> tcb,
189  const TcpRateOps::TcpRateSample &rs);
190 
191  // Present in Linux but not in ns-3 yet:
192  /* call when ack arrives (optional) */
193  // void (*in_ack_event)(struct sock *sk, u32 flags);
194  /* new value of cwnd after loss (optional) */
195  // u32 (*undo_cwnd)(struct sock *sk);
196  /* hook for packet ack accounting (optional) */
197  // void (*pkts_acked)(struct sock *sk, u32 ext, int *attr, union tcp_cc_info *info);
198 
204  virtual Ptr<TcpCongestionOps> Fork () = 0;
205 };
206 
216 {
217 public:
222  static TypeId GetTypeId (void);
223 
224  TcpNewReno ();
225 
230  TcpNewReno (const TcpNewReno& sock);
231 
232  ~TcpNewReno ();
233 
234  std::string GetName () const;
235 
236  virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
237  virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
238  uint32_t bytesInFlight);
239  virtual Ptr<TcpCongestionOps> Fork ();
240 
241 protected:
242  virtual uint32_t SlowStart (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
243  virtual void CongestionAvoidance (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
244 };
245 
246 } // namespace ns3
247 
248 #endif // TCPCONGESTIONOPS_H
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
virtual void Init(Ptr< TcpSocketState > tcb)
Set configuration required by congestion control algorithm.
TcpCAEvent_t
Congestion avoidance events.
virtual void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Congestion avoidance algorithm implementation.
virtual uint32_t SlowStart(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Tcp NewReno slow start algorithm
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
virtual void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Try to increase the cWnd following the NewReno specification.
The NewReno implementation.
virtual void CwndEvent(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCAEvent_t event)
Trigger events/calculations on occurrence of congestion window event.
virtual std::string GetName() const =0
Get the name of the congestion control algorithm.
virtual Ptr< TcpCongestionOps > Fork()
Copy the congestion control algorithm across sockets.
static TypeId GetTypeId(void)
Get the type ID.
Rate Sample structure.
Definition: tcp-rate-ops.h:133
virtual void PktsAcked(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt)
Timing information on received ACK.
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Congestion control abstract class.
Information about the connection rate.
Definition: tcp-rate-ops.h:162
virtual uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight)=0
Get the slow start threshold after a loss event.
std::string GetName() const
Get the name of the congestion control algorithm.
virtual void CongestionStateSet(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState)
Trigger events/calculations specific to a congestion state.
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 bool HasCongControl() const
Returns true when Congestion Control Algorithm implements CongControl.
virtual Ptr< TcpCongestionOps > Fork()=0
Copy the congestion control algorithm across sockets.
a unique identifier for an interface.
Definition: type-id.h:58
virtual void CongControl(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateConnection &rc, const TcpRateOps::TcpRateSample &rs)
Called when packets are delivered to update cwnd and pacing rate.