diff --git a/src/devices/wifi/dca-txop.cc b/src/devices/wifi/dca-txop.cc index 7b87bc3a5..9ff952e2e 100644 --- a/src/devices/wifi/dca-txop.cc +++ b/src/devices/wifi/dca-txop.cc @@ -19,8 +19,8 @@ */ #include "ns3/assert.h" - #include "ns3/packet.h" +#include "ns3/log.h" #include "dca-txop.h" #include "dcf.h" @@ -30,19 +30,9 @@ #include "mac-tx-middle.h" #include "wifi-phy.h" +NS_LOG_COMPONENT_DEFINE ("DcaTxop"); -#define noDCA_TXOP_TRACE 1 - -#ifdef DCA_TXOP_TRACE -#include "ns3/simulator.h" -#include -# define TRACE(x) \ - std::cout <<"DCA TXOP now="<IsEmpty () || m_hasCurrent) { - TRACE ("access needed here"); + NS_LOG_DEBUG ("access needed here"); return true; } else { - TRACE ("no access needed here"); + NS_LOG_DEBUG ("no access needed here"); return false; } } @@ -389,7 +379,7 @@ DcaTxop::AccessGrantedNow (void) { if (m_queue->IsEmpty ()) { - TRACE ("queue empty"); + NS_LOG_DEBUG ("queue empty"); return; } bool found; @@ -404,7 +394,7 @@ DcaTxop::AccessGrantedNow (void) m_ssrc = 0; m_slrc = 0; m_fragmentNumber = 0; - TRACE ("dequeued size="< Parameters ()->GetMaxSsrc ()) @@ -505,7 +495,7 @@ DcaTxop::GotAck (double snr, WifiMode txMode) if (!NeedFragmentation () || IsLastFragment ()) { - TRACE ("got ack. tx done."); + NS_LOG_DEBUG ("got ack. tx done."); if (!m_txOkCallback.IsNull ()) { m_txOkCallback (m_currentHdr); @@ -520,13 +510,13 @@ DcaTxop::GotAck (double snr, WifiMode txMode) } else { - TRACE ("got ack. tx not done, size="< Parameters ()->GetMaxSlrc ()) @@ -552,7 +542,7 @@ DcaTxop::MissedAck (void) void DcaTxop::StartNext (void) { - TRACE ("start next packet fragment"); + NS_LOG_DEBUG ("start next packet fragment"); /* this callback is used only for fragments. */ NextFragment (); WifiMacHeader hdr; diff --git a/src/devices/wifi/mac-low.cc b/src/devices/wifi/mac-low.cc index f5b06aab4..c7e97a81c 100644 --- a/src/devices/wifi/mac-low.cc +++ b/src/devices/wifi/mac-low.cc @@ -19,10 +19,10 @@ */ #include "ns3/assert.h" - #include "ns3/packet.h" #include "ns3/simulator.h" #include "ns3/tag.h" +#include "ns3/log.h" #include "mac-low.h" #include "wifi-phy.h" @@ -31,15 +31,7 @@ #include "mac-stations.h" #include "mac-parameters.h" -#define noMAC_LOW_TRACE 1 - -#ifdef MAC_LOW_TRACE -# include -# define TRACE(x) \ - std::cout << "MAC LOW " << x << std::endl; -#else /* MAC_LOW_TRACE */ -# define TRACE(x) -#endif /* MAC_LOW_TRACE */ +NS_LOG_COMPONENT_DEFINE ("MacLow"); namespace ns3 { @@ -367,7 +359,7 @@ MacLow::StartTransmission (Packet packet, //NS_ASSERT (m_phy->IsStateIdle ()); - TRACE ("startTx size="<< GetCurrentSize () << ", to=" << m_currentHdr.GetAddr1()); + NS_LOG_DEBUG ("startTx size="<< GetCurrentSize () << ", to=" << m_currentHdr.GetAddr1()); if (m_txParams.MustSendRts ()) { @@ -385,7 +377,7 @@ MacLow::StartTransmission (Packet packet, void MacLow::ReceiveError (Packet packet, double rxSnr) { - TRACE ("rx failed "); + NS_LOG_DEBUG ("rx failed "); m_dropError (packet); if (m_txParams.MustWaitFastAck ()) { @@ -408,7 +400,7 @@ MacLow::ReceiveOk (Packet packet, double rxSnr, WifiMode txMode, WifiPreamble pr packet.RemoveHeader (hdr); bool isPrevNavZero = IsNavZero (Simulator::Now ()); - TRACE ("duration/id=" << hdr.GetDuration ()); + NS_LOG_DEBUG ("duration/id=" << hdr.GetDuration ()); NotifyNav (Simulator::Now (), &hdr); if (hdr.IsRts ()) { @@ -416,7 +408,7 @@ MacLow::ReceiveOk (Packet packet, double rxSnr, WifiMode txMode, WifiPreamble pr if (isPrevNavZero && hdr.GetAddr1 () == m_device->GetSelfAddress ()) { - TRACE ("rx RTS from=" << hdr.GetAddr2 () << ", schedule CTS"); + NS_LOG_DEBUG ("rx RTS from=" << hdr.GetAddr2 () << ", schedule CTS"); NS_ASSERT (m_sendCtsEvent.IsExpired ()); MacStation *station = m_stations->Lookup (hdr.GetAddr2 ()); station->ReportRxOk (rxSnr, txMode); @@ -431,7 +423,7 @@ MacLow::ReceiveOk (Packet packet, double rxSnr, WifiMode txMode, WifiPreamble pr } else { - TRACE ("rx RTS from=" << hdr.GetAddr2 () << ", cannot schedule CTS"); + NS_LOG_DEBUG ("rx RTS from=" << hdr.GetAddr2 () << ", cannot schedule CTS"); } } else if (hdr.IsCts () && @@ -439,7 +431,7 @@ MacLow::ReceiveOk (Packet packet, double rxSnr, WifiMode txMode, WifiPreamble pr m_ctsTimeoutEvent.IsRunning () && m_hasCurrent) { - TRACE ("receive cts from="<GetSelfAddress ()) { @@ -502,11 +494,11 @@ MacLow::ReceiveOk (Packet packet, double rxSnr, WifiMode txMode, WifiPreamble pr if (hdr.IsQosData () && hdr.IsQosNoAck ()) { - TRACE ("rx unicast/noAck from="<ReportDataFailed (); if (m_phy->IsStateIdle ()) { - TRACE ("fast Ack idle missed"); + NS_LOG_DEBUG ("fast Ack idle missed"); m_listener->MissedAck (); } m_listener = 0; @@ -750,12 +742,12 @@ MacLow::SuperFastAckTimeout () station->ReportDataFailed (); if (m_phy->IsStateIdle ()) { - TRACE ("super fast Ack failed"); + NS_LOG_DEBUG ("super fast Ack failed"); m_listener->MissedAck (); } else { - TRACE ("super fast Ack ok"); + NS_LOG_DEBUG ("super fast Ack ok"); m_listener->GotAck (0.0, WifiMode ()); } m_listener = 0; @@ -791,7 +783,7 @@ MacLow::SendRtsForPacket (void) } rts.SetDurationUs (duration.GetMicroSeconds ()); - TRACE ("tx RTS to="<< rts.GetAddr1 () << ", mode=" << (uint32_t)rtsTxMode); + NS_LOG_DEBUG ("tx RTS to="<< rts.GetAddr1 () << ", mode=" << rtsTxMode.GetPhyRate ()); Time txDuration = m_phy->CalculateTxDuration (GetRtsSize (), rtsTxMode, WIFI_PREAMBLE_LONG); Time timerDelay = txDuration + GetCtsTimeout (); @@ -851,7 +843,7 @@ MacLow::SendDataPacket (void) StartDataTxTimers (); WifiMode dataTxMode = GetDataTxMode (m_currentHdr.GetAddr1 (), GetCurrentSize ()); - TRACE ("tx "<< m_currentHdr.GetTypeString () << + NS_LOG_DEBUG ("tx "<< m_currentHdr.GetTypeString () << ", to=" << m_currentHdr.GetAddr1 () << ", mode=" << dataTxMode.GetPhyRate ()); Time duration = Seconds (0); @@ -915,7 +907,7 @@ MacLow::SendCtsAfterRts (Mac48Address source, Time duration, WifiMode txMode, do /* send a CTS when you receive a RTS * right after SIFS. */ - TRACE ("tx CTS to=" << source << ", mode=" << (uint32_t)txMode); + NS_LOG_DEBUG ("tx CTS to=" << source << ", mode=" << txMode.GetPhyRate ()); WifiMacHeader cts; cts.SetType (WIFI_MAC_CTL_CTS); cts.SetDsNotFrom (); @@ -946,7 +938,7 @@ MacLow::SendDataAfterCts (Mac48Address source, Time duration, WifiMode txMode) NS_ASSERT (m_hasCurrent); WifiMode dataTxMode = GetDataTxMode (m_currentHdr.GetAddr1 (), GetCurrentSize ()); - TRACE ("tx " << m_currentHdr.GetTypeString () << " to=" << m_currentHdr.GetAddr2 () << + NS_LOG_DEBUG ("tx " << m_currentHdr.GetTypeString () << " to=" << m_currentHdr.GetAddr2 () << ", mode=" << dataTxMode.GetPhyRate () << ", seq=0x"<< m_currentHdr.GetSequenceControl ()); StartDataTxTimers (); @@ -973,7 +965,7 @@ void MacLow::FastAckFailedTimeout (void) { m_listener->MissedAck (); - TRACE ("fast Ack busy but missed"); + NS_LOG_DEBUG ("fast Ack busy but missed"); } void @@ -982,7 +974,7 @@ MacLow::SendAckAfterData (Mac48Address source, Time duration, WifiMode txMode, d /* send an ACK when you receive * a packet after SIFS. */ - TRACE ("tx ACK to=" << source << ", mode=" << txMode.GetPhyRate ()); + NS_LOG_DEBUG ("tx ACK to=" << source << ", mode=" << txMode.GetPhyRate ()); WifiMacHeader ack; ack.SetType (WIFI_MAC_CTL_ACK); ack.SetDsNotFrom (); diff --git a/src/devices/wifi/wifi-phy.cc b/src/devices/wifi/wifi-phy.cc index d64e2d6dd..cfa3194bd 100644 --- a/src/devices/wifi/wifi-phy.cc +++ b/src/devices/wifi/wifi-phy.cc @@ -27,38 +27,11 @@ #include "ns3/simulator.h" #include "ns3/packet.h" #include "ns3/random-variable.h" - #include "ns3/assert.h" +#include "ns3/log.h" #include - -#define nopePHY80211_DEBUG 1 -#define nopePHY80211_STATE_DEBUG 1 - -/* All the state transitions are marked by these macros. */ -#ifdef PHY80211_STATE_DEBUG -#include -# define STATE_FROM(from) \ -std::cout << "PHY self=" << this << " old=" << StateToString (from); -# define STATE_TO(to) \ -std::cout << " new=" << StateToString (to); -# define STATE_AT(at) \ -std::cout << " at=" << at << std::endl; -#else -# define STATE_FROM(from) -# define STATE_TO(from) -# define STATE_AT(at) -#endif - -#ifdef PHY80211_DEBUG -#include -# define TRACE(x) \ - std::cout << "PHY80211 TRACE " << Simulator::Now ().GetSeconds () << " " << x << std::endl; -#else -# define TRACE(x) -#endif - - +NS_LOG_COMPONENT_DEFINE ("WifiPhy"); namespace ns3 { @@ -265,16 +238,16 @@ WifiPhy::ReceivePacket (Packet const packet, switch (GetState ()) { case WifiPhy::SYNC: - TRACE ("drop packet because already in Sync (power="<< - rxPowerW<<"W)"); + NS_LOG_DEBUG ("drop packet because already in Sync (power="<< + rxPowerW<<"W)"); if (endRx > m_endSync) { goto maybeCcaBusy; } break; case WifiPhy::TX: - TRACE ("drop packet because already in Tx (power="<< - rxPowerW<<"W)"); + NS_LOG_DEBUG ("drop packet because already in Tx (power="<< + rxPowerW<<"W)"); if (endRx > m_endTx) { goto maybeCcaBusy; @@ -295,8 +268,8 @@ WifiPhy::ReceivePacket (Packet const packet, } else { - TRACE ("drop packet because signal power too Small ("<< - rxPowerW<<"<"< event) * all SNIR changes in the snir vector. */ double per = CalculatePer (event, &ni); - TRACE ("mode="<<((uint32_t)event->GetPayloadMode ())<< - ", ber="<<(1-GetMode (event->GetPayloadMode ())->GetChunkSuccessRate (snr, 1))<< - ", snr="<