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 #include "ns3/tcp-rate-ops.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 
91  virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
92  uint32_t bytesInFlight) = 0;
93 
105  virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
106 
119  virtual void PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked,
120  const Time& rtt);
121 
138  virtual void CongestionStateSet (Ptr<TcpSocketState> tcb,
139  const TcpSocketState::TcpCongState_t newState);
140 
150  virtual void CwndEvent (Ptr<TcpSocketState> tcb,
151  const TcpSocketState::TcpCAEvent_t event);
152 
165  virtual bool HasCongControl () const;
166 
177  virtual void CongControl (Ptr<TcpSocketState> tcb,
179  const TcpRateOps::TcpRateSample &rs);
180 
181  // Present in Linux but not in ns-3 yet:
182  /* call when ack arrives (optional) */
183  // void (*in_ack_event)(struct sock *sk, u32 flags);
184  /* new value of cwnd after loss (optional) */
185  // u32 (*undo_cwnd)(struct sock *sk);
186  /* hook for packet ack accounting (optional) */
187  // void (*pkts_acked)(struct sock *sk, u32 ext, int *attr, union tcp_cc_info *info);
188 
194  virtual Ptr<TcpCongestionOps> Fork () = 0;
195 };
196 
206 {
207 public:
212  static TypeId GetTypeId (void);
213 
214  TcpNewReno ();
215 
220  TcpNewReno (const TcpNewReno& sock);
221 
222  ~TcpNewReno ();
223 
224  std::string GetName () const;
225 
226  virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
227  virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
228  uint32_t bytesInFlight);
229 
230  virtual Ptr<TcpCongestionOps> Fork ();
231 
232 protected:
233  virtual uint32_t SlowStart (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
234  virtual void CongestionAvoidance (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
235 };
236 
237 } // namespace ns3
238 
239 #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 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
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:131
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:160
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.