Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(308)

Unified Diff: src/internet/model/tcp-socket-base.h

Issue 299130043: TCP SACK + SACK emulation
Patch Set: Fixed NextSeg Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/internet/model/tcp-rx-buffer.cc ('k') | src/internet/model/tcp-socket-base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/internet/model/tcp-socket-base.h
diff --git a/src/internet/model/tcp-socket-base.h b/src/internet/model/tcp-socket-base.h
index 0e37d7c51e5c51854787a56e1b99a48150541943..6e0c8f9221c04519a279a34b4c9b8efd110b9899 100644
--- a/src/internet/model/tcp-socket-base.h
+++ b/src/internet/model/tcp-socket-base.h
@@ -126,12 +126,12 @@ public:
CA_OPEN, /**< Normal state, no dubious events */
CA_DISORDER, /**< In all the respects it is "Open",
* but requires a bit more attention. It is entered when
- * we see some SACKs or dupacks. It is split of "Open" */
+ * we see some Sacks or dupacks. It is split of "Open" */
CA_CWR, /**< cWnd was reduced due to some Congestion Notification event.
* It can be ECN, ICMP source quench, local device congestion.
* Not used in NS-3 right now. */
CA_RECOVERY, /**< CWND was reduced, we are fast-retransmitting. */
- CA_LOSS, /**< CWND was reduced due to RTO timeout or SACK reneging. */
+ CA_LOSS, /**< CWND was reduced due to RTO timeout or sack reneging. */
CA_LAST_STATE /**< Used only in debug messages */
} TcpCongState_t;
@@ -192,11 +192,11 @@ public:
* \brief A base class for implementation of a stream socket using TCP.
*
* This class contains the essential components of TCP, as well as a sockets
- * interface for upper layers to call. This serves as a base for other TCP
- * functions where the sliding window mechanism is handled here. This class
- * provides connection orientation and sliding window flow control. Part of
- * this class is modified from the original NS-3 TCP socket implementation
- * (TcpSocketImpl) by Raj Bhattacharjea <raj.b@gatech.edu> of Georgia Tech.
+ * interface for upper layers to call. This class provides connection orientation
+ * and sliding window flow control; congestion control is delegated to subclasses
+ * of TcpCongestionOps. Part of TcpSocketBase is modified from the original
+ * NS-3 TCP socket implementation (TcpSocketImpl) by
+ * Raj Bhattacharjea <raj.b@gatech.edu> of Georgia Tech.
*
* For IPv4 packets, the TOS set for the socket is used. The Bind and Connect
* operations set the TOS for the socket to the value specified in the provided
@@ -228,7 +228,12 @@ public:
* Congestion control, unlike older releases of ns-3, has been splitted from
* TcpSocketBase. In particular, each congestion control is now a subclass of
* the main TcpCongestionOps class. Switching between congestion algorithm is
- * now a matter of setting a pointer into the TcpSocketBase class.
+ * now a matter of setting a pointer into the TcpSocketBase class. The idea
+ * and the interfaces are inspired by the Linux operating system, and in
+ * particular from the structure tcp_congestion_ops.
+ *
+ * Transmission Control Block (TCB)
+ * --------------------------------
*
* The variables needed to congestion control classes to operate correctly have
* been moved inside the TcpSocketState class. It contains information on the
@@ -240,7 +245,7 @@ public:
* (see for example cWnd trace source).
*
* Fast retransmit
- * ---------------------------
+ * ----------------
*
* The fast retransmit enhancement is introduced in RFC 2581 and updated in
* RFC 5681. It basically reduces the time a sender waits before retransmitting
@@ -250,20 +255,45 @@ public:
* RFC 3042.
*
* In ns-3, these algorithms are included in this class, and it is implemented inside
- * the ReceivedAck method. The attribute which manages the number of dup ACKs
+ * the ProcessAck method. The attribute which manages the number of dup ACKs
* necessary to start the fast retransmit algorithm is named "ReTxThreshold",
* and its default value is 3, while the Limited Transmit one can be enabled
- * by setting the attribute "LimitedTransmit" to true.
+ * by setting the attribute "LimitedTransmit" to true. Before entering the
+ * recovery phase, the method EnterRecovery is called.
*
* Fast recovery
- * --------------------------
+ * -------------
*
* The fast recovery algorithm is introduced RFC 2001, and it basically
* avoids to reset cWnd to 1 segment after sensing a loss on the channel. Instead,
* the slow start threshold is halved, and the cWnd is set equal to such value,
* plus segments for the cWnd inflation.
*
- * The algorithm is implemented in the ReceivedAck method.
+ * The algorithm is implemented in the ProcessAck method.
+ *
+ * RTO expiration
+ * --------------
+ *
+ * When the Retransmission Time Out expires, the TCP faces a big performance
+ * drop. The expiration event is managed in ReTxTimeout method, that basically
+ * set the cWnd to 1 segment and start "from scratch" again.
+ *
+ * Options management
+ * ------------------
+ *
+ * SYN and SYN-ACK options, that are allowed only at the beginning of the
+ * connection, are managed in the DoForwardUp and SendEmptyPacket methods.
+ * To read all others, we have setup a cycle inside ReadOptions. For adding
+ * them, there is no a unique place, since the options (and the informations
+ * available to build them) are scattered around the code. For instance,
+ * the SACK option is built in SendEmptyPacket only under a certain conditions.
+ *
+ * SACK
+ * ----
+ *
+ * The SACK generation/management is delegated to the buffer classes, namely
+ * TcpTxBuffer and TcpRxBuffer. Please take a look on their documentation if
+ * you need more informations.
*
*/
class TcpSocketBase : public TcpSocket
@@ -603,9 +633,9 @@ protected:
* Note that this function did not implement the PSH flag.
*
* \param withAck forces an ACK to be sent
- * \returns true if some data have been sent
+ * \returns the number of packets sent
*/
- bool SendPendingData (bool withAck = false);
+ uint32_t SendPendingData (bool withAck = false);
/**
* \brief Extract at most maxSize bytes from the TxBuffer at sequence seq, add the
@@ -768,15 +798,21 @@ protected:
/**
* \brief Return count of number of unacked bytes
+ *
+ * The difference between SND.UNA and HighTx
+ *
* \returns count of number of unacked bytes
*/
virtual uint32_t UnAckDataCount (void) const;
/**
* \brief Return total bytes in flight
+ *
+ * Does not count segments lost and SACKed (or dupACKed)
+ *
* \returns total bytes in flight
*/
- virtual uint32_t BytesInFlight (void);
+ virtual uint32_t BytesInFlight (void) const;
/**
* \brief Return the max possible number of unacked bytes
@@ -829,6 +865,14 @@ protected:
virtual void ReceivedAck (Ptr<Packet> packet, const TcpHeader& tcpHeader);
/**
+ * \brief Process a received ack
+ * \param ackNumber ack number
+ * \param scoreboardUpdated if true indicates that the scoreboard has been
+ * updated with SACK information
+ */
+ virtual void ProcessAck (const SequenceNumber32 &ackNumber, bool scoreboardUpdated);
+
+ /**
* \brief Recv of a data, put into buffer, call L7 to get it if necessary
* \param packet the packet
* \param tcpHeader the packet's TCP header
@@ -870,21 +914,16 @@ protected:
void LimitedTransmit ();
/**
- * \brief Enter the FastRetransmit, and retransmit the head
+ * \brief Enter the CA_RECOVERY, and retransmit the head
*/
- void FastRetransmit ();
+ void EnterRecovery ();
/**
- * \brief Call Retransmit() upon RTO event
+ * \brief An RTO event happened
*/
virtual void ReTxTimeout (void);
/**
- * \brief Halving cwnd and call DoRetransmit()
- */
- virtual void Retransmit (void);
-
- /**
* \brief Action upon delay ACK timeout, i.e. send an ACK
*/
virtual void DelAckTimeout (void);
@@ -919,8 +958,10 @@ protected:
* Timestamp and Window scale are managed in other pieces of code.
*
* \param tcpHeader Header of the segment
+ * \param scoreboardUpdated indicates if the scoreboard was updated due to a
+ * SACK option
*/
- void ReadOptions (const TcpHeader &tcpHeader);
+ void ReadOptions (const TcpHeader &tcpHeader, bool &scoreboardUpdated);
/**
* \brief Return true if the specified option is enabled
@@ -958,6 +999,37 @@ protected:
*/
uint8_t CalculateWScale () const;
+ /**
+ * \brief Read the sack permitted option
+ *
+ * Currently this is a placeholder, since no operations should be done
+ * on such option.
+ *
+ * \param sack permitted option from the header
+ */
+ void ProcessOptionSackPermitted (const Ptr<const TcpOption> option);
+
+ /**
+ * \brief Read the sack option
+ *
+ * \param sack option from the header
+ */
+ bool ProcessOptionSack (const Ptr<const TcpOption> option);
+
+ /**
+ * \brief Add the sack permitted option to the header
+ *
+ * \param header TcpHeader where the method should add the option
+ */
+ void AddOptionSackPermitted (TcpHeader &header);
+
+ /**
+ * \brief Add the sack option to the header
+ *
+ * \param header TcpHeader where the method should add the option
+ */
+ void AddOptionSack (TcpHeader& header);
+
/** \brief Process the timestamp option from other side
*
* Get the timestamp and the echo, then save timestamp (which will
@@ -1049,6 +1121,7 @@ protected:
TracedValue<uint32_t> m_bytesInFlight; //!< Bytes in flight
// Options
+ bool m_sackEnabled; //!< RFC Sack option enabled
bool m_winScalingEnabled; //!< Window Scale option enabled (RFC 7323)
uint8_t m_rcvWindShift; //!< Window shift to apply to outgoing segments
uint8_t m_sndWindShift; //!< Window shift to apply to incoming segments
@@ -1062,7 +1135,6 @@ protected:
SequenceNumber32 m_recover; //!< Previous highest Tx seqnum for fast recovery
uint32_t m_retxThresh; //!< Fast Retransmit threshold
bool m_limitedTx; //!< perform limited transmit
- uint32_t m_retransOut; //!< Number of retransmission in this window
// Transmission Control Block
Ptr<TcpSocketState> m_tcb; //!< Congestion control informations
« no previous file with comments | « src/internet/model/tcp-rx-buffer.cc ('k') | src/internet/model/tcp-socket-base.cc » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b