1.1 --- a/src/applications/udp-echo/udp-echo-client.cc Thu Aug 13 09:36:53 2009 +0200
1.2 +++ b/src/applications/udp-echo/udp-echo-client.cc Thu Aug 13 09:47:53 2009 +0200
1.3 @@ -24,6 +24,7 @@
1.4 #include "ns3/socket-factory.h"
1.5 #include "ns3/packet.h"
1.6 #include "ns3/uinteger.h"
1.7 +#include "ns3/trace-source-accessor.h"
1.8 #include "udp-echo-client.h"
1.9
1.10 namespace ns3 {
1.11 @@ -62,6 +63,8 @@
1.12 MakeUintegerAccessor (&UdpEchoClient::SetDataSize,
1.13 &UdpEchoClient::GetDataSize),
1.14 MakeUintegerChecker<uint32_t> ())
1.15 + .AddTraceSource ("Tx", "A new packet is created and is sent",
1.16 + MakeTraceSourceAccessor (&UdpEchoClient::m_txTrace))
1.17 ;
1.18 return tid;
1.19 }
1.20 @@ -246,6 +249,7 @@
1.21
1.22 NS_ASSERT (m_sendEvent.IsExpired ());
1.23
1.24 + Ptr<Packet> p;
1.25 if (m_dataSize)
1.26 {
1.27 //
1.28 @@ -256,8 +260,7 @@
1.29 //
1.30 NS_ASSERT_MSG (m_dataSize == m_size, "UdpEchoClient::Send(): m_size and m_dataSize inconsistent");
1.31 NS_ASSERT_MSG (m_data, "UdpEchoClient::Send(): m_dataSize but no m_data");
1.32 - Ptr<Packet> p = Create<Packet> (m_data, m_dataSize);
1.33 - m_socket->Send (p);
1.34 + p = Create<Packet> (m_data, m_dataSize);
1.35 }
1.36 else
1.37 {
1.38 @@ -268,9 +271,12 @@
1.39 // this case, we don't worry about it either. But we do allow m_size
1.40 // to have a value different from the (zero) m_dataSize.
1.41 //
1.42 - Ptr<Packet> p = Create<Packet> (m_size);
1.43 - m_socket->Send (p);
1.44 + p = Create<Packet> (m_size);
1.45 }
1.46 + // call to the trace sinks before the packet is actually sent,
1.47 + // so that tags added to the packet can be sent as well
1.48 + m_txTrace (p);
1.49 + m_socket->Send (p);
1.50
1.51 ++m_sent;
1.52
2.1 --- a/src/applications/udp-echo/udp-echo-client.h Thu Aug 13 09:36:53 2009 +0200
2.2 +++ b/src/applications/udp-echo/udp-echo-client.h Thu Aug 13 09:47:53 2009 +0200
2.3 @@ -23,6 +23,7 @@
2.4 #include "ns3/event-id.h"
2.5 #include "ns3/ptr.h"
2.6 #include "ns3/ipv4-address.h"
2.7 +#include "ns3/traced-callback.h"
2.8
2.9 namespace ns3 {
2.10
2.11 @@ -140,7 +141,8 @@
2.12 Ipv4Address m_peerAddress;
2.13 uint16_t m_peerPort;
2.14 EventId m_sendEvent;
2.15 -
2.16 + /// Callbacks for tracing the packet Tx events
2.17 + TracedCallback<Ptr<const Packet> > m_txTrace;
2.18 };
2.19
2.20 } // namespace ns3