View | Details | Raw Unified | Return to bug 2817
Collapse All | Expand All

(-)a/src/applications/model/onoff-application.cc (+7 lines)
 Lines 91-96    Link Here 
91
    .AddTraceSource ("Tx", "A new packet is created and is sent",
91
    .AddTraceSource ("Tx", "A new packet is created and is sent",
92
                     MakeTraceSourceAccessor (&OnOffApplication::m_txTrace),
92
                     MakeTraceSourceAccessor (&OnOffApplication::m_txTrace),
93
                     "ns3::Packet::TracedCallback")
93
                     "ns3::Packet::TracedCallback")
94
    .AddTraceSource ("TxWithAddresses", "A new packet is created and is sent",
95
                     MakeTraceSourceAccessor (&OnOffApplication::m_txTraceWithAddresses),
96
                     "ns3::Packet::TwoAddressTracedCallback")
94
  ;
97
  ;
95
  return tid;
98
  return tid;
96
}
99
}
 Lines 283-288    Link Here 
283
  m_txTrace (packet);
286
  m_txTrace (packet);
284
  m_socket->Send (packet);
287
  m_socket->Send (packet);
285
  m_totBytes += m_pktSize;
288
  m_totBytes += m_pktSize;
289
  Address localAddress;
290
  m_socket->GetSockName (localAddress);
286
  if (InetSocketAddress::IsMatchingType (m_peer))
291
  if (InetSocketAddress::IsMatchingType (m_peer))
287
    {
292
    {
288
      NS_LOG_INFO ("At time " << Simulator::Now ().GetSeconds ()
293
      NS_LOG_INFO ("At time " << Simulator::Now ().GetSeconds ()
 Lines 291-296    Link Here 
291
                   << InetSocketAddress::ConvertFrom(m_peer).GetIpv4 ()
296
                   << InetSocketAddress::ConvertFrom(m_peer).GetIpv4 ()
292
                   << " port " << InetSocketAddress::ConvertFrom (m_peer).GetPort ()
297
                   << " port " << InetSocketAddress::ConvertFrom (m_peer).GetPort ()
293
                   << " total Tx " << m_totBytes << " bytes");
298
                   << " total Tx " << m_totBytes << " bytes");
299
      m_txTraceWithAddresses (packet, localAddress, InetSocketAddress::ConvertFrom (m_peer));
294
    }
300
    }
295
  else if (Inet6SocketAddress::IsMatchingType (m_peer))
301
  else if (Inet6SocketAddress::IsMatchingType (m_peer))
296
    {
302
    {
 Lines 300-305    Link Here 
300
                   << Inet6SocketAddress::ConvertFrom(m_peer).GetIpv6 ()
306
                   << Inet6SocketAddress::ConvertFrom(m_peer).GetIpv6 ()
301
                   << " port " << Inet6SocketAddress::ConvertFrom (m_peer).GetPort ()
307
                   << " port " << Inet6SocketAddress::ConvertFrom (m_peer).GetPort ()
302
                   << " total Tx " << m_totBytes << " bytes");
308
                   << " total Tx " << m_totBytes << " bytes");
309
      m_txTraceWithAddresses (packet, localAddress, Inet6SocketAddress::ConvertFrom(m_peer));
303
    }
310
    }
304
  m_lastStartTime = Simulator::Now ();
311
  m_lastStartTime = Simulator::Now ();
305
  m_residualBits = 0;
312
  m_residualBits = 0;
(-)a/src/applications/model/onoff-application.h (+3 lines)
 Lines 167-172    Link Here 
167
  /// Traced Callback: transmitted packets.
167
  /// Traced Callback: transmitted packets.
168
  TracedCallback<Ptr<const Packet> > m_txTrace;
168
  TracedCallback<Ptr<const Packet> > m_txTrace;
169
169
170
  /// Callbacks for tracing the packet Tx events, includes source and destination addresses
171
  TracedCallback<Ptr<const Packet>, const Address &, const Address &> m_txTraceWithAddresses;
172
170
private:
173
private:
171
  /**
174
  /**
172
   * \brief Schedule the next packet transmission
175
   * \brief Schedule the next packet transmission
(-)a/src/applications/model/packet-sink.cc (+6 lines)
 Lines 59-64    Link Here 
59
                     "A packet has been received",
59
                     "A packet has been received",
60
                     MakeTraceSourceAccessor (&PacketSink::m_rxTrace),
60
                     MakeTraceSourceAccessor (&PacketSink::m_rxTrace),
61
                     "ns3::Packet::AddressTracedCallback")
61
                     "ns3::Packet::AddressTracedCallback")
62
    .AddTraceSource ("RxWithAddresses", "A packet has been received",
63
                     MakeTraceSourceAccessor (&PacketSink::m_rxTraceWithAddresses),
64
                     "ns3::Packet::TwoAddressTracedCallback")
62
  ;
65
  ;
63
  return tid;
66
  return tid;
64
}
67
}
 Lines 165-170    Link Here 
165
  NS_LOG_FUNCTION (this << socket);
168
  NS_LOG_FUNCTION (this << socket);
166
  Ptr<Packet> packet;
169
  Ptr<Packet> packet;
167
  Address from;
170
  Address from;
171
  Address localAddress;
168
  while ((packet = socket->RecvFrom (from)))
172
  while ((packet = socket->RecvFrom (from)))
169
    {
173
    {
170
      if (packet->GetSize () == 0)
174
      if (packet->GetSize () == 0)
 Lines 190-196    Link Here 
190
                       << " port " << Inet6SocketAddress::ConvertFrom (from).GetPort ()
194
                       << " port " << Inet6SocketAddress::ConvertFrom (from).GetPort ()
191
                       << " total Rx " << m_totalRx << " bytes");
195
                       << " total Rx " << m_totalRx << " bytes");
192
        }
196
        }
197
      socket->GetSockName (localAddress);
193
      m_rxTrace (packet, from);
198
      m_rxTrace (packet, from);
199
      m_rxTraceWithAddresses (packet, from, localAddress);
194
    }
200
    }
195
}
201
}
196
202
(-)a/src/applications/model/packet-sink.h (+3 lines)
 Lines 133-138    Link Here 
133
  /// Traced Callback: received packets, source address.
133
  /// Traced Callback: received packets, source address.
134
  TracedCallback<Ptr<const Packet>, const Address &> m_rxTrace;
134
  TracedCallback<Ptr<const Packet>, const Address &> m_rxTrace;
135
135
136
  /// Callback for tracing the packet Rx events, includes source and destination addresses
137
  TracedCallback<Ptr<const Packet>, const Address &, const Address &> m_rxTraceWithAddresses;
138
136
};
139
};
137
140
138
} // namespace ns3
141
} // namespace ns3
(-)a/src/applications/model/udp-echo-client.cc (-1 / +23 lines)
 Lines 70-75    Link Here 
70
    .AddTraceSource ("Tx", "A new packet is created and is sent",
70
    .AddTraceSource ("Tx", "A new packet is created and is sent",
71
                     MakeTraceSourceAccessor (&UdpEchoClient::m_txTrace),
71
                     MakeTraceSourceAccessor (&UdpEchoClient::m_txTrace),
72
                     "ns3::Packet::TracedCallback")
72
                     "ns3::Packet::TracedCallback")
73
    .AddTraceSource ("Rx", "A packet has been received",
74
                     MakeTraceSourceAccessor (&UdpEchoClient::m_rxTrace),
75
                     "ns3::Packet::TracedCallback")
76
    .AddTraceSource ("TxWithAddresses", "A new packet is created and is sent",
77
                     MakeTraceSourceAccessor (&UdpEchoClient::m_txTraceWithAddresses),
78
                     "ns3::Packet::TwoAddressTracedCallback")
79
    .AddTraceSource ("RxWithAddresses", "A packet has been received",
80
                     MakeTraceSourceAccessor (&UdpEchoClient::m_rxTraceWithAddresses),
81
                     "ns3::Packet::TwoAddressTracedCallback")
73
  ;
82
  ;
74
  return tid;
83
  return tid;
75
}
84
}
 Lines 324-334    Link Here 
324
      //
333
      //
325
      p = Create<Packet> (m_size);
334
      p = Create<Packet> (m_size);
326
    }
335
    }
336
  Address localAddress;
337
  m_socket->GetSockName (localAddress);
327
  // call to the trace sinks before the packet is actually sent,
338
  // call to the trace sinks before the packet is actually sent,
328
  // so that tags added to the packet can be sent as well
339
  // so that tags added to the packet can be sent as well
329
  m_txTrace (p);
340
  m_txTrace (p);
341
  if (Ipv4Address::IsMatchingType (m_peerAddress))
342
    {
343
      m_txTraceWithAddresses (p, localAddress, InetSocketAddress (Ipv4Address::ConvertFrom (m_peerAddress), m_peerPort));
344
    }
345
  else if (Ipv6Address::IsMatchingType (m_peerAddress))
346
    {
347
      m_txTraceWithAddresses (p, localAddress, Inet6SocketAddress (Ipv6Address::ConvertFrom (m_peerAddress), m_peerPort));
348
    }
330
  m_socket->Send (p);
349
  m_socket->Send (p);
331
332
  ++m_sent;
350
  ++m_sent;
333
351
334
  if (Ipv4Address::IsMatchingType (m_peerAddress))
352
  if (Ipv4Address::IsMatchingType (m_peerAddress))
 Lines 364-369    Link Here 
364
  NS_LOG_FUNCTION (this << socket);
382
  NS_LOG_FUNCTION (this << socket);
365
  Ptr<Packet> packet;
383
  Ptr<Packet> packet;
366
  Address from;
384
  Address from;
385
  Address localAddress;
367
  while ((packet = socket->RecvFrom (from)))
386
  while ((packet = socket->RecvFrom (from)))
368
    {
387
    {
369
      if (InetSocketAddress::IsMatchingType (from))
388
      if (InetSocketAddress::IsMatchingType (from))
 Lines 378-383    Link Here 
378
                       Inet6SocketAddress::ConvertFrom (from).GetIpv6 () << " port " <<
397
                       Inet6SocketAddress::ConvertFrom (from).GetIpv6 () << " port " <<
379
                       Inet6SocketAddress::ConvertFrom (from).GetPort ());
398
                       Inet6SocketAddress::ConvertFrom (from).GetPort ());
380
        }
399
        }
400
      socket->GetSockName (localAddress);
401
      m_rxTrace (packet);
402
      m_rxTraceWithAddresses (packet, from, localAddress);
381
    }
403
    }
382
}
404
}
383
405
(-)a/src/applications/model/udp-echo-client.h (+10 lines)
 Lines 172-177    Link Here 
172
172
173
  /// Callbacks for tracing the packet Tx events
173
  /// Callbacks for tracing the packet Tx events
174
  TracedCallback<Ptr<const Packet> > m_txTrace;
174
  TracedCallback<Ptr<const Packet> > m_txTrace;
175
176
  /// Callbacks for tracing the packet Rx events
177
  TracedCallback<Ptr<const Packet> > m_rxTrace;
178
  
179
  /// Callbacks for tracing the packet Tx events, includes source and destination addresses
180
  TracedCallback<Ptr<const Packet>, const Address &, const Address &> m_txTraceWithAddresses;
181
  
182
  /// Callbacks for tracing the packet Rx events, includes source and destination addresses
183
  TracedCallback<Ptr<const Packet>, const Address &, const Address &> m_rxTraceWithAddresses;
184
175
};
185
};
176
186
177
} // namespace ns3
187
} // namespace ns3
(-)a/src/applications/model/udp-echo-server.cc (+10 lines)
 Lines 49-54    Link Here 
49
                   UintegerValue (9),
49
                   UintegerValue (9),
50
                   MakeUintegerAccessor (&UdpEchoServer::m_port),
50
                   MakeUintegerAccessor (&UdpEchoServer::m_port),
51
                   MakeUintegerChecker<uint16_t> ())
51
                   MakeUintegerChecker<uint16_t> ())
52
    .AddTraceSource ("Rx", "A packet has been received",
53
                     MakeTraceSourceAccessor (&UdpEchoServer::m_rxTrace),
54
                     "ns3::Packet::TracedCallback")
55
    .AddTraceSource ("RxWithAddresses", "A packet has been received",
56
                     MakeTraceSourceAccessor (&UdpEchoServer::m_rxTraceWithAddresses),
57
                     "ns3::Packet::TwoAddressTracedCallback")
52
  ;
58
  ;
53
  return tid;
59
  return tid;
54
}
60
}
 Lines 153-160    Link Here 
153
159
154
  Ptr<Packet> packet;
160
  Ptr<Packet> packet;
155
  Address from;
161
  Address from;
162
  Address localAddress;
156
  while ((packet = socket->RecvFrom (from)))
163
  while ((packet = socket->RecvFrom (from)))
157
    {
164
    {
165
      socket->GetSockName (localAddress);
166
      m_rxTrace (packet);
167
      m_rxTraceWithAddresses (packet, from, localAddress);
158
      if (InetSocketAddress::IsMatchingType (from))
168
      if (InetSocketAddress::IsMatchingType (from))
159
        {
169
        {
160
          NS_LOG_INFO ("At time " << Simulator::Now ().GetSeconds () << "s server received " << packet->GetSize () << " bytes from " <<
170
          NS_LOG_INFO ("At time " << Simulator::Now ().GetSeconds () << "s server received " << packet->GetSize () << " bytes from " <<
(-)a/src/applications/model/udp-echo-server.h (+7 lines)
 Lines 23-28    Link Here 
23
#include "ns3/event-id.h"
23
#include "ns3/event-id.h"
24
#include "ns3/ptr.h"
24
#include "ns3/ptr.h"
25
#include "ns3/address.h"
25
#include "ns3/address.h"
26
#include "ns3/traced-callback.h"
26
27
27
namespace ns3 {
28
namespace ns3 {
28
29
 Lines 72-77    Link Here 
72
  Ptr<Socket> m_socket; //!< IPv4 Socket
73
  Ptr<Socket> m_socket; //!< IPv4 Socket
73
  Ptr<Socket> m_socket6; //!< IPv6 Socket
74
  Ptr<Socket> m_socket6; //!< IPv6 Socket
74
  Address m_local; //!< local multicast address
75
  Address m_local; //!< local multicast address
76
77
  /// Callbacks for tracing the packet Rx events
78
  TracedCallback<Ptr<const Packet> > m_rxTrace;
79
80
  /// Callbacks for tracing the packet Rx events, includes source and destination addresses
81
  TracedCallback<Ptr<const Packet>, const Address &, const Address &> m_rxTraceWithAddresses;
75
};
82
};
76
83
77
} // namespace ns3
84
} // namespace ns3
(-)a/src/applications/model/udp-server.cc (+10 lines)
 Lines 59-64    Link Here 
59
                   MakeUintegerAccessor (&UdpServer::GetPacketWindowSize,
59
                   MakeUintegerAccessor (&UdpServer::GetPacketWindowSize,
60
                                         &UdpServer::SetPacketWindowSize),
60
                                         &UdpServer::SetPacketWindowSize),
61
                   MakeUintegerChecker<uint16_t> (8,256))
61
                   MakeUintegerChecker<uint16_t> (8,256))
62
    .AddTraceSource ("Rx", "A packet has been received",
63
                     MakeTraceSourceAccessor (&UdpServer::m_rxTrace),
64
                     "ns3::Packet::TracedCallback")
65
    .AddTraceSource ("RxWithAddresses", "A packet has been received",
66
                     MakeTraceSourceAccessor (&UdpServer::m_rxTraceWithAddresses),
67
                     "ns3::Packet::TwoAddressTracedCallback")
62
  ;
68
  ;
63
  return tid;
69
  return tid;
64
}
70
}
 Lines 162-169    Link Here 
162
  NS_LOG_FUNCTION (this << socket);
168
  NS_LOG_FUNCTION (this << socket);
163
  Ptr<Packet> packet;
169
  Ptr<Packet> packet;
164
  Address from;
170
  Address from;
171
  Address localAddress;
165
  while ((packet = socket->RecvFrom (from)))
172
  while ((packet = socket->RecvFrom (from)))
166
    {
173
    {
174
      socket->GetSockName (localAddress);
175
      m_rxTrace (packet);
176
      m_rxTraceWithAddresses (packet, from, localAddress);
167
      if (packet->GetSize () > 0)
177
      if (packet->GetSize () > 0)
168
        {
178
        {
169
          SeqTsHeader seqTs;
179
          SeqTsHeader seqTs;
(-)a/src/applications/model/udp-server.h (+9 lines)
 Lines 27-33    Link Here 
27
#include "ns3/event-id.h"
27
#include "ns3/event-id.h"
28
#include "ns3/ptr.h"
28
#include "ns3/ptr.h"
29
#include "ns3/address.h"
29
#include "ns3/address.h"
30
#include "ns3/traced-callback.h"
30
#include "packet-loss-counter.h"
31
#include "packet-loss-counter.h"
32
31
namespace ns3 {
33
namespace ns3 {
32
/**
34
/**
33
 * \ingroup applications
35
 * \ingroup applications
 Lines 100-105    Link Here 
100
  Ptr<Socket> m_socket6; //!< IPv6 Socket
102
  Ptr<Socket> m_socket6; //!< IPv6 Socket
101
  uint64_t m_received; //!< Number of received packets
103
  uint64_t m_received; //!< Number of received packets
102
  PacketLossCounter m_lossCounter; //!< Lost packet counter
104
  PacketLossCounter m_lossCounter; //!< Lost packet counter
105
106
  /// Callbacks for tracing the packet Rx events
107
  TracedCallback<Ptr<const Packet> > m_rxTrace;
108
109
  /// Callbacks for tracing the packet Rx events, includes source and destination addresses
110
  TracedCallback<Ptr<const Packet>, const Address &, const Address &> m_rxTraceWithAddresses;
111
103
};
112
};
104
113
105
} // namespace ns3
114
} // namespace ns3
(-)a/src/network/model/packet.h (+10 lines)
 Lines 701-706    Link Here 
701
  typedef void (* AddressTracedCallback)
701
  typedef void (* AddressTracedCallback)
702
    (Ptr<const Packet> packet, const Address &address);
702
    (Ptr<const Packet> packet, const Address &address);
703
  
703
  
704
   /**
705
    * TracedCallback signature for packet and source/destination addresses.
706
    *
707
    * \param [in] packet The packet.
708
    * \param [in] srcAddress The source address.
709
    * \param [in] destAddress The destination address.
710
    */
711
  typedef void (* TwoAddressTracedCallback)
712
    (const Ptr<const Packet> packet, const Address &srcAddress, const Address &destAddress);
713
704
  /**
714
  /**
705
   * TracedCallback signature for packet and Mac48Address.
715
   * TracedCallback signature for packet and Mac48Address.
706
   *
716
   *

Return to bug 2817