use function logging macros
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 15 Apr 2008 15:53:54 -0700
changeset 2985 fa0747c4ad5e
parent 2984 27b183b18d4d
child 2986 484e5030c441
use function logging macros
src/devices/wifi/dca-txop.cc
src/devices/wifi/ideal-wifi-manager.cc
src/devices/wifi/mac-low.cc
src/devices/wifi/mac-low.h
src/devices/wifi/mac-rx-middle.cc
src/devices/wifi/nqap-wifi-mac.cc
src/devices/wifi/nqsta-wifi-mac.cc
src/devices/wifi/wifi-mac-header.cc
src/devices/wifi/wifi-phy.cc
--- a/src/devices/wifi/dca-txop.cc	Tue Apr 15 15:29:43 2008 -0700
+++ b/src/devices/wifi/dca-txop.cc	Tue Apr 15 15:53:54 2008 -0700
@@ -37,7 +37,7 @@
 NS_LOG_COMPONENT_DEFINE ("DcaTxop");
 
 #define MY_DEBUG(x) \
-  NS_LOG_DEBUG (Simulator::Now () << " " << m_low->GetMac ()->GetAddress () << " " << x)
+  NS_LOG_DEBUG (m_low->GetMac ()->GetAddress () << " " << x)
 
 
 namespace ns3 {
@@ -122,6 +122,7 @@
   : m_manager (0),
     m_currentPacket (0)
 {
+  NS_LOG_FUNCTION (this);
   m_transmissionListener = new DcaTxop::TransmissionListener (this);
   m_dcf = new DcaTxop::Dcf (this);
   m_queue = CreateObject<WifiMacQueue> ();
@@ -130,11 +131,14 @@
 }
 
 DcaTxop::~DcaTxop ()
-{}
+{
+  NS_LOG_FUNCTION (this);
+}
 
 void
 DcaTxop::DoDispose (void)
 {
+  NS_LOG_FUNCTION (this);
   delete m_transmissionListener;
   delete m_dcf;
   delete m_rng;
@@ -151,6 +155,7 @@
 void
 DcaTxop::SetManager (DcfManager *manager)
 {
+  NS_LOG_FUNCTION (this << manager);
   m_manager = manager;
   m_manager->Add (m_dcf);
 }
@@ -158,11 +163,13 @@
 void 
 DcaTxop::SetLow (Ptr<MacLow> low)
 {
+  NS_LOG_FUNCTION (this << low);
   m_low = low;
 }
 void 
 DcaTxop::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> remoteManager)
 {
+  NS_LOG_FUNCTION (this << remoteManager);
   m_stationManager = remoteManager;
 }
 void 
@@ -179,26 +186,31 @@
 void 
 DcaTxop::SetMaxQueueSize (uint32_t size)
 {
+  NS_LOG_FUNCTION (this << size);
   m_queue->SetMaxSize (size);
 }
 void 
 DcaTxop::SetMaxQueueDelay (Time delay)
 {
+  NS_LOG_FUNCTION (this << delay);
   m_queue->SetMaxDelay (delay);
 }
 void 
 DcaTxop::SetMinCw (uint32_t minCw)
 {
+  NS_LOG_FUNCTION (this << minCw);
   m_dcf->SetCwMin (minCw);
 }
 void 
 DcaTxop::SetMaxCw (uint32_t maxCw)
 {
+  NS_LOG_FUNCTION (this << maxCw);
   m_dcf->SetCwMax (maxCw);
 }
 void 
 DcaTxop::SetAifsn (uint32_t aifsn)
 {
+  NS_LOG_FUNCTION (this << aifsn);
   m_dcf->SetAifsn (aifsn);
 }
 uint32_t 
@@ -220,6 +232,7 @@
 void 
 DcaTxop::Queue (Ptr<const Packet> packet, WifiMacHeader const &hdr)
 {
+  NS_LOG_FUNCTION (this << packet << &hdr);
   WifiMacTrailer fcs;
   uint32_t fullPacketSize = hdr.GetSerializedSize () + packet->GetSize () + fcs.GetSerializedSize ();
   WifiRemoteStation *station = GetStation (hdr.GetAddr1 ());
@@ -237,6 +250,7 @@
 void
 DcaTxop::RestartAccessIfNeeded (void)
 {
+  NS_LOG_FUNCTION (this);
   if ((m_currentPacket != 0 ||
        !m_queue->IsEmpty ()) &&
       !m_dcf->IsAccessRequested ())
@@ -248,6 +262,7 @@
 void
 DcaTxop::StartAccessIfNeeded (void)
 {
+  NS_LOG_FUNCTION (this);
   if (m_currentPacket == 0 &&
       !m_queue->IsEmpty () &&
       !m_dcf->IsAccessRequested ())
@@ -350,6 +365,7 @@
 void 
 DcaTxop::NotifyAccessGranted (void)
 {
+  NS_LOG_FUNCTION (this);
   if (m_currentPacket == 0) 
     {
       if (m_queue->IsEmpty ()) 
@@ -429,11 +445,13 @@
 void 
 DcaTxop::NotifyInternalCollision (void)
 {
+  NS_LOG_FUNCTION (this);
   NotifyCollision ();
 }
 void 
 DcaTxop::NotifyCollision (void)
 {
+  NS_LOG_FUNCTION (this);
   MY_DEBUG ("collision");
   m_dcf->StartBackoffNow (m_rng->GetNext (0, m_dcf->GetCw ()));
   RestartAccessIfNeeded ();
@@ -442,11 +460,13 @@
 void 
 DcaTxop::GotCts (double snr, WifiMode txMode)
 {
+  NS_LOG_FUNCTION (this << snr << txMode);
   MY_DEBUG ("got cts");
 }
 void 
 DcaTxop::MissedCts (void)
 {
+  NS_LOG_FUNCTION (this);
   MY_DEBUG ("missed cts");
   if (!NeedRtsRetransmission ())
     {
@@ -467,6 +487,7 @@
 void 
 DcaTxop::GotAck (double snr, WifiMode txMode)
 {
+  NS_LOG_FUNCTION (this << snr << txMode);
   if (!NeedFragmentation () ||
       IsLastFragment ()) 
     {
@@ -492,6 +513,7 @@
 void 
 DcaTxop::MissedAck (void)
 {
+  NS_LOG_FUNCTION (this);
   MY_DEBUG ("missed ack");
   if (!NeedDataRetransmission ()) 
     {
@@ -518,6 +540,7 @@
 void 
 DcaTxop::StartNext (void)
 {
+  NS_LOG_FUNCTION (this);
   MY_DEBUG ("start next packet fragment");
   /* this callback is used only for fragments. */
   NextFragment ();
@@ -541,6 +564,7 @@
 void
 DcaTxop::Cancel (void)
 {
+  NS_LOG_FUNCTION (this);
   MY_DEBUG ("transmission cancelled");
   /**
    * This happens in only one case: in an AP, you have two DcaTxop:
--- a/src/devices/wifi/ideal-wifi-manager.cc	Tue Apr 15 15:29:43 2008 -0700
+++ b/src/devices/wifi/ideal-wifi-manager.cc	Tue Apr 15 15:53:54 2008 -0700
@@ -23,17 +23,6 @@
 #include "ns3/double.h"
 #include <math.h>
 
-#define noIDEAL_DEBUG 1
-
-#ifdef IDEAL_DEBUG
-#include <iostream>
-#  define TRACE(x) \
-std::cout << "IDEAL TRACE " << x << std::endl;
-#else
-#  define TRACE(x)
-#endif
-
-
 namespace ns3 {
 
 NS_OBJECT_ENSURE_REGISTERED (IdealWifiManager);
@@ -115,13 +104,11 @@
 void 
 IdealWifiRemoteStation::DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
 {
-  TRACE ("got cts for rts snr="<<rtsSnr);
   m_lastSnr = rtsSnr;
 }
 void 
 IdealWifiRemoteStation::DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
 {
-  TRACE ("got cts for rts snr="<<dataSnr);
   m_lastSnr = dataSnr;
 }
 void 
--- a/src/devices/wifi/mac-low.cc	Tue Apr 15 15:29:43 2008 -0700
+++ b/src/devices/wifi/mac-low.cc	Tue Apr 15 15:53:54 2008 -0700
@@ -33,7 +33,7 @@
 NS_LOG_COMPONENT_DEFINE ("MacLow");
 
 #define MY_DEBUG(x) \
-  NS_LOG_DEBUG (Simulator::Now () << " " << m_mac->GetAddress () << " " << x)
+  NS_LOG_DEBUG (m_mac->GetAddress () << " " << x)
 
 namespace ns3 {
 
@@ -215,7 +215,30 @@
   return m_nextSize;
 }
 
-
+std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters &params)
+{
+  os << "[" 
+     << "send rts=" << params.m_sendRts << ", "
+     << "next size=" << params.m_nextSize << ", "
+     << "dur=" << params.m_overrideDurationId << ", "
+     << "ack=";
+  switch (params.m_waitAck) {
+  case MacLowTransmissionParameters::ACK_NONE:
+    os << "none";
+    break;
+  case MacLowTransmissionParameters::ACK_NORMAL:
+    os << "normal";
+    break;
+  case MacLowTransmissionParameters::ACK_FAST:
+    os << "fast";
+    break;
+  case MacLowTransmissionParameters::ACK_SUPER_FAST:
+    os << "super-fast";
+    break;
+  }
+  os << "]";
+  return os;
+}
 
 MacLow::MacLow ()
   : m_normalAckTimeoutEvent (),
@@ -230,16 +253,20 @@
     m_currentPacket (0),
     m_listener (0)
 {
+  NS_LOG_FUNCTION (this);
   m_lastNavDuration = Seconds (0);
   m_lastNavStart = Seconds (0);
 }
 
 MacLow::~MacLow ()
-{}
+{
+  NS_LOG_FUNCTION (this);
+}
 
 void 
 MacLow::DoDispose (void)
 {
+  NS_LOG_FUNCTION (this);
   CancelAllEvents ();
   m_phy = 0;
   m_mac = 0;
@@ -249,6 +276,7 @@
 void
 MacLow::CancelAllEvents (void)
 {
+  NS_LOG_FUNCTION (this);
   bool oneRunning = false;
   if (m_normalAckTimeoutEvent.IsRunning ()) 
     {
@@ -339,9 +367,10 @@
 void 
 MacLow::StartTransmission (Ptr<const Packet> packet, 
                            WifiMacHeader const*hdr, 
-                           MacLowTransmissionParameters parameters,
+                           MacLowTransmissionParameters params,
                            MacLowTransmissionListener *listener)
 {
+  NS_LOG_FUNCTION (this << packet << hdr << params << listener);
   /* m_currentPacket is not NULL because someone started
    * a transmission and was interrupted before one of:
    *   - ctsTimeout
@@ -360,7 +389,7 @@
   m_currentHdr = *hdr;
   CancelAllEvents ();
   m_listener = listener;
-  m_txParams = parameters;
+  m_txParams = params;
 
   //NS_ASSERT (m_phy->IsStateIdle ());
 
@@ -383,6 +412,7 @@
 void
 MacLow::ReceiveError (Ptr<Packet> packet, double rxSnr)
 {
+  NS_LOG_FUNCTION (this << packet << rxSnr);
   MY_DEBUG ("rx failed ");
   if (m_txParams.MustWaitFastAck ()) 
     {
@@ -396,6 +426,7 @@
 void 
 MacLow::ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiMode txMode, WifiPreamble preamble)
 {
+  NS_LOG_FUNCTION (this << packet << rxSnr << txMode << preamble);
   /* A packet is received from the PHY.
    * When we have handled this packet,
    * we handle any packet present in the
@@ -754,6 +785,7 @@
 MacLow::ForwardDown (Ptr<const Packet> packet, WifiMacHeader const* hdr, 
                      WifiMode txMode)
 {
+  NS_LOG_FUNCTION (this << packet << hdr << txMode);
   MY_DEBUG ("send " << hdr->GetTypeString () <<
             ", to=" << hdr->GetAddr1 () <<
             ", size=" << packet->GetSize () <<
@@ -773,6 +805,7 @@
 void
 MacLow::CtsTimeout (void)
 {
+  NS_LOG_FUNCTION (this);
   MY_DEBUG ("cts timeout");
   // XXX: should check that there was no rx start before now.
   // we should restart a new cts timeout now until the expected
@@ -787,6 +820,7 @@
 void
 MacLow::NormalAckTimeout (void)
 {
+  NS_LOG_FUNCTION (this);
   MY_DEBUG ("normal ack timeout");
   // XXX: should check that there was no rx start before now.
   // we should restart a new ack timeout now until the expected
@@ -800,6 +834,7 @@
 void
 MacLow::FastAckTimeout (void)
 {
+  NS_LOG_FUNCTION (this);
   WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ());
   station->ReportDataFailed ();
   MacLowTransmissionListener *listener = m_listener;
@@ -817,6 +852,7 @@
 void
 MacLow::SuperFastAckTimeout ()
 {
+  NS_LOG_FUNCTION (this);
   WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ());
   station->ReportDataFailed ();
   MacLowTransmissionListener *listener = m_listener;
@@ -836,6 +872,7 @@
 void
 MacLow::SendRtsForPacket (void)
 {
+  NS_LOG_FUNCTION (this);
   /* send an RTS for this packet. */
   WifiMacHeader rts;
   rts.SetType (WIFI_MAC_CTL_RTS);
@@ -917,6 +954,7 @@
 void
 MacLow::SendDataPacket (void)
 {
+  NS_LOG_FUNCTION (this);
   /* send this packet directly. No RTS is needed. */
   StartDataTxTimers ();
 
@@ -977,6 +1015,7 @@
 void
 MacLow::SendCtsAfterRts (Mac48Address source, Time duration, WifiMode rtsTxMode, double rtsSnr)
 {
+  NS_LOG_FUNCTION (this);
   /* send a CTS when you receive a RTS 
    * right after SIFS.
    */
@@ -1007,6 +1046,7 @@
 void
 MacLow::SendDataAfterCts (Mac48Address source, Time duration, WifiMode txMode)
 {
+  NS_LOG_FUNCTION (this);
   /* send the third step in a 
    * RTS/CTS/DATA/ACK hanshake 
    */
@@ -1043,6 +1083,7 @@
 void
 MacLow::FastAckFailedTimeout (void)
 {
+  NS_LOG_FUNCTION (this);
   MacLowTransmissionListener *listener = m_listener;
   m_listener = 0;
   listener->MissedAck ();
@@ -1052,6 +1093,7 @@
 void
 MacLow::SendAckAfterData (Mac48Address source, Time duration, WifiMode dataTxMode, double dataSnr)
 {
+  NS_LOG_FUNCTION (this);
   /* send an ACK when you receive 
    * a packet after SIFS. 
    */
--- a/src/devices/wifi/mac-low.h	Tue Apr 15 15:29:43 2008 -0700
+++ b/src/devices/wifi/mac-low.h	Tue Apr 15 15:53:54 2008 -0700
@@ -22,6 +22,7 @@
 
 #include <vector>
 #include <stdint.h>
+#include <ostream>
 
 #include "wifi-mac-header.h"
 #include "wifi-mode.h"
@@ -252,6 +253,7 @@
   uint32_t GetNextPacketSize (void) const;
 
 private:
+  friend std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters &params);
   uint32_t m_nextSize;
   enum {
     ACK_NONE,
@@ -263,6 +265,8 @@
   Time m_overrideDurationId;
 };
 
+std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters &params);
+
 
 /**
  * \brief handle RTS/CTS/DATA/ACK transactions.
--- a/src/devices/wifi/mac-rx-middle.cc	Tue Apr 15 15:29:43 2008 -0700
+++ b/src/devices/wifi/mac-rx-middle.cc	Tue Apr 15 15:53:54 2008 -0700
@@ -29,8 +29,6 @@
 
 NS_LOG_COMPONENT_DEFINE ("MacRxMiddle");
 
-#define TRACE(x) NS_LOG_DEBUG(Simulator::Now () << " " << x)
-
 namespace ns3 {
 
 
@@ -99,10 +97,13 @@
 
 
 MacRxMiddle::MacRxMiddle ()
-{}
+{
+  NS_LOG_FUNCTION_NOARGS ();
+}
 
 MacRxMiddle::~MacRxMiddle ()
 {
+  NS_LOG_FUNCTION_NOARGS ();
   for (OriginatorsI i = m_originatorStatus.begin ();
        i != m_originatorStatus.end (); i++) 
     {
@@ -122,16 +123,18 @@
 void 
 MacRxMiddle::SetForwardCallback (ForwardUpCallback callback)
 {
+  NS_LOG_FUNCTION_NOARGS ();
   m_callback = callback;
 }
 
 bool
 MacRxMiddle::SequenceControlSmaller (int seqca, int seqcb)
 {
+  NS_LOG_FUNCTION (seqca << seqcb);
   int seqa = seqca >> 4;
   int seqb = seqcb >> 4;
   int delta = seqb - seqa;
-  TRACE ("seqb="<<seqb<<", seqa="<<seqa<<", delta="<<delta);
+  NS_LOG_DEBUG ("seqb="<<seqb<<", seqa="<<seqa<<", delta="<<delta);
   if (delta <= 0 && delta < -2048) 
     {
       return true;
@@ -150,6 +153,7 @@
 OriginatorRxStatus *
 MacRxMiddle::Lookup (WifiMacHeader const *hdr)
 {
+  NS_LOG_FUNCTION (hdr);
   OriginatorRxStatus *originator;
   Mac48Address source = hdr->GetAddr2 ();
   if (hdr->IsQosData () &&
@@ -184,6 +188,7 @@
 MacRxMiddle::IsDuplicate (WifiMacHeader const*hdr, 
                           OriginatorRxStatus *originator) const
 {
+  NS_LOG_FUNCTION (hdr << originator);
   if (hdr->IsRetry () &&
       originator->GetLastSequenceControl () == hdr->GetSequenceControl ()) 
     {
@@ -196,13 +201,14 @@
 MacRxMiddle::HandleFragments (Ptr<Packet> packet, WifiMacHeader const*hdr,
                               OriginatorRxStatus *originator)
 {
+  NS_LOG_FUNCTION (packet << hdr << originator);
   if (originator->IsDeFragmenting ()) 
     {
       if (hdr->IsMoreFragments ()) 
         {
           if (originator->IsNextFragment (hdr->GetSequenceControl ())) 
             {
-              TRACE ("accumulate fragment seq="<<hdr->GetSequenceNumber ()<<
+              NS_LOG_DEBUG ("accumulate fragment seq="<<hdr->GetSequenceNumber ()<<
                      ", frag="<<hdr->GetFragmentNumber ()<<
                      ", size="<<packet->GetSize ());
               originator->AccumulateFragment (packet);
@@ -210,7 +216,7 @@
             } 
           else 
             {
-              TRACE ("non-ordered fragment");
+              NS_LOG_DEBUG ("non-ordered fragment");
             }
           return 0;
         } 
@@ -218,7 +224,7 @@
         {
           if (originator->IsNextFragment (hdr->GetSequenceControl ())) 
             {
-              TRACE ("accumulate last fragment seq="<<hdr->GetSequenceNumber ()<<
+              NS_LOG_DEBUG ("accumulate last fragment seq="<<hdr->GetSequenceNumber ()<<
                      ", frag="<<hdr->GetFragmentNumber ()<<
                      ", size="<<hdr->GetSize ());
               Ptr<Packet> p = originator->AccumulateLastFragment (packet);
@@ -227,7 +233,7 @@
             } 
           else 
             {
-              TRACE ("non-ordered fragment");
+              NS_LOG_DEBUG ("non-ordered fragment");
               return 0;
             }
         }
@@ -236,7 +242,7 @@
     {
       if (hdr->IsMoreFragments ()) 
         {
-          TRACE ("accumulate first fragment seq="<<hdr->GetSequenceNumber ()<<
+          NS_LOG_DEBUG ("accumulate first fragment seq="<<hdr->GetSequenceNumber ()<<
                  ", frag="<<hdr->GetFragmentNumber ()<<
                  ", size="<<packet->GetSize ());
           originator->AccumulateFirstFragment (packet);
@@ -253,6 +259,7 @@
 void
 MacRxMiddle::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
 {
+  NS_LOG_FUNCTION (packet << hdr);
   OriginatorRxStatus *originator = Lookup (hdr);
   if (hdr->IsData ()) 
     {
@@ -272,7 +279,7 @@
       // filter duplicates.
       if (IsDuplicate (hdr, originator)) 
         {
-          TRACE ("duplicate from="<<hdr->GetAddr2 ()<<
+          NS_LOG_DEBUG ("duplicate from="<<hdr->GetAddr2 ()<<
                  ", seq="<<hdr->GetSequenceNumber ()<<
                  ", frag="<<hdr->GetFragmentNumber ());
           return;
@@ -282,7 +289,7 @@
         {
           return;
         }
-      TRACE ("forwarding data from="<<hdr->GetAddr2 ()<<
+      NS_LOG_DEBUG ("forwarding data from="<<hdr->GetAddr2 ()<<
              ", seq="<<hdr->GetSequenceNumber ()<<
              ", frag="<<hdr->GetFragmentNumber ());
       if (!hdr->GetAddr1 ().IsBroadcast ())
@@ -293,7 +300,7 @@
     } 
   else 
     {
-      TRACE ("forwarding "<<hdr->GetTypeString ()<<
+      NS_LOG_DEBUG ("forwarding "<<hdr->GetTypeString ()<<
              ", from="<<hdr->GetAddr2 ()<<
              ", seq="<<hdr->GetSequenceNumber ()<<
              ", frag="<<hdr->GetFragmentNumber ());
--- a/src/devices/wifi/nqap-wifi-mac.cc	Tue Apr 15 15:29:43 2008 -0700
+++ b/src/devices/wifi/nqap-wifi-mac.cc	Tue Apr 15 15:53:54 2008 -0700
@@ -33,9 +33,6 @@
 
 NS_LOG_COMPONENT_DEFINE ("NqapWifiMac");
 
-#define TRACE(x) \
-  NS_LOG_DEBUG(Simulator::Now () << " " << GetAddress () << " " << x);
-
 namespace ns3 {
 
 NS_OBJECT_ENSURE_REGISTERED (NqapWifiMac);
@@ -61,6 +58,7 @@
 
 NqapWifiMac::NqapWifiMac ()
 {
+  NS_LOG_FUNCTION (this);
   m_rxMiddle = new MacRxMiddle ();
   m_rxMiddle->SetForwardCallback (MakeCallback (&NqapWifiMac::Receive, this));
 
@@ -82,11 +80,14 @@
   m_beaconDca->SetManager (m_dcfManager);
 }
 NqapWifiMac::~NqapWifiMac ()
-{}
+{
+  NS_LOG_FUNCTION (this);
+}
 
 void
 NqapWifiMac::DoDispose (void)
 {
+  NS_LOG_FUNCTION (this);
   delete m_rxMiddle;
   delete m_dcfManager;
   m_rxMiddle = 0;
@@ -102,6 +103,7 @@
 void
 NqapWifiMac::SetBeaconGeneration (bool enable)
 {
+  NS_LOG_FUNCTION (this << enable);
   if (enable)
     {
       m_beaconEvent = Simulator::ScheduleNow (&NqapWifiMac::SendOneBeacon, this);
@@ -121,18 +123,21 @@
 void 
 NqapWifiMac::SetSlot (Time slotTime)
 {
+  NS_LOG_FUNCTION (this << slotTime);
   m_dcfManager->SetSlot (slotTime);
   m_slot = slotTime;
 }
 void 
 NqapWifiMac::SetSifs (Time sifs)
 {
+  NS_LOG_FUNCTION (this << sifs);
   m_dcfManager->SetSifs (sifs);
   m_sifs = sifs;
 }
 void 
 NqapWifiMac::SetEifsNoDifs (Time eifsNoDifs)
 {
+  NS_LOG_FUNCTION (this << eifsNoDifs);
   m_dcfManager->SetEifsNoDifs (eifsNoDifs);
   m_eifsNoDifs = eifsNoDifs;
 }
@@ -156,6 +161,7 @@
 void 
 NqapWifiMac::SetWifiPhy (Ptr<WifiPhy> phy)
 {
+  NS_LOG_FUNCTION (this << phy);
   m_phy = phy;
   m_dcfManager->SetupPhyListener (phy);
   m_low->SetPhy (phy);
@@ -163,6 +169,7 @@
 void 
 NqapWifiMac::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager)
 {
+  NS_LOG_FUNCTION (this << stationManager);
   m_stationManager = stationManager;
   m_dca->SetWifiRemoteStationManager (stationManager);
   m_beaconDca->SetWifiRemoteStationManager (stationManager);
@@ -171,11 +178,13 @@
 void 
 NqapWifiMac::SetForwardUpCallback (Callback<void,Ptr<Packet>, const Mac48Address &> upCallback)
 {
+  NS_LOG_FUNCTION (this);
   m_upCallback = upCallback;
 }
 void 
 NqapWifiMac::SetLinkUpCallback (Callback<void> linkUp)
 {
+  NS_LOG_FUNCTION (this);
   if (!linkUp.IsNull ())
     {
       linkUp ();
@@ -183,7 +192,9 @@
 }
 void 
 NqapWifiMac::SetLinkDownCallback (Callback<void> linkDown)
-{}
+{
+  NS_LOG_FUNCTION (this);
+}
 Mac48Address 
 NqapWifiMac::GetAddress (void) const
 {
@@ -202,11 +213,13 @@
 void 
 NqapWifiMac::SetAddress (Mac48Address address)
 {
+  NS_LOG_FUNCTION (address);
   m_address = address;
 }
 void 
 NqapWifiMac::SetSsid (Ssid ssid)
 {
+  NS_LOG_FUNCTION (ssid);
   m_ssid = ssid;
 }
 
@@ -214,21 +227,25 @@
 void 
 NqapWifiMac::SetBeaconInterval (Time interval)
 {
+  NS_LOG_FUNCTION (this << interval);
   m_beaconInterval = interval;
 }
 void
 NqapWifiMac::StartBeaconing (void)
 {
+  NS_LOG_FUNCTION (this);
   SendOneBeacon ();
 }
 void 
 NqapWifiMac::ForwardUp (Ptr<Packet> packet, Mac48Address from)
 {
+  NS_LOG_FUNCTION (this << packet << from);
   m_upCallback (packet, from);
 }
 void 
 NqapWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to)
 {
+  NS_LOG_FUNCTION (this << packet << from << to);
   WifiMacHeader hdr;
   hdr.SetTypeData ();
   hdr.SetAddr1 (to);
@@ -241,6 +258,7 @@
 void 
 NqapWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
 {
+  NS_LOG_FUNCTION (this << packet << to);
   ForwardDown (packet, GetAddress (), to);
 }
 SupportedRates
@@ -265,7 +283,7 @@
 void
 NqapWifiMac::SendProbeResp (Mac48Address to)
 {
-  TRACE ("send probe response to="<<to);
+  NS_LOG_FUNCTION (this << to);
   WifiMacHeader hdr;
   hdr.SetProbeResp ();
   hdr.SetAddr1 (to);
@@ -285,7 +303,7 @@
 void
 NqapWifiMac::SendAssocResp (Mac48Address to, bool success)
 {
-  TRACE ("send assoc response to="<<to);
+  NS_LOG_FUNCTION (this << to << success);
   WifiMacHeader hdr;
   hdr.SetAssocResp ();
   hdr.SetAddr1 (to);
@@ -313,7 +331,7 @@
 void
 NqapWifiMac::SendOneBeacon (void)
 {
-  TRACE ("send beacon to="<<Mac48Address::GetBroadcast ());
+  NS_LOG_FUNCTION (this);
   WifiMacHeader hdr;
   hdr.SetBeacon ();
   hdr.SetAddr1 (Mac48Address::GetBroadcast ());
@@ -334,28 +352,32 @@
 void 
 NqapWifiMac::TxOk (WifiMacHeader const &hdr)
 {
+  NS_LOG_FUNCTION (this);
   WifiRemoteStation *station = m_stationManager->Lookup (hdr.GetAddr1 ());
   if (hdr.IsAssocResp () && 
       station->IsWaitAssocTxOk ()) 
     {
-      TRACE ("associated with sta="<<hdr.GetAddr1 ());
+      NS_LOG_DEBUG ("associated with sta="<<hdr.GetAddr1 ());
       station->RecordGotAssocTxOk ();
     }
 }
 void 
 NqapWifiMac::TxFailed (WifiMacHeader const &hdr)
 {
+  NS_LOG_FUNCTION (this);
   WifiRemoteStation *station = m_stationManager->Lookup (hdr.GetAddr1 ());
   if (hdr.IsAssocResp () && 
       station->IsWaitAssocTxOk ()) 
     {
-      TRACE ("assoc failed with sta="<<hdr.GetAddr1 ());
+      NS_LOG_DEBUG ("assoc failed with sta="<<hdr.GetAddr1 ());
       station->RecordGotAssocTxFailed ();
     }
 }
 void 
 NqapWifiMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
 {
+  NS_LOG_FUNCTION (this << packet << hdr);
+
   WifiRemoteStation *station = m_stationManager->Lookup (hdr->GetAddr2 ());
 
   if (hdr->IsData ()) 
@@ -367,12 +389,12 @@
         {
           if (hdr->GetAddr3 () == GetAddress ()) 
             {
-              TRACE ("frame for me from="<<hdr->GetAddr2 ());
+              NS_LOG_DEBUG ("frame for me from="<<hdr->GetAddr2 ());
               ForwardUp (packet, hdr->GetAddr2 ());
             } 
           else 
             {
-              TRACE ("forwarding frame from="<<hdr->GetAddr2 ()<<", to="<<hdr->GetAddr3 ());
+              NS_LOG_DEBUG ("forwarding frame from="<<hdr->GetAddr2 ()<<", to="<<hdr->GetAddr3 ());
               Ptr<Packet> copy = packet->Copy ();
               ForwardDown (packet,
                            hdr->GetAddr2 (), 
--- a/src/devices/wifi/nqsta-wifi-mac.cc	Tue Apr 15 15:29:43 2008 -0700
+++ b/src/devices/wifi/nqsta-wifi-mac.cc	Tue Apr 15 15:53:54 2008 -0700
@@ -36,9 +36,6 @@
 
 NS_LOG_COMPONENT_DEFINE ("NqstaWifiMac");
 
-#define TRACE(x) \
-  NS_LOG_DEBUG (Simulator::Now () << " " << GetAddress () << " " << x);
-
 /*
  * The state machine for this NQSTA is:
  --------------            -----------
@@ -94,6 +91,7 @@
     m_assocRequestEvent (),
     m_beaconWatchdogEnd (Seconds (0.0))
 {
+  NS_LOG_FUNCTION (this);
   m_rxMiddle = new MacRxMiddle ();
   m_rxMiddle->SetForwardCallback (MakeCallback (&NqstaWifiMac::Receive, this));
 
@@ -110,11 +108,14 @@
 }
 
 NqstaWifiMac::~NqstaWifiMac ()
-{}
+{
+  NS_LOG_FUNCTION (this);
+}
 
 void
 NqstaWifiMac::DoDispose (void)
 {
+  NS_LOG_FUNCTION (this);
   delete m_rxMiddle;
   delete m_dcfManager;
   m_rxMiddle = 0;
@@ -128,18 +129,21 @@
 void 
 NqstaWifiMac::SetSlot (Time slotTime)
 {
+  NS_LOG_FUNCTION (this << slotTime);
   m_dcfManager->SetSlot (slotTime);
   m_slot = slotTime;
 }
 void 
 NqstaWifiMac::SetSifs (Time sifs)
 {
+  NS_LOG_FUNCTION (this << sifs);
   m_dcfManager->SetSifs (sifs);
   m_sifs = sifs;
 }
 void 
 NqstaWifiMac::SetEifsNoDifs (Time eifsNoDifs)
 {
+  NS_LOG_FUNCTION (this << eifsNoDifs);
   m_dcfManager->SetEifsNoDifs (eifsNoDifs);
   m_eifsNoDifs = eifsNoDifs;
 }
@@ -206,33 +210,39 @@
 void 
 NqstaWifiMac::SetAddress (Mac48Address address)
 {
+  NS_LOG_FUNCTION (this << address);
   m_address = address;
 }
 void 
 NqstaWifiMac::SetSsid (Ssid ssid)
 {
+  NS_LOG_FUNCTION (this << ssid);
   m_ssid = ssid;
 }
 
 void 
 NqstaWifiMac::SetMaxMissedBeacons (uint32_t missed)
 {
+  NS_LOG_FUNCTION (this << missed);
   m_maxMissedBeacons = missed;
 }
 void 
 NqstaWifiMac::SetProbeRequestTimeout (Time timeout)
 {
+  NS_LOG_FUNCTION (this << timeout);
   m_probeRequestTimeout = timeout;
 }
 void 
 NqstaWifiMac::SetAssocRequestTimeout (Time timeout)
 {
+  NS_LOG_FUNCTION (this << timeout);
   m_assocRequestTimeout = timeout;
 }
 
 void 
 NqstaWifiMac::StartActiveAssociation (void)
 {
+  NS_LOG_FUNCTION (this);
   TryToEnsureAssociated ();
 }
 
@@ -245,11 +255,13 @@
 void 
 NqstaWifiMac::SetBssid (Mac48Address bssid)
 {
+  NS_LOG_FUNCTION (this << bssid);
   m_bssid = bssid;
 }
 void 
 NqstaWifiMac::SetActiveProbing (bool enable)
 {
+  NS_LOG_FUNCTION (this << enable);
   if (enable)
     {
       TryToEnsureAssociated ();
@@ -262,12 +274,13 @@
 void 
 NqstaWifiMac::ForwardUp (Ptr<Packet> packet, const Mac48Address &address)
 {
+  NS_LOG_FUNCTION (this << packet << address);
   m_forwardUp (packet, address);
 }
 void
 NqstaWifiMac::SendProbeRequest (void)
 {
-  TRACE ("send probe request");
+  NS_LOG_FUNCTION (this);
   WifiMacHeader hdr;
   hdr.SetProbeReq ();
   hdr.SetAddr1 (GetBroadcastBssid ());
@@ -290,7 +303,7 @@
 void
 NqstaWifiMac::SendAssociationRequest (void)
 {
-  TRACE ("send assoc request to=" << GetBssid ());
+  NS_LOG_FUNCTION (this << GetBssid ());
   WifiMacHeader hdr;
   hdr.SetAssocReq ();
   hdr.SetAddr1 (GetBssid ());
@@ -312,6 +325,7 @@
 void
 NqstaWifiMac::TryToEnsureAssociated (void)
 {
+  NS_LOG_FUNCTION (this);
   switch (m_state) {
   case ASSOCIATED:
     return;
@@ -351,37 +365,40 @@
 void
 NqstaWifiMac::AssocRequestTimeout (void)
 {
-  TRACE ("assoc request timeout");
+  NS_LOG_FUNCTION (this);
   m_state = WAIT_ASSOC_RESP;
   SendAssociationRequest ();
 }
 void
 NqstaWifiMac::ProbeRequestTimeout (void)
 {
-  TRACE ("probe request timeout");
+  NS_LOG_FUNCTION (this);
   m_state = WAIT_PROBE_RESP;
   SendProbeRequest ();
 }
 void 
 NqstaWifiMac::MissedBeacons (void)
 {
+  NS_LOG_FUNCTION (this);
   if (m_beaconWatchdogEnd > Simulator::Now ())
     {
       m_beaconWatchdog = Simulator::Schedule (m_beaconWatchdogEnd - Simulator::Now (),
                                               &NqstaWifiMac::MissedBeacons, this);
       return;
     }
-  TRACE ("beacon missed");
+  NS_LOG_DEBUG ("beacon missed");
   m_state = BEACON_MISSED;
   TryToEnsureAssociated ();
 }
 void 
 NqstaWifiMac::RestartBeaconWatchdog (Time delay)
 {
+  NS_LOG_FUNCTION (this << delay);
   m_beaconWatchdogEnd = std::max (Simulator::Now () + delay, m_beaconWatchdogEnd);
   if (Simulator::GetDelayLeft (m_beaconWatchdog) < delay &&
       m_beaconWatchdog.IsExpired ())
     {
+      NS_LOG_DEBUG ("really restart watchdog.");
       m_beaconWatchdog = Simulator::Schedule (delay, &NqstaWifiMac::MissedBeacons, this);
     }
 }
@@ -394,12 +411,13 @@
 void 
 NqstaWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
 {
+  NS_LOG_FUNCTION (this << packet << to);
   if (!IsAssociated ()) 
     {
       TryToEnsureAssociated ();
       return;
     }
-  //TRACE ("enqueue size="<<packet->GetSize ()<<", to="<<to);
+  //NS_LOG_DEBUG ("enqueue size="<<packet->GetSize ()<<", to="<<to);
   WifiMacHeader hdr;
   hdr.SetTypeData ();
   hdr.SetAddr1 (GetBssid ());
@@ -413,6 +431,7 @@
 void 
 NqstaWifiMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
 {
+  NS_LOG_FUNCTION (this << packet << hdr);
   NS_ASSERT (!hdr->IsCtl ());
   if (hdr->GetAddr1 () != GetAddress () &&
       !hdr->GetAddr1 ().IsBroadcast ()) 
@@ -487,7 +506,7 @@
           if (assocResp.GetStatusCode ().IsSuccess ()) 
             {
               m_state = ASSOCIATED;
-              TRACE ("assoc completed"); 
+              NS_LOG_DEBUG ("assoc completed"); 
               SupportedRates rates = assocResp.GetSupportedRates ();
               WifiRemoteStation *ap = m_stationManager->Lookup (hdr->GetAddr2 ());
               for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
@@ -509,7 +528,7 @@
             } 
           else 
             {
-              TRACE ("assoc refused");
+              NS_LOG_DEBUG ("assoc refused");
               m_state = REFUSED;
             }
         }
--- a/src/devices/wifi/wifi-mac-header.cc	Tue Apr 15 15:29:43 2008 -0700
+++ b/src/devices/wifi/wifi-mac-header.cc	Tue Apr 15 15:53:54 2008 -0700
@@ -21,17 +21,6 @@
 #include "ns3/address-utils.h"
 #include "wifi-mac-header.h"
 
-#define MAC80211HEADER_DEBUG 1
-
-#ifdef MAC80211HEADER_DEBUG
-#include <iostream>
-#  define TRACE(x) \
-std::Cout << "MAC80211HEADER " << x << std::Endl;
-#else
-#  define TRACE(x)
-#endif
-
-
 namespace ns3 {
 
 NS_OBJECT_ENSURE_REGISTERED (WifiMacHeader);
--- a/src/devices/wifi/wifi-phy.cc	Tue Apr 15 15:29:43 2008 -0700
+++ b/src/devices/wifi/wifi-phy.cc	Tue Apr 15 15:53:54 2008 -0700
@@ -258,14 +258,19 @@
     m_previousStateChangeTime (Seconds (0)),
     m_endSyncEvent (),
     m_random (0.0, 1.0)
-{}
+{
+  NS_LOG_FUNCTION (this);
+}
 
 WifiPhy::~WifiPhy ()
-{}
+{
+  NS_LOG_FUNCTION (this);
+}
 
 void
 WifiPhy::DoDispose (void)
 {
+  NS_LOG_FUNCTION (this);
   m_channel = 0;
   m_events.clear ();
   m_modes.clear ();
@@ -274,6 +279,7 @@
 void
 WifiPhy::SetStandard (enum WifiPhyStandard standard)
 {
+  NS_LOG_FUNCTION (this << standard);
   m_standard = standard;
   switch (standard) {
   case WIFI_PHY_STANDARD_80211a:
@@ -292,36 +298,43 @@
 void 
 WifiPhy::SetRxNoise (double db)
 {
+  NS_LOG_FUNCTION (this << db);
   m_rxNoiseRatio = DbToRatio (db);
 }
 void 
 WifiPhy::SetTxPowerStart (double start)
 {
+  NS_LOG_FUNCTION (this << start);
   m_txPowerBaseDbm = start;
 }
 void 
 WifiPhy::SetTxPowerEnd (double end)
 {
+  NS_LOG_FUNCTION (this << end);
   m_txPowerEndDbm = end;
 }
 void 
 WifiPhy::SetNTxPower (uint32_t n)
 {
+  NS_LOG_FUNCTION (this << n);
   m_nTxPower = n;
 }
 void 
 WifiPhy::SetTxGain (double gain)
 {
+  NS_LOG_FUNCTION (this << gain);
   m_txGainDb = gain;
 }
 void 
 WifiPhy::SetRxGain (double gain)
 {
+  NS_LOG_FUNCTION (this << gain);
   m_rxGainDb = gain;
 }
 void 
 WifiPhy::SetEdThreshold (double threshold)
 {
+  NS_LOG_FUNCTION (this << threshold);
   m_edThresholdW = DbmToW (threshold);
 }
 double 
@@ -384,6 +397,7 @@
                              WifiMode txMode,
                              enum WifiPreamble preamble)
 {
+  NS_LOG_FUNCTION (this << packet << rxPowerDbm << txMode << preamble);
   rxPowerDbm += m_rxGainDb;
   double rxPowerW = DbmToW (rxPowerDbm);
   Time rxDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble);
@@ -472,6 +486,7 @@
 void 
 WifiPhy::SendPacket (Ptr<const Packet> packet, WifiMode txMode, WifiPreamble preamble, uint8_t txPower)
 {
+  NS_LOG_FUNCTION (this << packet << txMode << preamble << txPower);
   /* Transmission can happen if:
    *  - we are syncing on a packet. It is the responsability of the
    *    MAC layer to avoid doing this but the PHY does nothing to 
@@ -529,6 +544,7 @@
 void
 WifiPhy::Configure80211aParameters (void)
 {
+  NS_LOG_FUNCTION (this);
   m_plcpLongPreambleDelayUs = 16;
   m_plcpShortPreambleDelayUs = 16;
   m_longPlcpHeaderMode = g_6mba;
@@ -558,6 +574,7 @@
 void
 WifiPhy::Configure80211a (void)
 {
+  NS_LOG_FUNCTION (this);
   Configure80211aParameters ();
   m_modes.push_back (g_6mba);
   m_modes.push_back (g_9mba);
@@ -574,6 +591,7 @@
 void
 WifiPhy::ConfigureHolland (void)
 {
+  NS_LOG_FUNCTION (this);
   Configure80211aParameters ();
   m_modes.push_back (g_6mba);
   m_modes.push_back (g_12mba);
@@ -1329,6 +1347,7 @@
 void
 WifiPhy::EndSync (Ptr<Packet> packet, Ptr<RxEvent> event)
 {
+  NS_LOG_FUNCTION (this << packet << event);
   NS_ASSERT (IsStateSync ());
   NS_ASSERT (event->GetEndTime () == Simulator::Now ());