Prepend ascii trace lines with action and time
authorTom Henderson <tomh@tomh.org>
Sun, 30 Mar 2008 22:39:27 -0700
changeset 2802 6beac0ec2c5d
parent 2801 edbd094336b5
child 2803 2ce2256f8454
Prepend ascii trace lines with action and time
src/helper/point-to-point-helper.cc
src/helper/point-to-point-helper.h
--- a/src/helper/point-to-point-helper.cc	Sun Mar 30 21:41:25 2008 -0700
+++ b/src/helper/point-to-point-helper.cc	Sun Mar 30 22:39:27 2008 -0700
@@ -1,4 +1,5 @@
 #include "point-to-point-helper.h"
+#include "ns3/simulator.h"
 #include "ns3/point-to-point-net-device.h"
 #include "ns3/point-to-point-channel.h"
 #include "ns3/queue.h"
@@ -94,13 +95,16 @@
   Packet::EnableMetadata ();
   std::ostringstream oss;
   oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/Rx";
-  Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiEvent, &os));
+  Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiRxEvent, &os));
   oss.str ("");
   oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Enqueue";
-  Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiEvent, &os));
+  Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiEnqueueEvent, &os));
   oss.str ("");
   oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Dequeue";
-  Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiEvent, &os));
+  Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiDequeueEvent, &os));
+  oss.str ("");
+  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Drop";
+  Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiDropEvent, &os));
 }
 void 
 PointToPointHelper::EnableAscii (std::ostream &os, NetDeviceContainer d)
@@ -173,8 +177,27 @@
   writer->WritePacket (packet);
 }
 void 
-PointToPointHelper::AsciiEvent (std::ostream *os, std::string path, Ptr<const Packet> packet)
+PointToPointHelper::AsciiEnqueueEvent (std::ostream *os, std::string path, Ptr<const Packet> packet)
+{
+  *os << "+ " << Simulator::Now ().GetSeconds () << " ";
+  *os << path << " " << *packet << std::endl;
+}
+void 
+PointToPointHelper::AsciiDequeueEvent (std::ostream *os, std::string path, Ptr<const Packet> packet)
 {
+  *os << "- " << Simulator::Now ().GetSeconds () << " ";
+  *os << path << " " << *packet << std::endl;
+}
+void 
+PointToPointHelper::AsciiDropEvent (std::ostream *os, std::string path, Ptr<const Packet> packet)
+{
+  *os << "d " << Simulator::Now ().GetSeconds () << " ";
+  *os << path << " " << *packet << std::endl;
+}
+void 
+PointToPointHelper::AsciiRxEvent (std::ostream *os, std::string path, Ptr<const Packet> packet)
+{
+  *os << "r " << Simulator::Now ().GetSeconds () << " ";
   *os << path << " " << *packet << std::endl;
 }
 
--- a/src/helper/point-to-point-helper.h	Sun Mar 30 21:41:25 2008 -0700
+++ b/src/helper/point-to-point-helper.h	Sun Mar 30 22:39:27 2008 -0700
@@ -93,7 +93,10 @@
   void EnableAscii (Ptr<Node> node, Ptr<NetDevice> device);
   static void RxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet);
   static void EnqueueEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet);
-  static void AsciiEvent (std::ostream *os, std::string path, Ptr<const Packet> packet);
+  static void AsciiEnqueueEvent (std::ostream *os, std::string path, Ptr<const Packet> packet);
+  static void AsciiDequeueEvent (std::ostream *os, std::string path, Ptr<const Packet> packet);
+  static void AsciiDropEvent (std::ostream *os, std::string path, Ptr<const Packet> packet);
+  static void AsciiRxEvent (std::ostream *os, std::string path, Ptr<const Packet> packet);
   ObjectFactory m_queueFactory;
   ObjectFactory m_channelFactory;
   ObjectFactory m_deviceFactory;