A Discrete-Event Network Simulator
API
tcp-socket-state.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2018 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 #ifndef TCP_SOCKET_STATE_H
19 #define TCP_SOCKET_STATE_H
20 
21 #include "ns3/object.h"
22 #include "ns3/data-rate.h"
23 #include "ns3/traced-value.h"
24 #include "ns3/sequence-number.h"
25 #include "tcp-rx-buffer.h"
26 
27 namespace ns3 {
28 
41 class TcpSocketState : public Object
42 {
43 public:
49  static TypeId GetTypeId (void);
50 
54  TcpSocketState () : Object () { }
55 
60  TcpSocketState (const TcpSocketState &other);
61 
76  typedef enum
77  {
79  CA_DISORDER,
82  CA_CWR,
89 
90  // Note: "not triggered" events are currently not triggered by the code.
94  typedef enum
95  {
104  } TcpCAEvent_t;
105 
112  typedef enum
113  {
114  Off = 0,
115  On = 1,
117  } UseEcn_t;
118 
122  typedef enum
123  {
124  NotECT = 0,
125  Ect1 = 1,
126  Ect0 = 2,
127  CongExp = 3,
128  } EcnCodePoint_t;
129 
133  typedef enum
134  {
137  } EcnMode_t;
138 
143  typedef enum
144  {
150  ECN_CWR_SENT
153 
158 
162  static const char* const EcnStateName[TcpSocketState::ECN_CWR_SENT + 1];
163 
164  // Congestion control
168  uint32_t m_initialCWnd {0};
169  uint32_t m_initialSsThresh {0};
170 
171  // Recovery
172  // This variable is used for implementing following flag of Linux: FLAG_RETRANS_DATA_ACKED
173  // and is used only during a recovery phase to keep track of acknowledgement of retransmitted packet.
174  bool m_isRetransDataAcked {false};
175 
176  // Segment
177  uint32_t m_segmentSize {0};
179 
181 
183 
186 
187  uint32_t m_rcvTimestampValue {0};
188  uint32_t m_rcvTimestampEchoReply {0};
189 
190  // Pacing related variables
191  bool m_pacing {false};
194  uint16_t m_pacingSsRatio {0};
195  uint16_t m_pacingCaRatio {0};
196  bool m_paceInitialWindow {false};
197 
199 
202 
204 
207 
209 
210  uint32_t m_lastAckedSackedBytes {0};
211 
217  uint32_t GetCwndInSegments () const
218  {
219  return m_cWnd / m_segmentSize;
220  }
221 
227  uint32_t GetSsThreshInSegments () const
228  {
229  return m_ssThresh / m_segmentSize;
230  }
231 
236 };
237 
238 namespace TracedValueCallback {
239 
247  typedef void (* TcpCongState)(const TcpSocketState::TcpCongState_t oldValue,
248  const TcpSocketState::TcpCongState_t newValue);
249 
257  typedef void (* EcnState)(const TcpSocketState::EcnState_t oldValue,
258  const TcpSocketState::EcnState_t newValue);
259 
260 } // namespace TracedValueCallback
261 
262 } //namespace ns3
263 
264 #endif /* TCP_SOCKET_STATE_H */
Class for representing data rates.
Definition: data-rate.h:89
A base class which provides memory management and object aggregation.
Definition: object.h:88
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Data structure that records the congestion state of a connection.
EcnCodePoint_t
ECN code points.
uint32_t m_segmentSize
Segment size.
TcpCAEvent_t
Congestion avoidance events.
@ CA_EVENT_ECN_IS_CE
received CE marked IP packet.
@ CA_EVENT_ECN_NO_CE
ECT set, but not CE marked.
@ CA_EVENT_DELAYED_ACK
Delayed ack is sent.
@ CA_EVENT_NON_DELAYED_ACK
Non-delayed ack is sent.
@ CA_EVENT_COMPLETE_CWR
end of congestion recovery
@ CA_EVENT_CWND_RESTART
congestion window restart.
@ CA_EVENT_LOSS
loss timeout
@ CA_EVENT_TX_START
first transmit when no packets in flight
Time m_minRtt
Minimum RTT observed throughout the connection.
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
uint32_t m_initialSsThresh
Initial Slow Start Threshold value.
EcnMode_t m_ecnMode
ECN mode.
Callback< void, uint8_t > m_sendEmptyPacketCallback
Callback to send an empty packet.
TracedValue< DataRate > m_pacingRate
Current Pacing rate.
UseEcn_t
Parameter value related to ECN enable/disable functionality similar to sysctl for tcp_ecn.
@ AcceptOnly
Enable only when the peer endpoint is ECN capable.
TracedValue< TcpCongState_t > m_congState
State in the Congestion state machine.
bool m_paceInitialWindow
Enable/Disable pacing for the initial window.
DataRate m_maxPacingRate
Max Pacing rate.
UseEcn_t m_useEcn
Socket ECN capability.
bool m_pacing
Pacing status.
bool m_isRetransDataAcked
Retransmitted data is ACKed if true.
uint32_t GetCwndInSegments() const
Get cwnd in segments rather than bytes.
static const char *const TcpCongStateName[TcpSocketState::CA_LAST_STATE]
Literal names of TCP states for use in log messages.
TcpCongState_t
Definition of the Congestion state machine.
@ CA_RECOVERY
CWND was reduced, we are fast-retransmitting.
@ CA_DISORDER
In all the respects it is "Open", but requires a bit more attention.
@ CA_LAST_STATE
Used only in debug messages.
@ CA_CWR
cWnd was reduced due to some congestion notification event, such as ECN, ICMP source quench,...
@ CA_LOSS
CWND was reduced due to RTO timeout or SACK reneging.
@ CA_OPEN
Normal state, no dubious events.
SequenceNumber32 m_lastAckedSeq
Last sequence ACKed.
@ DctcpEcn
ECN functionality as described in RFC 8257.
@ ClassicEcn
ECN functionality as described in RFC 3168.
TracedValue< uint32_t > m_cWnd
Congestion window.
uint32_t m_initialCWnd
Initial cWnd value.
uint32_t m_rcvTimestampEchoReply
Sender Timestamp echoed by the receiver.
TracedValue< Time > m_lastRtt
Last RTT sample collected.
EcnState_t
Definition of the Ecn state machine.
@ ECN_CWR_SENT
Sender has reduced the congestion window, and sent a packet with CWR bit set in TCP header.
@ ECN_DISABLED
ECN disabled traffic
@ ECN_ECE_RCVD
Last ACK received had ECE bit set in TCP header
@ ECN_IDLE
ECN is enabled but currently there is no action pertaining to ECE or CWR to be taken
@ ECN_CE_RCVD
Last packet received had CE bit set in IP header
@ ECN_SENDING_ECE
Receiver sends an ACK with ECE bit set in TCP header
TcpSocketState()
TcpSocketState Constructor.
TracedValue< uint32_t > m_bytesInFlight
Bytes in flight.
TracedValue< uint32_t > m_cWndInfl
Inflated congestion window trace (used only for backward compatibility purpose)
uint32_t GetSsThreshInSegments() const
Get slow start thresh in segments rather than bytes.
uint16_t m_pacingCaRatio
CA pacing ratio.
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
TracedValue< SequenceNumber32 > m_nextTxSequence
Next seqnum to be sent (SND.NXT), ReTx pushes it back.
uint32_t m_lastAckedSackedBytes
The number of bytes acked and sacked as indicated by the current ACK received.
uint16_t m_pacingSsRatio
SS pacing ratio.
static const char *const EcnStateName[TcpSocketState::ECN_CWR_SENT+1]
Literal names of ECN states for use in log messages.
TracedValue< EcnState_t > m_ecnState
Current ECN State, represented as combination of EcnState values.
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
static TypeId GetTypeId(void)
Get the type ID.
uint32_t m_rcvTimestampValue
Receiver Timestamp value.
EcnCodePoint_t m_ectCodePoint
ECT code point to use.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Definition: nstime.h:282
a unique identifier for an interface.
Definition: type-id.h:59
void(* TcpCongState)(const TcpSocketState::TcpCongState_t oldValue, const TcpSocketState::TcpCongState_t newValue)
TracedValue Callback signature for TcpCongState_t.
void(* EcnState)(const TcpSocketState::EcnState_t oldValue, const TcpSocketState::EcnState_t newValue)
TracedValue Callback signature for EcnState_t.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
Every class exported by the ns3 library is enclosed in the ns3 namespace.