--- a/src/wifi/model/sta-wifi-mac.cc Tue Jun 16 13:13:06 2015 -0700
+++ b/src/wifi/model/sta-wifi-mac.cc Sun Jun 21 00:23:45 2015 +0200
@@ -16,18 +16,17 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- * Author: Mirko Banchi <mk.banchi@gmail.com>
+ * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ * Mirko Banchi <mk.banchi@gmail.com>
*/
+
#include "sta-wifi-mac.h"
-
#include "ns3/log.h"
#include "ns3/simulator.h"
#include "ns3/string.h"
#include "ns3/pointer.h"
#include "ns3/boolean.h"
#include "ns3/trace-source-accessor.h"
-
#include "qos-tag.h"
#include "mac-low.h"
#include "dcf-manager.h"
@@ -82,7 +81,12 @@
UintegerValue (10),
MakeUintegerAccessor (&StaWifiMac::m_maxMissedBeacons),
MakeUintegerChecker<uint32_t> ())
- .AddAttribute ("ActiveProbing", "If true, we send probe requests. If false, we don't. NOTE: if more than one STA in your simulation is using active probing, you should enable it at a different simulation time for each STA, otherwise all the STAs will start sending probes at the same time resulting in collisions. See bug 1060 for more info.",
+ .AddAttribute ("ActiveProbing",
+ "If true, we send probe requests. If false, we don't."
+ "NOTE: if more than one STA in your simulation is using active probing, "
+ "you should enable it at a different simulation time for each STA, "
+ "otherwise all the STAs will start sending probes at the same time resulting in collisions. "
+ "See bug 1060 for more info.",
BooleanValue (false),
MakeBooleanAccessor (&StaWifiMac::SetActiveProbing, &StaWifiMac::GetActiveProbing),
MakeBooleanChecker ())
@@ -104,8 +108,8 @@
{
NS_LOG_FUNCTION (this);
- // Let the lower layers know that we are acting as a non-AP STA in
- // an infrastructure BSS.
+ //Let the lower layers know that we are acting as a non-AP STA in
+ //an infrastructure BSS.
SetTypeOfStation (STA);
}
@@ -156,7 +160,7 @@
}
m_activeProbing = enable;
}
-
+
bool StaWifiMac::GetActiveProbing (void) const
{
return m_activeProbing;
@@ -179,16 +183,16 @@
probe.SetSupportedRates (GetSupportedRates ());
if (m_htSupported)
{
- probe.SetHtCapabilities (GetHtCapabilities());
- hdr.SetNoOrder();
+ probe.SetHtCapabilities (GetHtCapabilities ());
+ hdr.SetNoOrder ();
}
packet->AddHeader (probe);
- // The standard is not clear on the correct queue for management
- // frames if we are a QoS AP. The approach taken here is to always
- // use the DCF for these regardless of whether we have a QoS
- // association or not.
+ //The standard is not clear on the correct queue for management
+ //frames if we are a QoS AP. The approach taken here is to always
+ //use the DCF for these regardless of whether we have a QoS
+ //association or not.
m_dca->Queue (packet, hdr);
if (m_probeRequestEvent.IsRunning ())
@@ -216,16 +220,16 @@
assoc.SetSupportedRates (GetSupportedRates ());
if (m_htSupported)
{
- assoc.SetHtCapabilities (GetHtCapabilities());
- hdr.SetNoOrder();
+ assoc.SetHtCapabilities (GetHtCapabilities ());
+ hdr.SetNoOrder ();
}
packet->AddHeader (assoc);
- // The standard is not clear on the correct queue for management
- // frames if we are a QoS AP. The approach taken here is to always
- // use the DCF for these regardless of whether we have a QoS
- // association or not.
+ //The standard is not clear on the correct queue for management
+ //frames if we are a QoS AP. The approach taken here is to always
+ //use the DCF for these regardless of whether we have a QoS
+ //association or not.
m_dca->Queue (packet, hdr);
if (m_assocRequestEvent.IsRunning ())
@@ -258,10 +262,10 @@
* We try to initiate a probe request now.
*/
m_linkDown ();
- if (m_activeProbing)
+ if (m_activeProbing)
{
- SetState (WAIT_PROBE_RESP);
- SendProbeRequest ();
+ SetState (WAIT_PROBE_RESP);
+ SendProbeRequest ();
}
break;
case WAIT_ASSOC_RESP:
@@ -352,31 +356,31 @@
}
WifiMacHeader hdr;
- // If we are not a QoS AP then we definitely want to use AC_BE to
- // transmit the packet. A TID of zero will map to AC_BE (through \c
- // QosUtilsMapTidToAc()), so we use that as our default here.
+ //If we are not a QoS AP then we definitely want to use AC_BE to
+ //transmit the packet. A TID of zero will map to AC_BE (through \c
+ //QosUtilsMapTidToAc()), so we use that as our default here.
uint8_t tid = 0;
- // For now, an AP that supports QoS does not support non-QoS
- // associations, and vice versa. In future the AP model should
- // support simultaneously associated QoS and non-QoS STAs, at which
- // point there will need to be per-association QoS state maintained
- // by the association state machine, and consulted here.
+ //For now, an AP that supports QoS does not support non-QoS
+ //associations, and vice versa. In future the AP model should
+ //support simultaneously associated QoS and non-QoS STAs, at which
+ //point there will need to be per-association QoS state maintained
+ //by the association state machine, and consulted here.
if (m_qosSupported)
{
hdr.SetType (WIFI_MAC_QOSDATA);
hdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK);
hdr.SetQosNoEosp ();
hdr.SetQosNoAmsdu ();
- // Transmission of multiple frames in the same TXOP is not
- // supported for now
+ //Transmission of multiple frames in the same TXOP is not
+ //supported for now
hdr.SetQosTxopLimit (0);
- // Fill in the QoS control field in the MAC header
+ //Fill in the QoS control field in the MAC header
tid = QosUtilsGetTidForPacket (packet);
- // Any value greater than 7 is invalid and likely indicates that
- // the packet had no QoS tag, so we revert to zero, which'll
- // mean that AC_BE is used.
+ //Any value greater than 7 is invalid and likely indicates that
+ //the packet had no QoS tag, so we revert to zero, which'll
+ //mean that AC_BE is used.
if (tid > 7)
{
tid = 0;
@@ -387,9 +391,9 @@
{
hdr.SetTypeData ();
}
-if (m_htSupported)
+ if (m_htSupported)
{
- hdr.SetNoOrder();
+ hdr.SetNoOrder ();
}
hdr.SetAddr1 (GetBssid ());
@@ -400,7 +404,7 @@
if (m_qosSupported)
{
- // Sanity check that the TID is valid
+ //Sanity check that the TID is valid
NS_ASSERT (tid < 8);
m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
}
@@ -447,7 +451,6 @@
NotifyRxDrop (packet);
return;
}
-
if (hdr->IsQosData ())
{
if (hdr->IsQosAmsdu ())
@@ -470,7 +473,7 @@
else if (hdr->IsProbeReq ()
|| hdr->IsAssocReq ())
{
- // This is a frame aimed at an AP, so we can safely ignore it.
+ //This is a frame aimed at an AP, so we can safely ignore it.
NotifyRxDrop (packet);
return;
}
@@ -487,12 +490,12 @@
SupportedRates rates = beacon.GetSupportedRates ();
for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
{
- uint32_t selector = m_phy->GetBssMembershipSelector (i);
- if (!rates.IsSupportedRate (selector))
- {
- goodBeacon = false;
- }
- }
+ uint32_t selector = m_phy->GetBssMembershipSelector (i);
+ if (!rates.IsSupportedRate (selector))
+ {
+ goodBeacon = false;
+ }
+ }
if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ())
{
goodBeacon = false;
@@ -524,11 +527,11 @@
SupportedRates rates = probeResp.GetSupportedRates ();
for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
{
- uint32_t selector = m_phy->GetBssMembershipSelector (i);
- if (!rates.IsSupportedRate (selector))
- {
- return;
- }
+ uint32_t selector = m_phy->GetBssMembershipSelector (i);
+ if (!rates.IsSupportedRate (selector))
+ {
+ return;
+ }
}
SetBssid (hdr->GetAddr3 ());
Time delay = MicroSeconds (probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons);
@@ -575,17 +578,17 @@
}
}
}
- if(m_htSupported)
+ if (m_htSupported)
{
HtCapabilities htcapabilities = assocResp.GetHtCapabilities ();
- for (uint32_t i = 0; i < m_phy->GetNMcs(); i++)
+ for (uint32_t i = 0; i < m_phy->GetNMcs (); i++)
{
- uint8_t mcs=m_phy->GetMcs(i);
- if (htcapabilities.IsSupportedMcs (mcs))
- {
- m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
+ uint8_t mcs = m_phy->GetMcs (i);
+ if (htcapabilities.IsSupportedMcs (mcs))
+ {
+ m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
//here should add a control to add basic MCS when it is implemented
- }
+ }
}
}
if (!m_linkUp.IsNull ())
@@ -602,9 +605,9 @@
return;
}
- // Invoke the receive handler of our parent class to deal with any
- // other frames. Specifically, this will handle Block Ack-related
- // Management Action frames.
+ //Invoke the receive handler of our parent class to deal with any
+ //other frames. Specifically, this will handle Block Ack-related
+ //Management Action frames.
RegularWifiMac::Receive (packet, hdr);
}
@@ -612,11 +615,11 @@
StaWifiMac::GetSupportedRates (void) const
{
SupportedRates rates;
- if(m_htSupported)
+ if (m_htSupported)
{
- for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors(); i++)
+ for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
{
- rates.SetBasicRate(m_phy->GetBssMembershipSelector(i));
+ rates.SetBasicRate (m_phy->GetBssMembershipSelector (i));
}
}
for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
@@ -626,20 +629,22 @@
}
return rates;
}
+
HtCapabilities
StaWifiMac::GetHtCapabilities (void) const
{
- HtCapabilities capabilities;
- capabilities.SetHtSupported(1);
- capabilities.SetLdpc (m_phy->GetLdpc());
- capabilities.SetShortGuardInterval20 (m_phy->GetGuardInterval());
- capabilities.SetGreenfield (m_phy->GetGreenfield());
-for (uint8_t i =0 ; i < m_phy->GetNMcs();i++)
- {
- capabilities.SetRxMcsBitmask(m_phy->GetMcs(i));
- }
- return capabilities;
+ HtCapabilities capabilities;
+ capabilities.SetHtSupported (1);
+ capabilities.SetLdpc (m_phy->GetLdpc ());
+ capabilities.SetShortGuardInterval20 (m_phy->GetGuardInterval ());
+ capabilities.SetGreenfield (m_phy->GetGreenfield ());
+ for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
+ {
+ capabilities.SetRxMcsBitmask (m_phy->GetMcs (i));
+ }
+ return capabilities;
}
+
void
StaWifiMac::SetState (MacState value)
{
@@ -656,4 +661,4 @@
m_state = value;
}
-} // namespace ns3
+} //namespace ns3