A Discrete-Event Network Simulator
API
tcp-socket-state.cc
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 #include "tcp-socket-state.h"
19 
20 namespace ns3 {
21 
22 NS_OBJECT_ENSURE_REGISTERED (TcpSocketState);
23 
24 TypeId
26 {
27  static TypeId tid = TypeId ("ns3::TcpSocketState")
28  .SetParent<Object> ()
29  .SetGroupName ("Internet")
30  .AddConstructor <TcpSocketState> ()
31  .AddAttribute ("EnablePacing", "Enable Pacing",
32  BooleanValue (false),
35  .AddAttribute ("MaxPacingRate", "Set Max Pacing Rate",
36  DataRateValue (DataRate ("4Gb/s")),
39  .AddAttribute ("PacingSsRatio", "Percent pacing rate increase for slow start conditions",
40  UintegerValue (200),
42  MakeUintegerChecker<uint16_t> ())
43  .AddAttribute ("PacingCaRatio", "Percent pacing rate increase for congestion avoidance conditions",
44  UintegerValue (120),
46  MakeUintegerChecker<uint16_t> ())
47  .AddAttribute ("PaceInitialWindow", "Perform pacing for initial window of data",
48  BooleanValue (false),
51  .AddTraceSource ("PacingRate",
52  "The current TCP pacing rate",
54  "ns3::TracedValueCallback::DataRate")
55  .AddTraceSource ("CongestionWindow",
56  "The TCP connection's congestion window",
58  "ns3::TracedValueCallback::Uint32")
59  .AddTraceSource ("CongestionWindowInflated",
60  "The TCP connection's inflated congestion window",
62  "ns3::TracedValueCallback::Uint32")
63  .AddTraceSource ("SlowStartThreshold",
64  "TCP slow start threshold (bytes)",
66  "ns3::TracedValueCallback::Uint32")
67  .AddTraceSource ("CongState",
68  "TCP Congestion machine state",
70  "ns3::TracedValueCallback::TcpCongState")
71  .AddTraceSource ("EcnState",
72  "Trace ECN state change of socket",
74  "ns3::TracedValueCallback::EcnState")
75  .AddTraceSource ("HighestSequence",
76  "Highest sequence number received from peer",
78  "ns3::TracedValueCallback::SequenceNumber32")
79  .AddTraceSource ("NextTxSequence",
80  "Next sequence number to send (SND.NXT)",
82  "ns3::TracedValueCallback::SequenceNumber32")
83  .AddTraceSource ("BytesInFlight",
84  "The TCP connection's congestion window",
86  "ns3::TracedValueCallback::Uint32")
87  .AddTraceSource ("RTT",
88  "Last RTT sample",
90  "ns3::TracedValueCallback::Time")
91  ;
92  return tid;
93 }
94 
96  : Object (other),
97  m_cWnd (other.m_cWnd),
98  m_ssThresh (other.m_ssThresh),
99  m_initialCWnd (other.m_initialCWnd),
100  m_initialSsThresh (other.m_initialSsThresh),
101  m_segmentSize (other.m_segmentSize),
102  m_lastAckedSeq (other.m_lastAckedSeq),
103  m_congState (other.m_congState),
104  m_ecnState (other.m_ecnState),
105  m_highTxMark (other.m_highTxMark),
106  m_nextTxSequence (other.m_nextTxSequence),
107  m_rcvTimestampValue (other.m_rcvTimestampValue),
108  m_rcvTimestampEchoReply (other.m_rcvTimestampEchoReply),
109  m_pacing (other.m_pacing),
110  m_maxPacingRate (other.m_maxPacingRate),
111  m_pacingRate (other.m_pacingRate),
112  m_pacingSsRatio (other.m_pacingSsRatio),
113  m_pacingCaRatio (other.m_pacingCaRatio),
114  m_paceInitialWindow (other.m_paceInitialWindow),
115  m_minRtt (other.m_minRtt),
116  m_bytesInFlight (other.m_bytesInFlight),
117  m_lastRtt (other.m_lastRtt),
118  m_ecnMode (other.m_ecnMode),
119  m_useEcn (other.m_useEcn),
120  m_ectCodePoint (other.m_ectCodePoint),
121  m_lastAckedSackedBytes (other.m_lastAckedSackedBytes)
122 
123 {
124 }
125 
126 const char* const
128 {
129  "CA_OPEN", "CA_DISORDER", "CA_CWR", "CA_RECOVERY", "CA_LOSS"
130 };
131 
132 const char* const
134 {
135  "ECN_DISABLED", "ECN_IDLE", "ECN_CE_RCVD", "ECN_SENDING_ECE", "ECN_ECE_RCVD", "ECN_CWR_SENT"
136 };
137 
138 } //namespace ns3
AttributeValue implementation for Boolean.
Definition: boolean.h:36
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
bool m_pacing
Pacing status.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: boolean.h:85
static const char *const EcnStateName[TcpSocketState::ECN_CWR_SENT+1]
Literal names of ECN states for use in log messages.
static const char *const TcpCongStateName[TcpSocketState::CA_LAST_STATE]
Literal names of TCP states for use in log messages.
TracedValue< EcnState_t > m_ecnState
Current ECN State, represented as combination of EcnState values.
TcpSocketState()
TcpSocketState Constructor.
Data structure that records the congestion state of a connection.
bool m_paceInitialWindow
Enable/Disable pacing for the initial window.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Class for representing data rates.
Definition: data-rate.h:88
TracedValue< uint32_t > m_cWndInfl
Inflated congestion window trace (used only for backward compatibility purpose)
TracedValue< DataRate > m_pacingRate
Current Pacing rate.
Hold an unsigned integer type.
Definition: uinteger.h:44
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: data-rate.h:298
TracedValue< uint32_t > m_bytesInFlight
Bytes in flight.
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
Ptr< const AttributeChecker > MakeDataRateChecker(void)
Definition: data-rate.cc:30
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Used only in debug messages.
TracedValue< TcpCongState_t > m_congState
State in the Congestion state machine.
static TypeId GetTypeId(void)
Get the type ID.
TracedValue< uint32_t > m_cWnd
Congestion window.
Sender has reduced the congestion window, and sent a packet with CWR bit set in TCP header...
uint16_t m_pacingSsRatio
SS pacing ratio.
AttributeValue implementation for DataRate.
Definition: data-rate.h:298
TracedValue< Time > m_lastRtt
Last RTT sample collected.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
uint16_t m_pacingCaRatio
CA pacing ratio.
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
A base class which provides memory management and object aggregation.
Definition: object.h:87
DataRate m_maxPacingRate
Max Pacing rate.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
TracedValue< SequenceNumber32 > m_nextTxSequence
Next seqnum to be sent (SND.NXT), ReTx pushes it back.