Added a Tx trace source to the UDP echo client application class. The trace source allows tracing every packet that is sent from the UdpEchoClient application class. The code is copied and pasted from the Tx trace source of the OnOffApplication class. diff -r 49d753ae46c5 src/applications/udp-echo/udp-echo-client.cc --- a/src/applications/udp-echo/udp-echo-client.cc Wed Jul 15 23:03:04 2009 +0800 +++ b/src/applications/udp-echo/udp-echo-client.cc Thu Jul 16 23:21:43 2009 +0800 @@ -24,6 +24,7 @@ #include "ns3/socket-factory.h" #include "ns3/packet.h" #include "ns3/uinteger.h" +#include "ns3/trace-source-accessor.h" #include "udp-echo-client.h" namespace ns3 { @@ -62,6 +63,8 @@ MakeUintegerAccessor (&UdpEchoClient::SetDataSize, &UdpEchoClient::GetDataSize), MakeUintegerChecker ()) + .AddTraceSource ("Tx", "A new packet is created and is sent", + MakeTraceSourceAccessor (&UdpEchoClient::m_txTrace)) ; return tid; } @@ -246,6 +249,7 @@ NS_ASSERT (m_sendEvent.IsExpired ()); + Ptr p; if (m_dataSize) { // @@ -256,7 +260,7 @@ // NS_ASSERT_MSG (m_dataSize == m_size, "UdpEchoClient::Send(): m_size and m_dataSize inconsistent"); NS_ASSERT_MSG (m_data, "UdpEchoClient::Send(): m_dataSize but no m_data"); - Ptr p = Create (m_data, m_dataSize); + p = Create (m_data, m_dataSize); m_socket->Send (p); } else @@ -268,7 +272,10 @@ // this case, we don't worry about it either. But we do allow m_size // to have a value different from the (zero) m_dataSize. // - Ptr p = Create (m_size); + p = Create (m_size); + // call to the trace sinks before the packet is actually sent, + // so that tags added to the packet can be sent as well + m_txTrace (p); m_socket->Send (p); } diff -r 49d753ae46c5 src/applications/udp-echo/udp-echo-client.h --- a/src/applications/udp-echo/udp-echo-client.h Wed Jul 15 23:03:04 2009 +0800 +++ b/src/applications/udp-echo/udp-echo-client.h Thu Jul 16 23:21:43 2009 +0800 @@ -23,6 +23,7 @@ #include "ns3/event-id.h" #include "ns3/ptr.h" #include "ns3/ipv4-address.h" +#include "ns3/traced-callback.h" namespace ns3 { @@ -140,7 +141,8 @@ Ipv4Address m_peerAddress; uint16_t m_peerPort; EventId m_sendEvent; - + /// Callbacks for tracing the packet Tx events + TracedCallback > m_txTrace; }; } // namespace ns3