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 "ns3/tcp-socket-state.h"
23 
24 namespace ns3 {
25 
50 class TcpCongestionOps : public Object
51 {
52 public:
57  static TypeId GetTypeId (void);
58 
60 
65  TcpCongestionOps (const TcpCongestionOps &other);
66 
67  virtual ~TcpCongestionOps ();
68 
74  virtual std::string GetName () const = 0;
75 
90  virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
91  uint32_t bytesInFlight) = 0;
92 
104  virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked) = 0;
105 
118  virtual void PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked,
119  const Time& rtt)
120  {
121  NS_UNUSED (tcb);
122  NS_UNUSED (segmentsAcked);
123  NS_UNUSED (rtt);
124  }
125 
136  const TcpSocketState::TcpCongState_t newState)
137  {
138  NS_UNUSED (tcb);
139  NS_UNUSED (newState);
140  }
141 
151  virtual void CwndEvent (Ptr<TcpSocketState> tcb,
152  const TcpSocketState::TcpCAEvent_t event)
153  {
154  NS_UNUSED (tcb);
155  NS_UNUSED (event);
156  }
157  // Present in Linux but not in ns-3 yet:
158  /* call when ack arrives (optional) */
159  // void (*in_ack_event)(struct sock *sk, u32 flags);
160  /* new value of cwnd after loss (optional) */
161  // u32 (*undo_cwnd)(struct sock *sk);
162  /* hook for packet ack accounting (optional) */
163 
169  virtual Ptr<TcpCongestionOps> Fork () = 0;
170 };
171 
181 {
182 public:
187  static TypeId GetTypeId (void);
188 
189  TcpNewReno ();
190 
195  TcpNewReno (const TcpNewReno& sock);
196 
197  ~TcpNewReno ();
198 
199  std::string GetName () const;
200 
201  virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
202  virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
203  uint32_t bytesInFlight);
204 
205  virtual Ptr<TcpCongestionOps> Fork ();
206 
207 protected:
208  virtual uint32_t SlowStart (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
209  virtual void CongestionAvoidance (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
210 };
211 
212 } // namespace ns3
213 
214 #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
#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 std::string GetName() const =0
Get the name of the congestion control algorithm.
virtual Ptr< TcpCongestionOps > Fork()
Copy the congestion control algorithm across socket.
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Congestion control abstract class.
virtual void CwndEvent(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCAEvent_t event)
Trigger events/calculations on occurrence congestion window event.
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.
std::string GetName() const
Get the name of the congestion control algorithm.
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