LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2010 Adrian Sai-wah Tam | 3 * Copyright (c) 2010 Adrian Sai-wah Tam |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "tcp-rx-buffer.h" | 34 #include "tcp-rx-buffer.h" |
35 #include "rtt-estimator.h" | 35 #include "rtt-estimator.h" |
36 | 36 |
37 namespace ns3 { | 37 namespace ns3 { |
38 | 38 |
39 class Ipv4EndPoint; | 39 class Ipv4EndPoint; |
40 class Node; | 40 class Node; |
41 class Packet; | 41 class Packet; |
42 class TcpL4Protocol; | 42 class TcpL4Protocol; |
43 class TcpHeader; | 43 class TcpHeader; |
44 | |
45 /* Names of the 11 TCP states */ | |
46 typedef enum { | |
47 CLOSED, // 0 | |
48 LISTEN, // 1 | |
49 SYN_SENT, // 2 | |
50 SYN_RCVD, // 3 | |
51 ESTABLISHED, // 4 | |
52 CLOSE_WAIT, // 5 | |
53 LAST_ACK, // 6 | |
54 FIN_WAIT_1, // 7 | |
55 FIN_WAIT_2, // 8 | |
56 CLOSING, // 9 | |
57 TIME_WAIT, // 10 | |
58 LAST_STATE } States_t; | |
59 | 44 |
60 /** | 45 /** |
61 * \ingroup socket | 46 * \ingroup socket |
62 * \ingroup tcp | 47 * \ingroup tcp |
63 * | 48 * |
64 * \brief A base class for implementation of a stream socket using TCP. | 49 * \brief A base class for implementation of a stream socket using TCP. |
65 * | 50 * |
66 * This class contains the essential components of TCP, as well as a sockets | 51 * This class contains the essential components of TCP, as well as a sockets |
67 * interface for upper layers to call. This serves as a base for other TCP | 52 * interface for upper layers to call. This serves as a base for other TCP |
68 * functions where the sliding window mechanism is handled here. This class | 53 * functions where the sliding window mechanism is handled here. This class |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 virtual uint32_t UnAckDataCount (void); // Return count of number of una
cked bytes | 155 virtual uint32_t UnAckDataCount (void); // Return count of number of una
cked bytes |
171 virtual uint32_t BytesInFlight (void); // Return total bytes in flight | 156 virtual uint32_t BytesInFlight (void); // Return total bytes in flight |
172 virtual uint32_t Window (void); // Return the max possible numbe
r of unacked bytes | 157 virtual uint32_t Window (void); // Return the max possible numbe
r of unacked bytes |
173 virtual uint32_t AvailableWindow (void); // Return unfilled portion of wi
ndow | 158 virtual uint32_t AvailableWindow (void); // Return unfilled portion of wi
ndow |
174 virtual uint16_t AdvertisedWindowSize (void); // The amount of Rx window annou
nced to the peer | 159 virtual uint16_t AdvertisedWindowSize (void); // The amount of Rx window annou
nced to the peer |
175 | 160 |
176 // Manage data tx/rx | 161 // Manage data tx/rx |
177 virtual Ptr<TcpSocketBase> Fork (void) = 0; // Call CopyObject<> to clone me | 162 virtual Ptr<TcpSocketBase> Fork (void) = 0; // Call CopyObject<> to clone me |
178 virtual void ReceivedAck (Ptr<Packet>, const TcpHeader&); // Received an ACK p
acket | 163 virtual void ReceivedAck (Ptr<Packet>, const TcpHeader&); // Received an ACK p
acket |
179 virtual void ReceivedData (Ptr<Packet>, const TcpHeader&); // Recv of a data,
put into buffer, call L7 to get it if necessary | 164 virtual void ReceivedData (Ptr<Packet>, const TcpHeader&); // Recv of a data,
put into buffer, call L7 to get it if necessary |
| 165 virtual void EstimateRtt (const TcpHeader&); // RTT accounting |
180 virtual void NewAck (SequenceNumber32 const& seq); // Update buffers w.r.t. AC
K | 166 virtual void NewAck (SequenceNumber32 const& seq); // Update buffers w.r.t. AC
K |
181 virtual void DupAck (const TcpHeader& t, uint32_t count) = 0; // Received dupa
ck | 167 virtual void DupAck (const TcpHeader& t, uint32_t count) = 0; // Received dupa
ck |
182 virtual void ReTxTimeout (void); // Call Retransmit() upon RTO event | 168 virtual void ReTxTimeout (void); // Call Retransmit() upon RTO event |
183 virtual void Retransmit (void); // Halving cwnd and call DoRetransmit() | 169 virtual void Retransmit (void); // Halving cwnd and call DoRetransmit() |
184 virtual void DelAckTimeout (void); // Action upon delay ACK timeout, i.e. sen
d an ACK | 170 virtual void DelAckTimeout (void); // Action upon delay ACK timeout, i.e. sen
d an ACK |
185 virtual void LastAckTimeout (void); // Timeout at LAST_ACK, close the connecti
on | 171 virtual void LastAckTimeout (void); // Timeout at LAST_ACK, close the connecti
on |
186 virtual void PersistTimeout (void); // Send 1 byte probe to get an updated win
dow size | 172 virtual void PersistTimeout (void); // Send 1 byte probe to get an updated win
dow size |
187 virtual void DoRetransmit (void); // Retransmit the oldest packet | 173 virtual void DoRetransmit (void); // Retransmit the oldest packet |
188 | 174 |
189 protected: | 175 protected: |
190 // Counters and events | 176 // Counters and events |
191 EventId m_retxEvent; //< Retransmission event | 177 EventId m_retxEvent; //< Retransmission event |
192 EventId m_lastAckEvent; //< Last ACK timeout event | 178 EventId m_lastAckEvent; //< Last ACK timeout event |
193 EventId m_delAckEvent; //< Delayed ACK timeout event | 179 EventId m_delAckEvent; //< Delayed ACK timeout event |
194 EventId m_persistEvent; //< Persist event: Send 1 byte to probe for a non-
zero Rx window | 180 EventId m_persistEvent; //< Persist event: Send 1 byte to probe f
or a non-zero Rx window |
195 uint32_t m_dupAckCount; //< Dupack counter | 181 uint32_t m_dupAckCount; //< Dupack counter |
196 uint32_t m_delAckCount; //< Delayed ACK counter | 182 uint32_t m_delAckCount; //< Delayed ACK counter |
197 uint32_t m_delAckMaxCount; //< Number of packet to fire an ACK before delay t
imeout | 183 uint32_t m_delAckMaxCount; //< Number of packet to fire an ACK befor
e delay timeout |
198 uint32_t m_cnCount; //< Count of remaining connection retries | 184 uint32_t m_cnCount; //< Count of remaining connection retries |
199 Time m_delAckTimeout; //< Time to delay an ACK | 185 TracedValue<Time> m_rto; //< Retransmit timeout |
200 Time m_persistTimeout; //< Time between sending 1-byte probes | 186 TracedValue<Time> m_lastRtt; //< Last RTT sample collected |
201 Time m_cnTimeout; //< Timeout for connection retry | 187 Time m_delAckTimeout; //< Time to delay an ACK |
| 188 Time m_persistTimeout; //< Time between sending 1-byte probes |
| 189 Time m_cnTimeout; //< Timeout for connection retry |
202 | 190 |
203 // Connections to other layers of TCP/IP | 191 // Connections to other layers of TCP/IP |
204 Ipv4EndPoint* m_endPoint; | 192 Ipv4EndPoint* m_endPoint; |
205 Ptr<Node> m_node; | 193 Ptr<Node> m_node; |
206 Ptr<TcpL4Protocol> m_tcp; | 194 Ptr<TcpL4Protocol> m_tcp; |
207 | 195 |
208 // Round trip time estimation | 196 // Round trip time estimation |
209 Ptr<RttEstimator> m_rtt; | 197 Ptr<RttEstimator> m_rtt; |
210 | 198 |
211 // Rx and Tx buffer management | 199 // Rx and Tx buffer management |
212 SequenceNumber32 m_nextTxSequence; //< Next seqnum to be sent (SND.NXT), ReTx
pushes it back | 200 TracedValue<SequenceNumber32> m_nextTxSequence; //< Next seqnum to be sent (SN
D.NXT), ReTx pushes it back |
213 SequenceNumber32 m_highTxMark; //< Highest seqno ever sent, regardless of
ReTx | 201 TracedValue<SequenceNumber32> m_highTxMark; //< Highest seqno ever sent, r
egardless of ReTx |
214 TcpRxBuffer m_rxBuffer; //< Rx buffer (reordering buffer) | 202 TcpRxBuffer m_rxBuffer; //< Rx buffer (reordering buff
er) |
215 TcpTxBuffer m_txBuffer; //< Tx buffer | 203 TcpTxBuffer m_txBuffer; //< Tx buffer |
216 | 204 |
217 // State-related attributes | 205 // State-related attributes |
218 States_t m_state; //< TCP state | 206 TracedValue<TcpStates_t> m_state; //< TCP state |
219 enum SocketErrno m_errno; //< Socket error code | 207 enum SocketErrno m_errno; //< Socket error code |
220 bool m_closeNotified; //< Told app to close socket | 208 bool m_closeNotified; //< Told app to close socket |
221 bool m_closeOnEmpty; //< Close socket upon tx buffer emptied | 209 bool m_closeOnEmpty; //< Close socket upon tx buffer empt
ied |
222 bool m_shutdownSend; //< Send no longer allowed | 210 bool m_shutdownSend; //< Send no longer allowed |
223 bool m_shutdownRecv; //< Receive no longer allowed | 211 bool m_shutdownRecv; //< Receive no longer allowed |
224 bool m_connected; //< Connection established | 212 bool m_connected; //< Connection established |
225 | 213 |
226 // Window management | 214 // Window management |
227 uint32_t m_segmentSize; //< SegmentSize | 215 uint32_t m_segmentSize; //< Segment size |
228 uint32_t m_rxWindowSize; //< Flow control window at remote side | 216 TracedValue<uint32_t> m_rWnd; //< Flow control window at remote side |
229 | |
230 // Literal names of TCP states for use in log messages */ | |
231 static const char* const TcpStateName[LAST_STATE]; | |
232 }; | 217 }; |
233 | 218 |
234 } // namespace ns3 | 219 } // namespace ns3 |
235 | 220 |
236 #endif /* TCP_SOCKET_BASE_H */ | 221 #endif /* TCP_SOCKET_BASE_H */ |
LEFT | RIGHT |