diff --git a/src/devices/wifi/dca-txop.cc b/src/devices/wifi/dca-txop.cc index eba746669..5701e1bc3 100644 --- a/src/devices/wifi/dca-txop.cc +++ b/src/devices/wifi/dca-txop.cc @@ -36,9 +36,8 @@ NS_LOG_COMPONENT_DEFINE ("DcaTxop"); -#define MY_DEBUG(x) \ - NS_LOG_DEBUG (m_low->GetAddress () << " " << x) - +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT std::clog << "[mac=" << m_low->GetAddress () << "] "; namespace ns3 { @@ -361,7 +360,7 @@ DcaTxop::NotifyAccessGranted (void) { if (m_queue->IsEmpty ()) { - MY_DEBUG ("queue empty"); + NS_LOG_DEBUG ("queue empty"); return; } m_currentPacket = m_queue->Dequeue (&m_currentHdr); @@ -372,7 +371,7 @@ DcaTxop::NotifyAccessGranted (void) m_currentHdr.SetNoMoreFragments (); m_currentHdr.SetNoRetry (); m_fragmentNumber = 0; - MY_DEBUG ("dequeued size="<GetSize ()<< + NS_LOG_DEBUG ("dequeued size="<GetSize ()<< ", to="<StartTransmission (m_currentPacket, &m_currentHdr, @@ -451,7 +450,7 @@ void DcaTxop::NotifyCollision (void) { NS_LOG_FUNCTION (this); - MY_DEBUG ("collision"); + NS_LOG_DEBUG ("collision"); m_dcf->StartBackoffNow (m_rng->GetNext (0, m_dcf->GetCw ())); RestartAccessIfNeeded (); } @@ -467,16 +466,16 @@ void DcaTxop::GotCts (double snr, WifiMode txMode) { NS_LOG_FUNCTION (this << snr << txMode); - MY_DEBUG ("got cts"); + NS_LOG_DEBUG ("got cts"); } void DcaTxop::MissedCts (void) { NS_LOG_FUNCTION (this); - MY_DEBUG ("missed cts"); + NS_LOG_DEBUG ("missed cts"); if (!NeedRtsRetransmission ()) { - MY_DEBUG ("Cts Fail"); + NS_LOG_DEBUG ("Cts Fail"); WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ()); station->ReportFinalRtsFailed (); if (!m_txFailedCallback.IsNull ()) @@ -501,7 +500,7 @@ DcaTxop::GotAck (double snr, WifiMode txMode) if (!NeedFragmentation () || IsLastFragment ()) { - MY_DEBUG ("got ack. tx done."); + NS_LOG_DEBUG ("got ack. tx done."); if (!m_txOkCallback.IsNull ()) { m_txOkCallback (m_currentHdr); @@ -517,17 +516,17 @@ DcaTxop::GotAck (double snr, WifiMode txMode) } else { - MY_DEBUG ("got ack. tx not done, size="<GetSize ()); + NS_LOG_DEBUG ("got ack. tx not done, size="<GetSize ()); } } void DcaTxop::MissedAck (void) { NS_LOG_FUNCTION (this); - MY_DEBUG ("missed ack"); + NS_LOG_DEBUG ("missed ack"); if (!NeedDataRetransmission ()) { - MY_DEBUG ("Ack Fail"); + NS_LOG_DEBUG ("Ack Fail"); WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ()); station->ReportFinalDataFailed (); if (!m_txFailedCallback.IsNull ()) @@ -540,7 +539,7 @@ DcaTxop::MissedAck (void) } else { - MY_DEBUG ("Retransmit"); + NS_LOG_DEBUG ("Retransmit"); m_currentHdr.SetRetry (); m_dcf->UpdateFailedCw (); } @@ -551,7 +550,7 @@ void DcaTxop::StartNext (void) { NS_LOG_FUNCTION (this); - MY_DEBUG ("start next packet fragment"); + NS_LOG_DEBUG ("start next packet fragment"); /* this callback is used only for fragments. */ NextFragment (); WifiMacHeader hdr; @@ -575,7 +574,7 @@ void DcaTxop::Cancel (void) { NS_LOG_FUNCTION (this); - MY_DEBUG ("transmission cancelled"); + NS_LOG_DEBUG ("transmission cancelled"); /** * This happens in only one case: in an AP, you have two DcaTxop: * - one is used exclusively for beacons and has a high priority. diff --git a/src/devices/wifi/edca-txop-n.cc b/src/devices/wifi/edca-txop-n.cc index 9473da398..f703bc79d 100644 --- a/src/devices/wifi/edca-txop-n.cc +++ b/src/devices/wifi/edca-txop-n.cc @@ -37,8 +37,8 @@ NS_LOG_COMPONENT_DEFINE ("EdcaTxopN"); -#define MY_DEBUG(x) \ - NS_LOG_DEBUG (m_low->GetAddress () << " " << x) +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT std::clog << "[mac=" << m_low->GetAddress () << "] "; namespace ns3 { @@ -317,7 +317,7 @@ EdcaTxopN::NotifyAccessGranted (void) { if (m_queue->IsEmpty () && !m_baManager->HasPackets ()) { - MY_DEBUG ("queue is empty"); + NS_LOG_DEBUG ("queue is empty"); return; } struct Bar bar; @@ -332,7 +332,7 @@ EdcaTxopN::NotifyAccessGranted (void) { if (m_queue->PeekFirstAvailable (&m_currentHdr, m_currentPacketTimestamp, m_qosBlockedDestinations) == 0) { - MY_DEBUG ("no available packets in the queue"); + NS_LOG_DEBUG ("no available packets in the queue"); return; } if (m_currentHdr.IsQosData () && !m_currentHdr.GetAddr1 ().IsBroadcast () && @@ -351,7 +351,7 @@ EdcaTxopN::NotifyAccessGranted (void) m_currentHdr.SetNoMoreFragments (); m_currentHdr.SetNoRetry (); m_fragmentNumber = 0; - MY_DEBUG ("dequeued size="<GetSize ()<< + NS_LOG_DEBUG ("dequeued size="<GetSize ()<< ", to="< fragment = GetFragmentPacket (&hdr); if (IsLastFragment ()) { - MY_DEBUG ("fragmenting last fragment size=" << fragment->GetSize ()); + NS_LOG_DEBUG ("fragmenting last fragment size=" << fragment->GetSize ()); params.DisableNextData (); } else { - MY_DEBUG ("fragmenting size=" << fragment->GetSize ()); + NS_LOG_DEBUG ("fragmenting size=" << fragment->GetSize ()); params.EnableNextData (GetNextFragmentSize ()); } m_low->StartTransmission (fragment, &hdr, params, @@ -453,18 +453,18 @@ EdcaTxopN::NotifyAccessGranted (void) m_currentHdr.SetAddr3 (m_low->GetBssid ()); m_currentPacket = currentAggregatedPacket; currentAggregatedPacket = 0; - MY_DEBUG ("tx unicast A-MSDU"); + NS_LOG_DEBUG ("tx unicast A-MSDU"); } } if (NeedRts ()) { params.EnableRts (); - MY_DEBUG ("tx unicast rts"); + NS_LOG_DEBUG ("tx unicast rts"); } else { params.DisableRts (); - MY_DEBUG ("tx unicast"); + NS_LOG_DEBUG ("tx unicast"); } params.DisableNextData (); m_low->StartTransmission (m_currentPacket, &m_currentHdr, @@ -492,17 +492,17 @@ void EdcaTxopN::GotCts (double snr, WifiMode txMode) { NS_LOG_FUNCTION (this << snr << txMode); - MY_DEBUG ("got cts"); + NS_LOG_DEBUG ("got cts"); } void EdcaTxopN::MissedCts (void) { NS_LOG_FUNCTION (this); - MY_DEBUG ("missed cts"); + NS_LOG_DEBUG ("missed cts"); if (!NeedRtsRetransmission ()) { - MY_DEBUG ("Cts Fail"); + NS_LOG_DEBUG ("Cts Fail"); WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ()); station->ReportFinalRtsFailed (); if (!m_txFailedCallback.IsNull ()) @@ -548,7 +548,7 @@ EdcaTxopN::GotAck (double snr, WifiMode txMode) IsLastFragment () || m_currentHdr.IsQosAmsdu ()) { - MY_DEBUG ("got ack. tx done."); + NS_LOG_DEBUG ("got ack. tx done."); if (!m_txOkCallback.IsNull ()) { m_txOkCallback (m_currentHdr); @@ -582,7 +582,7 @@ EdcaTxopN::GotAck (double snr, WifiMode txMode) } else { - MY_DEBUG ("got ack. tx not done, size="<GetSize ()); + NS_LOG_DEBUG ("got ack. tx not done, size="<GetSize ()); } } @@ -590,10 +590,10 @@ void EdcaTxopN::MissedAck (void) { NS_LOG_FUNCTION (this); - MY_DEBUG ("missed ack"); + NS_LOG_DEBUG ("missed ack"); if (!NeedDataRetransmission ()) { - MY_DEBUG ("Ack Fail"); + NS_LOG_DEBUG ("Ack Fail"); WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ()); station->ReportFinalDataFailed (); if (!m_txFailedCallback.IsNull ()) @@ -606,7 +606,7 @@ EdcaTxopN::MissedAck (void) } else { - MY_DEBUG ("Retransmit"); + NS_LOG_DEBUG ("Retransmit"); m_currentHdr.SetRetry (); m_dcf->UpdateFailedCw (); } @@ -618,9 +618,9 @@ void EdcaTxopN::MissedBlockAck (void) { NS_LOG_FUNCTION (this); - MY_DEBUG ("missed block ack"); + NS_LOG_DEBUG ("missed block ack"); //should i report this to station addressed by ADDR1? - MY_DEBUG ("Retransmit block ack request"); + NS_LOG_DEBUG ("Retransmit block ack request"); m_currentHdr.SetRetry (); m_dcf->UpdateFailedCw (); @@ -689,7 +689,7 @@ void EdcaTxopN::StartNext (void) { NS_LOG_FUNCTION (this); - MY_DEBUG ("start next packet fragment"); + NS_LOG_DEBUG ("start next packet fragment"); /* this callback is used only for fragments. */ NextFragment (); WifiMacHeader hdr; @@ -713,7 +713,7 @@ void EdcaTxopN::Cancel (void) { NS_LOG_FUNCTION (this); - MY_DEBUG ("transmission cancelled"); + NS_LOG_DEBUG ("transmission cancelled"); } bool @@ -835,18 +835,18 @@ void EdcaTxopN::GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient) { NS_LOG_FUNCTION (this); - MY_DEBUG ("received ADDBA response from "<GetTid (); if (m_baManager->ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::PENDING)) { if (respHdr->GetStatusCode ().IsSuccess ()) { - MY_DEBUG ("block ack agreement established with "<UpdateAgreement (respHdr, recipient); } else { - MY_DEBUG ("discard ADDBA response"<NotifyAgreementUnsuccessful (recipient, tid); } } @@ -857,14 +857,14 @@ void EdcaTxopN::GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient) { NS_LOG_FUNCTION (this); - MY_DEBUG ("received DELBA frame from="<