add logging to WifiRemoteStationManager

This commit is contained in:
Tom Henderson
2014-11-19 13:22:52 -08:00
parent 92fc236e1c
commit 5601229646

View File

@@ -18,6 +18,7 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include <iostream>
#include "wifi-remote-station-manager.h"
#include "ns3/simulator.h"
#include "ns3/assert.h"
@@ -418,6 +419,7 @@ WifiRemoteStationManager::SetFragmentationThreshold (uint32_t threshold)
void
WifiRemoteStationManager::Reset (Mac48Address address)
{
NS_LOG_FUNCTION (this << address);
NS_ASSERT (!address.IsGroup ());
WifiRemoteStationState *state = LookupState (address);
state->m_operationalRateSet.clear ();
@@ -428,6 +430,7 @@ WifiRemoteStationManager::Reset (Mac48Address address)
void
WifiRemoteStationManager::AddSupportedMode (Mac48Address address, WifiMode mode)
{
NS_LOG_FUNCTION (this << address << mode);
NS_ASSERT (!address.IsGroup ());
WifiRemoteStationState *state = LookupState (address);
for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
@@ -464,6 +467,7 @@ WifiRemoteStationManager::AddBssMembershipParameters(Mac48Address address, uint3
void
WifiRemoteStationManager::AddSupportedMcs (Mac48Address address, uint8_t mcs)
{
NS_LOG_FUNCTION (this << address << (uint16_t) mcs);
NS_ASSERT (!address.IsGroup ());
WifiRemoteStationState *state = LookupState (address);
for (WifiMcsListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
@@ -531,6 +535,7 @@ void
WifiRemoteStationManager::PrepareForQueue (Mac48Address address, const WifiMacHeader *header,
Ptr<const Packet> packet, uint32_t fullPacketSize)
{
NS_LOG_FUNCTION (this << address << *header << packet << fullPacketSize);
if (IsLowLatency () || address.IsGroup ())
{
return;
@@ -558,6 +563,7 @@ WifiTxVector
WifiRemoteStationManager::GetDataTxVector (Mac48Address address, const WifiMacHeader *header,
Ptr<const Packet> packet, uint32_t fullPacketSize)
{
NS_LOG_FUNCTION (this << address << *header << packet << fullPacketSize);
if (address.IsGroup ())
{
WifiTxVector v;
@@ -586,7 +592,7 @@ WifiTxVector
WifiRemoteStationManager::GetCtsToSelfTxVector(const WifiMacHeader *header,
Ptr<const Packet> packet)
{
NS_LOG_FUNCTION (this << *header << packet);
if (!IsLowLatency ())
{
HighLatencyCtsToSelfTxVectorTag ctstoselftag;
@@ -611,6 +617,7 @@ WifiTxVector
WifiRemoteStationManager::GetRtsTxVector (Mac48Address address, const WifiMacHeader *header,
Ptr<const Packet> packet)
{
NS_LOG_FUNCTION (this << address << *header << packet);
NS_ASSERT (!address.IsGroup ());
if (!IsLowLatency ())
{
@@ -628,6 +635,7 @@ WifiRemoteStationManager::GetRtsTxVector (Mac48Address address, const WifiMacHea
void
WifiRemoteStationManager::ReportRtsFailed (Mac48Address address, const WifiMacHeader *header)
{
NS_LOG_FUNCTION (this << address << *header);
NS_ASSERT (!address.IsGroup ());
WifiRemoteStation *station = Lookup (address, header);
station->m_ssrc++;
@@ -637,6 +645,7 @@ WifiRemoteStationManager::ReportRtsFailed (Mac48Address address, const WifiMacHe
void
WifiRemoteStationManager::ReportDataFailed (Mac48Address address, const WifiMacHeader *header)
{
NS_LOG_FUNCTION (this << address << *header);
NS_ASSERT (!address.IsGroup ());
WifiRemoteStation *station = Lookup (address, header);
station->m_slrc++;
@@ -647,6 +656,7 @@ void
WifiRemoteStationManager::ReportRtsOk (Mac48Address address, const WifiMacHeader *header,
double ctsSnr, WifiMode ctsMode, double rtsSnr)
{
NS_LOG_FUNCTION (this << address << *header << ctsSnr << ctsMode << rtsSnr);
NS_ASSERT (!address.IsGroup ());
WifiRemoteStation *station = Lookup (address, header);
station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
@@ -657,6 +667,7 @@ void
WifiRemoteStationManager::ReportDataOk (Mac48Address address, const WifiMacHeader *header,
double ackSnr, WifiMode ackMode, double dataSnr)
{
NS_LOG_FUNCTION (this << address << *header << ackSnr << ackMode << dataSnr);
NS_ASSERT (!address.IsGroup ());
WifiRemoteStation *station = Lookup (address, header);
station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
@@ -666,6 +677,7 @@ WifiRemoteStationManager::ReportDataOk (Mac48Address address, const WifiMacHeade
void
WifiRemoteStationManager::ReportFinalRtsFailed (Mac48Address address, const WifiMacHeader *header)
{
NS_LOG_FUNCTION (this << address << *header);
NS_ASSERT (!address.IsGroup ());
WifiRemoteStation *station = Lookup (address, header);
station->m_state->m_info.NotifyTxFailed ();
@@ -676,6 +688,7 @@ WifiRemoteStationManager::ReportFinalRtsFailed (Mac48Address address, const Wifi
void
WifiRemoteStationManager::ReportFinalDataFailed (Mac48Address address, const WifiMacHeader *header)
{
NS_LOG_FUNCTION (this << address << *header);
NS_ASSERT (!address.IsGroup ());
WifiRemoteStation *station = Lookup (address, header);
station->m_state->m_info.NotifyTxFailed ();
@@ -687,6 +700,7 @@ void
WifiRemoteStationManager::ReportRxOk (Mac48Address address, const WifiMacHeader *header,
double rxSnr, WifiMode txMode)
{
NS_LOG_FUNCTION (this << address << *header << rxSnr << txMode);
if (address.IsGroup ())
{
return;
@@ -698,6 +712,7 @@ bool
WifiRemoteStationManager::NeedRts (Mac48Address address, const WifiMacHeader *header,
Ptr<const Packet> packet)
{
NS_LOG_FUNCTION (this << address << *header << packet);
if (address.IsGroup ())
{
return false;
@@ -708,6 +723,7 @@ WifiRemoteStationManager::NeedRts (Mac48Address address, const WifiMacHeader *he
bool
WifiRemoteStationManager::NeedCtsToSelf (WifiTxVector txVector)
{
NS_LOG_FUNCTION (this << txVector);
WifiMode mode = txVector.GetMode();
// search the BSS Basic Rate set if the used mode in the basic set then no need for Cts to self
@@ -716,6 +732,7 @@ WifiRemoteStationManager::NeedCtsToSelf (WifiTxVector txVector)
{
if (mode == *i)
{
NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
return false;
}
}
@@ -727,46 +744,55 @@ WifiRemoteStationManager::NeedCtsToSelf (WifiTxVector txVector)
{
if (mcs == *i)
{
NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
return false;
}
}
}
NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
return true;
}
bool
WifiRemoteStationManager::NeedRtsRetransmission (Mac48Address address, const WifiMacHeader *header,
Ptr<const Packet> packet)
{
NS_LOG_FUNCTION (this << address << packet << *header);
NS_ASSERT (!address.IsGroup ());
WifiRemoteStation *station = Lookup (address, header);
bool normally = station->m_ssrc < GetMaxSsrc ();
NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_ssrc << " result: " << std::boolalpha << normally);
return DoNeedRtsRetransmission (station, packet, normally);
}
bool
WifiRemoteStationManager::NeedDataRetransmission (Mac48Address address, const WifiMacHeader *header,
Ptr<const Packet> packet)
{
NS_LOG_FUNCTION (this << address << packet << *header);
NS_ASSERT (!address.IsGroup ());
WifiRemoteStation *station = Lookup (address, header);
bool normally = station->m_slrc < GetMaxSlrc ();
NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_slrc << " result: " << std::boolalpha << normally);
return DoNeedDataRetransmission (station, packet, normally);
}
bool
WifiRemoteStationManager::NeedFragmentation (Mac48Address address, const WifiMacHeader *header,
Ptr<const Packet> packet)
{
NS_LOG_FUNCTION (this << address << packet << *header);
if (address.IsGroup ())
{
return false;
}
WifiRemoteStation *station = Lookup (address, header);
bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
return DoNeedFragmentation (station, packet, normally);
}
void
WifiRemoteStationManager::DoSetFragmentationThreshold (uint32_t threshold)
{
NS_LOG_FUNCTION (this << threshold);
if (threshold < 256)
{
/*
@@ -802,6 +828,7 @@ WifiRemoteStationManager::DoGetFragmentationThreshold (void) const
uint32_t
WifiRemoteStationManager::GetNFragments (const WifiMacHeader *header, Ptr<const Packet> packet)
{
NS_LOG_FUNCTION (this << *header << packet);
//The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
@@ -810,6 +837,7 @@ WifiRemoteStationManager::GetNFragments (const WifiMacHeader *header, Ptr<const
{
nFragments++;
}
NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
return nFragments;
}
@@ -817,39 +845,48 @@ uint32_t
WifiRemoteStationManager::GetFragmentSize (Mac48Address address, const WifiMacHeader *header,
Ptr<const Packet> packet, uint32_t fragmentNumber)
{
NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
NS_ASSERT (!address.IsGroup ());
uint32_t nFragment = GetNFragments (header, packet);
if (fragmentNumber >= nFragment)
{
NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
return 0;
}
//Last fragment
if (fragmentNumber == nFragment - 1)
{
uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
return lastFragmentSize;
}
//All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
else
{
return GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
uint32_t fragmentSize = GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
return fragmentSize;
}
}
uint32_t
WifiRemoteStationManager::GetFragmentOffset (Mac48Address address, const WifiMacHeader *header,
Ptr<const Packet> packet, uint32_t fragmentNumber)
{
NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
NS_ASSERT (!address.IsGroup ());
NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
return fragmentOffset;
}
bool
WifiRemoteStationManager::IsLastFragment (Mac48Address address, const WifiMacHeader *header,
Ptr<const Packet> packet, uint32_t fragmentNumber)
{
NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
NS_ASSERT (!address.IsGroup ());
bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
return isLast;
}
WifiMode
@@ -869,6 +906,7 @@ WifiRemoteStationManager::GetControlAnswerMode (Mac48Address address, WifiMode r
* sequence (as defined in Annex G) and that is of the same
* modulation class (see Section 9.7.8) as the received frame...
*/
NS_LOG_FUNCTION (this << address << reqMode);
WifiMode mode = GetDefaultMode ();
bool found = false;
@@ -998,6 +1036,7 @@ WifiRemoteStationManager::GetControlAnswerMode (Mac48Address address, WifiMode r
<< ". Check standard and selected rates match.");
}
NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
return mode;
}
@@ -1143,10 +1182,12 @@ WifiRemoteStationManager::GetInfo (Mac48Address address)
WifiRemoteStationState *
WifiRemoteStationManager::LookupState (Mac48Address address) const
{
NS_LOG_FUNCTION (this << address);
for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
{
if ((*i)->m_address == address)
{
NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
return (*i);
}
}
@@ -1161,6 +1202,7 @@ WifiRemoteStationManager::LookupState (Mac48Address address) const
state->m_tx=1;
state->m_stbc=false;
const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
return state;
}
WifiRemoteStation *
@@ -1180,6 +1222,7 @@ WifiRemoteStationManager::Lookup (Mac48Address address, const WifiMacHeader *hea
WifiRemoteStation *
WifiRemoteStationManager::Lookup (Mac48Address address, uint8_t tid) const
{
NS_LOG_FUNCTION (this << address << (uint16_t) tid);
for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
{
if ((*i)->m_tid == tid
@@ -1204,6 +1247,7 @@ WifiRemoteStationManager::Lookup (Mac48Address address, uint8_t tid) const
void
WifiRemoteStationManager::AddStationHtCapabilities (Mac48Address from, HtCapabilities htcapabilities)
{
NS_LOG_FUNCTION (this << from << htcapabilities);
WifiRemoteStationState *state;
state=LookupState (from);
state->m_shortGuardInterval=htcapabilities.GetShortGuardInterval20();
@@ -1229,6 +1273,7 @@ WifiRemoteStationManager::GetDefaultMcs (void) const
void
WifiRemoteStationManager::Reset (void)
{
NS_LOG_FUNCTION (this);
for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
{
delete (*i);
@@ -1243,6 +1288,7 @@ WifiRemoteStationManager::Reset (void)
void
WifiRemoteStationManager::AddBasicMode (WifiMode mode)
{
NS_LOG_FUNCTION (this << mode);
for (uint32_t i = 0; i < GetNBasicModes (); i++)
{
if (GetBasicMode (i) == mode)