A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tcp-socket.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #include "ns3/object.h"
22 #include "ns3/log.h"
23 #include "ns3/uinteger.h"
24 #include "ns3/double.h"
25 #include "ns3/boolean.h"
26 #include "ns3/trace-source-accessor.h"
27 #include "ns3/nstime.h"
28 #include "tcp-socket.h"
29 
30 NS_LOG_COMPONENT_DEFINE ("TcpSocket");
31 
32 namespace ns3 {
33 
35  ;
36 
37 const char* const TcpSocket::TcpStateName[LAST_STATE] = { "CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD", "ESTABLISHED", "CLOSE_WAIT", "LAST_ACK", "FIN_WAIT_1", "FIN_WAIT_2", "CLOSING", "TIME_WAIT" };
38 
39 TypeId
41 {
42  static TypeId tid = TypeId ("ns3::TcpSocket")
43  .SetParent<Socket> ()
44  .AddAttribute ("SndBufSize",
45  "TcpSocket maximum transmit buffer size (bytes)",
46  UintegerValue (131072), // 128k
47  MakeUintegerAccessor (&TcpSocket::GetSndBufSize,
49  MakeUintegerChecker<uint32_t> ())
50  .AddAttribute ("RcvBufSize",
51  "TcpSocket maximum receive buffer size (bytes)",
52  UintegerValue (131072),
53  MakeUintegerAccessor (&TcpSocket::GetRcvBufSize,
55  MakeUintegerChecker<uint32_t> ())
56  .AddAttribute ("SegmentSize",
57  "TCP maximum segment size in bytes (may be adjusted based on MTU discovery)",
58  UintegerValue (536),
59  MakeUintegerAccessor (&TcpSocket::GetSegSize,
61  MakeUintegerChecker<uint32_t> ())
62  .AddAttribute ("SlowStartThreshold",
63  "TCP slow start threshold (bytes)",
64  UintegerValue (0xffff),
65  MakeUintegerAccessor (&TcpSocket::GetSSThresh,
67  MakeUintegerChecker<uint32_t> ())
68  .AddAttribute ("InitialCwnd",
69  "TCP initial congestion window size (segments)",
70  UintegerValue (1),
71  MakeUintegerAccessor (&TcpSocket::GetInitialCwnd,
73  MakeUintegerChecker<uint32_t> ())
74  .AddAttribute ("ConnTimeout",
75  "TCP retransmission timeout when opening connection (seconds)",
76  TimeValue (Seconds (3)),
77  MakeTimeAccessor (&TcpSocket::GetConnTimeout,
79  MakeTimeChecker ())
80  .AddAttribute ("ConnCount",
81  "Number of connection attempts (SYN retransmissions) before returning failure",
82  UintegerValue (6),
83  MakeUintegerAccessor (&TcpSocket::GetConnCount,
85  MakeUintegerChecker<uint32_t> ())
86  .AddAttribute ("DelAckTimeout",
87  "Timeout value for TCP delayed acks, in seconds",
88  TimeValue (Seconds (0.2)),
89  MakeTimeAccessor (&TcpSocket::GetDelAckTimeout,
91  MakeTimeChecker ())
92  .AddAttribute ("DelAckCount",
93  "Number of packets to wait before sending a TCP ack",
94  UintegerValue (2),
95  MakeUintegerAccessor (&TcpSocket::GetDelAckMaxCount,
97  MakeUintegerChecker<uint32_t> ())
98  .AddAttribute ("TcpNoDelay", "Set to true to disable Nagle's algorithm",
99  BooleanValue (true),
100  MakeBooleanAccessor (&TcpSocket::GetTcpNoDelay,
102  MakeBooleanChecker ())
103  .AddAttribute ("PersistTimeout",
104  "Persist timeout to probe for rx window",
105  TimeValue (Seconds (6)),
106  MakeTimeAccessor (&TcpSocket::GetPersistTimeout,
108  MakeTimeChecker ())
109  ;
110  return tid;
111 }
112 
114 {
116 }
117 
119 {
121 }
122 
123 } // namespace ns3
virtual void SetSndBufSize(uint32_t size)=0
Set the send buffer size.
Hold a bool native type.
Definition: boolean.h:38
NS_LOG_COMPONENT_DEFINE("TcpSocket")
virtual void SetSSThresh(uint32_t threshold)=0
Set the Slow Start Threshold.
virtual ~TcpSocket(void)
Definition: tcp-socket.cc:118
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition: log.h:309
virtual void SetInitialCwnd(uint32_t cwnd)=0
Set the initial Congestion Window.
virtual void SetRcvBufSize(uint32_t size)=0
Set the receive buffer size.
virtual void SetPersistTimeout(Time timeout)=0
Set the timout for persistent connection.
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:40
static const char *const TcpStateName[LAST_STATE]
Literal names of TCP states for use in log messages.
Definition: tcp-socket.h:80
hold objects of type ns3::Time
Definition: nstime.h:961
Hold an unsigned integer type.
Definition: uinteger.h:46
virtual uint32_t GetSndBufSize(void) const =0
Get the send buffer size.
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 GetSSThresh(void) const =0
Get the Slow Start Threshold.
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.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:452
virtual void SetSegSize(uint32_t size)=0
Set the segment size.
a unique identifier for an interface.
Definition: type-id.h:49
virtual uint32_t GetInitialCwnd(void) const =0
Get the initial Congestion Window.
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
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.