add wifi helper tracing.

This commit is contained in:
Mathieu Lacage
2008-03-31 09:34:51 -07:00
parent f2769ba5a5
commit 9bcf1cdac5
2 changed files with 36 additions and 8 deletions

View File

@@ -19,20 +19,35 @@ NS_LOG_COMPONENT_DEFINE ("WifiHelper");
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 PhyRxEvent (Ptr<PcapWriter> writer,
Ptr<const Packet> packet, double snr, WifiMode mode,
enum WifiPreamble preamble)
static void PcapPhyRxEvent (Ptr<PcapWriter> writer,
Ptr<const Packet> packet, double snr, WifiMode mode,
enum WifiPreamble preamble)
{
writer->WritePacket (packet);
}
static void AsciiPhyTxEvent (std::ostream *os, std::string context,
Ptr<const Packet> packet,
WifiMode mode, WifiPreamble preamble,
uint8_t txLevel)
{
*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;
}
WifiHelper::WifiHelper ()
{
@@ -120,9 +135,21 @@ WifiHelper::EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid
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

View File

@@ -121,6 +121,7 @@ public:
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