|
24 |
#include "ns3/socket-factory.h" |
24 |
#include "ns3/socket-factory.h" |
25 |
#include "ns3/packet.h" |
25 |
#include "ns3/packet.h" |
26 |
#include "ns3/uinteger.h" |
26 |
#include "ns3/uinteger.h" |
|
|
27 |
#include "ns3/trace-source-accessor.h" |
27 |
#include "udp-echo-client.h" |
28 |
#include "udp-echo-client.h" |
28 |
|
29 |
|
29 |
namespace ns3 { |
30 |
namespace ns3 { |
|
62 |
MakeUintegerAccessor (&UdpEchoClient::SetDataSize, |
63 |
MakeUintegerAccessor (&UdpEchoClient::SetDataSize, |
63 |
&UdpEchoClient::GetDataSize), |
64 |
&UdpEchoClient::GetDataSize), |
64 |
MakeUintegerChecker<uint32_t> ()) |
65 |
MakeUintegerChecker<uint32_t> ()) |
|
|
66 |
.AddTraceSource ("Tx", "A new packet is created and is sent", |
67 |
MakeTraceSourceAccessor (&UdpEchoClient::m_txTrace)) |
65 |
; |
68 |
; |
66 |
return tid; |
69 |
return tid; |
67 |
} |
70 |
} |
|
246 |
|
249 |
|
247 |
NS_ASSERT (m_sendEvent.IsExpired ()); |
250 |
NS_ASSERT (m_sendEvent.IsExpired ()); |
248 |
|
251 |
|
|
|
252 |
Ptr<Packet> p; |
249 |
if (m_dataSize) |
253 |
if (m_dataSize) |
250 |
{ |
254 |
{ |
251 |
// |
255 |
// |
|
256 |
// |
260 |
// |
257 |
NS_ASSERT_MSG (m_dataSize == m_size, "UdpEchoClient::Send(): m_size and m_dataSize inconsistent"); |
261 |
NS_ASSERT_MSG (m_dataSize == m_size, "UdpEchoClient::Send(): m_size and m_dataSize inconsistent"); |
258 |
NS_ASSERT_MSG (m_data, "UdpEchoClient::Send(): m_dataSize but no m_data"); |
262 |
NS_ASSERT_MSG (m_data, "UdpEchoClient::Send(): m_dataSize but no m_data"); |
259 |
Ptr<Packet> p = Create<Packet> (m_data, m_dataSize); |
263 |
p = Create<Packet> (m_data, m_dataSize); |
260 |
m_socket->Send (p); |
264 |
m_socket->Send (p); |
261 |
} |
265 |
} |
262 |
else |
266 |
else |
|
268 |
// this case, we don't worry about it either. But we do allow m_size |
272 |
// this case, we don't worry about it either. But we do allow m_size |
269 |
// to have a value different from the (zero) m_dataSize. |
273 |
// to have a value different from the (zero) m_dataSize. |
270 |
// |
274 |
// |
271 |
Ptr<Packet> p = Create<Packet> (m_size); |
275 |
p = Create<Packet> (m_size); |
|
|
276 |
// call to the trace sinks before the packet is actually sent, |
277 |
// so that tags added to the packet can be sent as well |
278 |
m_txTrace (p); |
272 |
m_socket->Send (p); |
279 |
m_socket->Send (p); |
273 |
} |
280 |
} |
274 |
|
281 |
|