A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-socket.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006 Georgia Tech Research Corporation
3 * 2007 INRIA
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 * Authors: George F. Riley<riley@ece.gatech.edu>
19 * Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20 */
21
22#ifndef TCP_SOCKET_H
23#define TCP_SOCKET_H
24
25#include "ns3/callback.h"
26#include "ns3/nstime.h"
27#include "ns3/object.h"
28#include "ns3/ptr.h"
29#include "ns3/socket.h"
30#include "ns3/traced-callback.h"
31
32namespace ns3
33{
34
35class Node;
36class Packet;
37
47class TcpSocket : public Socket
48{
49 public:
55 static TypeId GetTypeId();
56
57 TcpSocket();
58 ~TcpSocket() override;
59
66 {
67 CLOSED = 0,
70 SYN_RCVD,
76 LAST_ACK,
82 CLOSING,
84 TIME_WAIT,
90 };
91
95 static const char* const TcpStateName[TcpSocket::LAST_STATE];
96
97 private:
98 // Indirect the attribute setting and getting through private virtual methods
99
104 virtual void SetSndBufSize(uint32_t size) = 0;
105
110 virtual uint32_t GetSndBufSize() const = 0;
111
116 virtual void SetRcvBufSize(uint32_t size) = 0;
117
122 virtual uint32_t GetRcvBufSize() const = 0;
123
128 virtual void SetSegSize(uint32_t size) = 0;
129
134 virtual uint32_t GetSegSize() const = 0;
135
140 virtual void SetInitialSSThresh(uint32_t threshold) = 0;
141
146 virtual uint32_t GetInitialSSThresh() const = 0;
147
152 virtual void SetInitialCwnd(uint32_t cwnd) = 0;
153
158 virtual uint32_t GetInitialCwnd() const = 0;
159
164 virtual void SetConnTimeout(Time timeout) = 0;
165
170 virtual Time GetConnTimeout() const = 0;
171
176 virtual void SetSynRetries(uint32_t count) = 0;
177
182 virtual uint32_t GetSynRetries() const = 0;
183
188 virtual void SetDataRetries(uint32_t retries) = 0;
189
194 virtual uint32_t GetDataRetries() const = 0;
195
200 virtual void SetDelAckTimeout(Time timeout) = 0;
201
206 virtual Time GetDelAckTimeout() const = 0;
207
212 virtual void SetDelAckMaxCount(uint32_t count) = 0;
213
218 virtual uint32_t GetDelAckMaxCount() const = 0;
219
224 virtual void SetTcpNoDelay(bool noDelay) = 0;
225
230 virtual bool GetTcpNoDelay() const = 0;
231
241 virtual void SetPersistTimeout(Time timeout) = 0;
242
252 virtual Time GetPersistTimeout() const = 0;
253};
254
263 const TcpSocket::TcpStates_t newValue);
264
265} // namespace ns3
266
267#endif /* TCP_SOCKET_H */
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:68
(abstract) base class of all TcpSockets
Definition: tcp-socket.h:48
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.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
TcpStates_t
Names of the 11 TCP states.
Definition: tcp-socket.h:66
void(* TcpStatesTracedValueCallback)(const TcpSocket::TcpStates_t oldValue, const TcpSocket::TcpStates_t newValue)
TracedValue Callback signature for TcpStates_t.
Definition: tcp-socket.h:262
@ ESTABLISHED
Connection established
Definition: tcp-socket.h:72
@ FIN_WAIT_2
All buffered data sent, waiting for remote to shutdown.
Definition: tcp-socket.h:81
@ LISTEN
Listening for a connection
Definition: tcp-socket.h:68
@ LAST_STATE
Last state, used only in debug messages
Definition: tcp-socket.h:89
@ CLOSE_WAIT
Remote side has shutdown and is waiting for us to finish writing our data and to shutdown (we have to...
Definition: tcp-socket.h:73
@ SYN_SENT
Sent a connection request, waiting for ack
Definition: tcp-socket.h:69
@ CLOSED
Socket is finished
Definition: tcp-socket.h:67
@ FIN_WAIT_1
Our side has shutdown, waiting to complete transmission of remaining buffered data
Definition: tcp-socket.h:79
@ TIME_WAIT
Timeout to catch resent junk before entering closed, can only be entered from FIN_WAIT2 or CLOSING.
Definition: tcp-socket.h:84
@ SYN_RCVD
Received a connection request, sent ack, waiting for final ack in three-way handshake.
Definition: tcp-socket.h:70
@ LAST_ACK
Our side has shutdown after remote has shutdown.
Definition: tcp-socket.h:76
@ CLOSING
Both sides have shutdown but we still have data we have to finish sending
Definition: tcp-socket.h:82
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Time timeout