24 #include "ns3/packet.h"
25 #include "ns3/simulator.h"
32 #include "ns3/ht-configuration.h"
33 #include "ns3/he-configuration.h"
46 .SetGroupName (
"Wifi")
48 .AddAttribute (
"ProbeRequestTimeout",
"The duration to actively probe the channel.",
52 .AddAttribute (
"WaitBeaconTimeout",
"The duration to dwell on a channel while passively scanning for beacon",
56 .AddAttribute (
"AssocRequestTimeout",
"The interval between two consecutive association request attempts.",
60 .AddAttribute (
"MaxMissedBeacons",
61 "Number of beacons which much be consecutively missed before "
62 "we attempt to restart association.",
65 MakeUintegerChecker<uint32_t> ())
66 .AddAttribute (
"ActiveProbing",
67 "If true, we send probe requests. If false, we don't."
68 "NOTE: if more than one STA in your simulation is using active probing, "
69 "you should enable it at a different simulation time for each STA, "
70 "otherwise all the STAs will start sending probes at the same time resulting in collisions. "
71 "See bug 1060 for more info.",
75 .AddTraceSource (
"Assoc",
"Associated with an access point.",
77 "ns3::Mac48Address::TracedCallback")
78 .AddTraceSource (
"DeAssoc",
"Association with an access point lost.",
80 "ns3::Mac48Address::TracedCallback")
81 .AddTraceSource (
"BeaconArrival",
82 "Time of beacons arrival from associated AP",
84 "ns3::Time::TracedCallback")
90 : m_state (UNASSOCIATED),
93 m_probeRequestEvent (),
94 m_assocRequestEvent (),
95 m_beaconWatchdogEnd (
Seconds (0))
130 NS_LOG_DEBUG (
"STA is still scanning, reset scanning process");
385 NS_LOG_DEBUG (
"Exhausted list of candidate AP; restart scanning");
428 NS_LOG_DEBUG (
"Set state to UNASSOCIATED and start scanning");
557 NS_LOG_LOGIC (
"Received data frame while not associated: ignore");
563 NS_LOG_LOGIC (
"Received data frame not from the DS: ignore");
569 NS_LOG_LOGIC (
"Received data frame not from the BSS we are associated with: ignore");
608 bool goodBeacon =
false;
616 bool bssMembershipSelectorMatch =
false;
618 for (
const auto & selector : selectorList)
622 NS_LOG_LOGIC (
"Beacon is matched to our BSS membership selector");
623 bssMembershipSelectorMatch =
true;
626 if (selectorList.size () > 0 && bssMembershipSelectorMatch ==
false)
742 if (newApInfo.
m_bssid == (*i).m_bssid)
751 if (newApInfo.
m_snr > (*i).m_snr)
768 for (
const auto & mode :
GetWifiPhy ()->GetModeList ())
801 bool qosSupported =
false;
887 for (
const auto & selector :
GetWifiPhy ()->GetBssMembershipSelectorList ())
891 NS_LOG_DEBUG (
"Supported rates do not fit with the BSS membership selector");
895 for (
const auto & mode :
GetWifiPhy ()->GetModeList ())
910 bool isErpAllowed =
false;
956 bool isErpAllowed =
false;
992 bool qosSupported =
false;
1050 for (
const auto & mode :
GetWifiPhy ()->GetModeList ())
1108 for (
const auto & mode :
GetWifiPhy ()->GetModeList ())
1110 uint64_t modeDataRate = mode.GetDataRate (
GetWifiPhy ()->GetChannelWidth ());
1111 NS_LOG_DEBUG (
"Adding supported rate of " << modeDataRate);
1116 for (
const auto & selector :
GetWifiPhy ()->GetBssMembershipSelectorList ())
1130 return capabilities;
1175 NS_LOG_DEBUG (
"PHY capabilities changed: send reassociation request");
AttributeValue implementation for Boolean.
bool IsNull(void) const
Check for null implementation.
uint16_t GetBeTxopLimit(void) const
Return the AC_BE TXOP Limit field in the EdcaParameterSet information element.
uint32_t GetBeCWmin(void) const
Return the AC_BE CWmin field in the EdcaParameterSet information element.
uint8_t GetVoAifsn(void) const
Return the AC_VO AIFSN field in the EdcaParameterSet information element.
uint8_t GetBeAifsn(void) const
Return the AC_BE AIFSN field in the EdcaParameterSet information element.
uint16_t GetVoTxopLimit(void) const
Return the AC_VO TXOP Limit field in the EdcaParameterSet information element.
uint32_t GetVoCWmax(void) const
Return the AC_VO CWmax field in the EdcaParameterSet information element.
uint32_t GetViCWmin(void) const
Return the AC_VI CWmin field in the EdcaParameterSet information element.
uint8_t GetBkAifsn(void) const
Return the AC_BK AIFSN field in the EdcaParameterSet information element.
uint8_t IsQosSupported(void) const
Is QOS supported function.
uint32_t GetViCWmax(void) const
Return the AC_VI CWmax field in the EdcaParameterSet information element.
uint8_t GetViAifsn(void) const
Return the AC_VI AIFSN field in the EdcaParameterSet information element.
uint32_t GetBeCWmax(void) const
Return the AC_BE CWmax field in the EdcaParameterSet information element.
uint32_t GetBkCWmax(void) const
Return the AC_BK CWmax field in the EdcaParameterSet information element.
uint16_t GetViTxopLimit(void) const
Return the AC_VI TXOP Limit field in the EdcaParameterSet information element.
uint32_t GetBkCWmin(void) const
Return the AC_BK CWmin field in the EdcaParameterSet information element.
uint32_t GetVoCWmin(void) const
Return the AC_VO CWmin field in the EdcaParameterSet information element.
uint16_t GetBkTxopLimit(void) const
Return the AC_BK TXOP Limit field in the EdcaParameterSet information element.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
The Extended Capabilities Information Element.
The IEEE 802.11ax HE Capabilities.
bool IsSupportedRxMcs(uint8_t mcs) const
Is RX MCS supported.
uint16_t GetSupportedMcsAndNss() const
Return the MCS and NSS field in the HE Capabilities information element.
The HE Operation Information Element.
uint8_t GetBssColor(void) const
Get the BSS color.
The HT Capabilities Information Element.
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
static Mac48Address GetBroadcast(void)
The MU EDCA Parameter Set.
uint16_t GetMuCwMin(uint8_t aci) const
Get the CWmin value encoded by the ECWmin subfield of the ECWmin/ECWmax field in the MU AC Parameter ...
uint8_t GetMuAifsn(uint8_t aci) const
Get the AIFSN subfield of the ACI/AIFSN field in the MU AC Parameter Record field corresponding to th...
bool IsPresent(void) const
Return true if a valid MU EDCA Parameter Set is present in this object.
uint16_t GetMuCwMax(uint8_t aci) const
Get the CWmax value encoded by the ECWmax subfield of the ECWmin/ECWmax field in the MU AC Parameter ...
Time GetMuEdcaTimer(uint8_t aci) const
Get the MU EDCA Timer value encoded in the MU AC Parameter Record field corresponding to the given AC...
bool IsInitialized(void) const
Check if the object has been initialized.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
void SetMuCwMax(uint16_t cwMax)
Set the maximum contention window size to use while the MU EDCA Timer is running.
void SetMuEdcaTimer(Time timer)
Set the MU EDCA Timer.
void SetMuAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS while the MU EDCA Timer is running.
void SetMuCwMin(uint16_t cwMin)
Set the minimum contention window size to use while the MU EDCA Timer is running.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now(void)
Return the current simulation virtual time.
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Introspection did not find any typical Config paths.
double Get(void) const
Return the SNR value.
bool IsEqual(const Ssid &o) const
Check if the two SSIDs are equal.
The Wifi MAC high model for a non-AP STA in a BSS.
Time m_waitBeaconTimeout
wait beacon timeout
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current STA.
void ScanningTimeout(void)
This method is called after wait beacon timeout or wait probe request timeout has occurred.
bool m_activeProbing
active probing
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
void SetEdcaParameters(AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
Set the EDCA parameters.
void SetState(MacState value)
Set the current MAC state.
Time m_beaconWatchdogEnd
beacon watchdog end
void UpdateApInfoFromProbeResp(MgtProbeResponseHeader probeResp, Mac48Address apAddr, Mac48Address bssid)
Update AP's information from probe response.
TracedCallback< Mac48Address > m_deAssocLogger
disassociation logger
void NotifyChannelSwitching(void) override
Notify that channel has been switched.
void SendProbeRequest(void)
Forward a probe request packet to the DCF.
void UpdateApInfoFromBeacon(MgtBeaconHeader beacon, Mac48Address apAddr, Mac48Address bssid)
Update associated AP's information from beacon.
MacState
The current MAC state of the STA.
EventId m_beaconWatchdog
beacon watchdog
uint16_t GetAssociationId(void) const
Return the association ID.
void UpdateCandidateApList(ApInfo newApInfo)
Update list of candidate AP to associate.
void UpdateApInfoFromAssocResp(MgtAssocResponseHeader assocResp, Mac48Address apAddr)
Update AP's information from association response.
bool IsWaitAssocResp(void) const
Return whether we are waiting for an association response from an AP.
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
void TryToEnsureAssociated(void)
Try to ensure that we are associated with an AP by taking an appropriate action depending on the curr...
bool IsAssociated(void) const
Return whether we are associated with an AP.
void Disassociated(void)
Take actions after disassociation.
uint32_t m_maxMissedBeacons
maximum missed beacons
EventId m_waitBeaconEvent
wait beacon event
TracedCallback< Mac48Address > m_assocLogger
association logger
void AssocRequestTimeout(void)
This method is called after the association timeout occurred.
void Receive(Ptr< WifiMacQueueItem > mpdu) override
Handle a received packet.
void RestartBeaconWatchdog(Time delay)
Restarts the beacon timer.
void MissedBeacons(void)
This method is called after we have not received a beacon from the AP.
EventId m_probeRequestEvent
probe request event
static TypeId GetTypeId(void)
Get the type ID.
void StartScanning(void)
Start the scanning process which trigger active or passive scanning based on the active probing flag.
uint16_t m_aid
Association AID.
MacState m_state
MAC state.
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
void SetMuEdcaParameters(AcIndex ac, uint16_t cwMin, uint16_t cwMax, uint8_t aifsn, Time muEdcaTimer)
Set the MU EDCA parameters.
void SetWifiPhy(const Ptr< WifiPhy > phy) override
void PhyCapabilitiesChanged(void)
Indicate that PHY capabilities have changed.
TracedCallback< Time > m_beaconArrival
beacon arrival logger
Time m_assocRequestTimeout
association request timeout
void DoInitialize(void) override
Initialize() implementation.
Time m_probeRequestTimeout
probe request timeout
void SetActiveProbing(bool enable)
Enable or disable active probing.
std::vector< ApInfo > m_candidateAps
list of candidate APs to associate to
EventId m_assocRequestEvent
association request event
bool GetActiveProbing(void) const
Return whether active probing is enabled.
void SendAssociationRequest(bool isReassoc)
Forward an association or reassociation request packet to the DCF.
bool IsSuccess(void) const
Return whether the status code is success.
The Supported Rates Information Element.
void AddBssMembershipSelectorRate(uint64_t bs)
Add a special value to the supported rate set, corresponding to a BSS membership selector.
bool IsBasicRate(uint64_t bs) const
Check if the given rate is a basic rate.
bool IsBssMembershipSelectorRate(uint64_t bs) const
Check if the given rate is a BSS membership selector value.
void AddSupportedRate(uint64_t bs)
Add the given rate to the supported rates.
bool IsSupportedRate(uint64_t bs) const
Check if the given rate is supported.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
The IEEE 802.11ac VHT Capabilities.
bool IsSupportedRxMcs(uint8_t mcs) const
Returns true if receive MCS is supported.
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
The VHT Operation Information Element.
base class for all MAC-level wifi objects.
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities of the device.
bool GetShortSlotTimeSupported(void) const
Ptr< HeConfiguration > GetHeConfiguration(void) const
Callback< void > m_linkDown
Callback when a link is down.
bool GetVhtSupported() const
Return whether the device supports VHT.
bool GetQosSupported() const
Return whether the device supports QoS.
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
Mac48Address GetAddress(void) const
Ptr< QosTxop > GetBEQueue(void) const
Accessor for the AC_BE channel access function.
bool GetHtSupported() const
Return whether the device supports HT.
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
Ptr< QosTxop > GetVOQueue(void) const
Accessor for the AC_VO channel access function.
Mac48Address GetBssid(void) const
bool GetHeSupported() const
Return whether the device supports HE.
virtual void Receive(Ptr< WifiMacQueueItem > mpdu)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
virtual void NotifyChannelSwitching(void)
Notify that channel has been switched.
Ptr< WifiPhy > GetWifiPhy(void) const
virtual void SetWifiPhy(Ptr< WifiPhy > phy)
virtual void DeaggregateAmsduAndForward(Ptr< WifiMacQueueItem > mpdu)
This method can be called to de-aggregate an A-MSDU and forward the constituent packets up the stack.
void NotifyRxDrop(Ptr< const Packet > packet)
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
virtual void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
bool GetErpSupported() const
Return whether the device supports ERP.
Callback< void > m_linkUp
Callback when a link is up.
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
void NotifyTxDrop(Ptr< const Packet > packet)
void SetBssid(Mac48Address bssid)
Ptr< Txop > GetTxop(void) const
Accessor for the Txop object.
std::list< uint8_t > GetBssMembershipSelectorList(void) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
void SetSlot(Time slot)
Set the slot duration for this PHY.
Time GetDelayUntilIdle(void)
void SetCapabilitiesChangedCallback(Callback< void > callback)
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
void RemoveAllSupportedMcs(Mac48Address address)
Invoked in a STA or AP to delete all of the supported MCS by a destination.
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtCapabilities)
Records VHT capabilities of the remote station.
void SetShortPreambleEnabled(bool enable)
Enable or disable short PHY preambles.
void SetQosSupport(Mac48Address from, bool qosSupported)
Records QoS support of the remote station.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
void AddSupportedMode(Mac48Address address, WifiMode mode)
Invoked in a STA or AP to store the set of modes supported by a destination which is also supported l...
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
Records HT capabilities of the remote station.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a QoS tag is attached to the packet, returns a value < 8.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ WIFI_MOD_CLASS_ERP_OFDM
ERP-OFDM (18.4)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
@ WIFI_MAC_MGT_PROBE_REQUEST
@ WIFI_MAC_MGT_ASSOCIATION_REQUEST
@ WIFI_MAC_MGT_REASSOCIATION_REQUEST
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Struct to hold information regarding observed AP through active/passive scanning.
double m_snr
SNR in linear scale.
Mac48Address m_bssid
BSSID.
MgtProbeResponseHeader m_probeResp
Probe Response header.
Mac48Address m_apAddr
AP MAC address.
MgtBeaconHeader m_beacon
Beacon header.
bool m_activeProbing
Flag whether active probing is used or not.