diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index a6e5c6959..b7f905444 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -41,6 +41,7 @@ been tested on Linux. As of this release, the latest known version to work with - (core) !2018 - `AddDeprecatedName` is now supported in TypeId. - (energy) !2018 - Energy module now uses the `ns3::energy` namespace in its TypeId. - (lr-wpan) !2163 - Lr-wpan module now uses the `ns3::lrwpan` namespace in its TypeId. +- (internet) !2027 - TcpSocketBase: Added TCP retransmission trace ### Bugs fixed diff --git a/src/internet/model/tcp-socket-base.cc b/src/internet/model/tcp-socket-base.cc index 361dfb7f4..1fa7970ba 100644 --- a/src/internet/model/tcp-socket-base.cc +++ b/src/internet/model/tcp-socket-base.cc @@ -266,6 +266,10 @@ TcpSocketBase::GetTypeId() "Send tcp packet to IP protocol", MakeTraceSourceAccessor(&TcpSocketBase::m_txTrace), "ns3::TcpSocketBase::TcpTxRxTracedCallback") + .AddTraceSource("Retransmission", + "Notification of a TCP retransmission", + MakeTraceSourceAccessor(&TcpSocketBase::m_retransmissionTrace), + "ns3::TcpSocketBase::RetransmissionCallback") .AddTraceSource("Rx", "Receive tcp packet from IP protocol", MakeTraceSourceAccessor(&TcpSocketBase::m_rxTrace), @@ -3275,6 +3279,25 @@ TcpSocketBase::SendDataPacket(SequenceNumber32 seq, uint32_t maxSize, bool withA } m_txTrace(p, header, this); + if (isRetransmission) + { + if (m_endPoint) + { + m_retransmissionTrace(p, + header, + m_endPoint->GetLocalAddress(), + m_endPoint->GetPeerAddress(), + this); + } + else + { + m_retransmissionTrace(p, + header, + m_endPoint6->GetLocalAddress(), + m_endPoint6->GetPeerAddress(), + this); + } + } if (m_endPoint) { diff --git a/src/internet/model/tcp-socket-base.h b/src/internet/model/tcp-socket-base.h index c06bc1c99..a5cb1e7c7 100644 --- a/src/internet/model/tcp-socket-base.h +++ b/src/internet/model/tcp-socket-base.h @@ -641,7 +641,7 @@ class TcpSocketBase : public TcpSocket void BindToNetDevice(Ptr netdevice) override; // NetDevice with my m_endPoint /** - * TracedCallback signature for tcp packet transmission or reception events. + * TracedCallback signature for TCP packet transmission or reception events. * * \param [in] packet The packet. * \param [in] header The TcpHeader @@ -651,6 +651,21 @@ class TcpSocketBase : public TcpSocket const TcpHeader& header, const Ptr socket); + /** + * TracedCallback signature for TCP packet retransmission events. + * + * \param [in] packet The packet. + * \param [in] header The TcpHeader + * \param [in] localAddr The local address + * \param [in] peerAddr The peer/remote address + * \param [in] socket This socket + */ + typedef void (*RetransmissionCallback)(const Ptr packet, + const TcpHeader& header, + const Address& localAddr, + const Address& peerAddr, + const Ptr socket); + protected: // Implementing ns3::TcpSocket -- Attribute get/set // inherited, no need to doc @@ -1421,12 +1436,19 @@ class TcpSocketBase : public TcpSocket // Guesses over the other connection end bool m_isFirstPartialAck{true}; //!< First partial ACK during RECOVERY - // The following two traces pass a packet with a TCP header + // The following three traces pass a packet with a TCP header TracedCallback, const TcpHeader&, Ptr> m_txTrace; //!< Trace of transmitted packets + TracedCallback, + const TcpHeader&, + const Address&, + const Address&, + Ptr> + m_retransmissionTrace; //!< Trace of retransmitted packets + TracedCallback, const TcpHeader&, Ptr>