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/object.h"
23 #include "ns3/timer.h"
24 #include "ns3/tcp-socket-base.h"
25 
26 namespace ns3 {
27 
52 class TcpCongestionOps : public Object
53 {
54 public:
59  static TypeId GetTypeId (void);
60 
62 
67  TcpCongestionOps (const TcpCongestionOps &other);
68 
69  virtual ~TcpCongestionOps ();
70 
76  virtual std::string GetName () const = 0;
77 
92  virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
93  uint32_t bytesInFlight) = 0;
94 
106  virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked) = 0;
107 
120  virtual void PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked,
121  const Time& rtt)
122  {
123  }
124 
135  const TcpSocketState::TcpCongState_t newState)
136  {
137  }
138 
139  // Present in Linux but not in ns-3 yet:
140  /* call when cwnd event occurs (optional) */
141  // void (*cwnd_event)(struct sock *sk, enum tcp_ca_event ev);
142  /* call when ack arrives (optional) */
143  // void (*in_ack_event)(struct sock *sk, u32 flags);
144  /* new value of cwnd after loss (optional) */
145  // u32 (*undo_cwnd)(struct sock *sk);
146  /* hook for packet ack accounting (optional) */
147  // void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us);
148 
154  virtual Ptr<TcpCongestionOps> Fork () = 0;
155 };
156 
166 {
167 public:
172  static TypeId GetTypeId (void);
173 
174  TcpNewReno ();
175 
180  TcpNewReno (const TcpNewReno& sock);
181 
182  ~TcpNewReno ();
183 
184  std::string GetName () const;
185 
186  virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
187  virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
188  uint32_t bytesInFlight);
189 
190  virtual Ptr<TcpCongestionOps> Fork ();
191 
192 protected:
193  virtual uint32_t SlowStart (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
194  virtual void CongestionAvoidance (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
195 };
196 
197 } // namespace ns3
198 
199 #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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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