diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index b7f905444..fef0299ff 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -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 diff --git a/src/applications/model/bulk-send-application.cc b/src/applications/model/bulk-send-application.cc index 0922c3d3d..ead5da68e 100644 --- a/src/applications/model/bulk-send-application.cc +++ b/src/applications/model/bulk-send-application.cc @@ -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 tcpSocket = DynamicCast(m_socket); + if (tcpSocket) + { + tcpSocket->TraceConnectWithoutContext( + "Retransmission", + MakeCallback(&BulkSendApplication::PacketRetransmitted, this)); + } } if (m_connected) { @@ -331,4 +344,15 @@ BulkSendApplication::DataSend(Ptr socket, uint32_t) } } +void +BulkSendApplication::PacketRetransmitted(Ptr p, + const TcpHeader& header, + const Address& localAddr, + const Address& peerAddr, + Ptr socket) +{ + NS_LOG_FUNCTION(this << p << header << localAddr << peerAddr << socket); + m_retransmissionTrace(p, header, localAddr, peerAddr, socket); +} + } // Namespace ns3 diff --git a/src/applications/model/bulk-send-application.h b/src/applications/model/bulk-send-application.h index 914bc5157..d60587740 100644 --- a/src/applications/model/bulk-send-application.h +++ b/src/applications/model/bulk-send-application.h @@ -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> m_txTrace; + /// Traced Callback: retransmitted packets + TracedCallback, + const TcpHeader&, + const Address&, + const Address&, + Ptr> + m_retransmissionTrace; + /// Callback for tracing the packet Tx events, includes source, destination, the packet sent, /// and header TracedCallback, const Address&, const Address&, const SeqTsSizeHeader&> @@ -151,6 +161,20 @@ class BulkSendApplication : public Application * \param unused actually unused */ void DataSend(Ptr 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 p, + const TcpHeader& header, + const Address& localAddr, + const Address& peerAddr, + Ptr socket); }; } // namespace ns3