A Discrete-Event Network Simulator
API
tcp-socket-state.cc
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 #include "tcp-socket-state.h"
18 
19 namespace ns3
20 {
21 
22 NS_OBJECT_ENSURE_REGISTERED(TcpSocketState);
23 
24 TypeId
26 {
27  static TypeId tid =
28  TypeId("ns3::TcpSocketState")
29  .SetParent<Object>()
30  .SetGroupName("Internet")
31  .AddConstructor<TcpSocketState>()
32  .AddAttribute("EnablePacing",
33  "Enable Pacing",
34  BooleanValue(false),
37  .AddAttribute("MaxPacingRate",
38  "Set Max Pacing Rate",
39  DataRateValue(DataRate("4Gb/s")),
40  MakeDataRateAccessor(&TcpSocketState::m_maxPacingRate),
41  MakeDataRateChecker())
42  .AddAttribute("PacingSsRatio",
43  "Percent pacing rate increase for slow start conditions",
44  UintegerValue(200),
46  MakeUintegerChecker<uint16_t>())
47  .AddAttribute("PacingCaRatio",
48  "Percent pacing rate increase for congestion avoidance conditions",
49  UintegerValue(120),
51  MakeUintegerChecker<uint16_t>())
52  .AddAttribute("PaceInitialWindow",
53  "Perform pacing for initial window of data",
54  BooleanValue(false),
57  .AddTraceSource("PacingRate",
58  "The current TCP pacing rate",
60  "ns3::TracedValueCallback::DataRate")
61  .AddTraceSource("CongestionWindow",
62  "The TCP connection's congestion window",
64  "ns3::TracedValueCallback::Uint32")
65  .AddTraceSource("CongestionWindowInflated",
66  "The TCP connection's inflated congestion window",
68  "ns3::TracedValueCallback::Uint32")
69  .AddTraceSource("SlowStartThreshold",
70  "TCP slow start threshold (bytes)",
72  "ns3::TracedValueCallback::Uint32")
73  .AddTraceSource("CongState",
74  "TCP Congestion machine state",
76  "ns3::TracedValueCallback::TcpCongState")
77  .AddTraceSource("EcnState",
78  "Trace ECN state change of socket",
80  "ns3::TracedValueCallback::EcnState")
81  .AddTraceSource("HighestSequence",
82  "Highest sequence number received from peer",
84  "ns3::TracedValueCallback::SequenceNumber32")
85  .AddTraceSource("NextTxSequence",
86  "Next sequence number to send (SND.NXT)",
88  "ns3::TracedValueCallback::SequenceNumber32")
89  .AddTraceSource("BytesInFlight",
90  "The TCP connection's congestion window",
92  "ns3::TracedValueCallback::Uint32")
93  .AddTraceSource("RTT",
94  "Last RTT sample",
96  "ns3::TracedValueCallback::Time");
97  return tid;
98 }
99 
101  : Object(other),
102  m_cWnd(other.m_cWnd),
103  m_ssThresh(other.m_ssThresh),
104  m_initialCWnd(other.m_initialCWnd),
105  m_initialSsThresh(other.m_initialSsThresh),
106  m_segmentSize(other.m_segmentSize),
107  m_lastAckedSeq(other.m_lastAckedSeq),
108  m_congState(other.m_congState),
109  m_ecnState(other.m_ecnState),
110  m_highTxMark(other.m_highTxMark),
111  m_nextTxSequence(other.m_nextTxSequence),
112  m_rcvTimestampValue(other.m_rcvTimestampValue),
113  m_rcvTimestampEchoReply(other.m_rcvTimestampEchoReply),
114  m_pacing(other.m_pacing),
115  m_maxPacingRate(other.m_maxPacingRate),
116  m_pacingRate(other.m_pacingRate),
117  m_pacingSsRatio(other.m_pacingSsRatio),
118  m_pacingCaRatio(other.m_pacingCaRatio),
119  m_paceInitialWindow(other.m_paceInitialWindow),
120  m_minRtt(other.m_minRtt),
121  m_bytesInFlight(other.m_bytesInFlight),
122  m_lastRtt(other.m_lastRtt),
123  m_ecnMode(other.m_ecnMode),
124  m_useEcn(other.m_useEcn),
125  m_ectCodePoint(other.m_ectCodePoint),
126  m_lastAckedSackedBytes(other.m_lastAckedSackedBytes)
127 
128 {
129 }
130 
132  "CA_OPEN",
133  "CA_DISORDER",
134  "CA_CWR",
135  "CA_RECOVERY",
136  "CA_LOSS",
137 };
138 
140  "ECN_DISABLED",
141  "ECN_IDLE",
142  "ECN_CE_RCVD",
143  "ECN_SENDING_ECE",
144  "ECN_ECE_RCVD",
145  "ECN_CWR_SENT",
146 };
147 
148 } // namespace ns3
A base class which provides memory management and object aggregation.
Definition: object.h:89
Data structure that records the congestion state of a connection.
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
TracedValue< DataRate > m_pacingRate
Current Pacing rate.
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.
bool m_pacing
Pacing status.
static TypeId GetTypeId()
Get the type ID.
static const char *const TcpCongStateName[TcpSocketState::CA_LAST_STATE]
Literal names of TCP states for use in log messages.
@ CA_LAST_STATE
Used only in debug messages.
TracedValue< uint32_t > m_cWnd
Congestion window.
TracedValue< Time > m_lastRtt
Last RTT sample collected.
@ ECN_CWR_SENT
Sender has reduced the congestion window, and sent a packet with CWR 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)
uint16_t m_pacingCaRatio
CA pacing ratio.
TracedValue< SequenceNumber32 > m_nextTxSequence
Next seqnum to be sent (SND.NXT), ReTx pushes it back.
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.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
Hold an unsigned integer type.
Definition: uinteger.h:45
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Definition: data-rate.h:327
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:86
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46