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
nsc-tcp-socket-impl.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* This program is free software; you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License version 2 as
5
* published by the Free Software Foundation;
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
*/
16
#ifndef NSC_TCP_SOCKET_IMPL_H
17
#define NSC_TCP_SOCKET_IMPL_H
18
19
#include <stdint.h>
20
#include <queue>
21
#include <vector>
22
23
#include "ns3/callback.h"
24
#include "ns3/traced-value.h"
25
#include "ns3/tcp-socket.h"
26
#include "ns3/ptr.h"
27
#include "ns3/ipv4-address.h"
28
#include "ns3/inet-socket-address.h"
29
#include "ns3/event-id.h"
30
#include "
pending-data.h
"
31
#include "ns3/sequence-number.h"
32
33
struct
INetStreamSocket
;
34
35
namespace
ns3 {
36
37
class
Ipv4EndPoint;
38
class
Node;
39
class
Packet;
40
class
NscTcpL4Protocol;
41
class
TcpHeader;
42
53
class
NscTcpSocketImpl
:
public
TcpSocket
54
{
55
public
:
56
static
TypeId
GetTypeId
(
void
);
60
NscTcpSocketImpl
();
61
NscTcpSocketImpl
(
const
NscTcpSocketImpl
& sock);
62
virtual
~NscTcpSocketImpl
();
63
64
void
SetNode
(
Ptr<Node>
node);
65
void
SetTcp
(
Ptr<NscTcpL4Protocol>
tcp);
66
67
virtual
enum
SocketErrno
GetErrno
(
void
)
const
;
68
virtual
enum
SocketType
GetSocketType
(
void
)
const
;
69
virtual
Ptr<Node>
GetNode
(
void
)
const
;
70
virtual
int
Bind
(
void
);
71
virtual
int
Bind6
(
void
);
72
virtual
int
Bind
(
const
Address
&address);
73
virtual
int
Close
(
void
);
74
virtual
int
ShutdownSend
(
void
);
75
virtual
int
ShutdownRecv
(
void
);
76
virtual
int
Connect
(
const
Address
&address);
77
virtual
int
Listen
(
void
);
78
virtual
uint32_t
GetTxAvailable
(
void
)
const
;
79
virtual
int
Send
(
Ptr<Packet>
p, uint32_t flags);
80
virtual
int
SendTo
(
Ptr<Packet>
p, uint32_t flags,
const
Address
&toAddress);
81
virtual
uint32_t
GetRxAvailable
(
void
)
const
;
82
virtual
Ptr<Packet>
Recv
(uint32_t maxSize, uint32_t flags);
83
virtual
Ptr<Packet>
RecvFrom
(uint32_t maxSize, uint32_t flags,
84
Address
&fromAddress);
85
virtual
int
GetSockName
(
Address
&address)
const
;
86
virtual
bool
SetAllowBroadcast
(
bool
allowBroadcast);
87
virtual
bool
GetAllowBroadcast
()
const
;
88
89
private
:
90
void
NSCWakeup
(
void
);
91
friend
class
Tcp
;
92
// invoked by Tcp class
93
int
FinishBind
(
void
);
94
void
ForwardUp
(
Ptr<Packet>
p,
Ipv4Header
header, uint16_t
port
,
95
Ptr<Ipv4Interface>
incomingInterface);
96
void
Destroy
(
void
);
97
//methods for state
98
bool
SendPendingData
(
void
);
99
bool
ReadPendingData
(
void
);
100
bool
Accept
(
void
);
101
void
CompleteFork
(
void
);
102
void
ConnectionSucceeded
();
103
104
// Manage data tx/rx
105
// XXX This should be virtual and overridden
106
Ptr<NscTcpSocketImpl>
Copy
();
107
108
// attribute related
109
virtual
void
SetSndBufSize
(uint32_t size);
110
virtual
uint32_t
GetSndBufSize
(
void
)
const
;
111
virtual
void
SetRcvBufSize
(uint32_t size);
112
virtual
uint32_t
GetRcvBufSize
(
void
)
const
;
113
virtual
void
SetSegSize
(uint32_t size);
114
virtual
uint32_t
GetSegSize
(
void
)
const
;
115
virtual
void
SetAdvWin
(uint32_t window);
116
virtual
uint32_t
GetAdvWin
(
void
)
const
;
117
virtual
void
SetSSThresh
(uint32_t threshold);
118
virtual
uint32_t
GetSSThresh
(
void
)
const
;
119
virtual
void
SetInitialCwnd
(uint32_t cwnd);
120
virtual
uint32_t
GetInitialCwnd
(
void
)
const
;
121
virtual
void
SetConnTimeout
(
Time
timeout
);
122
virtual
Time
GetConnTimeout
(
void
)
const
;
123
virtual
void
SetConnCount
(uint32_t count);
124
virtual
uint32_t
GetConnCount
(
void
)
const
;
125
virtual
void
SetDelAckTimeout
(
Time
timeout
);
126
virtual
Time
GetDelAckTimeout
(
void
)
const
;
127
virtual
void
SetDelAckMaxCount
(uint32_t count);
128
virtual
uint32_t
GetDelAckMaxCount
(
void
)
const
;
129
virtual
void
SetTcpNoDelay
(
bool
noDelay);
130
virtual
bool
GetTcpNoDelay
(
void
)
const
;
131
virtual
void
SetPersistTimeout
(
Time
timeout
);
132
virtual
Time
GetPersistTimeout
(
void
)
const
;
133
134
enum
Socket::SocketErrno
GetNativeNs3Errno
(
int
err)
const
;
135
uint32_t
m_delAckMaxCount
;
136
Time
m_delAckTimeout
;
137
bool
m_noDelay
;
138
139
Ipv4EndPoint
*
m_endPoint
;
140
Ptr<Node>
m_node
;
141
Ptr<NscTcpL4Protocol>
m_tcp
;
142
Ipv4Address
m_remoteAddress
;
143
uint16_t
m_remotePort
;
144
//these two are so that the socket/endpoint cloning works
145
Ipv4Address
m_localAddress
;
146
uint16_t
m_localPort
;
147
InetSocketAddress
m_peerAddress
;
148
enum
SocketErrno
m_errno
;
149
bool
m_shutdownSend
;
150
bool
m_shutdownRecv
;
151
bool
m_connected
;
152
153
//manage the state information
154
TracedValue<TcpStates_t>
m_state
;
155
bool
m_closeOnEmpty
;
156
157
//needed to queue data when in SYN_SENT state
158
std::queue<Ptr<Packet> >
m_txBuffer
;
159
uint32_t
m_txBufferSize
;
160
161
// Window management
162
uint32_t
m_segmentSize
;
//SegmentSize
163
uint32_t
m_rxWindowSize
;
164
uint32_t
m_advertisedWindowSize
;
//Window to advertise
165
TracedValue<uint32_t>
m_cWnd
;
//Congestion window
166
uint32_t
m_ssThresh
;
//Slow Start Threshold
167
uint32_t
m_initialCWnd
;
//Initial cWnd value
168
169
// Round trip time estimation
170
Time
m_lastMeasuredRtt
;
171
172
// Timer-related members
173
Time
m_cnTimeout
;
174
uint32_t
m_cnCount
;
175
Time
m_persistTimeout
;
176
177
// Temporary queue for delivering data to application
178
std::queue<Ptr<Packet> >
m_deliveryQueue
;
179
uint32_t
m_rxAvailable
;
180
INetStreamSocket
*
m_nscTcpSocket
;
181
182
// Attributes
183
uint32_t
m_sndBufSize
;
// buffer limit for the outgoing queue
184
uint32_t
m_rcvBufSize
;
// maximum receive socket buffer size
185
};
186
187
}
// namespace ns3
188
189
#endif
/* NSC_TCP_SOCKET_IMPL_H */
src
internet
model
nsc-tcp-socket-impl.h
Generated on Tue Oct 9 2012 16:45:39 for ns-3 by
1.8.1.2