A Discrete-Event Network Simulator
API
tcp-socket.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006 Georgia Tech Research Corporation
4  * 2007 INRIA
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: George F. Riley<riley@ece.gatech.edu>
20  * Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
21  */
22 
23 #ifndef TCP_SOCKET_H
24 #define TCP_SOCKET_H
25 
26 #include "ns3/socket.h"
27 #include "ns3/traced-callback.h"
28 #include "ns3/callback.h"
29 #include "ns3/ptr.h"
30 #include "ns3/object.h"
31 #include "ns3/nstime.h"
32 
33 namespace ns3 {
34 
35 class Node;
36 class Packet;
37 
47 class TcpSocket : public Socket
48 {
49 public:
55  static TypeId GetTypeId (void);
56 
57  TcpSocket (void);
58  virtual ~TcpSocket (void);
59 
65  typedef enum {
66  CLOSED = 0,
69  SYN_RCVD,
72  CLOSE_WAIT,
75  LAST_ACK,
78  FIN_WAIT_1,
81  CLOSING,
83  TIME_WAIT,
88  LAST_STATE
90 
94  static const char* const TcpStateName[TcpSocket::LAST_STATE];
95 
96 private:
97  // Indirect the attribute setting and getting through private virtual methods
98 
103  virtual void SetSndBufSize (uint32_t size) = 0;
104 
109  virtual uint32_t GetSndBufSize (void) const = 0;
110 
115  virtual void SetRcvBufSize (uint32_t size) = 0;
116 
121  virtual uint32_t GetRcvBufSize (void) const = 0;
122 
127  virtual void SetSegSize (uint32_t size) = 0;
128 
133  virtual uint32_t GetSegSize (void) const = 0;
134 
139  virtual void SetInitialSSThresh (uint32_t threshold) = 0;
140 
145  virtual uint32_t GetInitialSSThresh (void) const = 0;
146 
151  virtual void SetInitialCwnd (uint32_t cwnd) = 0;
152 
157  virtual uint32_t GetInitialCwnd (void) const = 0;
158 
163  virtual void SetConnTimeout (Time timeout) = 0;
164 
169  virtual Time GetConnTimeout (void) const = 0;
170 
175  virtual void SetSynRetries (uint32_t count) = 0;
176 
181  virtual uint32_t GetSynRetries (void) const = 0;
182 
187  virtual void SetDataRetries (uint32_t retries) = 0;
188 
193  virtual uint32_t GetDataRetries (void) const = 0;
194 
199  virtual void SetDelAckTimeout (Time timeout) = 0;
200 
205  virtual Time GetDelAckTimeout (void) const = 0;
206 
211  virtual void SetDelAckMaxCount (uint32_t count) = 0;
212 
217  virtual uint32_t GetDelAckMaxCount (void) const = 0;
218 
223  virtual void SetTcpNoDelay (bool noDelay) = 0;
224 
229  virtual bool GetTcpNoDelay (void) const = 0;
230 
240  virtual void SetPersistTimeout (Time timeout) = 0;
241 
251  virtual Time GetPersistTimeout (void) const = 0;
252 
253 };
254 
262 typedef void (* TcpStatesTracedValueCallback)(const TcpSocket::TcpStates_t oldValue,
263  const TcpSocket::TcpStates_t newValue);
264 
265 } // namespace ns3
266 
267 #endif /* TCP_SOCKET_H */
268 
269 
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:67
(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 ~TcpSocket(void)
Definition: tcp-socket.cc:131
virtual bool GetTcpNoDelay(void) const =0
Check if Nagle's algorithm is enabled or not.
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:94
virtual Time GetPersistTimeout(void) const =0
Get the timeout for persistent connection.
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-socket.cc:45
virtual void SetDelAckMaxCount(uint32_t count)=0
Set the number of packet to fire an ACK before delay timeout.
virtual uint32_t GetDataRetries(void) const =0
Get the number of data transmission retries before giving up.
virtual void SetPersistTimeout(Time timeout)=0
Set the timeout for persistent connection.
virtual uint32_t GetInitialSSThresh(void) const =0
Get the initial Slow Start Threshold.
virtual uint32_t GetDelAckMaxCount(void) const =0
Get the number of packet to fire an ACK before delay timeout.
virtual uint32_t GetSynRetries(void) const =0
Get the number of connection retries before giving up.
virtual uint32_t GetSegSize(void) const =0
Get the segment size.
virtual void SetSegSize(uint32_t size)=0
Set the segment size.
virtual uint32_t GetSndBufSize(void) const =0
Get the send buffer size.
virtual uint32_t GetRcvBufSize(void) const =0
Get the receive buffer size.
virtual void SetSndBufSize(uint32_t size)=0
Set the send buffer size.
virtual Time GetConnTimeout(void) const =0
Get the connection timeout.
virtual void SetDataRetries(uint32_t retries)=0
Set the number of data transmission retries before giving up.
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 Time GetDelAckTimeout(void) const =0
Get the time to delay an ACK.
virtual uint32_t GetInitialCwnd(void) const =0
Get the initial Congestion Window.
virtual void SetInitialCwnd(uint32_t cwnd)=0
Set the initial Congestion Window.
virtual void SetSynRetries(uint32_t count)=0
Set the number of connection retries before giving up.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
a unique identifier for an interface.
Definition: type-id.h:59
TcpStates_t
Names of the 11 TCP states.
Definition: tcp-socket.h:65
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:71
@ FIN_WAIT_2
All buffered data sent, waiting for remote to shutdown.
Definition: tcp-socket.h:80
@ LISTEN
Listening for a connection
Definition: tcp-socket.h:67
@ LAST_STATE
Last state, used only in debug messages
Definition: tcp-socket.h:88
@ 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:72
@ SYN_SENT
Sent a connection request, waiting for ack
Definition: tcp-socket.h:68
@ CLOSED
Socket is finished
Definition: tcp-socket.h:66
@ FIN_WAIT_1
Our side has shutdown, waiting to complete transmission of remaining buffered data
Definition: tcp-socket.h:78
@ TIME_WAIT
Timeout to catch resent junk before entering closed, can only be entered from FIN_WAIT2 or CLOSING.
Definition: tcp-socket.h:83
@ SYN_RCVD
Received a connection request, sent ack, waiting for final ack in three-way handshake.
Definition: tcp-socket.h:69
@ LAST_ACK
Our side has shutdown after remote has shutdown.
Definition: tcp-socket.h:75
@ CLOSING
Both sides have shutdown but we still have data we have to finish sending
Definition: tcp-socket.h:81
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Time timeout