add wifi helper tracing.
--- a/src/helper/wifi-helper.cc Mon Mar 31 12:22:05 2008 -0400
+++ b/src/helper/wifi-helper.cc Mon Mar 31 09:34:51 2008 -0700
@@ -19,18 +19,33 @@
namespace ns3 {
-static void PhyTxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet,
- WifiMode mode, WifiPreamble preamble,
- uint8_t txLevel)
+static void PcapPhyTxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet,
+ WifiMode mode, WifiPreamble preamble,
+ uint8_t txLevel)
+{
+ writer->WritePacket (packet);
+}
+
+static void PcapPhyRxEvent (Ptr<PcapWriter> writer,
+ Ptr<const Packet> packet, double snr, WifiMode mode,
+ enum WifiPreamble preamble)
{
writer->WritePacket (packet);
}
-static void PhyRxEvent (Ptr<PcapWriter> writer,
- Ptr<const Packet> packet, double snr, WifiMode mode,
- enum WifiPreamble preamble)
+static void AsciiPhyTxEvent (std::ostream *os, std::string context,
+ Ptr<const Packet> packet,
+ WifiMode mode, WifiPreamble preamble,
+ uint8_t txLevel)
{
- writer->WritePacket (packet);
+ *os << context << " " << *packet << std::endl;
+}
+
+static void AsciiPhyRxOkEvent (std::ostream *os, std::string context,
+ Ptr<const Packet> packet, double snr, WifiMode mode,
+ enum WifiPreamble preamble)
+{
+ *os << context << " " << *packet << std::endl;
}
@@ -120,9 +135,21 @@
pcap->WriteWifiHeader ();
oss.str ("");
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/Tx";
- Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PhyTxEvent, pcap));
+ Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PcapPhyTxEvent, pcap));
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/RxOk";
- Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PhyRxEvent, pcap));
+ Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PcapPhyRxEvent, pcap));
+}
+
+void
+WifiHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
+{
+ Packet::EnableMetadata ();
+ std::ostringstream oss;
+ oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/RxOk";
+ Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyRxOkEvent, &os));
+ oss.str ("");
+ oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/Tx";
+ Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyTxEvent, &os));
}
NetDeviceContainer
--- a/src/helper/wifi-helper.h Mon Mar 31 12:22:05 2008 -0400
+++ b/src/helper/wifi-helper.h Mon Mar 31 09:34:51 2008 -0700
@@ -121,6 +121,7 @@
static void EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid);
+ static void EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid);
/**
* \param c a set of nodes