author | Gustavo J. A. M. Carneiro <gjc@inescporto.pt> |
Tue, 15 Jun 2010 18:29:45 +0100 | |
changeset 6437 | c11291f51d57 |
parent 6434 | ac8b4bf77e50 |
child 6442 | f380cf1aa4d8 |
permissions | -rw-r--r-- |
3578 | 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 "tcp-typedefs.h" |
|
31 |
#include "pending-data.h" |
|
6434
ac8b4bf77e50
Bug 385 - Add a generic "sequence number" class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6273
diff
changeset
|
32 |
#include "ns3/sequence-number.h" |
4740
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3778
diff
changeset
|
33 |
|
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3778
diff
changeset
|
34 |
struct INetStreamSocket; |
3578 | 35 |
|
36 |
namespace ns3 { |
|
37 |
||
38 |
class Ipv4EndPoint; |
|
39 |
class Node; |
|
40 |
class Packet; |
|
41 |
class NscTcpL4Protocol; |
|
42 |
class TcpHeader; |
|
43 |
||
3691 | 44 |
/** |
45 |
* \ingroup socket |
|
46 |
* \ingroup nsctcp |
|
47 |
* |
|
48 |
* \brief Socket logic for the NSC TCP sockets. |
|
49 |
* |
|
50 |
* Most of the TCP internal |
|
51 |
* logic is handled by the NSC tcp library itself; this class maps ns3::Socket |
|
52 |
* calls to the NSC TCP library. |
|
53 |
*/ |
|
3578 | 54 |
class NscTcpSocketImpl : public TcpSocket |
55 |
{ |
|
56 |
public: |
|
57 |
static TypeId GetTypeId (void); |
|
58 |
/** |
|
59 |
* Create an unbound tcp socket. |
|
60 |
*/ |
|
61 |
NscTcpSocketImpl (); |
|
62 |
NscTcpSocketImpl (const NscTcpSocketImpl& sock); |
|
63 |
virtual ~NscTcpSocketImpl (); |
|
64 |
||
65 |
void SetNode (Ptr<Node> node); |
|
66 |
void SetTcp (Ptr<NscTcpL4Protocol> tcp); |
|
67 |
||
68 |
virtual enum SocketErrno GetErrno (void) const; |
|
69 |
virtual Ptr<Node> GetNode (void) const; |
|
70 |
virtual int Bind (void); |
|
71 |
virtual int Bind (const Address &address); |
|
72 |
virtual int Close (void); |
|
73 |
virtual int ShutdownSend (void); |
|
74 |
virtual int ShutdownRecv (void); |
|
75 |
virtual int Connect(const Address &address); |
|
3772
f0d8608ab155
Remove queue limit from listen
Craig Dowell <craigdo@ee.washington.edu>
parents:
3691
diff
changeset
|
76 |
virtual int Listen(void); |
3578 | 77 |
virtual uint32_t GetTxAvailable (void) const; |
78 |
virtual int Send (Ptr<Packet> p, uint32_t flags); |
|
79 |
virtual int SendTo(Ptr<Packet> p, uint32_t flags, const Address &toAddress); |
|
80 |
virtual uint32_t GetRxAvailable (void) const; |
|
81 |
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags); |
|
82 |
virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, |
|
83 |
Address &fromAddress); |
|
3778
78c4c41557f3
Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
3772
diff
changeset
|
84 |
virtual int GetSockName (Address &address) const; |
6437
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6434
diff
changeset
|
85 |
virtual void SetAllowBroadcast (bool allowBroadcast); |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6434
diff
changeset
|
86 |
virtual bool GetAllowBroadcast () const; |
3578 | 87 |
|
88 |
private: |
|
89 |
void NSCWakeup(void); |
|
90 |
friend class Tcp; |
|
91 |
// invoked by Tcp class |
|
92 |
int FinishBind (void); |
|
5971
805783c866fc
Bug 748 - Cloned TCP socket uses wrong source address
Fabian Mauchle <f1mauchl@hsr.ch>
parents:
4740
diff
changeset
|
93 |
void ForwardUp (Ptr<Packet> p, Ipv4Address saddr, Ipv4Address daddr, uint16_t port); |
3578 | 94 |
void Destroy (void); |
95 |
//methods for state |
|
96 |
bool SendPendingData(void); |
|
97 |
bool ReadPendingData(void); |
|
98 |
bool Accept(void); |
|
99 |
void CompleteFork(void); |
|
100 |
void ConnectionSucceeded(); |
|
101 |
||
102 |
// Manage data tx/rx |
|
103 |
// XXX This should be virtual and overridden |
|
104 |
Ptr<NscTcpSocketImpl> Copy (); |
|
105 |
||
106 |
// attribute related |
|
107 |
virtual void SetSndBufSize (uint32_t size); |
|
108 |
virtual uint32_t GetSndBufSize (void) const; |
|
109 |
virtual void SetRcvBufSize (uint32_t size); |
|
110 |
virtual uint32_t GetRcvBufSize (void) const; |
|
111 |
virtual void SetSegSize (uint32_t size); |
|
112 |
virtual uint32_t GetSegSize (void) const; |
|
113 |
virtual void SetAdvWin (uint32_t window); |
|
114 |
virtual uint32_t GetAdvWin (void) const; |
|
115 |
virtual void SetSSThresh (uint32_t threshold); |
|
116 |
virtual uint32_t GetSSThresh (void) const; |
|
117 |
virtual void SetInitialCwnd (uint32_t cwnd); |
|
118 |
virtual uint32_t GetInitialCwnd (void) const; |
|
119 |
virtual void SetConnTimeout (Time timeout); |
|
120 |
virtual Time GetConnTimeout (void) const; |
|
121 |
virtual void SetConnCount (uint32_t count); |
|
122 |
virtual uint32_t GetConnCount (void) const; |
|
123 |
virtual void SetDelAckTimeout (Time timeout); |
|
124 |
virtual Time GetDelAckTimeout (void) const; |
|
125 |
virtual void SetDelAckMaxCount (uint32_t count); |
|
126 |
virtual uint32_t GetDelAckMaxCount (void) const; |
|
127 |
||
128 |
enum Socket::SocketErrno GetNativeNs3Errno(int err) const; |
|
129 |
uint32_t m_delAckMaxCount; |
|
130 |
Time m_delAckTimeout; |
|
131 |
||
132 |
Ipv4EndPoint *m_endPoint; |
|
133 |
Ptr<Node> m_node; |
|
134 |
Ptr<NscTcpL4Protocol> m_tcp; |
|
135 |
Ipv4Address m_remoteAddress; |
|
136 |
uint16_t m_remotePort; |
|
137 |
//these two are so that the socket/endpoint cloning works |
|
138 |
Ipv4Address m_localAddress; |
|
139 |
uint16_t m_localPort; |
|
140 |
InetSocketAddress m_peerAddress; |
|
141 |
enum SocketErrno m_errno; |
|
142 |
bool m_shutdownSend; |
|
143 |
bool m_shutdownRecv; |
|
144 |
bool m_connected; |
|
145 |
||
6273
8d70de29d514
spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents:
5971
diff
changeset
|
146 |
//manage the state information |
3578 | 147 |
States_t m_state; |
148 |
bool m_closeOnEmpty; |
|
149 |
||
150 |
//needed to queue data when in SYN_SENT state |
|
151 |
std::queue<Ptr<Packet> > m_txBuffer; |
|
152 |
uint32_t m_txBufferSize; |
|
153 |
||
154 |
// Window management |
|
155 |
uint32_t m_segmentSize; //SegmentSize |
|
156 |
uint32_t m_rxWindowSize; |
|
157 |
uint32_t m_advertisedWindowSize; //Window to advertise |
|
158 |
TracedValue<uint32_t> m_cWnd; //Congestion window |
|
159 |
uint32_t m_ssThresh; //Slow Start Threshold |
|
160 |
uint32_t m_initialCWnd; //Initial cWnd value |
|
161 |
||
162 |
// Round trip time estimation |
|
163 |
Time m_lastMeasuredRtt; |
|
164 |
||
165 |
// Timer-related members |
|
166 |
Time m_cnTimeout; |
|
167 |
uint32_t m_cnCount; |
|
168 |
||
169 |
// Temporary queue for delivering data to application |
|
170 |
std::queue<Ptr<Packet> > m_deliveryQueue; |
|
171 |
uint32_t m_rxAvailable; |
|
172 |
INetStreamSocket* m_nscTcpSocket; |
|
173 |
||
174 |
// Attributes |
|
175 |
uint32_t m_sndBufSize; // buffer limit for the outgoing queue |
|
176 |
uint32_t m_rcvBufSize; // maximum receive socket buffer size |
|
177 |
}; |
|
178 |
||
179 |
}//namespace ns3 |
|
180 |
||
181 |
#endif /* NSC_TCP_SOCKET_IMPL_H */ |