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

(-)a/src/node/node.cc (+29 lines)
 Lines 60-65   NodeNetDeviceIndex::GetTypeName (void) c Link Here 
60
}
60
}
61
61
62
62
63
NodeApplicationIndex::NodeApplicationIndex ()
64
  : m_index (0)
65
{}
66
NodeApplicationIndex::NodeApplicationIndex (uint32_t index)
67
  : m_index (index)
68
{}
69
uint32_t 
70
NodeApplicationIndex::Get (void) const
71
{
72
  return m_index;
73
}
74
void 
75
NodeApplicationIndex::Print (std::ostream &os) const
76
{
77
  os << "device=" << m_index;
78
}
79
uint16_t 
80
NodeApplicationIndex::GetUid (void)
81
{
82
  static uint16_t uid = AllocateUid<NodeApplicationIndex> ("NodeApplicationIndex");
83
  return uid;
84
}
85
std::string 
86
NodeApplicationIndex::GetTypeName (void) const
87
{
88
  return "ns3::NodeApplicationIndex";
89
}
90
63
91
64
Node::Node()
92
Node::Node()
65
  : m_id(0), 
93
  : m_id(0), 
 Lines 92-97   Node::GetTraceResolver (void) const Link Here 
92
{
120
{
93
  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
121
  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
94
  resolver->AddArray ("devices", m_devices.begin (), m_devices.end (), NodeNetDeviceIndex ());
122
  resolver->AddArray ("devices", m_devices.begin (), m_devices.end (), NodeNetDeviceIndex ());
123
  resolver->AddArray ("applications", m_applications.begin (), m_applications.end (), NodeApplicationIndex ());
95
  resolver->SetParentResolver (Object::GetTraceResolver ());
124
  resolver->SetParentResolver (Object::GetTraceResolver ());
96
  return resolver;
125
  return resolver;
97
}
126
}
(-)a/src/node/node.h (+19 lines)
 Lines 48-53   public: Link Here 
48
  NodeNetDeviceIndex (uint32_t index);
48
  NodeNetDeviceIndex (uint32_t index);
49
  /**
49
  /**
50
   * \returns the index of the NetDevice within its container Node.
50
   * \returns the index of the NetDevice within its container Node.
51
   */
52
  uint32_t Get (void) const;
53
  void Print (std::ostream &os) const;
54
  std::string GetTypeName (void) const;
55
  static uint16_t GetUid (void);
56
private:
57
  uint32_t m_index;
58
};
59
60
/**
61
 * \brief hold in a TraceContext the index of an Application within a Node
62
 */
63
class NodeApplicationIndex : public TraceContextElement
64
{
65
public:
66
  NodeApplicationIndex ();
67
  NodeApplicationIndex (uint32_t index);
68
  /**
69
   * \returns the index of the Application within its container Node.
51
   */
70
   */
52
  uint32_t Get (void) const;
71
  uint32_t Get (void) const;
53
  void Print (std::ostream &os) const;
72
  void Print (std::ostream &os) const;
(-)a/src/applications/onoff/onoff-application.cc (+15 lines)
 Lines 33-38    Link Here 
33
#include "ns3/socket-factory.h"
33
#include "ns3/socket-factory.h"
34
#include "ns3/default-value.h"
34
#include "ns3/default-value.h"
35
#include "ns3/packet.h"
35
#include "ns3/packet.h"
36
#include "ns3/composite-trace-resolver.h"
36
#include "onoff-application.h"
37
#include "onoff-application.h"
37
38
38
NS_LOG_COMPONENT_DEFINE ("OnOffApplication");
39
NS_LOG_COMPONENT_DEFINE ("OnOffApplication");
 Lines 241-246   void OnOffApplication::SendPacket() Link Here 
241
242
242
  NS_ASSERT (m_sendEvent.IsExpired ());
243
  NS_ASSERT (m_sendEvent.IsExpired ());
243
  Ptr<Packet> packet = Create<Packet> (m_pktSize);
244
  Ptr<Packet> packet = Create<Packet> (m_pktSize);
245
  m_txTrace (packet);
244
  m_socket->Send (packet);
246
  m_socket->Send (packet);
245
  m_totBytes += m_pktSize;
247
  m_totBytes += m_pktSize;
246
  m_lastStartTime = Simulator::Now();
248
  m_lastStartTime = Simulator::Now();
 Lines 262-265   void OnOffApplication::ConnectionFailed( Link Here 
262
  cout << "OnOffApplication, Connection Failed" << endl;
264
  cout << "OnOffApplication, Connection Failed" << endl;
263
}
265
}
264
266
267
Ptr<TraceResolver> 
268
OnOffApplication::GetTraceResolver (void) const
269
{
270
  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
271
  resolver->AddSource ("tx",
272
                       TraceDoc ("A new packet is created is sent",
273
                                 "Ptr<const Packet>",
274
                                 "The newly-created packet."),
275
                       m_txTrace);
276
  resolver->SetParentResolver (Application::GetTraceResolver ());
277
  return resolver;
278
}
279
265
} // Namespace ns3
280
} // Namespace ns3
(-)a/src/applications/onoff/onoff-application.h (+3 lines)
 Lines 29-34    Link Here 
29
#include "ns3/event-id.h"
29
#include "ns3/event-id.h"
30
#include "ns3/ptr.h"
30
#include "ns3/ptr.h"
31
#include "ns3/data-rate.h"
31
#include "ns3/data-rate.h"
32
#include "ns3/callback-trace-source.h"
32
33
33
namespace ns3 {
34
namespace ns3 {
34
35
 Lines 135-142   private: Link Here 
135
  EventId         m_sendEvent;    // Eventid of pending "send packet" event
136
  EventId         m_sendEvent;    // Eventid of pending "send packet" event
136
  bool            m_sending;      // True if currently in sending state
137
  bool            m_sending;      // True if currently in sending state
137
  std::string     m_iid;
138
  std::string     m_iid;
139
  CallbackTraceSource<Ptr<const Packet> > m_txTrace;
138
  
140
  
139
private:
141
private:
142
  virtual Ptr<TraceResolver> GetTraceResolver (void) const;
140
  void ScheduleNextTx();
143
  void ScheduleNextTx();
141
  void ScheduleStartEvent();
144
  void ScheduleStartEvent();
142
  void ScheduleStopEvent();
145
  void ScheduleStopEvent();
(-)a/src/applications/onoff/onoff-application.cc (-1 / +1 lines)
 Lines 269-275   OnOffApplication::GetTraceResolver (void Link Here 
269
{
269
{
270
  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
270
  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
271
  resolver->AddSource ("tx",
271
  resolver->AddSource ("tx",
272
                       TraceDoc ("A new packet is created is sent",
272
                       TraceDoc ("A new packet is created and is sent",
273
                                 "Ptr<const Packet>",
273
                                 "Ptr<const Packet>",
274
                                 "The newly-created packet."),
274
                                 "The newly-created packet."),
275
                       m_txTrace);
275
                       m_txTrace);
(-)a/src/applications/packet-sink/packet-sink.cc (-1 / +17 lines)
 Lines 25-30    Link Here 
25
#include "ns3/simulator.h"
25
#include "ns3/simulator.h"
26
#include "ns3/socket-factory.h"
26
#include "ns3/socket-factory.h"
27
#include "ns3/packet.h"
27
#include "ns3/packet.h"
28
#include "ns3/composite-trace-resolver.h"
28
#include "packet-sink.h"
29
#include "packet-sink.h"
29
30
30
using namespace std;
31
using namespace std;
 Lines 101-108   void PacketSink::Receive(Ptr<Socket> soc Link Here 
101
      NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " << 
102
      NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " << 
102
        address.GetIpv4() << " [" << address << "]---'" << 
103
        address.GetIpv4() << " [" << address << "]---'" << 
103
        packet->PeekData() << "'");
104
        packet->PeekData() << "'");
104
      // TODO:  Add a tracing source here
105
    }
105
    }
106
  m_rxTrace (packet, from);
107
}
108
109
Ptr<TraceResolver> 
110
PacketSink::GetTraceResolver (void) const
111
{
112
  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
113
  resolver->AddSource ("rx",
114
                       TraceDoc ("A new packet has been received",
115
                                 "Ptr<const Packet>",
116
                                 "The newly-received packet.",
117
                                 "const Address &",
118
                                 "The source address of the received packet."),
119
                       m_rxTrace);
120
  resolver->SetParentResolver (Application::GetTraceResolver ());
121
  return resolver;
106
}
122
}
107
123
108
} // Namespace ns3
124
} // Namespace ns3
(-)a/src/applications/packet-sink/packet-sink.h (+5 lines)
 Lines 24-29    Link Here 
24
#include "ns3/application.h"
24
#include "ns3/application.h"
25
#include "ns3/event-id.h"
25
#include "ns3/event-id.h"
26
#include "ns3/ptr.h"
26
#include "ns3/ptr.h"
27
#include "ns3/callback-trace-source.h"
28
#include "ns3/address.h"
27
29
28
namespace ns3 {
30
namespace ns3 {
29
31
 Lines 68-73   private: Link Here 
68
  // inherited from Application base class.
70
  // inherited from Application base class.
69
  virtual void StartApplication (void);    // Called at time specified by Start
71
  virtual void StartApplication (void);    // Called at time specified by Start
70
  virtual void StopApplication (void);     // Called at time specified by Stop
72
  virtual void StopApplication (void);     // Called at time specified by Stop
73
  // inherited from Object base class.
74
  virtual Ptr<TraceResolver> GetTraceResolver (void) const;
71
75
72
  void Construct (Ptr<Node> n,
76
  void Construct (Ptr<Node> n,
73
                  const Address &local,
77
                  const Address &local,
 Lines 78-83   private: Link Here 
78
  Ptr<Socket>     m_socket;       // Associated socket
82
  Ptr<Socket>     m_socket;       // Associated socket
79
  Address         m_local;        // Local address to bind to
83
  Address         m_local;        // Local address to bind to
80
  std::string     m_iid;          // Protocol name (e.g., "Udp")
84
  std::string     m_iid;          // Protocol name (e.g., "Udp")
85
  CallbackTraceSource<Ptr<const Packet>, const Address &> m_rxTrace;
81
  
86
  
82
};
87
};
83
88

Return to bug 119