tcp: Add TCP retransmission trace source

This commit is contained in:
Andreas Boltres
2024-09-03 14:30:07 +00:00
committed by Tom Henderson
parent 8d4e8f60c9
commit f70eabb0f9
3 changed files with 48 additions and 2 deletions

View File

@@ -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)
{

View File

@@ -641,7 +641,7 @@ class TcpSocketBase : public TcpSocket
void BindToNetDevice(Ptr<NetDevice> 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<const TcpSocketBase> 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<const Packet> packet,
const TcpHeader& header,
const Address& localAddr,
const Address& peerAddr,
const Ptr<const TcpSocketBase> 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<Ptr<const Packet>,
const TcpHeader&,
Ptr<const TcpSocketBase>>
m_txTrace; //!< Trace of transmitted packets
TracedCallback<Ptr<const Packet>,
const TcpHeader&,
const Address&,
const Address&,
Ptr<const TcpSocketBase>>
m_retransmissionTrace; //!< Trace of retransmitted packets
TracedCallback<Ptr<const Packet>,
const TcpHeader&,
Ptr<const TcpSocketBase>>