From aa776c802a55fb58108598137b2fd763cdc32d1c Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Wed, 10 Dec 2008 01:47:59 -0800 Subject: [PATCH] bug 405: add more context to wifi logging --- src/devices/wifi/adhoc-wifi-mac.cc | 3 ++ src/devices/wifi/mac-low.cc | 45 +++++++++++++++--------------- src/devices/wifi/nqap-wifi-mac.cc | 3 ++ src/devices/wifi/nqsta-wifi-mac.cc | 3 ++ 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/devices/wifi/adhoc-wifi-mac.cc b/src/devices/wifi/adhoc-wifi-mac.cc index 84513c666..50a79e051 100644 --- a/src/devices/wifi/adhoc-wifi-mac.cc +++ b/src/devices/wifi/adhoc-wifi-mac.cc @@ -33,6 +33,9 @@ namespace ns3 { NS_OBJECT_ENSURE_REGISTERED (AdhocWifiMac); +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT if (m_low != 0) {std::clog << "[mac=" << m_low->GetAddress () << "] ";} + TypeId AdhocWifiMac::GetTypeId (void) { diff --git a/src/devices/wifi/mac-low.cc b/src/devices/wifi/mac-low.cc index 89f31a94b..a18bbe858 100644 --- a/src/devices/wifi/mac-low.cc +++ b/src/devices/wifi/mac-low.cc @@ -31,8 +31,9 @@ NS_LOG_COMPONENT_DEFINE ("MacLow"); -#define MY_DEBUG(x) \ - NS_LOG_DEBUG (m_self << " " << x) +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT std::clog << "[mac=" << m_self << "] " + namespace ns3 { @@ -457,7 +458,7 @@ MacLow::StartTransmission (Ptr packet, //NS_ASSERT (m_phy->IsStateIdle ()); - MY_DEBUG ("startTx size="<< GetSize (m_currentPacket, &m_currentHdr) << + NS_LOG_DEBUG ("startTx size="<< GetSize (m_currentPacket, &m_currentHdr) << ", to=" << m_currentHdr.GetAddr1()<<", listener="< packet, double rxSnr) { NS_LOG_FUNCTION (this << packet << rxSnr); - MY_DEBUG ("rx failed "); + NS_LOG_DEBUG ("rx failed "); if (m_txParams.MustWaitFastAck ()) { NS_ASSERT (m_fastAckFailedTimeoutEvent.IsExpired ()); @@ -500,7 +501,7 @@ MacLow::ReceiveOk (Ptr packet, double rxSnr, WifiMode txMode, WifiPreamb packet->RemoveHeader (hdr); bool isPrevNavZero = IsNavZero (); - MY_DEBUG ("duration/id=" << hdr.GetDuration ()); + NS_LOG_DEBUG ("duration/id=" << hdr.GetDuration ()); NotifyNav (hdr, txMode, preamble); if (hdr.IsRts ()) { @@ -513,7 +514,7 @@ MacLow::ReceiveOk (Ptr packet, double rxSnr, WifiMode txMode, WifiPreamb if (isPrevNavZero && hdr.GetAddr1 () == m_self) { - MY_DEBUG ("rx RTS from=" << hdr.GetAddr2 () << ", schedule CTS"); + NS_LOG_DEBUG ("rx RTS from=" << hdr.GetAddr2 () << ", schedule CTS"); NS_ASSERT (m_sendCtsEvent.IsExpired ()); WifiRemoteStation *station = GetStation (hdr.GetAddr2 ()); station->ReportRxOk (rxSnr, txMode); @@ -526,7 +527,7 @@ MacLow::ReceiveOk (Ptr packet, double rxSnr, WifiMode txMode, WifiPreamb } else { - MY_DEBUG ("rx RTS from=" << hdr.GetAddr2 () << ", cannot schedule CTS"); + NS_LOG_DEBUG ("rx RTS from=" << hdr.GetAddr2 () << ", cannot schedule CTS"); } } else if (hdr.IsCts () && @@ -534,7 +535,7 @@ MacLow::ReceiveOk (Ptr packet, double rxSnr, WifiMode txMode, WifiPreamb m_ctsTimeoutEvent.IsRunning () && m_currentPacket != 0) { - MY_DEBUG ("receive cts from="< packet, double rxSnr, WifiMode txMode, WifiPreamb if (hdr.IsQosData () && hdr.IsQosNoAck ()) { - MY_DEBUG ("rx unicast/noAck from="< packet, WifiMacHeader const* hdr, WifiMode txMode) { NS_LOG_FUNCTION (this << packet << hdr << txMode); - MY_DEBUG ("send " << hdr->GetTypeString () << + NS_LOG_DEBUG ("send " << hdr->GetTypeString () << ", to=" << hdr->GetAddr1 () << ", size=" << packet->GetSize () << ", mode=" << txMode << @@ -845,7 +846,7 @@ void MacLow::CtsTimeout (void) { NS_LOG_FUNCTION (this); - MY_DEBUG ("cts timeout"); + NS_LOG_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 // end of rx if there was a rx start before now. @@ -860,7 +861,7 @@ void MacLow::NormalAckTimeout (void) { NS_LOG_FUNCTION (this); - MY_DEBUG ("normal ack timeout"); + NS_LOG_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 // end of rx if there was a rx start before now. @@ -880,12 +881,12 @@ MacLow::FastAckTimeout (void) m_listener = 0; if (m_phy->IsStateIdle ()) { - MY_DEBUG ("fast Ack idle missed"); + NS_LOG_DEBUG ("fast Ack idle missed"); listener->MissedAck (); } else { - MY_DEBUG ("fast Ack ok"); + NS_LOG_DEBUG ("fast Ack ok"); } } void @@ -898,12 +899,12 @@ MacLow::SuperFastAckTimeout () m_listener = 0; if (m_phy->IsStateIdle ()) { - MY_DEBUG ("super fast Ack failed"); + NS_LOG_DEBUG ("super fast Ack failed"); listener->MissedAck (); } else { - MY_DEBUG ("super fast Ack ok"); + NS_LOG_DEBUG ("super fast Ack ok"); listener->GotAck (0.0, WifiMode ()); } } @@ -1128,7 +1129,7 @@ MacLow::FastAckFailedTimeout (void) MacLowTransmissionListener *listener = m_listener; m_listener = 0; listener->MissedAck (); - MY_DEBUG ("fast Ack busy but missed"); + NS_LOG_DEBUG ("fast Ack busy but missed"); } void diff --git a/src/devices/wifi/nqap-wifi-mac.cc b/src/devices/wifi/nqap-wifi-mac.cc index f5f6c5016..c5bb6d518 100644 --- a/src/devices/wifi/nqap-wifi-mac.cc +++ b/src/devices/wifi/nqap-wifi-mac.cc @@ -37,6 +37,9 @@ namespace ns3 { NS_OBJECT_ENSURE_REGISTERED (NqapWifiMac); +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT if (m_low != 0) {std::clog << "[mac=" << m_low->GetAddress () << "] ";} + TypeId NqapWifiMac::GetTypeId (void) { diff --git a/src/devices/wifi/nqsta-wifi-mac.cc b/src/devices/wifi/nqsta-wifi-mac.cc index 781aaa303..3bfd032e6 100644 --- a/src/devices/wifi/nqsta-wifi-mac.cc +++ b/src/devices/wifi/nqsta-wifi-mac.cc @@ -36,6 +36,9 @@ NS_LOG_COMPONENT_DEFINE ("NqstaWifiMac"); +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT if (m_low != 0) {std::clog << "[mac=" << m_low->GetAddress () << "] ";} + /* * The state machine for this NQSTA is: -------------- -----------