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 */
ns3::TcpSocketState::Ect0
@ Ect0
Markable.
Definition: tcp-socket-state.h:126
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::TcpSocketState::m_maxPacingRate
DataRate m_maxPacingRate
Max Pacing rate.
Definition: tcp-socket-state.h:192
ns3::TcpSocketState::ECN_ECE_RCVD
@ ECN_ECE_RCVD
Last ACK received had ECE bit set in TCP header
Definition: tcp-socket-state.h:149
ns3::Callback< void, uint8_t >
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TcpSocketState::m_highTxMark
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
Definition: tcp-socket-state.h:184
ns3::TcpSocketState::m_pacingRate
TracedValue< DataRate > m_pacingRate
Current Pacing rate.
Definition: tcp-socket-state.h:193
ns3::TcpSocketState::m_nextTxSequence
TracedValue< SequenceNumber32 > m_nextTxSequence
Next seqnum to be sent (SND.NXT), ReTx pushes it back.
Definition: tcp-socket-state.h:185
ns3::TcpSocketState::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition: tcp-socket-state.h:177
ns3::TcpSocketState::CA_OPEN
@ CA_OPEN
Normal state, no dubious events.
Definition: tcp-socket-state.h:78
ns3::TcpSocketState::CA_EVENT_TX_START
@ CA_EVENT_TX_START
first transmit when no packets in flight
Definition: tcp-socket-state.h:96
ns3::TcpSocketState::TcpCongState_t
TcpCongState_t
Definition of the Congestion state machine.
Definition: tcp-socket-state.h:77
ns3::TracedValueCallback::TcpCongState
void(* TcpCongState)(const TcpSocketState::TcpCongState_t oldValue, const TcpSocketState::TcpCongState_t newValue)
TracedValue Callback signature for TcpCongState_t.
Definition: tcp-socket-state.h:247
ns3::TcpSocketState::m_lastAckedSeq
SequenceNumber32 m_lastAckedSeq
Last sequence ACKed.
Definition: tcp-socket-state.h:178
ns3::TcpSocketState::m_ecnState
TracedValue< EcnState_t > m_ecnState
Current ECN State, represented as combination of EcnState values.
Definition: tcp-socket-state.h:182
ns3::TcpSocketState::EcnCodePoint_t
EcnCodePoint_t
ECN code points.
Definition: tcp-socket-state.h:123
ns3::TcpSocketState::m_lastAckedSackedBytes
uint32_t m_lastAckedSackedBytes
The number of bytes acked and sacked as indicated by the current ACK received.
Definition: tcp-socket-state.h:210
ns3::TcpSocketState::CA_DISORDER
@ CA_DISORDER
In all the respects it is "Open", but requires a bit more attention.
Definition: tcp-socket-state.h:79
ns3::TcpSocketState::m_initialSsThresh
uint32_t m_initialSsThresh
Initial Slow Start Threshold value.
Definition: tcp-socket-state.h:169
ns3::TcpSocketState::m_ectCodePoint
EcnCodePoint_t m_ectCodePoint
ECT code point to use.
Definition: tcp-socket-state.h:208
ns3::TracedValueCallback::EcnState
void(* EcnState)(const TcpSocketState::EcnState_t oldValue, const TcpSocketState::EcnState_t newValue)
TracedValue Callback signature for EcnState_t.
Definition: tcp-socket-state.h:257
ns3::TcpSocketState::EcnStateName
static const char *const EcnStateName[TcpSocketState::ECN_CWR_SENT+1]
Literal names of ECN states for use in log messages.
Definition: tcp-socket-state.h:162
ns3::TcpSocketState::m_rcvTimestampValue
uint32_t m_rcvTimestampValue
Receiver Timestamp value.
Definition: tcp-socket-state.h:187
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::DataRate
Class for representing data rates.
Definition: data-rate.h:89
ns3::TcpSocketState::CongExp
@ CongExp
Marked.
Definition: tcp-socket-state.h:127
ns3::TcpSocketState::Off
@ Off
Disable.
Definition: tcp-socket-state.h:114
ns3::TcpSocketState::m_congState
TracedValue< TcpCongState_t > m_congState
State in the Congestion state machine.
Definition: tcp-socket-state.h:180
tcp-rx-buffer.h
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::TcpSocketState
Data structure that records the congestion state of a connection.
Definition: tcp-socket-state.h:42
ns3::TcpSocketState::TcpCongStateName
static const char *const TcpCongStateName[TcpSocketState::CA_LAST_STATE]
Literal names of TCP states for use in log messages.
Definition: tcp-socket-state.h:157
ns3::TcpSocketState::GetSsThreshInSegments
uint32_t GetSsThreshInSegments() const
Get slow start thresh in segments rather than bytes.
Definition: tcp-socket-state.h:227
ns3::TcpSocketState::ECN_DISABLED
@ ECN_DISABLED
ECN disabled traffic
Definition: tcp-socket-state.h:145
ns3::Time::Max
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Definition: nstime.h:283
ns3::TcpSocketState::ECN_IDLE
@ ECN_IDLE
ECN is enabled but currently there is no action pertaining to ECE or CWR to be taken
Definition: tcp-socket-state.h:146
ns3::TcpSocketState::ECN_CWR_SENT
@ ECN_CWR_SENT
Sender has reduced the congestion window, and sent a packet with CWR bit set in TCP header.
Definition: tcp-socket-state.h:150
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::TcpSocketState::NotECT
@ NotECT
Unmarkable.
Definition: tcp-socket-state.h:124
ns3::TcpSocketState::m_cWndInfl
TracedValue< uint32_t > m_cWndInfl
Inflated congestion window trace (used only for backward compatibility purpose)
Definition: tcp-socket-state.h:166
ns3::TcpSocketState::TcpSocketState
TcpSocketState()
TcpSocketState Constructor.
Definition: tcp-socket-state.h:54
ns3::TcpSocketState::m_initialCWnd
uint32_t m_initialCWnd
Initial cWnd value.
Definition: tcp-socket-state.h:168
ns3::TcpSocketState::AcceptOnly
@ AcceptOnly
Enable only when the peer endpoint is ECN capable.
Definition: tcp-socket-state.h:116
ns3::TcpSocketState::EcnState_t
EcnState_t
Definition of the Ecn state machine.
Definition: tcp-socket-state.h:144
ns3::TcpSocketState::DctcpEcn
@ DctcpEcn
ECN functionality as described in RFC 8257.
Definition: tcp-socket-state.h:136
ns3::TcpSocketState::CA_LOSS
@ CA_LOSS
CWND was reduced due to RTO timeout or SACK reneging.
Definition: tcp-socket-state.h:86
ns3::TcpSocketState::m_rxBuffer
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
Definition: tcp-socket-state.h:203
ns3::TcpSocketState::Ect1
@ Ect1
Markable.
Definition: tcp-socket-state.h:125
ns3::TcpSocketState::CA_EVENT_ECN_IS_CE
@ CA_EVENT_ECN_IS_CE
received CE marked IP packet.
Definition: tcp-socket-state.h:101
ns3::TcpSocketState::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-socket-state.cc:25
ns3::TcpSocketState::UseEcn_t
UseEcn_t
Parameter value related to ECN enable/disable functionality similar to sysctl for tcp_ecn.
Definition: tcp-socket-state.h:113
ns3::TcpSocketState::CA_LAST_STATE
@ CA_LAST_STATE
Used only in debug messages.
Definition: tcp-socket-state.h:87
ns3::TcpSocketState::EcnMode_t
EcnMode_t
ECN Modes.
Definition: tcp-socket-state.h:134
ns3::TcpSocketState::CA_EVENT_ECN_NO_CE
@ CA_EVENT_ECN_NO_CE
ECT set, but not CE marked.
Definition: tcp-socket-state.h:100
ns3::TcpSocketState::ClassicEcn
@ ClassicEcn
ECN functionality as described in RFC 3168.
Definition: tcp-socket-state.h:135
ns3::TcpSocketState::GetCwndInSegments
uint32_t GetCwndInSegments() const
Get cwnd in segments rather than bytes.
Definition: tcp-socket-state.h:217
ns3::TcpSocketState::m_pacingCaRatio
uint16_t m_pacingCaRatio
CA pacing ratio.
Definition: tcp-socket-state.h:195
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::TracedValue< uint32_t >
ns3::TcpSocketState::CA_RECOVERY
@ CA_RECOVERY
CWND was reduced, we are fast-retransmitting.
Definition: tcp-socket-state.h:85
ns3::TcpSocketState::CA_EVENT_NON_DELAYED_ACK
@ CA_EVENT_NON_DELAYED_ACK
Non-delayed ack is sent.
Definition: tcp-socket-state.h:103
ns3::TcpSocketState::m_pacing
bool m_pacing
Pacing status.
Definition: tcp-socket-state.h:191
ns3::TcpSocketState::TcpCAEvent_t
TcpCAEvent_t
Congestion avoidance events.
Definition: tcp-socket-state.h:95
ns3::TcpSocketState::m_sendEmptyPacketCallback
Callback< void, uint8_t > m_sendEmptyPacketCallback
Callback to send an empty packet.
Definition: tcp-socket-state.h:235
ns3::TcpSocketState::m_bytesInFlight
TracedValue< uint32_t > m_bytesInFlight
Bytes in flight.
Definition: tcp-socket-state.h:200
ns3::TcpSocketState::m_useEcn
UseEcn_t m_useEcn
Socket ECN capability.
Definition: tcp-socket-state.h:206
ns3::TcpSocketState::m_cWnd
TracedValue< uint32_t > m_cWnd
Congestion window.
Definition: tcp-socket-state.h:165
ns3::TcpSocketState::CA_EVENT_CWND_RESTART
@ CA_EVENT_CWND_RESTART
congestion window restart.
Definition: tcp-socket-state.h:97
ns3::TcpSocketState::m_lastRtt
TracedValue< Time > m_lastRtt
Last RTT sample collected.
Definition: tcp-socket-state.h:201
ns3::TcpSocketState::ECN_CE_RCVD
@ ECN_CE_RCVD
Last packet received had CE bit set in IP header
Definition: tcp-socket-state.h:147
ns3::TcpSocketState::m_rcvTimestampEchoReply
uint32_t m_rcvTimestampEchoReply
Sender Timestamp echoed by the receiver.
Definition: tcp-socket-state.h:188
ns3::TcpSocketState::m_pacingSsRatio
uint16_t m_pacingSsRatio
SS pacing ratio.
Definition: tcp-socket-state.h:194
ns3::TcpSocketState::CA_EVENT_COMPLETE_CWR
@ CA_EVENT_COMPLETE_CWR
end of congestion recovery
Definition: tcp-socket-state.h:98
ns3::TcpSocketState::m_minRtt
Time m_minRtt
Minimum RTT observed throughout the connection.
Definition: tcp-socket-state.h:198
ns3::TcpSocketState::m_paceInitialWindow
bool m_paceInitialWindow
Enable/Disable pacing for the initial window.
Definition: tcp-socket-state.h:196
ns3::TcpSocketState::CA_EVENT_DELAYED_ACK
@ CA_EVENT_DELAYED_ACK
Delayed ack is sent.
Definition: tcp-socket-state.h:102
ns3::SequenceNumber< uint32_t, int32_t >
ns3::TcpSocketState::m_isRetransDataAcked
bool m_isRetransDataAcked
Retransmitted data is ACKed if true.
Definition: tcp-socket-state.h:174
ns3::TcpSocketState::m_ssThresh
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
Definition: tcp-socket-state.h:167
ns3::TcpSocketState::m_ecnMode
EcnMode_t m_ecnMode
ECN mode.
Definition: tcp-socket-state.h:205
ns3::TcpSocketState::CA_EVENT_LOSS
@ CA_EVENT_LOSS
loss timeout
Definition: tcp-socket-state.h:99
ns3::TcpSocketState::On
@ On
Enable.
Definition: tcp-socket-state.h:115
ns3::TcpSocketState::ECN_SENDING_ECE
@ ECN_SENDING_ECE
Receiver sends an ACK with ECE bit set in TCP header
Definition: tcp-socket-state.h:148
ns3::TcpSocketState::CA_CWR
@ CA_CWR
cWnd was reduced due to some congestion notification event, such as ECN, ICMP source quench,...
Definition: tcp-socket-state.h:82