24 #include "ns3/packet.h" 25 #include "ns3/simulator.h" 43 .SetGroupName (
"Wifi")
45 .AddAttribute (
"ProbeRequestTimeout",
"The duration to actively probe the channel.",
49 .AddAttribute (
"WaitBeaconTimeout",
"The duration to dwell on a channel while passively scanning for beacon",
53 .AddAttribute (
"AssocRequestTimeout",
"The interval between two consecutive association request attempts.",
57 .AddAttribute (
"MaxMissedBeacons",
58 "Number of beacons which much be consecutively missed before " 59 "we attempt to restart association.",
62 MakeUintegerChecker<uint32_t> ())
63 .AddAttribute (
"ActiveProbing",
64 "If true, we send probe requests. If false, we don't." 65 "NOTE: if more than one STA in your simulation is using active probing, " 66 "you should enable it at a different simulation time for each STA, " 67 "otherwise all the STAs will start sending probes at the same time resulting in collisions. " 68 "See bug 1060 for more info.",
72 .AddTraceSource (
"Assoc",
"Associated with an access point.",
74 "ns3::Mac48Address::TracedCallback")
75 .AddTraceSource (
"DeAssoc",
"Association with an access point lost.",
77 "ns3::Mac48Address::TracedCallback")
78 .AddTraceSource (
"BeaconArrival",
79 "Time of beacons arrival from associated AP",
81 "ns3::Time::TracedCallback")
87 : m_state (UNASSOCIATED),
89 m_probeRequestEvent (),
90 m_assocRequestEvent (),
91 m_beaconWatchdogEnd (
Seconds (0))
119 NS_LOG_DEBUG (
"STA is still scanning, reset scanning process");
366 NS_LOG_DEBUG (
"Exhausted list of candidate AP; restart scanning");
518 NS_LOG_LOGIC (
"Received data frame while not associated: ignore");
524 NS_LOG_LOGIC (
"Received data frame not from the DS: ignore");
530 NS_LOG_LOGIC (
"Received data frame not from the BSS we are associated with: ignore");
568 bool goodBeacon =
false;
589 bool bssMembershipSelectorMatch =
false;
595 NS_LOG_LOGIC (
"Beacon is matched to our BSS membership selector");
596 bssMembershipSelectorMatch =
true;
626 apInfo.
m_snr = snrTag.Get ();
639 if (!probeResp.GetSsid ().IsEqual (
GetSsid ()))
713 if (newApInfo.
m_bssid == (*i).m_bssid)
722 if (newApInfo.
m_snr > (*i).m_snr)
773 bool qosSupported =
false;
868 NS_LOG_DEBUG (
"Supported rates do not fit with the BSS membership selector");
888 bool isErpAllowed =
false;
935 bool isErpAllowed =
false;
972 bool qosSupported =
false;
1097 NS_LOG_DEBUG (
"Adding supported rate of " << modeDataRate);
1120 return capabilities;
1155 NS_LOG_DEBUG (
"PHY capabilities changed: send reassociation request");
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void SetWifiPhy(const Ptr< WifiPhy > phy)
bool IsSuccess(void) const
Return whether the status code is success.
bool m_activeProbing
Flag whether active probing is used or not.
TracedCallback< Mac48Address > m_deAssocLogger
deassoc logger
Simulation virtual time values and global simulation resolution.
void SendCfFrame(WifiMacType frameType, Mac48Address addr)
Sends CF frame to sta with address addr.
Time m_assocRequestTimeout
assoc request timeout
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
Handle a received packet.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
bool GetActiveProbing(void) const
Return whether active probing is enabled.
bool IsBssMembershipSelectorRate(uint64_t bs) const
Check if the given rate is a BSS membership selector value.
void DoInitialize(void)
Initialize() implementation.
AttributeValue implementation for Boolean.
bool GetHeSupported() const
Return whether the device supports HE.
Ptr< Txop > m_txop
This holds a pointer to the TXOP instance for this WifiMac - used for transmission of frames to non-Q...
WifiMode GetMcs(uint8_t mcs) const
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
bool IsSupportedRxMcs(uint8_t mcs) const
Is reeive MCS supported.
void SetEdcaParameters(AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
Set the EDCA parameters.
bool GetQosSupported() const
Return whether the device supports QoS.
uint16_t GetVoTxopLimit(void) const
Return the AC_VO TXOP Limit field in the EdcaParameterSet information element.
bool IsSupportedRate(uint64_t bs) const
Check if the given rate is supported.
void SetState(MacState value)
Set the current MAC state.
std::vector< ApInfo > m_candidateAps
list of candidate APs to associate
void AssocRequestTimeout(void)
This method is called after the association timeout occurred.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Time m_probeRequestTimeout
probe request timeout
EdcaQueues m_edca
This is a map from Access Category index to the corresponding channel access function.
bool DoNavStartNow(Time duration)
Start NAV with the given duration.
uint8_t GetNBssMembershipSelectors(void) const
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
void StartScanning(void)
Start the scanning process which trigger active or passive scanning based on the active probing flag...
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities of the device.
The Extended Capabilities Information ElementThis class knows how to serialise and deserialise the Ex...
The VHT Operation Information ElementThis class knows how to serialise and deserialise the VHT Operat...
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Struct to hold information regarding observed AP through active/passive scanning. ...
Callback< void > m_linkUp
Callback when a link is up.
void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
bool GetRifsSupported(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
The HT Capabilities Information ElementThis class knows how to serialise and deserialise the HT Capab...
void UpdateCandidateApList(ApInfo newApInfo)
Update list of candidate AP to associate.
bool GetPcfSupported() const
Return whether the device supports PCF.
uint32_t GetBeCWmin(void) const
Return the AC_BE CWmin field in the EdcaParameterSet information element.
void SetSlot(Time slotTime)
void NotifyRxDrop(Ptr< const Packet > packet)
The HT Operation Information ElementThis class knows how to serialise and deserialise the HT Operatio...
Mac48Address m_bssid
BSSID.
virtual void DeaggregateAmsduAndForward(Ptr< Packet > aggregatedPacket, const WifiMacHeader *hdr)
This method can be called to de-aggregate an A-MSDU and forward the constituent packets up the stack...
virtual void SetPcfSupported(bool enable)
Enable or disable PCF capability support.
TracedCallback< Mac48Address > m_assocLogger
assoc logger
bool IsBasicRate(uint64_t bs) const
Check if the given rate is a basic rate.
EventId m_assocRequestEvent
assoc request event
Ptr< WifiPhy > m_phy
Wifi PHY.
uint8_t GetCFPCount(void) const
Return the CFP Count in DTIM frames unit.
Time m_waitBeaconTimeout
wait beacon timeout
The Supported Rates Information ElementThis class knows how to serialise and deserialise the Supporte...
uint16_t GetViTxopLimit(void) const
Return the AC_VI TXOP Limit field in the EdcaParameterSet information element.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
bool GetShortSlotTimeSupported(void) const
void AddSupportedRate(uint64_t bs)
Add the given rate to the supported rates.
double Get(void) const
Return the SNR value.
virtual void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
Set up WifiRemoteStationManager associated with this StaWifiMac.
uint32_t GetBeCWmax(void) const
Return the AC_BE CWmax field in the EdcaParameterSet information element.
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a qos tag is attached to the packet, returns a value < 8.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
The Wifi MAC high model for a STA or AP in a BSS.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
uint8_t GetNonGfHtStasPresent(void) const
Return the non GF HT STAs present.
bool GetShortPlcpPreambleSupported(void) const
Return whether short PLCP preamble is supported.
MacState
The current MAC state of the STA.
uint16_t GetChannelWidth(void) const
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
void SetBssid(Mac48Address bssid)
uint8_t GetNMcs(void) const
The WifiPhy::GetNMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of t...
uint64_t GetCFPMaxDurationUs(void) const
Return the CFP MaxDuration in microseconds.
void SendProbeRequest(void)
Forward a probe request packet to the DCF.
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current STA.
void ForwardUp(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
void UpdateApInfoFromBeacon(MgtBeaconHeader beacon, Mac48Address apAddr, Mac48Address bssid)
Update associated AP's information from beacon.
bool GetErpSupported() const
Return whether the device supports ERP.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates...
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Mac48Address m_apAddr
AP MAC address.
AttributeValue implementation for Time.
bool GetVhtSupported() const
Return whether the device supports VHT.
The IEEE 802.11ac VHT Capabilities.
MacState m_state
MAC state.
void NotifyTxDrop(Ptr< const Packet > packet)
Hold an unsigned integer type.
void MissedBeacons(void)
This method is called after we have not received a beacon from the AP.
uint8_t GetBkAifsn(void) const
Return the AC_BK AIFSN field in the EdcaParameterSet information element.
The CF Parameter SetThis class knows how to serialise and deserialise the CF Parameter Set...
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
Records HT capabilities of the remote station.
MgtProbeResponseHeader m_probeResp
Probe Response header.
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
static Mac48Address GetBroadcast(void)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Mac48Address GetBssid(void) const
void ScanningTimeout(void)
This method is called after wait beacon timeout or wait probe request timeout has occurred...
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities hecapabilities)
Records HE capabilities of the remote station.
void SetCapabilitiesChangedCallback(Callback< void > callback)
WifiModulationClass GetModulationClass() const
Ptr< MacLow > m_low
MacLow (RTS, CTS, DATA, ACK etc.)
void SetQosSupport(Mac48Address from, bool qosSupported)
Records QoS support of the remote station.
uint32_t GetBkCWmin(void) const
Return the AC_BK CWmin field in the EdcaParameterSet information element.
Callback< void > m_linkDown
Callback when a link is down.
void SendCfPollResponse(void)
Forward a CF-Poll response packet to the CFP queue.
uint32_t m_maxMissedBeacons
maximum missed beacons
bool GetShortSlotTimeEnabled(void) const
Return whether the device uses short slot time.
EventId m_beaconWatchdog
beacon watchdog
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
void UpdateApInfoFromProbeResp(MgtProbeResponseHeader probeResp, Mac48Address apAddr, Mac48Address bssid)
Update AP's information from probe response.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetVoCWmin(void) const
Return the AC_VO CWmin field in the EdcaParameterSet information element.
void PhyCapabilitiesChanged(void)
Indicate that PHY capabilities have changed.
The EDCA Parameter SetThis class knows how to serialise and deserialise the EDCA Parameter Set...
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...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
static TypeId GetTypeId(void)
Get the type ID.
void AddBssMembershipSelectorRate(uint64_t bs)
Add a special value to the supported rate set, corresponding to a BSS membership selector.
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.
uint8_t GetBeAifsn(void) const
Return the AC_BE AIFSN field in the EdcaParameterSet information element.
void RestartBeaconWatchdog(Time delay)
Restarts the beacon timer.
void TryToEnsureAssociated(void)
Try to ensure that we are associated with an AP by taking an appropriate action depending on the curr...
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static Time Now(void)
Return the current simulation virtual time.
MgtBeaconHeader m_beacon
Beacon header.
EventId m_waitBeaconEvent
wait beacon event
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
uint8_t GetRifsMode(void) const
Return the RIFS mode.
uint32_t GetVoCWmax(void) const
Return the AC_VO CWmax field in the EdcaParameterSet information element.
uint64_t GetCFPDurRemainingUs(void) const
Return the CFP DurRemaining in microseconds.
void SetActiveProbing(bool enable)
Enable or disable active probing.
Mac48Address GetAddress(void) const
uint8_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
void UpdateApInfoFromAssocResp(MgtAssocResponseHeader assocResp, Mac48Address apAddr)
Update AP's information from association response.
uint16_t GetBkTxopLimit(void) const
Return the AC_BK TXOP Limit field in the EdcaParameterSet information element.
WifiMode GetMode(uint8_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
uint8_t GetBssMembershipSelector(uint8_t selector) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
uint8_t GetVoAifsn(void) const
Return the AC_VO AIFSN field in the EdcaParameterSet information element.
uint16_t GetBeTxopLimit(void) const
Return the AC_BE TXOP Limit field in the EdcaParameterSet information element.
virtual void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
bool IsSupportedRxMcs(uint8_t mcs) const
Get the is receive MCS supported.
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
bool GetHtSupported() const
Return whether the device supports HT.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
void Enqueue(Ptr< const Packet > packet, Mac48Address to)
void SetUseGreenfieldProtection(bool enable)
Enable or disable protection for stations that do not support HT greenfield format.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsEqual(const Ssid &o) const
Check if the two SSIDs are equal.
uint32_t GetBkCWmax(void) const
Return the AC_BK CWmax field in the EdcaParameterSet information element.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
uint32_t GetViCWmax(void) const
Return the AC_VI CWmax field in the EdcaParameterSet information element.
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
uint32_t GetViCWmin(void) const
Return the AC_VI CWmin field in the EdcaParameterSet information element.
bool IsWaitAssocResp(void) const
Return whether we are waiting for an association response from an AP.
Time m_beaconWatchdogEnd
beacon watchdog end
bool m_activeProbing
active probing
EventId m_probeRequestEvent
probe request event
void SetShortPreambleEnabled(bool enable)
Enable or disable short PLCP preambles.
The HE Operation Information ElementThis class knows how to serialise and deserialise the HE Operatio...
Ptr< WifiRemoteStationManager > m_stationManager
Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.)
bool IsNull(void) const
Check for null implementation.
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
bool IsBroadcast(void) const
Check if the SSID is broadcast.
The IEEE 802.11ax HE Capabilities.
uint8_t GetMcsValue(void) const
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
virtual void SetWifiPhy(const Ptr< WifiPhy > phy)
void RemoveAllSupportedMcs(Mac48Address address)
Invoked in a STA or AP to delete all of the supported MCS by a destination.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
uint8_t GetViAifsn(void) const
Return the AC_VI AIFSN field in the EdcaParameterSet information element.
uint8_t IsQosSupported(void) const
Is QOS supported function.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Introspection did not find any typical Config paths.
void SetRifsPermitted(bool allow)
Permit or prohibit RIFS.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
void AddHeader(const Header &header)
Add header to this packet.
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtcapabilities)
Records VHT capabilities of the remote station.
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
void SendAssociationRequest(bool isReassoc)
Forward an association or reassociation request packet to the DCF.
bool IsAssociated(void) const
Return whether we are associated with an AP.
TracedCallback< Time > m_beaconArrival
beacon arrival logger
The Wifi MAC high model for a non-AP STA in a BSS.