A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-socket.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
9#define __STDC_LIMIT_MACROS
10
11#include "tcp-socket.h"
12
13#include "ns3/boolean.h"
14#include "ns3/double.h"
15#include "ns3/log.h"
16#include "ns3/nstime.h"
17#include "ns3/object.h"
18#include "ns3/trace-source-accessor.h"
19#include "ns3/uinteger.h"
20
21namespace ns3
22{
23
24NS_LOG_COMPONENT_DEFINE("TcpSocket");
25
27
29 "CLOSED",
30 "LISTEN",
31 "SYN_SENT",
32 "SYN_RCVD",
33 "ESTABLISHED",
34 "CLOSE_WAIT",
35 "LAST_ACK",
36 "FIN_WAIT_1",
37 "FIN_WAIT_2",
38 "CLOSING",
39 "TIME_WAIT",
40};
41
42TypeId
44{
45 static TypeId tid =
46 TypeId("ns3::TcpSocket")
48 .SetGroupName("Internet")
49 .AddAttribute(
50 "SndBufSize",
51 "TcpSocket maximum transmit buffer size (bytes)",
52 UintegerValue(131072), // 128k
55 .AddAttribute(
56 "RcvBufSize",
57 "TcpSocket maximum receive buffer size (bytes)",
58 UintegerValue(131072),
61 .AddAttribute(
62 "SegmentSize",
63 "TCP maximum segment size in bytes (may be adjusted based on MTU discovery)",
64 UintegerValue(536),
67 .AddAttribute("InitialSlowStartThreshold",
68 "TCP initial slow start threshold (bytes)",
69 UintegerValue(UINT32_MAX),
73 .AddAttribute(
74 "InitialCwnd",
75 "TCP initial congestion window size (segments)",
76 UintegerValue(10),
79 .AddAttribute("ConnTimeout",
80 "TCP retransmission timeout when opening connection (seconds)",
84 .AddAttribute(
85 "ConnCount",
86 "Number of connection attempts (SYN retransmissions) before "
87 "returning failure",
91 .AddAttribute(
92 "DataRetries",
93 "Number of data retransmission attempts",
97 .AddAttribute(
98 "DelAckTimeout",
99 "Timeout value for TCP delayed acks, in seconds",
100 TimeValue(Seconds(0.2)),
103 .AddAttribute(
104 "DelAckCount",
105 "Number of packets to wait before sending a TCP ack",
106 UintegerValue(2),
109 .AddAttribute("TcpNoDelay",
110 "Set to true to disable Nagle's algorithm",
111 BooleanValue(true),
114 .AddAttribute(
115 "PersistTimeout",
116 "Persist timeout to probe for rx window",
117 TimeValue(Seconds(6)),
120 return tid;
121}
122
127
132
133} // namespace ns3
AttributeValue implementation for Boolean.
Definition boolean.h:26
A low-level Socket API based loosely on the BSD Socket API.
Definition socket.h:57
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
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:84
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:43
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.
AttributeValue implementation for Time.
Definition nstime.h:1431
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition boolean.cc:113
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:70
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition nstime.h:1432
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1452
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
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:35
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:35
@ LAST_STATE
Last state, used only in debug messages
Definition tcp-socket.h:78
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
Every class exported by the ns3 library is enclosed in the ns3 namespace.