15#include "ns3/assert.h"
16#include "ns3/attribute-container.h"
18#include "ns3/mgt-action-headers.h"
19#include "ns3/wifi-mpdu.h"
20#include "ns3/wifi-net-device.h"
21#include "ns3/wifi-phy-state-helper.h"
37 TypeId(
"ns3::EmlsrManager")
40 .AddAttribute(
"EmlsrPaddingDelay",
41 "The EMLSR Paddind Delay (not used by AP MLDs). "
42 "Possible values are 0 us, 32 us, 64 us, 128 us or 256 us.",
46 .AddAttribute(
"EmlsrTransitionDelay",
47 "The EMLSR Transition Delay (not used by AP MLDs). "
48 "Possible values are 0 us, 16 us, 32 us, 64 us, 128 us or 256 us.",
54 "The ID of the main PHY (position in the vector of PHYs held by "
55 "WifiNetDevice). This attribute cannot be set after construction.",
60 .AddAttribute(
"AuxPhyChannelWidth",
61 "The maximum channel width (MHz) supported by Aux PHYs. Note that the "
62 "maximum channel width is capped to the maximum channel width supported "
63 "by the configured maximum modulation class supported.",
69 .AddAttribute(
"AuxPhyMaxModClass",
70 "The maximum modulation class supported by Aux PHYs. Use "
71 "WIFI_MOD_CLASS_OFDM for non-HT.",
90 .AddAttribute(
"AuxPhyTxCapable",
91 "Whether Aux PHYs are capable of transmitting PPDUs.",
96 .AddAttribute(
"InDeviceInterference",
97 "Whether in-device interference is such that a PHY cannot decode "
98 "anything and cannot decrease the backoff counter when another PHY "
99 "of the same device is transmitting.",
104 .AddAttribute(
"PutAuxPhyToSleep",
105 "Whether Aux PHYs should be put into sleep mode while the Main PHY "
106 "is carrying out a (DL or UL) TXOP. Specifically, for DL TXOPs, aux "
107 "PHYs are put to sleep after receiving the ICF; for UL TXOPs, aux PHYs "
108 "are put to sleep when the CTS frame is received, if RTS/CTS is used, "
109 "or when the transmission of the data frame starts, otherwise. "
110 "Aux PHYs are resumed from sleep when the TXOP ends.",
116 "IDs of the links on which EMLSR mode will be enabled. An empty set "
117 "indicates to disable EMLSR.",
121 .AddAttribute(
"ResetCamState",
122 "Whether to reset the state of the ChannelAccessManager associated with "
123 "the link on which the main PHY has just switched to.",
128 .AddTraceSource(
"MainPhySwitch",
129 "This trace source is fired when the main PHY switches channel to "
130 "operate on another link. Information associated with the main PHY "
131 "switch is provided through a struct that is inherited from struct "
132 "EmlsrMainPhySwitchTrace (use the GetName() method to get the type "
133 "of the provided object).",
135 "ns3::EmlsrManager::MainPhySwitchCallback");
161 m_staMac->TraceDisconnectWithoutContext(
"DroppedMpdu",
167 status.timer.Cancel();
182 "EmlsrManager can only be installed on non-AP MLDs");
185 m_staMac->TraceConnectWithoutContext(
"DroppedMpdu",
187 m_staMac->TraceConnectWithoutContext(
207 NS_LOG_DEBUG(
"Record that no PHY is operating on link " << +linkId);
222 NS_ASSERT_MSG(duration.IsPositive(),
"Interval duration should not be negative");
224 NS_LOG_DEBUG(
"PHY " << +phy->GetPhyId() <<
" switched to link " << +linkId <<
" after "
226 <<
" since last time a PHY was operating on this link");
285const std::set<uint8_t>&
360std::optional<uint8_t>
369 std::stringstream ss;
372 std::copy(linkIds.cbegin(), linkIds.cend(), std::ostream_iterator<uint16_t>(ss,
" "));
375 NS_ABORT_MSG_IF(linkIds.size() == 1,
"Cannot enable EMLSR mode on a single link");
394 const auto& hdr = mpdu->GetHeader();
411 if (hdr.IsAction() && hdr.GetAddr2() ==
m_staMac->GetBssid(linkId))
416 action.protectedEhtAction ==
437 for (
auto id :
m_staMac->GetLinkIds())
439 if (
id != linkId &&
m_staMac->IsEmlsrLink(
id))
446 auto auxPhy =
m_staMac->GetWifiPhy(linkId);
448 if (
m_staMac->GetWifiPhy(linkId) != mainPhy)
458 auto uid = auxPhy->GetPreviouslyRxPpduUid();
459 mainPhy->SetPreviouslyRxPpduUid(uid);
474 auto phy =
m_staMac->GetWifiPhy(linkId);
482 return {
false, delay};
488 return {
true,
Time{0}};
500 NS_LOG_DEBUG(
"Aux PHY is not capable of transmitting a PPDU");
501 return {
false,
Time{0}};
514 NS_LOG_DEBUG(
"EMLSR is not enabled on link " << +linkId);
519 for (
auto id :
m_staMac->GetLinkIds())
521 if (
id != linkId &&
m_staMac->IsEmlsrLink(
id))
543 if (
auto mainPhy =
m_staMac->GetDevice()->GetPhy(
m_mainPhyId); mainPhy->IsStateSwitching())
567 NS_LOG_DEBUG(
"EMLSR is not enabled on link " << +linkId);
576 if (it->second.IsPending())
578 NS_LOG_DEBUG(
"Cancelling main PHY channel switch event on link " << +linkId);
596 if (ulTxopNotStarted)
612 std::set<uint8_t> linkIds;
613 for (
auto id :
m_staMac->GetLinkIds())
615 if ((
id != linkId) &&
m_staMac->IsEmlsrLink(
id))
638 for (
auto id :
m_staMac->GetLinkIds())
640 if (
id != linkId &&
m_staMac->IsEmlsrLink(
id))
658 <<
" on link " << +linkId);
669 NS_LOG_DEBUG(
"Resetting CCA ED threshold of PHY " << phy <<
" to " << threshIt->second
670 <<
" on link " << +linkId);
671 phy->SetCcaEdThreshold(threshIt->second);
683 NS_LOG_FUNCTION(
this << linkId << noSwitchDelay << resetBackoff << requestAccess
684 << traceInfo.GetName());
689 "Main PHY is already operating on link " << +linkId);
692 auto currMainPhyLinkId =
m_staMac->GetLinkForPhy(mainPhy);
693 traceInfo.fromLinkId = currMainPhyLinkId;
694 traceInfo.toLinkId = linkId;
697 NS_ASSERT_MSG(currMainPhyLinkId.has_value() || mainPhy->IsStateSwitching(),
698 "If the main PHY is not operating on a link, it must be switching");
702 NS_LOG_DEBUG(
"Main PHY (" << mainPhy <<
") is about to switch to " << newMainPhyChannel
703 <<
" to operate on link " << +linkId);
707 if (currMainPhyLinkId.has_value())
709 m_staMac->GetChannelAccessManager(*currMainPhyLinkId)
710 ->NotifySwitchingEmlsrLink(mainPhy, newMainPhyChannel, linkId);
715 "We should not ask the main PHY to switch channel while transmitting");
718 auto auxPhy =
GetStaMac()->GetWifiPhy(linkId);
721 const auto delay = mainPhy->GetChannelSwitchDelay();
722 const auto pifs = mainPhy->GetSifs() + mainPhy->GetSlot();
724 "Channel switch delay ("
726 <<
") should be shorter than the maximum between the Transition delay ("
733 mainPhy->SetOperatingChannel(newMainPhyChannel);
737 mainPhy->SetAttribute(
"ChannelSwitchDelay",
TimeValue(delay));
740 if (
m_staMac->GetWifiRemoteStationManager(linkId)->GetShortSlotTimeEnabled())
745 const auto timeToSwitchEnd = noSwitchDelay ?
Seconds(0) : delay;
749 if (!currMainPhyLinkId.has_value())
751 m_staMac->NotifySwitchingEmlsrLink(mainPhy, linkId, timeToSwitchEnd);
754 if (resetBackoff && currMainPhyLinkId.has_value())
757 m_staMac->GetChannelAccessManager(*currMainPhyLinkId)->ResetAllBackoffs();
766 m_staMac->GetQosTxop(acIndex)->StartAccessAfterEvent(
785 NS_LOG_DEBUG(
"Aux PHY (" << auxPhy <<
") is about to switch to " << newAuxPhyChannel
786 <<
" to operate on link " << +nextLinkId);
789 ->GetChannelAccessManager(currLinkId)
790 ->NotifySwitchingEmlsrLink(auxPhy, newAuxPhyChannel, nextLinkId);
792 auxPhy->SetOperatingChannel(newAuxPhyChannel);
794 if (
m_staMac->GetWifiRemoteStationManager(nextLinkId)->GetShortSlotTimeEnabled())
801 for (const auto& [acIndex, ac] : wifiAcList)
803 m_staMac->GetQosTxop(acIndex)->StartAccessAfterEvent(
805 Txop::DIDNT_HAVE_FRAMES_TO_TRANSMIT,
806 Txop::CHECK_MEDIUM_BUSY);
810 SetCcaEdThresholdOnLinkSwitch(auxPhy, nextLinkId);
814EmlsrManager::StartMediumSyncDelayTimer(uint8_t linkId)
818 if (m_mediumSyncDuration.IsZero())
824 auto phy = m_staMac->GetWifiPhy(linkId);
833 const auto [it, inserted] = m_mediumSyncDelayStatus.try_emplace(linkId);
836 it->second.msdNTxopsLeft = m_msdMaxNTxops;
838 if (!it->second.timer.IsPending())
841 << +linkId <<
" to " << +m_msdOfdmEdThreshold <<
" PHY " << phy);
842 m_prevCcaEdThreshold[phy] = phy->GetCcaEdThreshold();
843 phy->SetCcaEdThreshold(m_msdOfdmEdThreshold);
847 it->second.timer.Cancel();
848 NS_LOG_DEBUG(
"Starting MediumSyncDelay timer for " << m_mediumSyncDuration.As(Time::US)
849 <<
" on link " << +linkId);
850 it->second.timer = Simulator::Schedule(m_mediumSyncDuration,
851 &EmlsrManager::MediumSyncDelayTimerExpired,
857EmlsrManager::CancelMediumSyncDelayTimer(uint8_t linkId)
861 auto timerIt = m_mediumSyncDelayStatus.find(linkId);
863 NS_ASSERT(timerIt != m_mediumSyncDelayStatus.cend() && timerIt->second.timer.IsPending());
865 timerIt->second.timer.Cancel();
866 MediumSyncDelayTimerExpired(linkId);
870EmlsrManager::MediumSyncDelayTimerExpired(uint8_t linkId)
874 auto timerIt = m_mediumSyncDelayStatus.find(linkId);
876 NS_ASSERT(timerIt != m_mediumSyncDelayStatus.cend() && !timerIt->second.timer.IsPending());
879 auto phy = m_staMac->GetWifiPhy(linkId);
890 auto threshIt = m_prevCcaEdThreshold.find(phy);
892 "No value to restore for CCA ED threshold on PHY " << phy);
893 NS_LOG_DEBUG(
"Resetting CCA ED threshold of PHY " << phy <<
" to " << threshIt->second
894 <<
" on link " << +linkId);
895 phy->SetCcaEdThreshold(threshIt->second);
896 m_prevCcaEdThreshold.erase(threshIt);
900EmlsrManager::DecrementMediumSyncDelayNTxops(uint8_t linkId)
904 const auto timerIt = m_mediumSyncDelayStatus.find(linkId);
906 NS_ASSERT(timerIt != m_mediumSyncDelayStatus.cend() && timerIt->second.timer.IsPending());
907 NS_ASSERT(timerIt->second.msdNTxopsLeft != 0);
909 if (timerIt->second.msdNTxopsLeft)
911 --timerIt->second.msdNTxopsLeft.value();
916EmlsrManager::ResetMediumSyncDelayNTxops(uint8_t linkId)
920 auto timerIt = m_mediumSyncDelayStatus.find(linkId);
922 NS_ASSERT(timerIt != m_mediumSyncDelayStatus.cend() && timerIt->second.timer.IsPending());
923 timerIt->second.msdNTxopsLeft.reset();
927EmlsrManager::MediumSyncDelayNTxopsExceeded(uint8_t linkId)
931 auto timerIt = m_mediumSyncDelayStatus.find(linkId);
933 NS_ASSERT(timerIt != m_mediumSyncDelayStatus.cend() && timerIt->second.timer.IsPending());
934 return timerIt->second.msdNTxopsLeft == 0;
938EmlsrManager::GetEmlOmn()
943 if (m_lastAdvPaddingDelay != m_emlsrPaddingDelay ||
944 m_lastAdvTransitionDelay != m_emlsrTransitionDelay)
946 m_lastAdvPaddingDelay = m_emlsrPaddingDelay;
947 m_lastAdvTransitionDelay = m_emlsrTransitionDelay;
951 CommonInfoBasicMle::EncodeEmlsrPaddingDelay(m_lastAdvPaddingDelay);
953 CommonInfoBasicMle::EncodeEmlsrTransitionDelay(m_lastAdvTransitionDelay);
957 auto setupLinkIds = m_staMac->GetSetupLinkIds();
959 for (
auto emlsrLinkIt = m_nextEmlsrLinks->begin(); emlsrLinkIt != m_nextEmlsrLinks->end();)
961 if (
auto setupLinkIt = setupLinkIds.find(*emlsrLinkIt); setupLinkIt != setupLinkIds.cend())
963 setupLinkIds.erase(setupLinkIt);
969 NS_LOG_DEBUG(
"Link ID " << +(*emlsrLinkIt) <<
" has not been setup");
970 emlsrLinkIt = m_nextEmlsrLinks->erase(emlsrLinkIt);
981EmlsrManager::SendEmlOmn()
986 "AP did not advertise a Transition Timeout, cannot send EML notification");
987 NS_ASSERT_MSG(m_nextEmlsrLinks,
"Need to set EMLSR links before calling this method");
998 auto frame = GetEmlOmn();
999 auto linkId = GetLinkToSendEmlOmn();
1000 GetEhtFem(linkId)->SendEmlOmn(m_staMac->GetBssid(linkId), frame);
1008 const auto& hdr = mpdu->GetHeader();
1010 if (hdr.IsAssocReq())
1014 mpdu->GetPacket()->PeekHeader(assocReq);
1016 NS_ASSERT_MSG(mle,
"AssocReq should contain a Multi-Link Element");
1017 m_lastAdvPaddingDelay = mle->GetEmlsrPaddingDelay();
1018 m_lastAdvTransitionDelay = mle->GetEmlsrTransitionDelay();
1021 if (hdr.IsMgt() && hdr.IsAction())
1023 if (
auto [category, action] = WifiActionHeader::Peek(mpdu->GetPacket());
1024 category == WifiActionHeader::PROTECTED_EHT &&
1025 action.protectedEhtAction ==
1026 WifiActionHeader::PROTECTED_EHT_EML_OPERATING_MODE_NOTIFICATION)
1030 NS_ASSERT_MSG(m_emlsrTransitionTimeout,
"No transition timeout received from AP");
1031 m_transitionTimeoutEvent = Simulator::Schedule(*m_emlsrTransitionTimeout,
1032 &EmlsrManager::ChangeEmlsrMode,
1043 const auto& hdr = mpdu->GetHeader();
1045 if (hdr.IsMgt() && hdr.IsAction())
1047 auto pkt = mpdu->GetPacket()->Copy();
1048 if (
auto [category, action] = WifiActionHeader::Remove(pkt);
1049 category == WifiActionHeader::PROTECTED_EHT &&
1050 action.protectedEhtAction ==
1051 WifiActionHeader::PROTECTED_EHT_EML_OPERATING_MODE_NOTIFICATION)
1055 auto linkId = ResendNotification(mpdu);
1059 pkt->RemoveHeader(frame);
1060 GetEhtFem(*linkId)->SendEmlOmn(m_staMac->GetBssid(*linkId), frame);
1064 m_nextEmlsrLinks.reset();
1071EmlsrManager::ChangeEmlsrMode()
1082 NS_ASSERT_MSG(m_nextEmlsrLinks,
"No set of EMLSR links stored");
1083 m_emlsrLinks.swap(*m_nextEmlsrLinks);
1084 m_nextEmlsrLinks.reset();
1088 m_staMac->NotifyEmlsrModeChanged(m_emlsrLinks);
1090 ApplyMaxChannelWidthAndModClassOnAuxPhys();
1092 NotifyEmlsrModeChanged();
1096EmlsrManager::ApplyMaxChannelWidthAndModClassOnAuxPhys()
1099 auto currMainPhyLinkId = m_staMac->GetLinkForPhy(m_mainPhyId);
1102 for (
const auto linkId : m_staMac->GetLinkIds())
1104 auto auxPhy = m_staMac->GetWifiPhy(linkId);
1105 auto channel = GetChannelForAuxPhy(linkId);
1107 if (linkId == currMainPhyLinkId || !m_staMac->IsEmlsrLink(linkId) ||
1108 auxPhy->GetOperatingChannel() == channel)
1113 auxPhy->SetMaxModulationClassSupported(m_auxPhyMaxModClass);
1115 NS_LOG_DEBUG(
"Aux PHY (" << auxPhy <<
") is about to switch to " << channel
1116 <<
" to operate on link " << +linkId);
1122 auto cam = m_staMac->GetChannelAccessManager(linkId);
1123 cam->NotifySwitchingEmlsrLink(auxPhy, channel, linkId);
1126 const auto delay = auxPhy->GetChannelSwitchDelay();
1127 auxPhy->SetAttribute(
"ChannelSwitchDelay",
TimeValue(
Time{0}));
1128 auxPhy->SetOperatingChannel(channel);
1129 auxPhy->SetAttribute(
"ChannelSwitchDelay",
TimeValue(delay));
1136 cam->ResetAllBackoffs();
1137 Simulator::ScheduleNow([=,
this]() {
1140 m_staMac->GetQosTxop(acIndex)->StartAccessAfterEvent(
1142 Txop::DIDNT_HAVE_FRAMES_TO_TRANSMIT,
1143 Txop::CHECK_MEDIUM_BUSY);
1150EmlsrManager::ComputeOperatingChannels()
1154 m_mainPhyChannels.clear();
1155 m_auxPhyChannels.clear();
1157 auto linkIds = m_staMac->GetSetupLinkIds();
1159 for (
auto linkId : linkIds)
1161 const auto& channel = m_staMac->GetWifiPhy(linkId)->GetOperatingChannel();
1162 m_mainPhyChannels.emplace(linkId, channel);
1164 auto mainPhyChWidth = channel.GetWidth();
1165 auto auxPhyMaxWidth =
1167 if (auxPhyMaxWidth >= mainPhyChWidth)
1170 m_auxPhyChannels.emplace(linkId, channel);
1174 auto freq = channel.GetPrimaryChannelCenterFrequency(auxPhyMaxWidth);
1175 auto chIt = WifiPhyOperatingChannel::FindFirst(0,
1179 channel.GetPhyBand());
1180 NS_ASSERT_MSG(chIt != WifiPhyOperatingChannel::m_frequencyChannels.end(),
1181 "Primary" << auxPhyMaxWidth <<
" channel not found");
1182 m_auxPhyChannels.emplace(linkId, chIt);
1184 auto p20Index = channel.GetPrimaryChannelIndex(
MHz_u{20});
1185 while (mainPhyChWidth > auxPhyMaxWidth)
1187 mainPhyChWidth /= 2;
1190 m_auxPhyChannels[linkId].SetPrimary20Index(p20Index);
1195EmlsrManager::GetChannelForMainPhy(uint8_t linkId)
const
1197 auto it = m_mainPhyChannels.find(linkId);
1199 "Channel for main PHY on link ID " << +linkId <<
" not found");
1204EmlsrManager::GetChannelForAuxPhy(uint8_t linkId)
const
1206 auto it = m_auxPhyChannels.find(linkId);
1208 "Channel for aux PHY on link ID " << +linkId <<
" not found");
1213EmlsrManager::CancelAllSleepEvents()
1217 for (
auto& [
id, event] : m_auxPhyToSleepEvents)
1221 m_auxPhyToSleepEvents.clear();
1225EmlsrManager::SetSleepStateForAllAuxPhys(
bool sleep)
1229 CancelAllSleepEvents();
1231 for (
const auto& phy : m_staMac->GetDevice()->GetPhys())
1233 if (phy->GetPhyId() == m_mainPhyId)
1238 auto linkId = m_staMac->GetLinkForPhy(phy);
1240 if (linkId.has_value() && !m_staMac->IsEmlsrLink(*linkId))
1247 if (!phy->IsStateSleep())
1252 NS_LOG_DEBUG(
"PHY " << +phy->GetPhyId() <<
": Resuming from sleep");
1253 phy->ResumeFromSleep();
1256 if (linkId.has_value())
1258 auto it = m_startSleep.find(phy->GetPhyId());
1260 "No start sleep info for PHY ID " << phy->GetPhyId());
1261 const auto sleepDuration = Simulator::Now() - it->second;
1262 m_startSleep.erase(it);
1264 if (sleepDuration >
MicroSeconds(MEDIUM_SYNC_THRESHOLD_USEC))
1266 StartMediumSyncDelayTimer(*linkId);
1273 if (phy->IsStateSleep())
1283 std::stringstream ss;
1284 auto s = std::string(
"PHY ") + std::to_string(phy->GetPhyId()) +
": Setting sleep mode";
1285 if (phy->IsStateTx() || phy->IsStateSwitching())
1287 const auto delay = phy->GetDelayUntilIdle();
1289 m_auxPhyToSleepEvents[phy->GetPhyId()] = Simulator::Schedule(delay, [=,
this]() {
1290 phy->SetSleepMode(
true);
1291 m_startSleep[phy->GetPhyId()] = Simulator::Now();
1297 phy->SetSleepMode(
true);
1298 m_startSleep[phy->GetPhyId()] = Simulator::Now();
A container for one type of attribute.
AttributeValue implementation for Boolean.
void SendEmlOmn()
Send an EML Operating Mode Notification frame.
Time GetMediumSyncDuration() const
void ComputeOperatingChannels()
Compute the operating channels that the main PHY and the aux PHY(s) must switch to in order to operat...
void NotifyProtectionCompleted(uint8_t linkId)
Notify that protection (if required) is completed and data frame exchange can start on the given link...
void SetTransitionTimeout(Time timeout)
Set the Transition Timeout advertised by the associated AP with EMLSR activated.
static constexpr uint16_t MEDIUM_SYNC_THRESHOLD_USEC
The aMediumSyncThreshold defined by Sec. 35.3.16.18.1 of 802.11be D4.0.
bool m_auxPhyTxCapable
whether Aux PHYs are capable of transmitting PPDUs
std::optional< Time > GetTransitionTimeout() const
std::pair< bool, Time > GetDelayUntilAccessRequest(uint8_t linkId, AcIndex aci)
Notify that an UL TXOP is gained on the given link by the given AC.
virtual std::pair< bool, Time > DoGetDelayUntilAccessRequest(uint8_t linkId)=0
Subclasses have to provide an implementation for this method, that is called by the base class when t...
Ptr< EhtFrameExchangeManager > GetEhtFem(uint8_t linkId) const
void TxDropped(WifiMacDropReason reason, Ptr< const WifiMpdu > mpdu)
Notify that the given MPDU has been discarded for the given reason.
void NotifyUlTxopStart(uint8_t linkId)
Notify the start of an UL TXOP on the given link.
void TxOk(Ptr< const WifiMpdu > mpdu)
Notify the acknowledgment of the given MPDU.
void NotifyTxopEnd(uint8_t linkId, bool ulTxopNotStarted=false, bool ongoingDlTxop=false)
Notify the end of a TXOP on the given link.
std::map< uint8_t, EventId > m_ulMainPhySwitch
link ID-indexed map of timers started when an aux PHY gains an UL TXOP and schedules a channel switch...
bool m_inDeviceInterference
whether in-device interference is such that a PHY cannot decode anything and cannot decrease the back...
bool GetCamStateReset() const
void SetEmlsrLinks(const std::set< uint8_t > &linkIds)
Take actions to enable EMLSR mode on the given set of links, if non-empty, or disable EMLSR mode,...
void SetMediumSyncOfdmEdThreshold(int8_t threshold)
Set the Medium Synchronization OFDM ED threshold (dBm) to use while the MediumSyncDelay timer is runn...
uint8_t m_mainPhyId
ID of main PHY (position in the vector of PHYs held by WifiNetDevice)
int8_t GetMediumSyncOfdmEdThreshold() const
void NotifyIcfReceived(uint8_t linkId)
Notify the reception of an initial Control frame on the given link.
std::map< uint8_t, MediumSyncDelayStatus > m_mediumSyncDelayStatus
the status of MediumSyncDelay timers (link ID-indexed)
bool m_auxPhyToSleep
whether Aux PHYs should be put into sleep mode while the Main PHY is carrying out a (DL or UL) TXOP
virtual std::pair< bool, Time > GetDelayUnlessMainPhyTakesOverUlTxop(uint8_t linkId)=0
Subclasses have to provide an implementation for this method, that is called by the base class when t...
virtual void SwitchMainPhyIfTxopGainedByAuxPhy(uint8_t linkId, AcIndex aci)=0
Subclasses have to provide an implementation for this method, that is called by the base class when t...
void NotifyMgtFrameReceived(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Notify the reception of a management frame addressed to us.
virtual void DoNotifyUlTxopStart(uint8_t linkId)=0
Notify the subclass of the start of an UL TXOP on the given link.
Ptr< StaWifiMac > m_staMac
the MAC of the managed non-AP MLD
virtual void DoNotifyMgtFrameReceived(Ptr< const WifiMpdu > mpdu, uint8_t linkId)=0
Notify the subclass of the reception of a management frame addressed to us.
Time m_emlsrPaddingDelay
EMLSR Padding delay.
bool GetInDeviceInterference() const
virtual void NotifyMainPhySwitch(std::optional< uint8_t > currLinkId, uint8_t nextLinkId, Ptr< WifiPhy > auxPhy, Time duration)=0
Notify subclass that the main PHY is switching channel to operate on another link.
MHz_u m_auxPhyMaxWidth
max channel width supported by aux PHYs
virtual void NotifyInDeviceInterferenceStart(uint8_t linkId, Time duration)
Notify that an STA affiliated with the EMLSR client is causing in-device interference for the given a...
void SetMediumSyncMaxNTxops(std::optional< uint8_t > nTxops)
Set the maximum number of TXOPs a non-AP STA is allowed to attempt to initiate while the MediumSyncDe...
Time m_emlsrTransitionDelay
EMLSR Transition delay.
void SetWifiMac(Ptr< StaWifiMac > mac)
Set the wifi MAC.
bool GetAuxPhyTxCapable() const
const std::set< uint8_t > & GetEmlsrLinks() const
MainPhySwitchTracedCallback m_mainPhySwitchTrace
main PHY switch trace source
virtual void EmlsrLinkSwitchCallback(uint8_t linkId, Ptr< WifiPhy > phy)
Callback connected to the EmlsrLinkSwitch trace source of StaWifiMac.
Time m_mediumSyncDuration
duration of the MediumSyncDelay timer
std::optional< Time > m_emlsrTransitionTimeout
Transition timeout advertised by APs with EMLSR activated.
void SwitchAuxPhy(Ptr< WifiPhy > auxPhy, uint8_t currLinkId, uint8_t nextLinkId)
Switch channel on the Aux PHY operating on the given current link so that it operates on the given ne...
std::map< Ptr< WifiPhy >, dBm_u > m_prevCcaEdThreshold
the CCA sensitivity threshold to restore once the MediumSyncDelay timer expires or the PHY moves to a...
std::optional< Time > GetElapsedMediumSyncDelayTimer(uint8_t linkId) const
Check whether the MediumSyncDelay timer is running for the STA operating on the given link.
virtual void DoNotifyTxopEnd(uint8_t linkId)=0
Notify the subclass of the end of a TXOP on the given link.
virtual void DoSetWifiMac(Ptr< StaWifiMac > mac)
Allow subclasses to take actions when the MAC is set.
std::map< uint8_t, Time > m_noPhySince
link ID-indexed map of the time since no PHY is operating on the link
void SetAuxPhyTxCapable(bool capable)
Set the member variable indicating whether Aux PHYs are capable of transmitting PPDUs.
std::optional< std::set< uint8_t > > m_nextEmlsrLinks
ID of the links that will become the EMLSR links when the pending notification frame is acknowledged.
void SetCcaEdThresholdOnLinkSwitch(Ptr< WifiPhy > phy, uint8_t linkId)
Set the CCA ED threshold (if needed) on the given PHY that is switching channel to operate on the giv...
void SetMainPhyId(uint8_t mainPhyId)
Set the ID of main PHY (position in the vector of PHYs held by WifiNetDevice).
const WifiPhyOperatingChannel & GetChannelForMainPhy(uint8_t linkId) const
void SetMediumSyncDuration(Time duration)
Set the duration of the MediumSyncDelay timer.
void SwitchMainPhy(uint8_t linkId, bool noSwitchDelay, bool resetBackoff, bool requestAccess, EmlsrMainPhySwitchTrace &&traceInfo)
Switch channel on the Main PHY so that it operates on the given link.
static constexpr bool RESET_BACKOFF
reset backoff on main PHY switch
Time m_lastAdvTransitionDelay
last advertised transition delay
static constexpr bool DONT_REQUEST_ACCESS
do not request channel access when PHY switch ends
void DoDispose() override
Destructor implementation.
void StartMediumSyncDelayTimer(uint8_t linkId)
Start the MediumSyncDelay timer and take the appropriate actions.
int8_t m_msdOfdmEdThreshold
MediumSyncDelay OFDM ED threshold.
std::optional< uint8_t > m_msdMaxNTxops
MediumSyncDelay max number of TXOPs.
Ptr< StaWifiMac > GetStaMac() const
WifiModulationClass m_auxPhyMaxModClass
max modulation class supported by aux PHYs
uint8_t GetMainPhyId() const
std::optional< uint8_t > GetMediumSyncMaxNTxops() const
void SetCamStateReset(bool enable)
Set the member variable indicating whether the state of the CAM should be reset when the main PHY swi...
virtual void NotifyRtsSent(uint8_t linkId, Ptr< const WifiPsdu > rts, const WifiTxVector &txVector)
Notify that RTS transmission is starting on the given link.
EventId m_transitionTimeoutEvent
Timer started after the successful transmission of an EML Operating Mode Notification frame.
virtual void DoNotifyIcfReceived(uint8_t linkId)=0
Notify the subclass of the reception of an initial Control frame on the given link.
void SetInDeviceInterference(bool enable)
Set the member variable indicating whether in-device interference is such that a PHY cannot decode an...
const WifiPhyOperatingChannel & GetChannelForAuxPhy(uint8_t linkId) const
bool m_resetCamState
whether to reset the state of CAM when main PHY switches channel
static TypeId GetTypeId()
Get the type ID.
std::set< uint8_t > m_emlsrLinks
ID of the EMLSR links (empty if EMLSR mode is disabled)
void SetSleepStateForAllAuxPhys(bool sleep)
Set sleep state or awake state for all aux PHYs.
Hold variables of type enum.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsPending() const
This method is syntactic sugar for !IsExpired().
EventImpl * PeekEventImpl() const
void Invoke()
Called by the simulation engine to notify the event that it is time to execute.
Implement the header for Action frames of type EML Operating Mode Notification.
void SetLinkIdInBitmap(uint8_t linkId)
Set the bit position in the link bitmap corresponding to the given link.
EmlControl m_emlControl
EML Control field.
std::optional< EmlsrParamUpdate > m_emlsrParamUpdate
EMLSR Parameter Update field.
A base class which provides memory management and object aggregation.
virtual void DoDispose()
Destructor implementation.
bool IsInitialized() const
Check if the object has been initialized.
Smart pointer class similar to boost::intrusive_ptr.
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 EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
AttributeValue implementation for Time.
static constexpr bool DIDNT_HAVE_FRAMES_TO_TRANSMIT
no packet available for transmission was in the queue
static constexpr bool CHECK_MEDIUM_BUSY
generation of backoff (also) depends on the busy/idle state of the medium
a unique identifier for an interface.
@ ATTR_GET
The attribute can be read.
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
Class that keeps track of all information about the current PHY operating channel.
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< AttributeChecker > MakeAttributeContainerChecker()
Make uninitialized AttributeContainerChecker using explicit types.
Ptr< const AttributeAccessor > MakeAttributeContainerAccessor(T1 a1)
Make AttributeContainerAccessor using explicit types.
Ptr< const AttributeChecker > MakeBooleanChecker()
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 > MakeEnumAccessor(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 AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeChecker > MakeUintegerChecker()
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_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#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_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 Seconds(double 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.
WifiMacDropReason
The reason why an MPDU was dropped.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
@ WIFI_STANDARD_UNSPECIFIED
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_EHT
EHT (Clause 36)
@ 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.
static constexpr uint8_t DEFAULT_MSD_MAX_N_TXOPS
default MediumSyncDelay max number of TXOP attempts
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...
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
MHz_u GetMaximumChannelWidth(WifiModulationClass modulation)
Get the maximum channel width allowed for the given modulation class.
const std::map< AcIndex, WifiAc > wifiAcList
Map containing the four ACs in increasing order of priority (according to Table 10-1 "UP-to-AC Mappin...
static constexpr int8_t DEFAULT_MSD_OFDM_ED_THRESH
default MediumSyncDelay timer OFDM ED threshold
@ LOG_FUNCTION
Function tracing for non-trivial function calls.
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
static constexpr uint16_t DEFAULT_MSD_DURATION_USEC
default MediumSyncDelay timer duration (max PPDU TX time rounded to a multiple of 32 us)
Struct to trace that main PHY switched to start a DL TXOP after that an aux PHY received an ICF.
Base struct for EMLSR Main PHY switch traces.
uint8_t emlsrMode
EMLSR Mode.
uint8_t emlsrParamUpdateCtrl
EMLSR Parameter Update Control.
EMLSR Parameter Update field.