34#include "ns3/eht-configuration.h"
35#include "ns3/emlsr-manager.h"
36#include "ns3/he-configuration.h"
37#include "ns3/ht-configuration.h"
39#include "ns3/packet.h"
41#include "ns3/pointer.h"
42#include "ns3/random-variable-stream.h"
43#include "ns3/simulator.h"
44#include "ns3/string.h"
63 .AddAttribute(
"ProbeRequestTimeout",
64 "The duration to actively probe the channel.",
68 .AddAttribute(
"WaitBeaconTimeout",
69 "The duration to dwell on a channel while passively scanning for beacon",
73 .AddAttribute(
"AssocRequestTimeout",
74 "The interval between two consecutive association request attempts.",
78 .AddAttribute(
"MaxMissedBeacons",
79 "Number of beacons which much be consecutively missed before "
80 "we attempt to restart association.",
83 MakeUintegerChecker<uint32_t>())
86 "If true, we send probe requests. If false, we don't."
87 "NOTE: if more than one STA in your simulation is using active probing, "
88 "you should enable it at a different simulation time for each STA, "
89 "otherwise all the STAs will start sending probes at the same time resulting in "
91 "See bug 1060 for more info.",
95 .AddAttribute(
"ProbeDelay",
96 "Delay (in microseconds) to be used prior to transmitting a "
97 "Probe frame during active scanning.",
98 StringValue(
"ns3::UniformRandomVariable[Min=50.0|Max=250.0]"),
100 MakePointerChecker<RandomVariableStream>())
103 "Enable/disable power save mode on the given link. The power management mode is "
104 "actually changed when the AP acknowledges a frame sent with the Power Management "
105 "field set to the value corresponding to the requested mode",
110 MakeUintegerChecker<uint8_t>()))
111 .AddAttribute(
"PmModeSwitchTimeout",
112 "If switching to a new Power Management mode is not completed within "
113 "this amount of time, make another attempt at switching Power "
118 .AddTraceSource(
"Assoc",
119 "Associated with an access point. If this is an MLD that associated "
120 "with an AP MLD, the AP MLD address is provided.",
122 "ns3::Mac48Address::TracedCallback")
123 .AddTraceSource(
"LinkSetupCompleted",
124 "A link was setup in the context of ML setup with an AP MLD. "
125 "Provides ID of the setup link and AP MAC address",
127 "ns3::StaWifiMac::LinkSetupCallback")
128 .AddTraceSource(
"DeAssoc",
129 "Association with an access point lost. If this is an MLD "
130 "that disassociated with an AP MLD, the AP MLD address is provided.",
132 "ns3::Mac48Address::TracedCallback")
133 .AddTraceSource(
"LinkSetupCanceled",
134 "A link setup in the context of ML setup with an AP MLD was torn down. "
135 "Provides ID of the setup link and AP MAC address",
137 "ns3::StaWifiMac::LinkSetupCallback")
138 .AddTraceSource(
"BeaconArrival",
139 "Time of beacons arrival from associated AP",
141 "ns3::Time::TracedCallback")
142 .AddTraceSource(
"ReceivedBeaconInfo",
143 "Information about every received Beacon frame",
145 "ns3::ApInfo::TracedCallback");
150 : m_state(UNASSOCIATED),
152 m_assocRequestEvent()
197std::unique_ptr<WifiMac::LinkEntity>
200 return std::make_unique<StaLinkEntity>();
253 NS_LOG_DEBUG(
"STA is still scanning, reset scanning process");
269 for (
auto& phy : phys)
271 phy->SetCapabilitiesChangedCallback(
280 uint16_t width = phy->GetOperatingChannel().IsOfdm() ? 20 : phy->GetChannelWidth();
281 uint8_t ch = phy->GetOperatingChannel().GetPrimaryChannelNumber(width, phy->GetStandard());
282 return {ch, phy->GetPhyBand()};
319 packet->AddHeader(probe);
338std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader>
343 std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader> mgtFrame;
349 mgtFrame = std::move(reassoc);
357 auto fill = [&](
auto&& frame) {
358 frame.template Get<Ssid>() =
GetSsid();
360 frame.template Get<SupportedRates>() = supportedRates.rates;
361 frame.template Get<ExtendedSupportedRatesIE>() = supportedRates.extendedRates;
363 frame.SetListenInterval(0);
383 std::visit(fill, mgtFrame);
418 for (uint8_t index = 0; index <
GetNLinks(); index++)
421 if (index != linkId && link.apLinkId.has_value())
430 perStaProfile.
SetLinkId(link.apLinkId.value());
433 perStaProfile.SetCompleteProfile();
438 perStaProfile.SetStaMacAddress(link.feManager->GetAddress());
443 return multiLinkElement;
453 if (
GetLink(linkId).sendAssocReq)
462 "No BSSID set for the link on which the (Re)Association Request is to be sent");
468 hdr.
SetAddr2(link.feManager->GetAddress());
481 auto addMle = [&](
auto&& frame) {
484 std::visit(addMle, frame);
489 packet->AddHeader(std::get<MgtAssocRequestHeader>(frame));
493 packet->AddHeader(std::get<MgtReassocRequestHeader>(frame));
570 for (uint8_t linkId = 0; linkId <
GetNLinks(); linkId++)
599 if (!bestAp.has_value())
601 NS_LOG_DEBUG(
"Exhausted list of candidate AP; restart scanning");
606 NS_LOG_DEBUG(
"Attempting to associate with AP: " << *bestAp);
607 UpdateApInfo(bestAp->m_frame, bestAp->m_apAddr, bestAp->m_bssid, bestAp->m_linkId);
609 for (uint8_t linkId = 0; linkId <
GetNLinks(); linkId++)
612 link.sendAssocReq =
false;
613 link.apLinkId = std::nullopt;
614 link.bssid = std::nullopt;
620 for (
const auto& [localLinkId, apLinkId] : bestAp->m_setupLinks)
622 NS_LOG_DEBUG(
"Setting up link (local ID=" << +localLinkId <<
", AP ID=" << +apLinkId
625 if (localLinkId == bestAp->m_linkId)
634 "AP link address not set for local link " << +localLinkId);
638 auto getBeaconInterval = [](
auto&& frame) {
639 using T = std::decay_t<
decltype(frame)>;
640 if constexpr (std::is_same_v<T, MgtBeaconHeader> ||
641 std::is_same_v<T, MgtProbeResponseHeader>)
651 Time beaconInterval = std::visit(getBeaconInterval, bestAp->m_frame);
654 for (uint8_t linkId = 0; linkId <
GetNLinks(); linkId++)
680 if (link.beaconWatchdog.IsRunning())
682 link.beaconWatchdog.Cancel();
708 if (link.apLinkId.has_value())
715 link.apLinkId = std::nullopt;
716 link.bssid = std::nullopt;
717 link.phy->SetOffMode();
719 for (uint8_t
id = 0;
id <
GetNLinks();
id++)
728 NS_LOG_DEBUG(
"Set state to UNASSOCIATED and start scanning");
733 if (
GetNLinks() > 1 && mldAddress.has_value())
744 for (uint8_t
id = 0;
id <
GetNLinks();
id++)
756 link.beaconWatchdogEnd = std::max(
Simulator::Now() + delay, link.beaconWatchdogEnd);
784 std::set<uint8_t> linkIds;
785 for (uint8_t linkId = 0; linkId <
GetNLinks(); linkId++)
789 linkIds.insert(linkId);
795std::optional<uint8_t>
806 uint8_t linkId = *linkIds.begin();
873 uint8_t linkId = *linkIds.begin();
906 const WifiMacHeader* hdr = &mpdu->GetOriginal()->GetHeader();
926 NS_LOG_LOGIC(
"Received data frame while not associated: ignore");
932 NS_LOG_LOGIC(
"Received data frame not from the DS: ignore");
936 std::set<Mac48Address> apAddresses;
941 if (apAddresses.count(mpdu->GetHeader().GetAddr2()) == 0)
943 NS_LOG_LOGIC(
"Received data frame not from the BSS we are associated with: ignore");
957 NS_ASSERT(apAddresses.count(mpdu->GetHeader().GetAddr3()) != 0);
998 action.protectedEhtAction ==
1027 mpdu->GetPacket()->PeekHeader(beacon);
1036 goodBeacon = bssid.has_value() && (hdr.
GetAddr3() == *bssid);
1046 bool found = mpdu->GetPacket()->PeekPacketTag(snrTag);
1050 .m_snr = snrTag.
Get(),
1051 .m_frame = std::move(beacon),
1053 .m_linkId = linkId};
1089 mpdu->GetPacket()->PeekHeader(probeResp);
1095 bool found = mpdu->GetPacket()->PeekPacketTag(snrTag);
1099 .m_snr = snrTag.
Get(),
1100 .m_frame = std::move(probeResp),
1101 .m_channel = {GetCurrentChannel(linkId)},
1102 .m_linkId = linkId});
1117 std::optional<Mac48Address> apMldAddress;
1119 mpdu->GetPacket()->PeekHeader(assocResp);
1154 std::list<uint8_t> setupLinks(
GetNLinks());
1155 std::iota(setupLinks.begin(), setupLinks.end(), 0);
1158 setupLinks.remove(linkId);
1165 "The link on which the Association Response was received "
1166 "is not a link we requested to setup");
1168 "The link ID of the AP that transmitted the Association "
1169 "Response does not match the stored link ID");
1171 mle->GetMldMacAddress(),
1172 "The AP MLD MAC address in the received Multi-Link Element does not "
1173 "match the address stored in the station manager for link "
1176 for (std::size_t elem = 0; elem < mle->GetNPerStaProfileSubelements(); elem++)
1178 auto& perStaProfile = mle->GetPerStaProfile(elem);
1179 uint8_t apLinkId = perStaProfile.GetLinkId();
1180 uint8_t staLinkid = 0;
1183 if (
GetLink(staLinkid).apLinkId == apLinkId)
1189 std::optional<Mac48Address> bssid;
1191 !(bssid =
GetLink(staLinkid).bssid).has_value(),
1192 "Setup for AP link ID " << apLinkId <<
" was not requested");
1194 "The BSSID in the Per-STA Profile for link ID "
1195 << +staLinkid <<
" does not match the stored BSSID");
1198 perStaProfile.GetStaMacAddress()) != mle->GetMldMacAddress(),
1199 "The AP MLD MAC address in the received Multi-Link Element does not "
1200 "match the address stored in the station manager for link "
1207 "AID should be the same for all the links");
1209 NS_LOG_DEBUG(
"Setup on link " << staLinkid <<
" completed");
1221 setupLinks.remove(staLinkid);
1225 for (
const auto&
id : setupLinks)
1264 NS_ASSERT_MSG(psduMap.size() == 1 && psduMap.begin()->second->GetNMpdus() == 1 &&
1265 psduMap.begin()->second->GetHeader(0).IsAck(),
1266 "Expected a Normal Ack after Association Response frame");
1271 for (uint8_t
id = 0;
id <
GetNLinks();
id++)
1298 std::pair<bool, uint8_t>{
true,
id});
1319 std::pair<bool, uint8_t>{
false,
id});
1329 phy->TraceConnectWithoutContext(
"PhyTxPsduBegin", cb);
1331 [=]() { phy->TraceDisconnectWithoutContext(
"PhyTxPsduBegin", cb); });
1341 auto check = [&](
auto&& mgtFrame) ->
bool {
1343 NS_ASSERT(mgtFrame.template Get<SupportedRates>());
1345 mgtFrame.template Get<ExtendedSupportedRatesIE>()};
1346 for (
const auto& selector :
GetWifiPhy(linkId)->GetBssMembershipSelectorList())
1348 if (!rates.IsBssMembershipSelectorRate(selector))
1350 NS_LOG_DEBUG(
"Supported rates do not fit with the BSS membership selector");
1358 return std::visit(
check, frame);
1370 const std::optional<ErpInformation>* erpInformation =
nullptr;
1372 if (
const auto* beacon = std::get_if<MgtBeaconHeader>(&frame))
1376 else if (
const auto* probe = std::get_if<MgtProbeResponseHeader>(&frame))
1382 auto commonOps = [&](
auto&& frame) {
1383 const auto& capabilities = frame.Capabilities();
1384 NS_ASSERT(frame.template Get<SupportedRates>());
1386 frame.template Get<ExtendedSupportedRatesIE>()};
1387 for (
const auto& mode :
GetWifiPhy(linkId)->GetModeList())
1389 if (rates.IsSupportedRate(mode.GetDataRate(
GetWifiPhy(linkId)->GetChannelWidth())))
1392 if (rates.IsBasicRate(mode.GetDataRate(
GetWifiPhy(linkId)->GetChannelWidth())))
1399 bool isShortPreambleEnabled = capabilities.IsShortPreamble();
1400 if (erpInformation && erpInformation->has_value() &&
GetErpSupported(linkId))
1402 isShortPreambleEnabled &= !(*erpInformation)->GetBarkerPreambleMode();
1403 if ((*erpInformation)->GetUseProtection() != 0)
1411 if (capabilities.IsShortSlotTime() ==
true)
1424 capabilities.IsShortSlotTime());
1431 bool qosSupported =
false;
1432 const auto& edcaParameters = frame.template Get<EdcaParameterSet>();
1433 if (edcaParameters.has_value())
1435 qosSupported =
true;
1439 edcaParameters->GetBeCWmin(),
1440 edcaParameters->GetBeCWmax(),
1441 edcaParameters->GetBeAifsn(),
1445 edcaParameters->GetBkCWmin(),
1446 edcaParameters->GetBkCWmax(),
1447 edcaParameters->GetBkAifsn(),
1451 edcaParameters->GetViCWmin(),
1452 edcaParameters->GetViCWmax(),
1453 edcaParameters->GetViAifsn(),
1457 edcaParameters->GetVoCWmin(),
1458 edcaParameters->GetVoCWmax(),
1459 edcaParameters->GetVoAifsn(),
1470 if (
const auto& htCapabilities = frame.template Get<HtCapabilities>();
1471 htCapabilities.has_value())
1473 if (!htCapabilities->IsSupportedMcs(0))
1490 const auto& vhtCapabilities = frame.template Get<VhtCapabilities>();
1493 if (vhtCapabilities.has_value() &&
1494 vhtCapabilities->GetRxHighestSupportedLgiDataRate() > 0)
1501 if (vhtCapabilities->IsSupportedRxMcs(mcs.GetMcsValue()))
1514 const auto& heCapabilities = frame.template Get<HeCapabilities>();
1515 if (heCapabilities.has_value() && heCapabilities->GetSupportedMcsAndNss() != 0)
1520 if (heCapabilities->IsSupportedRxMcs(mcs.GetMcsValue()))
1525 if (
const auto& heOperation = frame.template Get<HeOperation>();
1526 heOperation.has_value())
1533 const auto& muEdcaParameters = frame.template Get<MuEdcaParameterSet>();
1534 if (muEdcaParameters.has_value())
1537 muEdcaParameters->GetMuCwMin(
AC_BE),
1538 muEdcaParameters->GetMuCwMax(
AC_BE),
1539 muEdcaParameters->GetMuAifsn(
AC_BE),
1540 muEdcaParameters->GetMuEdcaTimer(
AC_BE)},
1543 muEdcaParameters->GetMuCwMin(
AC_BK),
1544 muEdcaParameters->GetMuCwMax(
AC_BK),
1545 muEdcaParameters->GetMuAifsn(
AC_BK),
1546 muEdcaParameters->GetMuEdcaTimer(
AC_BK)},
1549 muEdcaParameters->GetMuCwMin(
AC_VI),
1550 muEdcaParameters->GetMuCwMax(
AC_VI),
1551 muEdcaParameters->GetMuAifsn(
AC_VI),
1552 muEdcaParameters->GetMuEdcaTimer(
AC_VI)},
1555 muEdcaParameters->GetMuCwMin(
AC_VO),
1556 muEdcaParameters->GetMuCwMax(
AC_VO),
1557 muEdcaParameters->GetMuAifsn(
AC_VO),
1558 muEdcaParameters->GetMuEdcaTimer(
AC_VO)},
1567 const auto& ehtCapabilities = frame.template Get<EhtCapabilities>();
1572 if (
const auto& mle = frame.template Get<MultiLinkElement>();
1575 m_emlsrManager->SetTransitionTimeout(mle->GetTransitionTimeout());
1580 std::visit(commonOps, frame);
1586 const auto [enable, linkId] = enableLinkIdPair;
1593 NS_LOG_DEBUG(
"Not associated yet, record the PM mode to switch to upon association");
1600 NS_LOG_DEBUG(
"Link " << +linkId <<
" has not been setup, ignore request");
1621 NS_LOG_DEBUG(
"Next transmitted frame will be sent with PM=" << enable);
1640 m_txop->
Queue(Create<WifiMpdu>(Create<Packet>(), hdr));
1661 auto linkIds = mpdu->GetInFlightLinkIds();
1663 "The TA of the acked MPDU (" << *mpdu
1664 <<
") is not a link "
1665 "address and the MPDU is not inflight");
1670 linkId = *linkIds.begin();
1671 mpdu =
GetTxopQueue(mpdu->GetQueueAc())->GetAlias(mpdu, *linkId);
1674 auto& link =
GetLink(*linkId);
1692 for (
const auto& mode :
GetWifiPhy(linkId)->GetModeList())
1694 uint64_t modeDataRate = mode.GetDataRate(
GetWifiPhy(linkId)->GetChannelWidth());
1695 NS_LOG_DEBUG(
"Adding supported rate of " << modeDataRate);
1700 for (
const auto& selector :
GetWifiPhy(linkId)->GetBssMembershipSelectorList())
1715 return capabilities;
1728 edca->SetMinCw(params.cwMin, linkId);
1729 edca->SetMaxCw(params.cwMax, linkId);
1730 edca->SetAifsn(params.aifsn, linkId);
1731 edca->SetTxopLimit(params.txopLimit, linkId);
1738 edca->SetMuCwMin(params.cwMin, linkId);
1739 edca->SetMuCwMax(params.cwMax, linkId);
1740 edca->SetMuAifsn(params.aifsn, linkId);
1741 edca->SetMuEdcaTimer(params.muEdcaTimer, linkId);
1750 NS_LOG_DEBUG(
"PHY capabilities changed: send reassociation request");
1775 os <<
"BSSID=" << apInfo.
m_bssid <<
", AP addr=" << apInfo.
m_apAddr <<
", SNR=" << apInfo.
m_snr
1777 <<
"}, Link ID=" << +apInfo.
m_linkId <<
", Frame=[";
1778 std::visit([&os](
auto&& frame) { frame.Print(os); }, apInfo.
m_frame);
AttributeValue implementation for Boolean.
Base class for Callback class.
bool IsNull() const
Check for null implementation.
The IEEE 802.11be EHT Capabilities.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsRunning() const
This method is syntactic sugar for !IsExpired().
The Extended Capabilities Information Element.
The Extended Supported Rates Information Element.
The IEEE 802.11ax HE Capabilities.
The HT Capabilities Information Element.
static Mac48Address ConvertFrom(const Address &address)
static Mac48Address GetBroadcast()
void SetLinkId(uint8_t linkId)
Set the Link ID subfield in the STA Control field.
void AddPerStaProfileSubelement()
Add a Per-STA Profile Subelement in the Link Info field.
void SetEmlsrSupported(bool supported)
Set the EMLSR Support subfield of the EML Capabilities subfield in the Common Info field to 1 if EMLS...
void SetEmlsrTransitionDelay(Time delay)
Set the EMLSR Transition Delay subfield of the EML Capabilities subfield in the Common Info field.
PerStaProfileSubelement & GetPerStaProfile(std::size_t i)
Get a reference to the i-th Per-STA Profile Subelement in the Link Info field.
void SetEmlsrPaddingDelay(Time delay)
Set the EMLSR Padding Delay subfield of the EML Capabilities subfield in the Common Info field.
void SetMldMacAddress(Mac48Address address)
Set the MLD MAC Address subfield in the Common Info field.
std::size_t GetNPerStaProfileSubelements() const
Return the number of Per-STA Profile Subelement in the Link Info field.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
bool IsInitialized() const
Check if the object has been initialized.
Hold objects of type std::pair<A, B>.
Smart pointer class similar to boost::intrusive_ptr.
virtual double GetValue()=0
Get the next random value drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
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() const
Return the SNR value.
The IEEE 802.11 SSID Information Element.
The Wifi MAC high model for a non-AP STA in a BSS.
std::set< uint8_t > GetSetupLinkIds() const
Get the IDs of the setup links (if any).
void ScanningTimeout(const std::optional< ApInfo > &bestAp)
This method is called after wait beacon timeout or wait probe request timeout has occurred.
Time m_waitBeaconTimeout
wait beacon timeout
void SetPowerSaveMode(const std::pair< bool, uint8_t > &enableLinkIdPair)
Enable or disable Power Save mode on the given link.
Ptr< WifiAssocManager > m_assocManager
Association Manager.
void MissedBeacons(uint8_t linkId)
This method is called after we have not received a beacon from the AP on the given link.
bool m_activeProbing
active probing
void DoInitialize() override
Initialize() implementation.
void SetAssocManager(Ptr< WifiAssocManager > assocManager)
Set the Association Manager.
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
std::unique_ptr< LinkEntity > CreateLinkEntity() const override
Create a LinkEntity object.
void SetState(MacState value)
Set the current MAC state.
AllSupportedRates GetSupportedRates(uint8_t linkId) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
void SetEdcaParameters(const EdcaParams ¶ms, uint8_t linkId)
Set the EDCA parameters for the given link.
TracedCallback< Mac48Address > m_deAssocLogger
disassociation logger
MacState
The current MAC state of the STA.
void NotifyChannelSwitching(uint8_t linkId) override
Notify that channel on the given link has been switched.
bool GetActiveProbing() const
Return whether active probing is enabled.
void PhyCapabilitiesChanged()
Indicate that PHY capabilities have changed.
void ReceiveProbeResp(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Process the Probe Response frame received on the given link.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void SetPmModeAfterAssociation(uint8_t linkId)
Set the Power Management mode of the setup links after association.
WifiScanParams::Channel GetCurrentChannel(uint8_t linkId) const
Get the current primary20 channel used on the given link as a (channel number, PHY band) pair.
uint16_t GetAssociationId() const
Return the association ID.
void TryToEnsureAssociated()
Try to ensure that we are associated with an AP by taking an appropriate action depending on the curr...
void ReceiveAssocResp(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Process the (Re)Association Response frame received on the given link.
void RestartBeaconWatchdog(Time delay, uint8_t linkId)
Restarts the beacon timer for the given link.
std::variant< MgtAssocRequestHeader, MgtReassocRequestHeader > GetAssociationRequest(bool isReassoc, uint8_t linkId) const
Get the (Re)Association Request frame to send on a given link.
static TypeId GetTypeId()
Get the type ID.
void DoDispose() override
Destructor implementation.
void SendProbeRequest(uint8_t linkId)
Enqueue a probe request packet for transmission on the given link.
StaLinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
uint32_t m_maxMissedBeacons
maximum missed beacons
TracedCallback< uint8_t, Mac48Address > m_setupCompleted
link setup completed logger
std::optional< uint8_t > GetApLinkId(uint8_t linkId) const
TracedCallback< Mac48Address > m_assocLogger
association logger
void SetWifiPhys(const std::vector< Ptr< WifiPhy > > &phys) override
void SetMuEdcaParameters(const MuEdcaParams ¶ms, uint8_t linkId)
Set the MU EDCA parameters for the given link.
void Disassociated(uint8_t linkId)
Check if any enabled link remains after the given link is disabled (because, e.g.,...
TracedCallback< uint8_t, Mac48Address > m_setupCanceled
link setup canceled logger
bool CheckSupportedRates(std::variant< MgtBeaconHeader, MgtProbeResponseHeader > frame, uint8_t linkId)
Determine whether the supported rates indicated in a given Beacon frame or Probe Response frame fit w...
Mac48Address DoGetLocalAddress(const Mac48Address &remoteAddr) const override
This method is called if this device is an MLD to determine the MAC address of the affiliated STA use...
void SetEmlsrManager(Ptr< EmlsrManager > emlsrManager)
Set the EMLSR Manager.
Time m_pmModeSwitchTimeout
PM mode switch timeout.
Ptr< EmlsrManager > GetEmlsrManager() const
void TxOk(Ptr< const WifiMpdu > mpdu)
Notify that the MPDU we sent was successfully received by the receiver (i.e.
void Receive(Ptr< const WifiMpdu > mpdu, uint8_t linkId) override
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
WifiPowerManagementMode GetPmMode(uint8_t linkId) const
Ptr< RandomVariableStream > m_probeDelay
RandomVariable used to randomize the time of the first Probe Response on each channel.
TracedCallback< ApInfo > m_beaconInfo
beacon info logger
uint16_t m_aid
Association AID.
MacState m_state
MAC state.
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
void StartScanning()
Start the scanning process which trigger active or passive scanning based on the active probing flag.
TracedCallback< Time > m_beaconArrival
beacon arrival logger
void AssocRequestTimeout()
This method is called after the association timeout occurred.
Ptr< EmlsrManager > m_emlsrManager
EMLSR Manager.
void UpdateApInfo(const MgtFrameType &frame, const Mac48Address &apAddr, const Mac48Address &bssid, uint8_t linkId)
Update associated AP's information from the given management frame (Beacon, Probe Response or Associa...
Time m_assocRequestTimeout
association request timeout
void ReceiveBeacon(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Process the Beacon frame received on the given link.
Time m_probeRequestTimeout
probe request timeout
void SetActiveProbing(bool enable)
Enable or disable active probing.
CapabilityInformation GetCapabilities(uint8_t linkId) const
Return the Capability information for the given link.
bool IsAssociated() const
Return whether we are associated with an AP.
std::variant< MgtBeaconHeader, MgtProbeResponseHeader, MgtAssocResponseHeader > MgtFrameType
type of the management frames used to get info about APs
bool IsWaitAssocResp() const
Return whether we are waiting for an association response from an AP.
MultiLinkElement GetMultiLinkElement(bool isReassoc, uint8_t linkId) const
Return the Multi-Link Element to include in the management frames transmitted on the given link.
EventId m_assocRequestEvent
association request event
void SendAssociationRequest(bool isReassoc)
Forward an association or reassociation request packet to the DCF.
bool IsSuccess() const
Return whether the status code is success.
Hold variables of type string.
The Supported Rates Information Element.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
a unique identifier for an interface.
@ ATTR_GET
The attribute can be read.
@ ATTR_SET
The attribute can be written.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
The IEEE 802.11ac VHT Capabilities.
base class for all MAC-level wifi objects.
Ptr< FrameExchangeManager > GetFrameExchangeManager(uint8_t linkId=SINGLE_LINK_OP_ID) const
Get the Frame Exchange Manager associated with the given link.
Ptr< QosTxop > GetBEQueue() const
Accessor for the AC_BE channel access function.
virtual void NotifyChannelSwitching(uint8_t linkId)
Notify that channel on the given link has been switched.
std::optional< Mac48Address > GetMldAddress(const Mac48Address &remoteAddr) const
Mac48Address GetBssid(uint8_t linkId) const
Ptr< HeConfiguration > GetHeConfiguration() const
Ptr< Txop > GetTxop() const
Accessor for the Txop object.
VhtCapabilities GetVhtCapabilities(uint8_t linkId) const
Return the VHT capabilities of the device for the given link.
Callback< void > m_linkDown
Callback when a link is down.
bool GetQosSupported() const
Return whether the device supports QoS.
Ptr< Txop > m_txop
TXOP used for transmission of frames to non-QoS peers.
uint8_t GetNLinks() const
Get the number of links (can be greater than 1 for 11be devices only).
void DoInitialize() override
Initialize() implementation.
bool GetErpSupported(uint8_t linkId) const
Return whether the device supports ERP on the given link.
bool GetHtSupported() const
Return whether the device supports HT.
Ptr< QosTxop > GetVOQueue() const
Accessor for the AC_VO channel access function.
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Ptr< WifiPhy > GetWifiPhy(uint8_t linkId=SINGLE_LINK_OP_ID) const
bool GetEhtSupported() const
Return whether the device supports EHT.
bool GetHeSupported() const
Return whether the device supports HE.
HtCapabilities GetHtCapabilities(uint8_t linkId) const
Return the HT capabilities of the device for the given link.
virtual std::optional< uint8_t > GetLinkIdByAddress(const Mac48Address &address) const
Get the ID of the link having the given MAC address, if any.
virtual bool HasFramesToTransmit(uint8_t linkId)
Check if the MAC has frames to transmit over the given link.
bool GetVhtSupported(uint8_t linkId) const
Return whether the device supports VHT on the given link.
virtual void DeaggregateAmsduAndForward(Ptr< const WifiMpdu > mpdu)
This method can be called to de-aggregate an A-MSDU and forward the constituent packets up the stack.
void SetBssid(Mac48Address bssid, uint8_t linkId)
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
ExtendedCapabilities GetExtendedCapabilities() const
Return the extended capabilities of the device.
virtual Ptr< WifiMacQueue > GetTxopQueue(AcIndex ac) const
Get the wifi MAC queue of the (Qos)Txop associated with the given AC, if such (Qos)Txop is installed,...
bool GetShortSlotTimeSupported() const
void NotifyRxDrop(Ptr< const Packet > packet)
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId=0) const
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
virtual void Receive(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
Mac48Address GetAddress() const
EhtCapabilities GetEhtCapabilities(uint8_t linkId) const
Return the EHT capabilities of the device for the given link.
Callback< void > m_linkUp
Callback when a link is up.
LinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
HeCapabilities GetHeCapabilities(uint8_t linkId) const
Return the HE capabilities of the device for the given link.
virtual void SetWifiPhys(const std::vector< Ptr< WifiPhy > > &phys)
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
void NotifyTxDrop(Ptr< const Packet > packet)
void DoDispose() override
Destructor implementation.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
void SetSlot(Time slot)
Set the slot duration for this PHY.
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
void SetOffMode()
Put in off mode.
bool HasFixedPhyBand() const
void ResumeFromOff()
Resume from off mode.
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.
std::optional< Mac48Address > GetAffiliatedStaAddress(const Mac48Address &mldAddress) const
Get the address of the remote station operating on this link and affiliated with the MLD having the g...
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 AddStationEhtCapabilities(Mac48Address from, EhtCapabilities ehtCapabilities)
Records EHT capabilities of the remote station.
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
Records HT capabilities of the remote station.
std::optional< Mac48Address > GetMldAddress(const Mac48Address &address) const
Get the address of the MLD the given station is affiliated with, if any.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#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 AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
#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_NOARGS()
Output the name of the function.
#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 NanoSeconds(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.
WifiPowerManagementMode
Enumeration for power management modes.
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a QoS tag is attached to the packet, returns a value < 8.
@ WIFI_PM_SWITCHING_TO_ACTIVE
@ WIFI_PM_SWITCHING_TO_PS
@ WIFI_PHY_BAND_UNSPECIFIED
Unspecified.
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
std::ostream & operator<<(std::ostream &os, const Angles &a)
@ WIFI_MAC_MGT_PROBE_REQUEST
@ WIFI_MAC_MGT_ASSOCIATION_RESPONSE
@ WIFI_MAC_MGT_ASSOCIATION_REQUEST
@ WIFI_MAC_MGT_REASSOCIATION_REQUEST
@ WIFI_MAC_MGT_PROBE_RESPONSE
@ WIFI_MAC_MGT_REASSOCIATION_RESPONSE
Struct containing all supported rates.
void AddBssMembershipSelectorRate(uint64_t bs)
Add a special value to the supported rate set, corresponding to a BSS membership selector.
void AddSupportedRate(uint64_t bs)
Add the given rate to the supported rates.
Struct to hold information regarding observed AP through active/passive scanning.
MgtFrameType m_frame
The body of the management frame used to update AP info.
WifiScanParams::Channel m_channel
The channel the management frame was received on.
Mac48Address m_apAddr
AP MAC address.
uint8_t m_linkId
ID of the link used to communicate with the AP.
Mac48Address m_bssid
BSSID.
double m_snr
SNR in linear scale.
Structure holding information specific to a single link.
bool sendAssocReq
whether this link is used to send the Association Request frame
std::optional< Mac48Address > bssid
BSSID of the AP to associate with over this link.
WifiPowerManagementMode pmMode
the current PM mode, if the STA is associated, or the PM mode to switch to upon association,...
std::optional< uint8_t > apLinkId
ID (as set by the AP) of the link we have setup or are setting up.
~StaLinkEntity() override
Destructor (a virtual method is needed to make this struct polymorphic)
Ptr< WifiPhy > phy
Wifi PHY object.
Struct identifying a channel to scan.
WifiPhyBand band
PHY band.
uint16_t number
channel number
Structure holding scan parameters.
std::list< Channel > ChannelList
typedef for a list of channels
std::vector< ChannelList > channelList
list of channels to scan, for each link
Time probeDelay
delay prior to transmitting a Probe Request
WifiScanType type
indicates either active or passive scanning
Time maxChannelTime
maximum time to spend on each channel
Ssid ssid
desired SSID or wildcard SSID
Time minChannelTime
minimum time to spend on each channel