Hook trace sources into the trace system. Add WifiTrace to give a 'simple' API to tracing wifi-specific sources.
--- a/src/devices/wifi/dca-txop.cc Fri Feb 22 23:28:01 2008 +0100
+++ b/src/devices/wifi/dca-txop.cc Fri Feb 22 23:34:53 2008 +0100
@@ -35,6 +35,7 @@
#include "mac-stations.h"
#include "wifi-phy.h"
#include "random-stream.h"
+#include "ns3/composite-trace-resolver.h"
NS_LOG_COMPONENT_DEFINE ("DcaTxop");
@@ -125,7 +126,7 @@
}
void
-DcaTxop::SetLow (MacLow *low)
+DcaTxop::SetLow (Ptr<MacLow> low)
{
m_low = low;
}
@@ -206,7 +207,7 @@
}
-MacLow *
+Ptr<MacLow>
DcaTxop::Low (void)
{
return m_low;
@@ -530,4 +531,21 @@
*/
}
+Ptr<TraceResolver>
+DcaTxop::GetTraceResolver (void) const
+{
+ Ptr<CompositeTraceResolver> resolver =
+ Create<CompositeTraceResolver> ();
+ resolver->AddSource ("ackTimeout",
+ TraceDoc ("ACK timeout",
+ "uint32_t", "Number of transmission attemps"),
+ m_acktimeoutTrace);
+ resolver->AddSource ("ctsTimeout",
+ TraceDoc ("CTS timeout",
+ "uint32_t", "Number of transmission attemps"),
+ m_ctstimeoutTrace);
+ resolver->SetParentResolver (Object::GetTraceResolver ());
+ return resolver;
+}
+
} // namespace ns3
--- a/src/devices/wifi/dca-txop.h Fri Feb 22 23:28:01 2008 +0100
+++ b/src/devices/wifi/dca-txop.h Fri Feb 22 23:34:53 2008 +0100
@@ -26,6 +26,7 @@
#include "ns3/packet.h"
#include "ns3/callback-trace-source.h"
#include "ns3/nstime.h"
+#include "ns3/object.h"
#include "wifi-mac-header.h"
#include "wifi-mode.h"
@@ -61,7 +62,7 @@
* The rts/cts policy is similar to the fragmentation policy: when
* a packet is bigger than a threshold, the rts/cts protocol is used.
*/
-class DcaTxop
+class DcaTxop : public Object
{
public:
typedef Callback <void, WifiMacHeader const&> TxOk;
@@ -80,7 +81,7 @@
DcaTxop (uint32_t cwMin, uint32_t cwMax, uint32_t aifsn, DcfManager *manager);
~DcaTxop ();
- void SetLow (MacLow *low);
+ void SetLow (Ptr<MacLow> low);
void SetParameters (MacParameters *parameters);
void SetStations (MacStations *stations);
void SetTxMiddle (MacTxMiddle *txMiddle);
@@ -115,7 +116,9 @@
friend class Dcf;
friend class TransmissionListener;
- MacLow *Low (void);
+ // Inherited from ns3::Object
+ virtual Ptr<TraceResolver> GetTraceResolver (void) const;
+ Ptr<MacLow> Low (void);
MacParameters *Parameters (void);
/* dcf notifications forwarded here */
@@ -151,7 +154,7 @@
TxFailed m_txFailedCallback;
WifiMacQueue *m_queue;
MacTxMiddle *m_txMiddle;
- MacLow *m_low;
+ Ptr <MacLow> m_low;
MacStations *m_stations;
MacParameters *m_parameters;
TransmissionListener *m_transmissionListener;
--- a/src/devices/wifi/mac-high-adhoc.cc Fri Feb 22 23:28:01 2008 +0100
+++ b/src/devices/wifi/mac-high-adhoc.cc Fri Feb 22 23:34:53 2008 +0100
@@ -49,7 +49,7 @@
m_callback = callback;
}
void
-MacHighAdhoc::SetDcaTxop (DcaTxop *dca)
+MacHighAdhoc::SetDcaTxop (Ptr<DcaTxop> dca)
{
m_dca = dca;
}
--- a/src/devices/wifi/mac-high-adhoc.h Fri Feb 22 23:28:01 2008 +0100
+++ b/src/devices/wifi/mac-high-adhoc.h Fri Feb 22 23:34:53 2008 +0100
@@ -49,7 +49,7 @@
void SetDevice (WifiNetDevice *device);
void SetForwardCallback (ForwardCallback callback);
- void SetDcaTxop (DcaTxop *dca);
+ void SetDcaTxop (Ptr<DcaTxop> dca);
void SetStations (MacStations *stations);
void SetPhy (Ptr<WifiPhy> phy);
@@ -60,7 +60,7 @@
/* invoked by the MacLows. */
void Receive (Ptr<Packet> packet, WifiMacHeader const*hdr);
private:
- DcaTxop *m_dca;
+ Ptr<DcaTxop> m_dca;
WifiNetDevice *m_device;
ForwardCallback m_callback;
MacStations *m_stations;
--- a/src/devices/wifi/mac-high-nqap.cc Fri Feb 22 23:28:01 2008 +0100
+++ b/src/devices/wifi/mac-high-nqap.cc Fri Feb 22 23:34:53 2008 +0100
@@ -47,14 +47,14 @@
}
void
-MacHighNqap::SetDcaTxop (DcaTxop *dca)
+MacHighNqap::SetDcaTxop (Ptr<DcaTxop> dca)
{
m_dca = dca;
m_dca->SetTxOkCallback (MakeCallback (&MacHighNqap::TxOk, this));
m_dca->SetTxFailedCallback (MakeCallback (&MacHighNqap::TxFailed, this));
}
void
-MacHighNqap::SetBeaconDcaTxop (DcaTxop *dca)
+MacHighNqap::SetBeaconDcaTxop (Ptr<DcaTxop> dca)
{
// we do not need to be notified when a beacon has been transmitted
// successfully or not.
--- a/src/devices/wifi/mac-high-nqap.h Fri Feb 22 23:28:01 2008 +0100
+++ b/src/devices/wifi/mac-high-nqap.h Fri Feb 22 23:34:53 2008 +0100
@@ -54,8 +54,8 @@
MacHighNqap ();
~MacHighNqap ();
- void SetDcaTxop (DcaTxop *dca);
- void SetBeaconDcaTxop (DcaTxop *dca);
+ void SetDcaTxop (Ptr<DcaTxop> dca);
+ void SetBeaconDcaTxop (Ptr<DcaTxop> dca);
void SetDevice (WifiNetDevice *device);
void SetStations (MacStations *stations);
void SetPhy (Ptr<WifiPhy> phy);
@@ -79,8 +79,8 @@
void SendOneBeacon (void);
SupportedRates GetSupportedRates (void) const;
- DcaTxop *m_dca;
- DcaTxop *m_beaconDca;
+ Ptr<DcaTxop> m_dca;
+ Ptr<DcaTxop> m_beaconDca;
WifiNetDevice *m_device;
MacStations *m_stations;
Ptr<WifiPhy> m_phy;
--- a/src/devices/wifi/mac-high-nqsta.cc Fri Feb 22 23:28:01 2008 +0100
+++ b/src/devices/wifi/mac-high-nqsta.cc Fri Feb 22 23:34:53 2008 +0100
@@ -76,7 +76,7 @@
}
void
-MacHighNqsta::SetDcaTxop (DcaTxop *dca)
+MacHighNqsta::SetDcaTxop (Ptr<DcaTxop> dca)
{
m_dca = dca;
}
--- a/src/devices/wifi/mac-high-nqsta.h Fri Feb 22 23:28:01 2008 +0100
+++ b/src/devices/wifi/mac-high-nqsta.h Fri Feb 22 23:34:53 2008 +0100
@@ -57,7 +57,7 @@
MacHighNqsta ();
~MacHighNqsta ();
- void SetDcaTxop (DcaTxop *dca);
+ void SetDcaTxop (Ptr<DcaTxop> dca);
void SetDevice (WifiNetDevice *device);
void SetForwardCallback (ForwardCallback callback);
void SetAssociatedCallback (AssociatedCallback callback);
@@ -122,7 +122,7 @@
ForwardCallback m_forward;
AssociatedCallback m_associatedCallback;
DisAssociatedCallback m_disAssociatedCallback;
- DcaTxop *m_dca;
+ Ptr<DcaTxop> m_dca;
EventId m_beaconWatchdog;
Time m_beaconWatchdogEnd;
Mac48Address m_bssid;
--- a/src/devices/wifi/mac-low.cc Fri Feb 22 23:28:01 2008 +0100
+++ b/src/devices/wifi/mac-low.cc Fri Feb 22 23:34:53 2008 +0100
@@ -31,6 +31,7 @@
#include "wifi-net-device.h"
#include "mac-stations.h"
#include "mac-parameters.h"
+#include "ns3/composite-trace-resolver.h"
NS_LOG_COMPONENT_DEFINE ("MacLow");
@@ -1076,4 +1077,17 @@
ForwardDown (packet, &ack, ackTxMode);
}
+Ptr<TraceResolver>
+MacLow::GetTraceResolver (void) const
+{
+ Ptr<CompositeTraceResolver> resolver =
+ Create<CompositeTraceResolver> ();
+ resolver->AddSource ("error",
+ TraceDoc ("Receive a packet with errors",
+ "Packet", "the packet received"),
+ m_dropError);
+ resolver->SetParentResolver (Object::GetTraceResolver ());
+ return resolver;
+}
+
} // namespace ns3
--- a/src/devices/wifi/mac-low.h Fri Feb 22 23:28:01 2008 +0100
+++ b/src/devices/wifi/mac-low.h Fri Feb 22 23:34:53 2008 +0100
@@ -270,12 +270,12 @@
/**
* \brief handle RTS/CTS/DATA/ACK transactions.
*/
-class MacLow {
+class MacLow : public Object {
public:
typedef Callback<void, Ptr<Packet> , WifiMacHeader const*> MacLowRxCallback;
MacLow ();
- ~MacLow ();
+ virtual ~MacLow ();
void SetDevice (Ptr<WifiNetDevice> device);
void SetPhy (Ptr<WifiPhy> phy);
@@ -340,6 +340,8 @@
*/
void ReceiveError (Ptr<Packet> packet, double rxSnr);
private:
+ // Inherited from ns3::Object.
+ virtual Ptr<TraceResolver> GetTraceResolver (void) const;
void CancelAllEvents (void);
uint32_t GetAckSize (void) const;
uint32_t GetRtsSize (void) const;
--- a/src/devices/wifi/wifi-net-device.cc Fri Feb 22 23:28:01 2008 +0100
+++ b/src/devices/wifi/wifi-net-device.cc Fri Feb 22 23:34:53 2008 +0100
@@ -237,7 +237,7 @@
m_stations->SetParameters (m_parameters);
// the MacLow
- MacLow *low = new MacLow ();
+ Ptr<MacLow> low = CreateObject<MacLow> ();
low->SetDevice (this);
low->SetPhy (m_phy);
low->SetStations (m_stations);
@@ -266,10 +266,10 @@
m_low->RegisterNavListener (m_navListener);
}
-DcaTxop *
+Ptr<DcaTxop>
WifiNetDevice::CreateDca (uint32_t minCw, uint32_t maxCw, uint32_t aifsn) const
{
- DcaTxop *dca = new DcaTxop (minCw, maxCw, aifsn, m_manager);
+ Ptr<DcaTxop> dca = CreateObject<DcaTxop> (minCw, maxCw, aifsn, m_manager);
dca->SetParameters (m_parameters);
dca->SetTxMiddle (m_txMiddle);
dca->SetLow (m_low);
@@ -297,6 +297,7 @@
m_txLogger,
WifiNetDeviceTraceType (WifiNetDeviceTraceType::TX));
resolver->AddComposite ("phy", m_phy);
+ resolver->AddComposite ("maclow", m_low);
resolver->SetParentResolver (NetDevice::GetTraceResolver ());
return resolver;
}
@@ -357,7 +358,6 @@
// cleanup local
m_channel = 0;
delete m_stations;
- delete m_low;
delete m_rxMiddle;
delete m_txMiddle;
delete m_parameters;
@@ -439,11 +439,19 @@
// chain up.
WifiNetDevice::DoDispose ();
// local cleanup
- delete m_dca;
delete m_high;
m_dca = 0;
m_high = 0;
}
+Ptr<TraceResolver>
+AdhocWifiNetDevice::GetTraceResolver (void) const
+{
+ Ptr<CompositeTraceResolver> resolver =
+ Create<CompositeTraceResolver> ();
+ resolver->AddComposite ("dca", m_dca);
+ resolver->SetParentResolver (WifiNetDevice::GetTraceResolver ());
+ return resolver;
+}
/*****************************************************
@@ -528,12 +536,20 @@
// chain up.
WifiNetDevice::DoDispose ();
// local cleanup
- delete m_dca;
delete m_high;
m_dca = 0;
m_high = 0;
}
+Ptr<TraceResolver>
+NqstaWifiNetDevice::GetTraceResolver (void) const
+{
+ Ptr<CompositeTraceResolver> resolver =
+ Create<CompositeTraceResolver> ();
+ resolver->AddComposite ("dca", m_dca);
+ resolver->SetParentResolver (WifiNetDevice::GetTraceResolver ());
+ return resolver;
+}
/*****************************************************
* AP code
@@ -623,14 +639,22 @@
// chain up.
WifiNetDevice::DoDispose ();
// local cleanup
- delete m_dca;
- delete m_beaconDca;
delete m_high;
m_dca = 0;
m_high = 0;
m_beaconDca = 0;
}
+Ptr<TraceResolver>
+NqapWifiNetDevice::GetTraceResolver (void) const
+{
+ Ptr<CompositeTraceResolver> resolver =
+ Create<CompositeTraceResolver> ();
+ resolver->AddComposite ("dca", m_dca);
+ resolver->AddComposite ("beaconDca", m_beaconDca);
+ resolver->SetParentResolver (WifiNetDevice::GetTraceResolver ());
+ return resolver;
+}
} // namespace ns3
--- a/src/devices/wifi/wifi-net-device.h Fri Feb 22 23:28:01 2008 +0100
+++ b/src/devices/wifi/wifi-net-device.h Fri Feb 22 23:34:53 2008 +0100
@@ -106,8 +106,6 @@
virtual bool DoNeedsArp (void) const;
virtual Ptr<Channel> DoGetChannel (void) const;
virtual bool SendTo (Ptr<Packet> packet, const Address &to, uint16_t protocolNumber);
- // inherited from Object
- virtual Ptr<TraceResolver> GetTraceResolver (void) const;
// defined for children
virtual void NotifyAttached (void) = 0;
virtual bool DoSendTo (Ptr<const Packet> packet, const Mac48Address &to) = 0;
@@ -117,17 +115,19 @@
CallbackTraceSource<Ptr<const Packet>, Mac48Address> m_rxLogger;
CallbackTraceSource<Ptr<const Packet>, Mac48Address> m_txLogger;
protected:
+ // inherited from Object
+ virtual Ptr<TraceResolver> GetTraceResolver (void) const;
WifiNetDevice (Ptr<Node> node);
WifiNetDevice (Ptr<Node> node, Mac48Address self);
void DoForwardUp (Ptr<Packet> packet, const Mac48Address &from);
- DcaTxop *CreateDca (uint32_t minCw, uint32_t maxCw, uint32_t aifsn) const;
+ Ptr<DcaTxop> CreateDca (uint32_t minCw, uint32_t maxCw, uint32_t aifsn) const;
// inherited from Object
virtual void DoDispose (void);
Ptr<WifiChannel> m_channel;
Ptr<WifiPhy> m_phy;
MacStations *m_stations;
- MacLow *m_low;
+ Ptr<MacLow> m_low;
MacRxMiddle *m_rxMiddle;
MacTxMiddle *m_txMiddle;
MacParameters *m_parameters;
@@ -161,9 +161,10 @@
// inherited from WifiNetDefice
virtual bool DoSendTo (Ptr<const Packet> packet, Mac48Address const & to);
virtual void NotifyAttached (void);
+ virtual Ptr<TraceResolver> GetTraceResolver (void) const;
Ssid m_ssid;
- DcaTxop *m_dca;
+ Ptr<DcaTxop> m_dca;
MacHighAdhoc *m_high;
};
@@ -207,9 +208,10 @@
// inherited from WifiNetDefice
virtual bool DoSendTo (Ptr<const Packet> packet, Mac48Address const & to);
virtual void NotifyAttached (void);
+ virtual Ptr<TraceResolver> GetTraceResolver (void) const;
Ssid m_ssid;
- DcaTxop *m_dca;
+ Ptr<DcaTxop> m_dca;
MacHighNqsta *m_high;
};
@@ -243,10 +245,11 @@
// inherited from WifiNetDefice
virtual bool DoSendTo (Ptr<const Packet> packet, Mac48Address const & to);
virtual void NotifyAttached (void);
+ virtual Ptr<TraceResolver> GetTraceResolver (void) const;
Ssid m_ssid;
- DcaTxop *m_dca;
- DcaTxop *m_beaconDca;
+ Ptr<DcaTxop> m_dca;
+ Ptr<DcaTxop> m_beaconDca;
MacHighNqap *m_high;
};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/wifi-trace.cc Fri Feb 22 23:34:53 2008 +0100
@@ -0,0 +1,197 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Federico Maguolo <maguolof@dei.unipd.it>
+ */
+#include "wifi-trace.h"
+
+#include "ns3/trace-context.h"
+#include "ns3/simulator.h"
+#include "ns3/node.h"
+#include "ns3/node-list.h"
+#include "ns3/packet.h"
+#include "ns3/queue.h"
+
+namespace ns3 {
+
+WifiTrace::WifiTrace (std::string filename)
+{
+ m_os.open (filename.c_str ());
+}
+
+WifiTrace::WifiTrace ()
+{}
+
+WifiTrace::~WifiTrace ()
+{
+ if (m_os.is_open ())
+ m_os.close ();
+}
+
+void
+WifiTrace::TraceAllNetDeviceRx (void)
+{
+ Packet::EnableMetadata ();
+ NodeList::Connect ("/nodes/*/devices/*/rx",
+ MakeCallback (&WifiTrace::LogDevRx, this));
+}
+
+void
+WifiTrace::TraceAllNetDeviceTx (void)
+{
+ Packet::EnableMetadata ();
+ NodeList::Connect ("/nodes/*/devices/*/tx",
+ MakeCallback (&WifiTrace::LogDevTx, this));
+}
+
+void
+WifiTrace::TraceAllPhy (void)
+{
+ Packet::EnableMetadata ();
+ NodeList::Connect ("/nodes/*/devices/*/*/state",
+ MakeCallback (&WifiTrace::LogPhy, this));
+}
+
+void
+WifiTrace::TraceAllErrors (void)
+{
+ Packet::EnableMetadata ();
+ NodeList::Connect ("/nodes/*/devices/*/*/error",
+ MakeCallback (&WifiTrace::LogErrors, this));
+}
+
+void
+WifiTrace::TraceAckTimeouts (void)
+{
+ Packet::EnableMetadata ();
+ NodeList::Connect ("/nodes/*/devices/*/*/ackTimeout",
+ MakeCallback (&WifiTrace::LogAckTimeout, this));
+}
+
+void
+WifiTrace::TraceCtsTimeouts (void)
+{
+ Packet::EnableMetadata ();
+ NodeList::Connect ("/nodes/*/devices/*/*/ctsTimeout",
+ MakeCallback (&WifiTrace::LogCtsTimeout, this));
+}
+
+void
+WifiTrace::LogDevRx (TraceContext const &context, Ptr<const Packet> p, Mac48Address addr)
+{
+ if (!m_os.is_open ())
+ return;
+ m_os << "r " << Simulator::Now ().GetSeconds () << " ";
+ uint8_t buf[6];
+ addr.CopyTo (buf);
+ for (uint8_t i = 0; i < 6; i++) {
+ m_os << (buf[i] + 0);
+ if (i < 5)
+ m_os << ".";
+ }
+ m_os << " ";
+ context.Print (m_os);
+ m_os << " pkt-uid=" << p->GetUid () << " ";
+ p->Print (m_os);
+ m_os << std::endl;
+}
+
+void
+WifiTrace::LogDevTx (TraceContext const &context, Ptr<const Packet> p, Mac48Address addr)
+{
+ if (!m_os.is_open ())
+ return;
+ m_os << "s " << Simulator::Now ().GetSeconds () << " ";
+ uint8_t buf[6];
+ addr.CopyTo (buf);
+ for (uint8_t i = 0; i < 6; i++) {
+ m_os << (buf[i] + 0);
+ if (i < 5)
+ m_os << ".";
+ }
+ m_os << " ";
+ context.Print (m_os);
+ m_os << " pkt-uid=" << p->GetUid () << " ";
+ p->Print (m_os);
+ m_os << std::endl;
+}
+
+void
+WifiTrace::LogErrors (TraceContext const &context, Ptr<const Packet> p)
+{
+ if (!m_os.is_open ())
+ return;
+ m_os << "d " << Simulator::Now ().GetSeconds () << " ";
+ context.Print (m_os);
+ m_os << " pkt-uid=" << p->GetUid () << " ";
+ p->Print (m_os);
+ m_os << std::endl;
+}
+
+void
+WifiTrace::LogPhy (TraceContext const &context, Time s, Time d, WifiPhy::State state)
+{
+ if (!m_os.is_open ())
+ return;
+ int prec = m_os.precision ();
+ m_os.precision (9);
+ m_os << "PHY " << Simulator::Now ().GetSeconds () << " ";
+ context.Print (m_os);
+ switch(state)
+ {
+ case WifiPhy::SYNC:
+ m_os << " SYNC";
+ break;
+ case WifiPhy::TX:
+ m_os << " TX";
+ break;
+ case WifiPhy::CCA_BUSY:
+ m_os << " CCA_BUSY";
+ break;
+ case WifiPhy::IDLE:
+ m_os << " IDLE";
+ break;
+ }
+ m_os << " t=" << s.GetSeconds () << " d=" << d.GetMicroSeconds ();
+ m_os << std::endl;
+ m_os.precision (prec);
+}
+
+void
+WifiTrace::LogAckTimeout (TraceContext const &context, uint32_t a)
+{
+ if (!m_os.is_open ())
+ return;
+ m_os << "ACK timeout " << Simulator::Now ().GetSeconds () << " ";
+ context.Print (m_os);
+ m_os << " attemps=" << (a+0);
+ m_os << std::endl;
+}
+
+void
+WifiTrace::LogCtsTimeout (TraceContext const &context, uint32_t a)
+{
+ if (!m_os.is_open ())
+ return;
+ m_os << "CTS timeout " << Simulator::Now ().GetSeconds () << " ";
+ context.Print (m_os);
+ m_os << " attemps=" << (a+0);
+ m_os << std::endl;
+}
+
+}//namespace ns3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/wifi-trace.h Fri Feb 22 23:34:53 2008 +0100
@@ -0,0 +1,60 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Federico Maguolo <maguolof@dei.unipd.it>
+ */
+#ifndef WIFI_TRACE_H
+#define WIFI_TRACE_H
+
+#include <string>
+#include <fstream>
+#include "ns3/wifi-phy.h"
+#include "ns3/mac48-address.h"
+//#include "ns3/ptr.h"
+
+namespace ns3 {
+
+class Packet;
+class TraceContext;
+
+class WifiTrace
+{
+public:
+ WifiTrace (std::string filename);
+ WifiTrace ();
+ virtual ~WifiTrace ();
+ void TraceAllNetDeviceRx (void);
+ void TraceAllNetDeviceTx (void);
+ void TraceAllPhy (void);
+ void TraceAllErrors (void);
+ void TraceAckTimeouts (void);
+ void TraceCtsTimeouts (void);
+protected:
+ virtual void LogErrors (TraceContext const &context, Ptr<const Packet> p);
+ virtual void LogDevRx (TraceContext const &context, Ptr<const Packet> p, Mac48Address addr);
+ virtual void LogDevTx (TraceContext const &context, Ptr<const Packet> p, Mac48Address addr);
+ virtual void LogPhy (TraceContext const &context, Time s, Time d, WifiPhy::State state);
+ virtual void LogAckTimeout (TraceContext const &context, uint32_t a);
+ virtual void LogCtsTimeout (TraceContext const &context, uint32_t a);
+private:
+ std::ofstream m_os;
+};
+
+}//namespace ns3
+
+#endif /* ASCII_TRACE_H */
--- a/src/devices/wifi/wscript Fri Feb 22 23:28:01 2008 +0100
+++ b/src/devices/wifi/wscript Fri Feb 22 23:34:53 2008 +0100
@@ -36,6 +36,7 @@
'dcf-manager-test.cc',
'onoe-mac-stations.cc',
'amrr-mac-stations.cc',
+ 'wifi-trace.cc',
]
headers = bld.create_obj('ns3header')
headers.source = [
@@ -47,4 +48,5 @@
'wifi-preamble.h',
'wifi-phy-standard.h',
'wifi-phy.h',
+ 'wifi-trace.h',
]