src/helper/yans-wifi-helper.cc
changeset 4712 74ed62336c36
parent 4709 b0743dbc4e55
child 4715 d0041768ff60
--- a/src/helper/yans-wifi-helper.cc	Thu Aug 13 12:54:21 2009 +0200
+++ b/src/helper/yans-wifi-helper.cc	Thu Aug 13 12:54:22 2009 +0200
@@ -25,6 +25,7 @@
 #include "ns3/yans-wifi-phy.h"
 #include "ns3/wifi-net-device.h"
 #include "ns3/pcap-writer.h"
+#include "ns3/ascii-writer.h"
 #include "ns3/simulator.h"
 #include "ns3/config.h"
 #include "ns3/names.h"
@@ -46,19 +47,19 @@
 }
 
 
-static void AsciiPhyTxEvent (std::ostream *os, std::string context, 
+static void AsciiPhyTxEvent (Ptr<AsciiWriter> writer, std::string path,
                              Ptr<const Packet> packet,
-                             WifiMode mode, WifiPreamble preamble, 
+                             WifiMode mode, WifiPreamble preamble,
                              uint8_t txLevel)
 {
-  *os << "+ " << Simulator::Now () << " " << context << " " << *packet << std::endl;
+  writer->WritePacket (AsciiWriter::TX, path, packet);
 }
 
-static void AsciiPhyRxOkEvent (std::ostream *os, std::string context, 
-                               Ptr<const Packet> packet, double snr, WifiMode mode, 
+static void AsciiPhyRxOkEvent (Ptr<AsciiWriter> writer, std::string path,
+                               Ptr<const Packet> packet, double snr, WifiMode mode,
                                enum WifiPreamble preamble)
 {
-  *os << "r " << Simulator::Now () << " " << context << " " << *packet << std::endl;
+  writer->WritePacket (AsciiWriter::RX, path, packet);
 }
 
 
@@ -307,13 +308,14 @@
 void 
 YansWifiPhyHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
 {
+  Ptr<AsciiWriter> writer = AsciiWriter::Get (os);
   Packet::EnablePrinting ();
   std::ostringstream oss;
   oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/RxOk";
-  Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyRxOkEvent, &os));
+  Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyRxOkEvent, writer));
   oss.str ("");
   oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/Tx";
-  Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyTxEvent, &os));
+  Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyTxEvent, writer));
 }
 void 
 YansWifiPhyHelper::EnableAscii (std::ostream &os, NetDeviceContainer d)