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 
25 namespace ns3 {
26 
27 class TcpSocketState;
28 class TcpSocketBase;
29 
45 class TcpCongestionOps : public Object
46 {
47 public:
52  static TypeId GetTypeId (void);
53 
55  TcpCongestionOps (const TcpCongestionOps &other);
56 
57  virtual ~TcpCongestionOps ();
58 
64  virtual std::string GetName () const = 0;
65 
80  virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
81  uint32_t bytesInFlight) = 0;
82 
94  virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked) = 0;
95 
108  virtual void PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked,
109  const Time& rtt) { }
110 
111  // Present in Linux but not in ns-3 yet:
112  /* call before changing ca_state (optional) */
113  // void (*set_state)(struct sock *sk, u8 new_state);
114  /* call when cwnd event occurs (optional) */
115  // void (*cwnd_event)(struct sock *sk, enum tcp_ca_event ev);
116  /* call when ack arrives (optional) */
117  // void (*in_ack_event)(struct sock *sk, u32 flags);
118  /* new value of cwnd after loss (optional) */
119  // u32 (*undo_cwnd)(struct sock *sk);
120  /* hook for packet ack accounting (optional) */
121  // void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us);
122 
128  virtual Ptr<TcpCongestionOps> Fork () = 0;
129 };
130 
140 {
141 public:
146  static TypeId GetTypeId (void);
147 
148  TcpNewReno ();
149  TcpNewReno (const TcpNewReno& sock);
150 
151  ~TcpNewReno ();
152 
153  std::string GetName () const;
154 
155  virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
156  virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
157  uint32_t bytesInFlight);
158 
159  virtual Ptr<TcpCongestionOps> Fork ();
160 
161 protected:
162  virtual uint32_t SlowStart (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
163  virtual void CongestionAvoidance (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
164 };
165 
166 } // namespace ns3
167 
168 #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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Congestion control abstract class.
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