A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-socket-state.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Natale Patriciello <natale.patriciello@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17#ifndef TCP_SOCKET_STATE_H
18#define TCP_SOCKET_STATE_H
19
20#include "tcp-rx-buffer.h"
21
22#include "ns3/data-rate.h"
23#include "ns3/object.h"
24#include "ns3/sequence-number.h"
25#include "ns3/traced-value.h"
26
27namespace ns3
28{
29
42class TcpSocketState : public Object
43{
44 public:
50 static TypeId GetTypeId();
51
56 : Object()
57 {
58 }
59
64 TcpSocketState(const TcpSocketState& other);
65
81 {
86 CA_CWR,
91 };
92
93 // Note: "not triggered" events are currently not triggered by the code.
98 {
107 };
108
116 {
117 Off = 0,
118 On = 1,
120 };
121
126 {
127 NotECT = 0,
128 Ect1 = 1,
129 Ect0 = 2,
131 };
132
137 {
139 DctcpEcn,
141 };
142
148 {
150 ECN_IDLE,
157 };
158
163
167 static const char* const EcnStateName[TcpSocketState::ECN_CWR_SENT + 1];
168
169 // Congestion control
172 0};
176
177 // Recovery
178 // This variable is used for implementing following flag of Linux: FLAG_RETRANS_DATA_ACKED
179 // and is used only during a recovery phase to keep track of acknowledgement of retransmitted
180 // packet.
182
183 // Segment
186
188
190 ECN_DISABLED};
191
194 0};
195
198
199 // Pacing related variables
200 bool m_pacing{false};
203 uint16_t m_pacingSsRatio{0};
204 uint16_t m_pacingCaRatio{0};
206
208
211
213
216
218
220 0};
222
229 {
230 return m_cWnd / m_segmentSize;
231 }
232
239 {
240 return m_ssThresh / m_segmentSize;
241 }
242
247};
248
249namespace TracedValueCallback
250{
251
259typedef void (*TcpCongState)(const TcpSocketState::TcpCongState_t oldValue,
260 const TcpSocketState::TcpCongState_t newValue);
261
269typedef void (*EcnState)(const TcpSocketState::EcnState_t oldValue,
270 const TcpSocketState::EcnState_t newValue);
271
272} // namespace TracedValueCallback
273
274} // namespace ns3
275
276#endif /* TCP_SOCKET_STATE_H */
Callback template class.
Definition: callback.h:438
Class for representing data rates.
Definition: data-rate.h:89
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
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.
static TypeId GetTypeId()
Get the type ID.
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.
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:105
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Definition: nstime.h:296
Trace classes with value semantics.
Definition: traced-value.h:116
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:1336
Every class exported by the ns3 library is enclosed in the ns3 namespace.