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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 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 |
183 virtual void ReTxTimeout (void); // Call Retransmit() upon RTO event | 168 virtual void ReTxTimeout (void); // Call Retransmit() upon RTO event |
184 virtual void Retransmit (void); // Halving cwnd and call DoRetransmit() | 169 virtual void Retransmit (void); // Halving cwnd and call DoRetransmit() |
185 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 |
186 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 |
187 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 |
188 virtual void DoRetransmit (void); // Retransmit the oldest packet | 173 virtual void DoRetransmit (void); // Retransmit the oldest packet |
189 | 174 |
190 protected: | 175 protected: |
191 // Counters and events | 176 // Counters and events |
192 EventId m_retxEvent; //< Retransmission event | 177 EventId m_retxEvent; //< Retransmission event |
193 EventId m_lastAckEvent; //< Last ACK timeout event | 178 EventId m_lastAckEvent; //< Last ACK timeout event |
194 EventId m_delAckEvent; //< Delayed ACK timeout event | 179 EventId m_delAckEvent; //< Delayed ACK timeout event |
195 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 |
196 uint32_t m_dupAckCount; //< Dupack counter | 181 uint32_t m_dupAckCount; //< Dupack counter |
197 uint32_t m_delAckCount; //< Delayed ACK counter | 182 uint32_t m_delAckCount; //< Delayed ACK counter |
198 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 |
199 uint32_t m_cnCount; //< Count of remaining connection retries | 184 uint32_t m_cnCount; //< Count of remaining connection retries |
200 Time m_delAckTimeout; //< Time to delay an ACK | 185 TracedValue<Time> m_rto; //< Retransmit timeout |
201 Time m_persistTimeout; //< Time between sending 1-byte probes | 186 TracedValue<Time> m_lastRtt; //< Last RTT sample collected |
202 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 |
203 | 190 |
204 // Connections to other layers of TCP/IP | 191 // Connections to other layers of TCP/IP |
205 Ipv4EndPoint* m_endPoint; | 192 Ipv4EndPoint* m_endPoint; |
206 Ptr<Node> m_node; | 193 Ptr<Node> m_node; |
207 Ptr<TcpL4Protocol> m_tcp; | 194 Ptr<TcpL4Protocol> m_tcp; |
208 | 195 |
209 // Round trip time estimation | 196 // Round trip time estimation |
210 Ptr<RttEstimator> m_rtt; | 197 Ptr<RttEstimator> m_rtt; |
211 | 198 |
212 // Rx and Tx buffer management | 199 // Rx and Tx buffer management |
213 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 |
214 SequenceNumber32 m_highTxMark; //< Highest seqno ever sent, regardless of
ReTx | 201 TracedValue<SequenceNumber32> m_highTxMark; //< Highest seqno ever sent, r
egardless of ReTx |
215 TcpRxBuffer m_rxBuffer; //< Rx buffer (reordering buffer) | 202 TcpRxBuffer m_rxBuffer; //< Rx buffer (reordering buff
er) |
216 TcpTxBuffer m_txBuffer; //< Tx buffer | 203 TcpTxBuffer m_txBuffer; //< Tx buffer |
217 | 204 |
218 // State-related attributes | 205 // State-related attributes |
219 States_t m_state; //< TCP state | 206 TracedValue<TcpStates_t> m_state; //< TCP state |
220 enum SocketErrno m_errno; //< Socket error code | 207 enum SocketErrno m_errno; //< Socket error code |
221 bool m_closeNotified; //< Told app to close socket | 208 bool m_closeNotified; //< Told app to close socket |
222 bool m_closeOnEmpty; //< Close socket upon tx buffer emptied | 209 bool m_closeOnEmpty; //< Close socket upon tx buffer empt
ied |
223 bool m_shutdownSend; //< Send no longer allowed | 210 bool m_shutdownSend; //< Send no longer allowed |
224 bool m_shutdownRecv; //< Receive no longer allowed | 211 bool m_shutdownRecv; //< Receive no longer allowed |
225 bool m_connected; //< Connection established | 212 bool m_connected; //< Connection established |
226 | 213 |
227 // Window management | 214 // Window management |
228 uint32_t m_segmentSize; //< SegmentSize | 215 uint32_t m_segmentSize; //< Segment size |
229 uint32_t m_rxWindowSize; //< Flow control window at remote side | 216 TracedValue<uint32_t> m_rWnd; //< Flow control window at remote side |
230 | |
231 // Literal names of TCP states for use in log messages */ | |
232 static const char* const TcpStateName[LAST_STATE]; | |
233 }; | 217 }; |
234 | 218 |
235 } // namespace ns3 | 219 } // namespace ns3 |
236 | 220 |
237 #endif /* TCP_SOCKET_BASE_H */ | 221 #endif /* TCP_SOCKET_BASE_H */ |
LEFT | RIGHT |