A Discrete-Event Network Simulator
API
tcp-socket.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 INRIA
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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18  */
19 
20 #define __STDC_LIMIT_MACROS
21 
22 #include "tcp-socket.h"
23 
24 #include "ns3/boolean.h"
25 #include "ns3/double.h"
26 #include "ns3/log.h"
27 #include "ns3/nstime.h"
28 #include "ns3/object.h"
29 #include "ns3/trace-source-accessor.h"
30 #include "ns3/uinteger.h"
31 
32 namespace ns3
33 {
34 
35 NS_LOG_COMPONENT_DEFINE("TcpSocket");
36 
38 
40  "CLOSED",
41  "LISTEN",
42  "SYN_SENT",
43  "SYN_RCVD",
44  "ESTABLISHED",
45  "CLOSE_WAIT",
46  "LAST_ACK",
47  "FIN_WAIT_1",
48  "FIN_WAIT_2",
49  "CLOSING",
50  "TIME_WAIT",
51 };
52 
53 TypeId
55 {
56  static TypeId tid =
57  TypeId("ns3::TcpSocket")
58  .SetParent<Socket>()
59  .SetGroupName("Internet")
60  .AddAttribute(
61  "SndBufSize",
62  "TcpSocket maximum transmit buffer size (bytes)",
63  UintegerValue(131072), // 128k
65  MakeUintegerChecker<uint32_t>())
66  .AddAttribute(
67  "RcvBufSize",
68  "TcpSocket maximum receive buffer size (bytes)",
69  UintegerValue(131072),
71  MakeUintegerChecker<uint32_t>())
72  .AddAttribute(
73  "SegmentSize",
74  "TCP maximum segment size in bytes (may be adjusted based on MTU discovery)",
75  UintegerValue(536),
77  MakeUintegerChecker<uint32_t>())
78  .AddAttribute("InitialSlowStartThreshold",
79  "TCP initial slow start threshold (bytes)",
83  MakeUintegerChecker<uint32_t>())
84  .AddAttribute(
85  "InitialCwnd",
86  "TCP initial congestion window size (segments)",
87  UintegerValue(10),
89  MakeUintegerChecker<uint32_t>())
90  .AddAttribute("ConnTimeout",
91  "TCP retransmission timeout when opening connection (seconds)",
92  TimeValue(Seconds(3)),
95  .AddAttribute(
96  "ConnCount",
97  "Number of connection attempts (SYN retransmissions) before "
98  "returning failure",
99  UintegerValue(6),
101  MakeUintegerChecker<uint32_t>())
102  .AddAttribute(
103  "DataRetries",
104  "Number of data retransmission attempts",
105  UintegerValue(6),
107  MakeUintegerChecker<uint32_t>())
108  .AddAttribute(
109  "DelAckTimeout",
110  "Timeout value for TCP delayed acks, in seconds",
111  TimeValue(Seconds(0.2)),
113  MakeTimeChecker())
114  .AddAttribute(
115  "DelAckCount",
116  "Number of packets to wait before sending a TCP ack",
117  UintegerValue(2),
119  MakeUintegerChecker<uint32_t>())
120  .AddAttribute("TcpNoDelay",
121  "Set to true to disable Nagle's algorithm",
122  BooleanValue(true),
125  .AddAttribute(
126  "PersistTimeout",
127  "Persist timeout to probe for rx window",
128  TimeValue(Seconds(6)),
130  MakeTimeChecker());
131  return tid;
132 }
133 
135 {
136  NS_LOG_FUNCTION(this);
137 }
138 
140 {
141  NS_LOG_FUNCTION(this);
142 }
143 
144 } // namespace ns3
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:68
virtual void SetInitialSSThresh(uint32_t threshold)=0
Set the initial Slow Start Threshold.
virtual uint32_t GetDataRetries() const =0
Get the number of data transmission retries before giving up.
virtual uint32_t GetRcvBufSize() const =0
Get the receive buffer size.
~TcpSocket() override
Definition: tcp-socket.cc:139
virtual uint32_t GetSndBufSize() const =0
Get the send buffer size.
virtual void SetRcvBufSize(uint32_t size)=0
Set the receive buffer size.
static const char *const TcpStateName[TcpSocket::LAST_STATE]
Literal names of TCP states for use in log messages.
Definition: tcp-socket.h:95
virtual Time GetPersistTimeout() const =0
Get the timeout for persistent connection.
virtual uint32_t GetInitialCwnd() const =0
Get the initial Congestion Window.
virtual uint32_t GetDelAckMaxCount() const =0
Get the number of packet to fire an ACK before delay timeout.
virtual void SetDelAckMaxCount(uint32_t count)=0
Set the number of packet to fire an ACK before delay timeout.
virtual void SetPersistTimeout(Time timeout)=0
Set the timeout for persistent connection.
virtual Time GetDelAckTimeout() const =0
Get the time to delay an ACK.
virtual uint32_t GetSynRetries() const =0
Get the number of connection retries before giving up.
virtual uint32_t GetInitialSSThresh() const =0
Get the initial Slow Start Threshold.
virtual void SetSegSize(uint32_t size)=0
Set the segment size.
virtual void SetSndBufSize(uint32_t size)=0
Set the send buffer size.
virtual uint32_t GetSegSize() const =0
Get the segment size.
virtual void SetDataRetries(uint32_t retries)=0
Set the number of data transmission retries before giving up.
static TypeId GetTypeId()
Get the type ID.
Definition: tcp-socket.cc:54
virtual void SetDelAckTimeout(Time timeout)=0
Set the time to delay an ACK.
virtual void SetConnTimeout(Time timeout)=0
Set the connection timeout.
virtual void SetTcpNoDelay(bool noDelay)=0
Enable/Disable Nagle's algorithm.
virtual void SetInitialCwnd(uint32_t cwnd)=0
Set the initial Congestion Window.
virtual bool GetTcpNoDelay() const =0
Check if Nagle's algorithm is enabled or not.
virtual void SetSynRetries(uint32_t count)=0
Set the number of connection retries before giving up.
virtual Time GetConnTimeout() const =0
Get the connection timeout.
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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
@ LAST_STATE
Last state, used only in debug messages
Definition: tcp-socket.h:89
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1414
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:533
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:86
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46