A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
34
NS_OBJECT_ENSURE_REGISTERED
(TcpSocket);
35
36
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"
};
37
38
TypeId
39
TcpSocket::GetTypeId
(
void
)
40
{
41
static
TypeId
tid =
TypeId
(
"ns3::TcpSocket"
)
42
.
SetParent
<
Socket
> ()
43
.AddAttribute (
"SndBufSize"
,
44
"TcpSocket maximum transmit buffer size (bytes)"
,
45
UintegerValue
(131072),
// 128k
46
MakeUintegerAccessor (&
TcpSocket::GetSndBufSize
,
47
&
TcpSocket::SetSndBufSize
),
48
MakeUintegerChecker<uint32_t> ())
49
.AddAttribute (
"RcvBufSize"
,
50
"TcpSocket maximum receive buffer size (bytes)"
,
51
UintegerValue
(131072),
52
MakeUintegerAccessor (&
TcpSocket::GetRcvBufSize
,
53
&
TcpSocket::SetRcvBufSize
),
54
MakeUintegerChecker<uint32_t> ())
55
.AddAttribute (
"SegmentSize"
,
56
"TCP maximum segment size in bytes (may be adjusted based on MTU discovery)"
,
57
UintegerValue
(536),
58
MakeUintegerAccessor (&
TcpSocket::GetSegSize
,
59
&
TcpSocket::SetSegSize
),
60
MakeUintegerChecker<uint32_t> ())
61
.AddAttribute (
"SlowStartThreshold"
,
62
"TCP slow start threshold (bytes)"
,
63
UintegerValue
(0xffff),
64
MakeUintegerAccessor (&
TcpSocket::GetSSThresh
,
65
&
TcpSocket::SetSSThresh
),
66
MakeUintegerChecker<uint32_t> ())
67
.AddAttribute (
"InitialCwnd"
,
68
"TCP initial congestion window size (segments)"
,
69
UintegerValue
(1),
70
MakeUintegerAccessor (&
TcpSocket::GetInitialCwnd
,
71
&
TcpSocket::SetInitialCwnd
),
72
MakeUintegerChecker<uint32_t> ())
73
.AddAttribute (
"ConnTimeout"
,
74
"TCP retransmission timeout when opening connection (seconds)"
,
75
TimeValue
(
Seconds
(3)),
76
MakeTimeAccessor (&
TcpSocket::GetConnTimeout
,
77
&
TcpSocket::SetConnTimeout
),
78
MakeTimeChecker ())
79
.AddAttribute (
"ConnCount"
,
80
"Number of connection attempts (SYN retransmissions) before returning failure"
,
81
UintegerValue
(6),
82
MakeUintegerAccessor (&
TcpSocket::GetConnCount
,
83
&
TcpSocket::SetConnCount
),
84
MakeUintegerChecker<uint32_t> ())
85
.AddAttribute (
"DelAckTimeout"
,
86
"Timeout value for TCP delayed acks, in seconds"
,
87
TimeValue
(
Seconds
(0.2)),
88
MakeTimeAccessor (&
TcpSocket::GetDelAckTimeout
,
89
&
TcpSocket::SetDelAckTimeout
),
90
MakeTimeChecker ())
91
.AddAttribute (
"DelAckCount"
,
92
"Number of packets to wait before sending a TCP ack"
,
93
UintegerValue
(2),
94
MakeUintegerAccessor (&
TcpSocket::GetDelAckMaxCount
,
95
&
TcpSocket::SetDelAckMaxCount
),
96
MakeUintegerChecker<uint32_t> ())
97
.AddAttribute (
"TcpNoDelay"
,
"Set to true to disable Nagle's algorithm"
,
98
BooleanValue
(
true
),
99
MakeBooleanAccessor (&
TcpSocket::GetTcpNoDelay
,
100
&
TcpSocket::SetTcpNoDelay
),
101
MakeBooleanChecker ())
102
.AddAttribute (
"PersistTimeout"
,
103
"Persist timeout to probe for rx window"
,
104
TimeValue
(
Seconds
(6)),
105
MakeTimeAccessor (&
TcpSocket::GetPersistTimeout
,
106
&
TcpSocket::SetPersistTimeout
),
107
MakeTimeChecker ())
108
;
109
return
tid;
110
}
111
112
TcpSocket::TcpSocket
()
113
{
114
NS_LOG_FUNCTION_NOARGS
();
115
}
116
117
TcpSocket::~TcpSocket
()
118
{
119
NS_LOG_FUNCTION_NOARGS
();
120
}
121
122
}
// namespace ns3
src
internet
model
tcp-socket.cc
Generated on Tue Nov 13 2012 10:32:15 for ns-3 by
1.8.1.2