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 
44 typedef enum {
45  CLOSED, // 0
46  LISTEN, // 1
47  SYN_SENT, // 2
48  SYN_RCVD, // 3
50  CLOSE_WAIT, // 5
51  LAST_ACK, // 6
52  FIN_WAIT_1, // 7
53  FIN_WAIT_2, // 8
54  CLOSING, // 9
55  TIME_WAIT, // 10
57 } TcpStates_t;
58 
66 typedef void (* TcpStatesTracedValueCallback)(const TcpStates_t oldValue,
67  const TcpStates_t newValue);
68 
77 class TcpSocket : public Socket
78 {
79 public:
85  static TypeId GetTypeId (void);
86 
87  TcpSocket (void);
88  virtual ~TcpSocket (void);
89 
93  static const char* const TcpStateName[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 
242 } // namespace ns3
243 
244 #endif /* TCP_SOCKET_H */
245 
246 
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:77
virtual ~TcpSocket(void)
Definition: tcp-socket.cc:118
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.
void(* TcpStatesTracedValueCallback)(const TcpStates_t oldValue, const TcpStates_t newValue)
TracedValue Callback signature for TcpStates_t.
Definition: tcp-socket.h:66
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:66
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-socket.cc:39
static const char *const TcpStateName[LAST_STATE]
Literal names of TCP states for use in log messages.
Definition: tcp-socket.h:93
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.
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.
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.
virtual Time GetConnTimeout(void) const =0
Get the connection timeout.
TcpStates_t
Names of the 11 TCP states.
Definition: tcp-socket.h:44
virtual void SetSegSize(uint32_t size)=0
Set the segment size.
a unique identifier for an interface.
Definition: type-id.h:57
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.