applications: (merges !2027) Add BulkSendApplication TCP retransmission trace

This commit is contained in:
Andreas Boltres
2024-09-03 14:32:40 +00:00
committed by Tom Henderson
parent f70eabb0f9
commit ee315fe465
3 changed files with 50 additions and 1 deletions

View File

@@ -42,6 +42,7 @@ been tested on Linux. As of this release, the latest known version to work with
- (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
- (applications) !2027 - BulkSendApplication: Added TCP retransmission trace consuming TcpSocketBase's TCP retransmission trace
### Bugs fixed

View File

@@ -17,6 +17,7 @@
#include "ns3/simulator.h"
#include "ns3/socket-factory.h"
#include "ns3/socket.h"
#include "ns3/tcp-socket-base.h"
#include "ns3/tcp-socket-factory.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/uinteger.h"
@@ -83,7 +84,12 @@ BulkSendApplication::GetTypeId()
.AddTraceSource("TxWithSeqTsSize",
"A new packet is created with SeqTsSizeHeader",
MakeTraceSourceAccessor(&BulkSendApplication::m_txTraceWithSeqTsSize),
"ns3::PacketSink::SeqTsSizeCallback");
"ns3::PacketSink::SeqTsSizeCallback")
.AddTraceSource("TcpRetransmission",
"The TCP socket retransmitted a packet",
MakeTraceSourceAccessor(&BulkSendApplication::m_retransmissionTrace),
"ns3::TcpSocketBase::RetransmissionCallback");
return tid;
}
@@ -185,6 +191,13 @@ BulkSendApplication::StartApplication() // Called at time specified by Start
m_socket->SetConnectCallback(MakeCallback(&BulkSendApplication::ConnectionSucceeded, this),
MakeCallback(&BulkSendApplication::ConnectionFailed, this));
m_socket->SetSendCallback(MakeCallback(&BulkSendApplication::DataSend, this));
Ptr<TcpSocketBase> tcpSocket = DynamicCast<TcpSocketBase>(m_socket);
if (tcpSocket)
{
tcpSocket->TraceConnectWithoutContext(
"Retransmission",
MakeCallback(&BulkSendApplication::PacketRetransmitted, this));
}
}
if (m_connected)
{
@@ -331,4 +344,15 @@ BulkSendApplication::DataSend(Ptr<Socket> socket, uint32_t)
}
}
void
BulkSendApplication::PacketRetransmitted(Ptr<const Packet> p,
const TcpHeader& header,
const Address& localAddr,
const Address& peerAddr,
Ptr<const TcpSocketBase> socket)
{
NS_LOG_FUNCTION(this << p << header << localAddr << peerAddr << socket);
m_retransmissionTrace(p, header, localAddr, peerAddr, socket);
}
} // Namespace ns3

View File

@@ -22,6 +22,8 @@ namespace ns3
class Address;
class Socket;
class TcpHeader;
class TcpSocketBase;
/**
* \ingroup applications
@@ -126,6 +128,14 @@ class BulkSendApplication : public Application
/// Traced Callback: sent packets
TracedCallback<Ptr<const Packet>> m_txTrace;
/// Traced Callback: retransmitted packets
TracedCallback<Ptr<const Packet>,
const TcpHeader&,
const Address&,
const Address&,
Ptr<const TcpSocketBase>>
m_retransmissionTrace;
/// Callback for tracing the packet Tx events, includes source, destination, the packet sent,
/// and header
TracedCallback<Ptr<const Packet>, const Address&, const Address&, const SeqTsSizeHeader&>
@@ -151,6 +161,20 @@ class BulkSendApplication : public Application
* \param unused actually unused
*/
void DataSend(Ptr<Socket> socket, uint32_t unused);
/**
* \brief Packet retransmitted (called by TcpSocketBase sockets via callback)
* \param p the retransmitted packet
* \param header the TCP header
* \param localAddr the local address
* \param peerAddr the peer address
* \param socket the socket that retransmitted the packet
*/
void PacketRetransmitted(Ptr<const Packet> p,
const TcpHeader& header,
const Address& localAddr,
const Address& peerAddr,
Ptr<const TcpSocketBase> socket);
};
} // namespace ns3