|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
24 #include "ns3/packet.h"
25 #include "ns3/simulator.h"
31 #include "ns3/ht-configuration.h"
32 #include "ns3/he-configuration.h"
45 .SetGroupName (
"Wifi")
47 .AddAttribute (
"ProbeRequestTimeout",
"The duration to actively probe the channel.",
51 .AddAttribute (
"WaitBeaconTimeout",
"The duration to dwell on a channel while passively scanning for beacon",
55 .AddAttribute (
"AssocRequestTimeout",
"The interval between two consecutive association request attempts.",
59 .AddAttribute (
"MaxMissedBeacons",
60 "Number of beacons which much be consecutively missed before "
61 "we attempt to restart association.",
64 MakeUintegerChecker<uint32_t> ())
65 .AddAttribute (
"ActiveProbing",
66 "If true, we send probe requests. If false, we don't."
67 "NOTE: if more than one STA in your simulation is using active probing, "
68 "you should enable it at a different simulation time for each STA, "
69 "otherwise all the STAs will start sending probes at the same time resulting in collisions. "
70 "See bug 1060 for more info.",
74 .AddTraceSource (
"Assoc",
"Associated with an access point.",
76 "ns3::Mac48Address::TracedCallback")
77 .AddTraceSource (
"DeAssoc",
"Association with an access point lost.",
79 "ns3::Mac48Address::TracedCallback")
80 .AddTraceSource (
"BeaconArrival",
81 "Time of beacons arrival from associated AP",
83 "ns3::Time::TracedCallback")
89 : m_state (UNASSOCIATED),
92 m_probeRequestEvent (),
93 m_assocRequestEvent (),
94 m_beaconWatchdogEnd (
Seconds (0))
129 NS_LOG_DEBUG (
"STA is still scanning, reset scanning process");
360 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");
569 bool goodBeacon =
false;
577 bool bssMembershipSelectorMatch =
false;
579 for (
const auto & selector : selectorList)
583 NS_LOG_LOGIC (
"Beacon is matched to our BSS membership selector");
584 bssMembershipSelectorMatch =
true;
587 if (selectorList.size () > 0 && bssMembershipSelectorMatch ==
false)
703 if (newApInfo.
m_bssid == (*i).m_bssid)
712 if (newApInfo.
m_snr > (*i).m_snr)
762 bool qosSupported =
false;
852 NS_LOG_DEBUG (
"Supported rates do not fit with the BSS membership selector");
871 bool isErpAllowed =
false;
917 bool isErpAllowed =
false;
953 bool qosSupported =
false;
1072 NS_LOG_DEBUG (
"Adding supported rate of " << modeDataRate);
1091 return capabilities;
1136 NS_LOG_DEBUG (
"PHY capabilities changed: send reassociation request");
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time m_waitBeaconTimeout
wait beacon timeout
bool IsBssMembershipSelectorRate(uint64_t bs) const
Check if the given rate is a BSS membership selector value.
uint32_t GetBkCWmin(void) const
Return the AC_BK CWmin field in the EdcaParameterSet information element.
The IEEE 802.11ac VHT Capabilities.
Time m_probeRequestTimeout
probe request timeout
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
static TypeId GetTypeId(void)
Get the type ID.
Ptr< const Packet > GetPacket(void) const
Get the packet stored in this item.
@ WIFI_MOD_CLASS_ERP_OFDM
ERP-OFDM (18.4)
void MissedBeacons(void)
This method is called after we have not received a beacon from the AP.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
uint16_t GetBkTxopLimit(void) const
Return the AC_BK TXOP Limit field in the EdcaParameterSet information element.
AttributeValue implementation for Boolean.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities of the device.
void NotifyTxDrop(Ptr< const Packet > packet)
void AddHeader(const Header &header)
Add header to this packet.
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Ssid GetSsid(void) const override
void SetMuEdcaParameters(AcIndex ac, uint16_t cwMin, uint16_t cwMax, uint8_t aifsn, Time muEdcaTimer)
Set the MU EDCA parameters.
double m_snr
SNR in linear scale.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsStateRx(void) const
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
bool IsNull(void) const
Check for null implementation.
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
void SetBssid(Mac48Address bssid)
Time GetDelayUntilIdle(void)
@ WIFI_MAC_MGT_ASSOCIATION_REQUEST
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Time m_assocRequestTimeout
association request timeout
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
bool m_activeProbing
Flag whether active probing is used or not.
bool GetHeSupported() const
Return whether the device supports HE.
@ WIFI_MAC_MGT_REASSOCIATION_REQUEST
The IEEE 802.11ax HE Capabilities.
Mac48Address GetBssid(void) const override
bool GetErpSupported() const
Return whether the device supports ERP.
TracedCallback< Mac48Address > m_deAssocLogger
disassociation logger
bool IsPresent(void) const
Return true if a valid MU EDCA Parameter Set is present in this object.
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
base class for all MAC-level wifi objects.
const WifiMacHeader & GetHeader(void) const
Get the header stored in this item.
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 ScanningTimeout(void)
This method is called after wait beacon timeout or wait probe request timeout has occurred.
bool GetQosSupported() const
Return whether the device supports QoS.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void SendAssociationRequest(bool isReassoc)
Forward an association or reassociation request packet to the DCF.
uint16_t m_aid
Association AID.
Mac48Address m_apAddr
AP MAC address.
MacState m_state
MAC state.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
The VHT Operation Information Element.
EventId m_probeRequestEvent
probe request event
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
void UpdateApInfoFromBeacon(MgtBeaconHeader beacon, Mac48Address apAddr, Mac48Address bssid)
Update associated AP's information from beacon.
std::vector< ApInfo > m_candidateAps
list of candidate APs to associate to
void AssocRequestTimeout(void)
This method is called after the association timeout occurred.
void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Callback< void > m_linkDown
Callback when a link is down.
Mac48Address m_bssid
BSSID.
Mac48Address GetAddress(void) const override
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...
uint16_t GetVoTxopLimit(void) const
Return the AC_VO TXOP Limit field in the EdcaParameterSet information element.
void UpdateCandidateApList(ApInfo newApInfo)
Update list of candidate AP to associate.
bool IsSupportedRate(uint64_t bs) const
Check if the given rate is supported.
The Supported Rates Information Element.
void SetCapabilitiesChangedCallback(Callback< void > callback)
static Mac48Address GetBroadcast(void)
uint8_t IsQosSupported(void) const
Is QOS supported function.
void SetMuCwMin(uint16_t cwMin)
Set the minimum contention window size to use while the MU EDCA Timer is running.
EdcaQueues m_edca
This is a map from Access Category index to the corresponding channel access function.
MacState
The current MAC state of the STA.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
void SetMuEdcaTimer(Time timer)
Set the MU EDCA Timer.
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...
uint32_t GetVoCWmax(void) const
Return the AC_VO CWmax field in the EdcaParameterSet information element.
void RemoveAllSupportedMcs(Mac48Address address)
Invoked in a STA or AP to delete all of the supported MCS by a destination.
void SetQosSupport(Mac48Address from, bool qosSupported)
Records QoS support of the remote station.
uint32_t m_maxMissedBeacons
maximum missed beacons
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 GetShortPhyPreambleSupported(void) const
Return whether short PHY preamble is supported.
uint32_t GetBkCWmax(void) const
Return the AC_BK CWmax field in the EdcaParameterSet information element.
EventId m_beaconWatchdog
beacon watchdog
bool GetVhtSupported() const
Return whether the device supports VHT.
The HT Capabilities Information Element.
EventId m_waitBeaconEvent
wait beacon event
void UpdateApInfoFromAssocResp(MgtAssocResponseHeader assocResp, Mac48Address apAddr)
Update AP's information from association response.
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
uint8_t GetVoAifsn(void) const
Return the AC_VO AIFSN field in the EdcaParameterSet information element.
MgtBeaconHeader m_beacon
Beacon header.
Struct to hold information regarding observed AP through active/passive scanning.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
bool IsEqual(const Ssid &o) const
Check if the two SSIDs are equal.
void SetWifiPhy(const Ptr< WifiPhy > phy) override
Callback< void > m_linkUp
Callback when a link is up.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Ptr< Txop > m_txop
This holds a pointer to the TXOP instance for this WifiMac - used for transmission of frames to non-Q...
bool GetShortSlotTimeSupported(void) const override
uint16_t GetViTxopLimit(void) const
Return the AC_VI TXOP Limit field in the EdcaParameterSet information element.
Ptr< HeConfiguration > GetHeConfiguration(void) const
uint32_t GetViCWmin(void) const
Return the AC_VI CWmin field in the EdcaParameterSet information element.
void SendProbeRequest(void)
Forward a probe request packet to the DCF.
bool m_activeProbing
active probing
Ptr< WifiRemoteStationManager > m_stationManager
Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.)
Ptr< const AttributeChecker > MakeBooleanChecker(void)
The HE Operation Information Element.
uint16_t GetBeTxopLimit(void) const
Return the AC_BE TXOP Limit field in the EdcaParameterSet information element.
uint8_t GetBssColor(void) const
Get the BSS color.
Simulation virtual time values and global simulation resolution.
EventId m_assocRequestEvent
association request event
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
bool IsBasicRate(uint64_t bs) const
Check if the given rate is a basic rate.
void SetTypeOfStation(TypeOfStation type) override
This method is invoked by a subclass to specify what type of station it is implementing.
bool IsSuccess(void) const
Return whether the status code is success.
void UpdateApInfoFromProbeResp(MgtProbeResponseHeader probeResp, Mac48Address apAddr, Mac48Address bssid)
Update AP's information from probe response.
void Receive(Ptr< WifiMacQueueItem > mpdu) override
Handle a received packet.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
bool GetShortSlotTimeEnabled(void) const
Return whether the device uses short slot time.
void SetShortPreambleEnabled(bool enable)
Enable or disable short PHY preambles.
MgtProbeResponseHeader m_probeResp
Probe Response header.
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
Records HT capabilities of the remote station.
Introspection did not find any typical Config paths.
void SetSlot(Time slot)
Set the slot duration for this PHY.
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...
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtCapabilities)
Records VHT capabilities of the remote station.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
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 ...
void SetEdcaParameters(AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
Set the EDCA parameters.
void NotifyRxDrop(Ptr< const Packet > packet)
uint16_t GetSupportedMcsAndNss() const
Return the MCS and NSS field in the HE Capabilities information element.
uint8_t GetBeAifsn(void) const
Return the AC_BE AIFSN field in the EdcaParameterSet information element.
The Extended Capabilities Information Element.
void SetState(MacState value)
Set the current MAC state.
@ WIFI_MAC_MGT_PROBE_REQUEST
void PhyCapabilitiesChanged(void)
Indicate that PHY capabilities have changed.
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
bool IsSupportedRxMcs(uint8_t mcs) const
Returns true if receive MCS is supported.
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
void SetWifiPhy(const Ptr< WifiPhy > phy) override
void DoInitialize(void) override
Initialize() implementation.
bool IsAssociated(void) const
Return whether we are associated with an AP.
double Get(void) const
Return the SNR value.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
AttributeValue implementation for Time.
void SetActiveProbing(bool enable)
Enable or disable active probing.
uint16_t GetChannelWidth(void) const
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
uint32_t GetBeCWmax(void) const
Return the AC_BE CWmax field in the EdcaParameterSet information element.
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
std::list< WifiMode > GetModeList(void) const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
The Wifi MAC high model for a non-AP STA in a BSS.
std::list< uint8_t > GetBssMembershipSelectorList(void) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
void StartScanning(void)
Start the scanning process which trigger active or passive scanning based on the active probing flag.
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
Hold an unsigned integer type.
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
void AddSupportedRate(uint64_t bs)
Add the given rate to the supported rates.
Ptr< WifiPhy > m_phy
Wifi PHY.
void RestartBeaconWatchdog(Time delay)
Restarts the beacon timer.
TracedCallback< Time > m_beaconArrival
beacon arrival logger
TracedCallback< Mac48Address > m_assocLogger
association logger
uint32_t GetViCWmax(void) const
Return the AC_VI CWmax field in the EdcaParameterSet information element.
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 ...
bool IsWaitAssocResp(void) const
Return whether we are waiting for an association response from an AP.
Time m_beaconWatchdogEnd
beacon watchdog end
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
void AddBssMembershipSelectorRate(uint64_t bs)
Add a special value to the supported rate set, corresponding to a BSS membership selector.
uint8_t GetViAifsn(void) const
Return the AC_VI AIFSN field in the EdcaParameterSet information element.
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
uint32_t GetVoCWmin(void) const
Return the AC_VO CWmin field in the EdcaParameterSet information element.
std::list< WifiMode > GetMcsList(void) const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
bool GetActiveProbing(void) const
Return whether active probing is enabled.
void SetMuAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS while the MU EDCA Timer is running.
uint32_t GetBeCWmin(void) const
Return the AC_BE CWmin field in the EdcaParameterSet information element.
bool GetHtSupported() const
Return whether the device supports HT.
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
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...
uint16_t GetAssociationId(void) const
Return the association ID.
void SetMuCwMax(uint16_t cwMax)
Set the maximum contention window size to use while the MU EDCA Timer is running.
void TryToEnsureAssociated(void)
Try to ensure that we are associated with an AP by taking an appropriate action depending on the curr...
bool IsSupportedRxMcs(uint8_t mcs) const
Is RX MCS supported.
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a QoS tag is attached to the packet, returns a value < 8.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current STA.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
uint8_t GetBkAifsn(void) const
Return the AC_BK AIFSN field in the EdcaParameterSet information element.
The MU EDCA Parameter Set.