diff --git a/src/helper/point-to-point-helper.cc b/src/helper/point-to-point-helper.cc index 6e6f7c6b9..ff85d689f 100644 --- a/src/helper/point-to-point-helper.cc +++ b/src/helper/point-to-point-helper.cc @@ -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 @@ PointToPointHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t dev 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 @@ PointToPointHelper::RxEvent (Ptr writer, Ptr packet) writer->WritePacket (packet); } void -PointToPointHelper::AsciiEvent (std::ostream *os, std::string path, Ptr packet) +PointToPointHelper::AsciiEnqueueEvent (std::ostream *os, std::string path, Ptr packet) { + *os << "+ " << Simulator::Now ().GetSeconds () << " "; + *os << path << " " << *packet << std::endl; +} +void +PointToPointHelper::AsciiDequeueEvent (std::ostream *os, std::string path, Ptr packet) +{ + *os << "- " << Simulator::Now ().GetSeconds () << " "; + *os << path << " " << *packet << std::endl; +} +void +PointToPointHelper::AsciiDropEvent (std::ostream *os, std::string path, Ptr packet) +{ + *os << "d " << Simulator::Now ().GetSeconds () << " "; + *os << path << " " << *packet << std::endl; +} +void +PointToPointHelper::AsciiRxEvent (std::ostream *os, std::string path, Ptr packet) +{ + *os << "r " << Simulator::Now ().GetSeconds () << " "; *os << path << " " << *packet << std::endl; } diff --git a/src/helper/point-to-point-helper.h b/src/helper/point-to-point-helper.h index 2315684e6..a9eaba760 100644 --- a/src/helper/point-to-point-helper.h +++ b/src/helper/point-to-point-helper.h @@ -93,7 +93,10 @@ private: void EnableAscii (Ptr node, Ptr device); static void RxEvent (Ptr writer, Ptr packet); static void EnqueueEvent (Ptr writer, Ptr packet); - static void AsciiEvent (std::ostream *os, std::string path, Ptr packet); + static void AsciiEnqueueEvent (std::ostream *os, std::string path, Ptr packet); + static void AsciiDequeueEvent (std::ostream *os, std::string path, Ptr packet); + static void AsciiDropEvent (std::ostream *os, std::string path, Ptr packet); + static void AsciiRxEvent (std::ostream *os, std::string path, Ptr packet); ObjectFactory m_queueFactory; ObjectFactory m_channelFactory; ObjectFactory m_deviceFactory;