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 
46 class TcpSocket : public Socket
47 {
48 public:
54  static TypeId GetTypeId (void);
55 
56  TcpSocket (void);
57  virtual ~TcpSocket (void);
58 
64  typedef enum {
65  CLOSED = 0,
88  } TcpStates_t;
89 
93  static const char* const TcpStateName[TcpSocket::LAST_STATE];
94 
95 private:
96  // Indirect the attribute setting and getting through private virtual methods
97 
102  virtual void SetSndBufSize (uint32_t size) = 0;
103 
108  virtual uint32_t GetSndBufSize (void) const = 0;
109 
114  virtual void SetRcvBufSize (uint32_t size) = 0;
115 
120  virtual uint32_t GetRcvBufSize (void) const = 0;
121 
126  virtual void SetSegSize (uint32_t size) = 0;
127 
132  virtual uint32_t GetSegSize (void) const = 0;
133 
138  virtual void SetInitialSSThresh (uint32_t threshold) = 0;
139 
144  virtual uint32_t GetInitialSSThresh (void) const = 0;
145 
150  virtual void SetInitialCwnd (uint32_t cwnd) = 0;
151 
156  virtual uint32_t GetInitialCwnd (void) const = 0;
157 
162  virtual void SetConnTimeout (Time timeout) = 0;
163 
168  virtual Time GetConnTimeout (void) const = 0;
169 
174  virtual void SetConnCount (uint32_t count) = 0;
175 
180  virtual uint32_t GetConnCount (void) const = 0;
181 
186  virtual void SetDelAckTimeout (Time timeout) = 0;
187 
192  virtual Time GetDelAckTimeout (void) const = 0;
193 
198  virtual void SetDelAckMaxCount (uint32_t count) = 0;
199 
204  virtual uint32_t GetDelAckMaxCount (void) const = 0;
205 
210  virtual void SetTcpNoDelay (bool noDelay) = 0;
211 
216  virtual bool GetTcpNoDelay (void) const = 0;
217 
227  virtual void SetPersistTimeout (Time timeout) = 0;
228 
238  virtual Time GetPersistTimeout (void) const = 0;
239 
240 };
241 
249 typedef void (* TcpStatesTracedValueCallback)(const TcpSocket::TcpStates_t oldValue,
250  const TcpSocket::TcpStates_t newValue);
251 
252 } // namespace ns3
253 
254 #endif /* TCP_SOCKET_H */
255 
256 
virtual void SetSndBufSize(uint32_t size)=0
Set the send buffer size.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
(abstract) base class of all TcpSockets
Definition: tcp-socket.h:46
Connection established.
Definition: tcp-socket.h:70
Sent a connection request, waiting for ack.
Definition: tcp-socket.h:67
Socket is finished.
Definition: tcp-socket.h:65
virtual ~TcpSocket(void)
Definition: tcp-socket.cc:122
Received a connection request, sent ack, waiting for final ack in three-way handshake.
Definition: tcp-socket.h:68
Both sides have shutdown but we still have data we have to finish sending.
Definition: tcp-socket.h:80
virtual void SetInitialCwnd(uint32_t cwnd)=0
Set the initial Congestion Window.
virtual void SetRcvBufSize(uint32_t size)=0
Set the receive buffer size.
ns3::Time timeout
virtual void SetInitialSSThresh(uint32_t threshold)=0
Set the initial Slow Start Threshold.
virtual void SetPersistTimeout(Time timeout)=0
Set the timout for persistent connection.
Our side has shutdown, waiting to complete transmission of remaining buffered data.
Definition: tcp-socket.h:77
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:66
static const char *const TcpStateName[TcpSocket::LAST_STATE]
Literal names of TCP states for use in log messages.
Definition: tcp-socket.h:93
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-socket.cc:43
virtual uint32_t GetSndBufSize(void) const =0
Get the send buffer size.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Last state, used only in debug messages.
Definition: tcp-socket.h:87
virtual void SetDelAckMaxCount(uint32_t count)=0
Set the number of packet to fire an ACK before delay timeout.
virtual void SetTcpNoDelay(bool noDelay)=0
Enable/Disable Nagle's algorithm.
virtual uint32_t GetRcvBufSize(void) const =0
Get the receive buffer size.
All buffered data sent, waiting for remote to shutdown.
Definition: tcp-socket.h:79
virtual void SetDelAckTimeout(Time timeout)=0
Set the time to delay an ACK.
virtual void SetConnCount(uint32_t count)=0
Set the number of connection retries before giving up.
virtual uint32_t GetSegSize(void) const =0
Get the segment size.
virtual Time GetDelAckTimeout(void) const =0
Get the time to delay an ACK.
virtual bool GetTcpNoDelay(void) const =0
Check if Nagle's algorithm is enabled or not.
virtual void SetConnTimeout(Time timeout)=0
Set the connection timeout.
virtual uint32_t GetDelAckMaxCount(void) const =0
Get the number of packet to fire an ACK before delay timeout.
Timeout to catch resent junk before entering closed, can only be entered from FIN_WAIT2 or CLOSING...
Definition: tcp-socket.h:82
virtual Time GetConnTimeout(void) const =0
Get the connection timeout.
Remote side has shutdown and is waiting for us to finish writing our data and to shutdown (we have to...
Definition: tcp-socket.h:71
Listening for a connection.
Definition: tcp-socket.h:66
TcpStates_t
Names of the 11 TCP states.
Definition: tcp-socket.h:64
virtual void SetSegSize(uint32_t size)=0
Set the segment size.
void(* TcpStatesTracedValueCallback)(const TcpSocket::TcpStates_t oldValue, const TcpSocket::TcpStates_t newValue)
TracedValue Callback signature for TcpStates_t.
Definition: tcp-socket.h:249
Our side has shutdown after remote has shutdown.
Definition: tcp-socket.h:74
a unique identifier for an interface.
Definition: type-id.h:58
virtual uint32_t GetInitialCwnd(void) const =0
Get the initial Congestion Window.
virtual uint32_t GetInitialSSThresh(void) const =0
Get the initial Slow Start Threshold.
virtual Time GetPersistTimeout(void) const =0
Get the timout for persistent connection.
virtual uint32_t GetConnCount(void) const =0
Get the number of connection retries before giving up.