A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
advanced-emlsr-manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Universita' di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
10
12
13#include "ns3/boolean.h"
14#include "ns3/log.h"
15#include "ns3/wifi-net-device.h"
16#include "ns3/wifi-phy-listener.h"
17#include "ns3/wifi-phy.h"
18
19#include <algorithm>
20#include <sstream>
21
22namespace ns3
23{
24
25NS_LOG_COMPONENT_DEFINE("AdvancedEmlsrManager");
26
28
29/**
30 * PHY listener connected to the main PHY while operating on the link of an aux PHY that is
31 * not TX capable.
32 *
33 * PHY notifications are forwarded to this EMLSR manager one timestep later because this EMLSR
34 * manager may then decide to switch the main PHY back to the preferred link. Given that notifying
35 * a PHY listener is only one of the actions that are performed when handling events such as RX end
36 * or CCA busy start, it is not a good idea to request a main PHY switch while performing other
37 * actions. Forwarding notifications a timestep later allows to first complete the handling of the
38 * given event and then (possibly) starting a main PHY switch.
39 */
41{
42 public:
43 /**
44 * Constructor
45 *
46 * @param emlsrManager the EMLSR manager
47 */
49 : m_emlsrManager(emlsrManager)
50 {
51 }
52
59
66
67 void NotifyRxEndError(const WifiTxVector& /* txVector */) override
68 {
69 }
70
71 void NotifyTxStart(Time /* duration */, dBm_u /* txPower */) override
72 {
73 }
74
75 void NotifyCcaBusyStart(Time /* duration */,
76 WifiChannelListType /* channelType */,
77 const std::vector<Time>& /* per20MhzDurations */) override
78 {
82 }
83
84 void NotifySwitchingStart(Time /* duration */) override
85 {
86 }
87
88 void NotifySleep() override
89 {
90 }
91
92 void NotifyOff() override
93 {
94 }
95
96 void NotifyWakeup() override
97 {
98 }
99
100 void NotifyOn() override
101 {
102 }
103
104 private:
106};
107
108TypeId
110{
111 static TypeId tid =
112 TypeId("ns3::AdvancedEmlsrManager")
114 .SetGroupName("Wifi")
115 .AddConstructor<AdvancedEmlsrManager>()
116 .AddAttribute("AllowUlTxopInRx",
117 "Whether a (main or aux) PHY is allowed to start an UL TXOP if "
118 "another PHY is receiving a PPDU (possibly starting a DL TXOP). "
119 "If this attribute is true, the PPDU may be dropped.",
120 BooleanValue(false),
123 .AddAttribute("InterruptSwitch",
124 "Whether the main PHY can be interrupted while switching to start "
125 "switching to another link.",
126 BooleanValue(false),
129 .AddAttribute("UseAuxPhyCca",
130 "Whether the CCA performed in the last PIFS interval by a non-TX "
131 "capable aux PHY should be used when the main PHY ends switching to "
132 "the aux PHY's link to determine whether TX can start or not (and what "
133 "bandwidth can be used for transmission) independently of whether the "
134 "aux PHY bandwidth is smaller than the main PHY bandwidth or not.",
135 BooleanValue(false),
138 .AddAttribute("SwitchMainPhyBackDelay",
139 "Duration of the timer started in case of non-TX capable aux PHY (that "
140 "does not switch link) when medium is sensed busy during the PIFS "
141 "interval preceding/following the main PHY switch end. When the timer "
142 "expires, the main PHY is switched back to the preferred link.",
146 .AddAttribute("KeepMainPhyAfterDlTxop",
147 "In case aux PHYs are not TX capable and do not switch link, after the "
148 "end of a DL TXOP carried out on an aux PHY link, the main PHY stays on "
149 "that link for a switch main PHY back delay, if this attribute is true, "
150 "or it returns to the preferred link, otherwise.",
151 BooleanValue(false),
154 .AddAttribute("CheckAccessOnMainPhyLink",
155 "In case aux PHYs are not TX capable and an Access Category, say it AC "
156 "X, is about to gain channel access on an aux PHY link, determine "
157 "whether the time the ACs with priority higher than or equal to AC X and "
158 "with frames to send on the main PHY link are expected to gain access on "
159 "the main PHY link should be taken into account when taking the decision "
160 "to switch the main PHY to the aux PHY link.",
161 BooleanValue(true),
164 .AddAttribute(
165 "MinAcToSkipCheckAccess",
166 "If the CheckAccessOnMainPhyLink attribute is set to false, indicate the "
167 "minimum priority AC for which it is allowed to skip the check related "
168 "to the expected channel access time on the main PHY link.",
172 "AC_BE",
174 "AC_VI",
176 "AC_VO",
178 "AC_BK"));
179 return tid;
180}
181
183{
184 NS_LOG_FUNCTION(this);
185 m_phyListener = std::make_shared<EmlsrPhyListener>(this);
186}
187
192
193void
195{
196 NS_LOG_FUNCTION(this);
197 for (auto phy : GetStaMac()->GetDevice()->GetPhys())
198 {
199 phy->TraceDisconnectWithoutContext(
200 "PhyRxMacHeaderEnd",
202 }
204 m_phyListener.reset();
206}
207
208void
210{
211 NS_LOG_FUNCTION(this);
212
213 // disconnect callbacks on all links
214 for (const auto& linkId : GetStaMac()->GetLinkIds())
215 {
216 GetStaMac()->GetChannelAccessManager(linkId)->TraceDisconnectWithoutContext(
217 "NSlotsLeftAlert",
219 }
220
221 // connect callbacks on EMLSR links
222 for (const auto& emlsrLinkId : GetEmlsrLinks())
223 {
224 GetStaMac()
225 ->GetChannelAccessManager(emlsrLinkId)
226 ->TraceConnectWithoutContext(
227 "NSlotsLeftAlert",
229 }
230
232}
233
234void
236{
237 NS_LOG_FUNCTION(this << mac);
238
239 for (auto phy : GetStaMac()->GetDevice()->GetPhys())
240 {
241 phy->TraceConnectWithoutContext(
242 "PhyRxMacHeaderEnd",
244 }
245}
246
247void
249{
250 NS_LOG_FUNCTION(this << phy->GetPhyId());
251
253 "PHY listener is still connected to PHY " << +m_auxPhyWithListener->GetPhyId());
254 phy->RegisterListener(m_phyListener);
256}
257
258void
260{
262 {
263 return; // do nothing
264 }
265
266 NS_LOG_FUNCTION(this << m_auxPhyWithListener->GetPhyId());
267 m_auxPhyWithListener->UnregisterListener(m_phyListener);
268 m_auxPhyWithListener = nullptr;
269}
270
271std::pair<bool, Time>
273{
274 NS_LOG_FUNCTION(this << linkId);
275
276 // prevent or allow an UL TXOP depending on whether another PHY is receiving a PPDU
277 for (const auto id : GetStaMac()->GetLinkIds())
278 {
279 if (id == linkId)
280 {
281 continue;
282 }
283
284 const auto [maybeIcf, delay] = CheckPossiblyReceivingIcf(id);
285
286 if (!maybeIcf)
287 {
288 // not receiving anything or receiving something that is certainly not an ICF
289 continue;
290 }
291
292 // a PPDU that may be an ICF is being received
294 {
295 return {false, delay};
296 }
297 }
298
299 auto phy = GetStaMac()->GetWifiPhy(linkId);
300 auto mainPhy = GetStaMac()->GetDevice()->GetPhy(m_mainPhyId);
301
302 if (phy == mainPhy)
303 {
304 if (!m_auxPhyTxCapable && m_ccaLastPifs.IsPending())
305 {
306 // main PHY has got access on the link it switched to (because the aux PHY is not TX
307 // capable) before a PIFS interval was elapsed: do not start the TXOP now
308 return {false, Time{0}};
309 }
310
311 // UL TXOP is going to start
312 m_rtsStartingUlTxop[linkId] = {Simulator::Now(), false};
313 }
314
315 return {true, Time{0}};
316}
317
318void
320 const WifiMacHeader& macHdr,
321 const WifiTxVector& txVector,
322 Time psduDuration)
323{
324 auto linkId = GetStaMac()->GetLinkForPhy(phy);
325 if (!linkId.has_value() || !m_useNotifiedMacHdr)
326 {
327 return;
328 }
329 NS_LOG_FUNCTION(this << *linkId << macHdr << txVector << psduDuration.As(Time::MS));
330
331 auto& ongoingTxopEnd = GetEhtFem(*linkId)->GetOngoingTxopEndEvent();
332 const auto isMainPhy = (phy->GetPhyId() == GetMainPhyId());
333
334 if (ongoingTxopEnd.IsPending() && macHdr.GetAddr1() != GetEhtFem(*linkId)->GetAddress() &&
335 !macHdr.IsTrigger() && !macHdr.IsBlockAck() &&
336 !(macHdr.IsCts() && macHdr.GetAddr1() == GetEhtFem(*linkId)->GetBssid() /* CTS-to-self */))
337 {
338 // the EMLSR client is no longer involved in the TXOP and switching to listening mode
339 ongoingTxopEnd.Cancel();
340 // this method is a callback connected to the PhyRxMacHeaderEnd trace source of WifiPhy
341 // and is called within a for loop that executes all the callbacks. The call to NotifyTxop
342 // below leads the main PHY to be connected back to the preferred link, thus
343 // the ResetPhy() method of the FEM on the auxiliary link is called, which disconnects
344 // another callback (FEM::ReceivedMacHdr) from the PhyRxMacHeaderEnd trace source of
345 // the main PHY, thus invalidating the list of callbacks on which the for loop iterates.
346 // Hence, schedule the call to NotifyTxopEnd to execute it outside such for loop.
348 }
349
350 if (!ongoingTxopEnd.IsPending() && GetStaMac()->IsEmlsrLink(*linkId) && isMainPhy &&
351 !GetEhtFem(*linkId)->UsingOtherEmlsrLink() &&
352 (macHdr.IsRts() || macHdr.IsBlockAckReq() || macHdr.IsData()) &&
353 (macHdr.GetAddr1() == GetEhtFem(*linkId)->GetAddress()))
354 {
355 // a frame that is starting a DL TXOP is being received by the main PHY; start blocking
356 // transmission on other links (which is normally done later on by PostProcessFrame()) to
357 // avoid starting an UL TXOP before the end of the MPDU
358 for (auto id : GetStaMac()->GetLinkIds())
359 {
360 if (id != *linkId && GetStaMac()->IsEmlsrLink(id))
361 {
363 }
364 }
365 return;
366 }
367
368 // if the MAC header has been received on the link on which the main PHY is operating (or on
369 // the link the main PHY is switching to), the switch main PHY back timer is running and channel
370 // access is not expected to be gained by the main PHY before the switch main PHY back timer
371 // expires (plus a channel switch delay), try to switch the main PHY back to the preferred link
372 const auto mainPhyInvolved =
373 isMainPhy || (m_mainPhySwitchInfo.disconnected && m_mainPhySwitchInfo.to == *linkId);
374 const auto delay =
375 Simulator::GetDelayLeft(m_switchMainPhyBackEvent) + phy->GetChannelSwitchDelay();
376
377 Simulator::ScheduleNow([=, this]() {
378 if (auto [accessExpected, reason] = GetAccessPossibleWithin(*linkId, delay);
379 m_switchMainPhyBackEvent.IsPending() && mainPhyInvolved && !accessExpected)
380 {
381 SwitchMainPhyBackDelayExpired(*linkId, reason);
382 }
383 });
384}
385
386void
388{
389 NS_LOG_FUNCTION(this << linkId << edca);
390
391 auto mainPhy = GetStaMac()->GetDevice()->GetPhy(m_mainPhyId);
392
393 if (m_switchAuxPhy && (!mainPhy->IsStateSwitching() || !m_interruptSwitching))
394 {
395 NS_LOG_DEBUG("SwitchAuxPhy true, nothing to do");
396 return;
397 }
398
400 {
401 NS_LOG_DEBUG("SwitchAuxPhy false, nothing to do");
402 return;
403 }
404
405 // we get here if:
406 // - SwitchAuxPhy is true, the main PHY is switching and switching can be interrupted
407 // or
408 // - SwitchAuxPhy is false and there is an aux PHY to reconnect
409
411 {
412 // DL TXOP ended, check if the main PHY must be kept on this link to try to gain an UL TXOP
414 "Switch main PHY back timer should not be running at the end of a DL TXOP");
415 NS_ASSERT_MSG(!mainPhy->IsStateSwitching(),
416 "Main PHY should not be switching at the end of a DL TXOP");
417
418 if (GetStaMac()->GetChannelAccessManager(linkId)->GetExpectedAccessWithin(
420 {
421 NS_LOG_DEBUG("Keep main PHY on link " << +linkId << " to try to gain an UL TXOP");
425 this,
426 linkId,
427 std::nullopt);
428 // start checking PHY activity on the link the main PHY is operating
429 RegisterListener(GetStaMac()->GetWifiPhy(linkId));
430 return;
431 }
432 }
433
434 std::shared_ptr<EmlsrMainPhySwitchTrace> traceInfo;
435
436 if (const auto it = m_rtsStartingUlTxop.find(linkId);
437 it != m_rtsStartingUlTxop.cend() && it->second.second)
438 {
439 // TXOP ended due to a CTS timeout following the RTS that started a TXOP
440 traceInfo = std::make_shared<EmlsrCtsAfterRtsTimeoutTrace>(Time{0});
441 m_rtsStartingUlTxop.erase(it);
442 }
443 else
444 {
445 traceInfo = std::make_shared<EmlsrTxopEndedTrace>();
446 }
447
448 // Note that the main PHY may be switching at the end of a TXOP when, e.g., the main PHY
449 // starts switching to a link on which an aux PHY gained a TXOP and sent an RTS, but the CTS
450 // is not received and the UL TXOP ends before the main PHY channel switch is completed.
451 // In such cases, wait until the main PHY channel switch is completed (unless the channel
452 // switching can be interrupted) before requesting a new channel switch.
453 // Backoff shall not be reset on the link left by the main PHY because a TXOP ended and
454 // a new backoff value must be generated.
455 if (m_switchAuxPhy || !mainPhy->IsStateSwitching() || m_interruptSwitching)
456 {
458 !m_switchAuxPhy || m_mainPhySwitchInfo.disconnected,
459 "Aux PHY next link ID should have a value when interrupting a main PHY switch");
460 uint8_t nextLinkId = m_switchAuxPhy ? m_mainPhySwitchInfo.from : GetMainPhyId();
461 SwitchMainPhy(nextLinkId, false, REQUEST_ACCESS, std::move(*traceInfo));
462 }
463 else
464 {
465 // delay link switch until current channel switching is completed
466 const auto delay = mainPhy->GetDelayUntilIdle();
467
468 if (auto info = std::dynamic_pointer_cast<EmlsrCtsAfterRtsTimeoutTrace>(traceInfo))
469 {
470 info->sinceCtsTimeout = delay;
471 }
472
473 Simulator::Schedule(delay, [=, this]() {
474 // request the main PHY to switch back to the preferred link only if in the meantime
475 // no TXOP started on another link (which will require the main PHY to switch link)
476 if (!GetEhtFem(linkId)->UsingOtherEmlsrLink())
477 {
478 SwitchMainPhy(GetMainPhyId(), false, REQUEST_ACCESS, std::move(*traceInfo));
479 }
480 });
481 }
482}
483
484std::optional<WifiIcfDrop>
486{
488
489 // if the switching can be interrupted, do not drop an ICF due to not enough time for switching
491 {
492 return std::nullopt;
493 }
494 return reason;
495}
496
497std::pair<bool, Time>
499{
500 NS_LOG_FUNCTION(this << linkId);
501
503 {
505 }
506
507 auto mainPhy = GetStaMac()->GetDevice()->GetPhy(m_mainPhyId);
508 auto state = mainPhy->GetState()->GetState();
509
511 state == WifiPhyState::IDLE || state == WifiPhyState::CCA_BUSY,
512 "Main PHY cannot be in state " << state);
513
514 auto timeToCtsEnd = GetTimeToCtsEnd(linkId);
515 auto switchingTime = mainPhy->GetChannelSwitchDelay();
516
517 if (switchingTime > timeToCtsEnd)
518 {
519 // switching takes longer than RTS/CTS exchange, release channel
520 NS_LOG_DEBUG("Not enough time for main PHY to switch link (main PHY state: "
521 << mainPhy->GetState()->GetState() << ")");
522 // retry channel access when the CTS was expected to be received
523 return {false, timeToCtsEnd};
524 }
525
526 // TXOP can be started, main PHY will be scheduled to switch by NotifyRtsSent as soon as the
527 // transmission of the RTS is notified
528 m_rtsStartingUlTxop[linkId] = {Simulator::Now(), false};
529
530 return {true, Time{0}};
531}
532
533void
535{
536 NS_LOG_FUNCTION(this << phy->GetPhyId() << linkId << edca->GetAccessCategory());
537
538 const auto caManager = GetStaMac()->GetChannelAccessManager(linkId);
539 const auto pifs = phy->GetSifs() + phy->GetSlot();
540
541 const auto isBusy = caManager->IsBusy(); // check NAV and CCA on primary20
542 // check CCA on the entire channel
543 auto width = caManager->GetLargestIdlePrimaryChannel(pifs, Simulator::Now());
544
545 // lambda to perform the actions needed when a TXOP is not started
546 auto txopNotStarted = [=, this]() {
547 // check when access may be granted to determine whether to switch the main PHY back
548 // to the preferred link (if aux PHYs do not switch link)
549 const auto mainPhy = GetStaMac()->GetDevice()->GetPhy(GetMainPhyId());
550 const auto delay =
551 Simulator::GetDelayLeft(m_switchMainPhyBackEvent) + mainPhy->GetChannelSwitchDelay();
552
553 if (auto [accessExpected, reason] = GetAccessPossibleWithin(linkId, delay);
554 !m_switchAuxPhy && m_switchMainPhyBackEvent.IsPending() && !accessExpected)
555 {
556 NS_LOG_DEBUG("No AC is expected to get backoff soon, switch main PHY back");
557 SwitchMainPhyBackDelayExpired(linkId, reason);
558 }
559
560 // restart channel access
561 edca->NotifyChannelReleased(linkId); // to set access to NOT_REQUESTED
562 edca->StartAccessAfterEvent(linkId,
565 };
566
567 if (!m_switchAuxPhy && !m_switchMainPhyBackEvent.IsPending())
568 {
569 NS_LOG_DEBUG("Main PHY switched back (or scheduled to switch back) before PIFS check");
570 txopNotStarted();
571 }
572 else if (!isBusy && width > MHz_u{0})
573 {
574 // medium idle, start TXOP
575 width = std::min(width, GetChannelForMainPhy(linkId).GetTotalWidth());
576
577 // if this function is called at the end of the main PHY switch, it is executed before the
578 // main PHY is connected to this link in order to use the CCA information of the aux PHY.
579 // Schedule now the TXOP start so that we first connect the main PHY to this link.
582 {
583 NotifyUlTxopStart(linkId);
584 }
585 else
586 {
587 txopNotStarted();
588 }
589 });
590 }
591 else
592 {
593 NS_LOG_DEBUG("Medium busy in the last PIFS interval");
594 txopNotStarted();
595 }
596}
597
598void
600 uint8_t linkId,
601 std::optional<WifiExpectedAccessReason> stopReason)
602{
603 if (g_log.IsEnabled(ns3::LOG_FUNCTION))
604 {
605 std::stringstream ss;
606 if (stopReason.has_value())
607 {
608 ss << stopReason.value();
609 }
610 NS_LOG_FUNCTION(this << linkId << ss.str());
611 }
612
614
615 NS_ASSERT_MSG(!m_switchAuxPhy, "Don't expect this to be called when aux PHYs switch link");
616 Time extension{0};
617
618 // check if the timer must be restarted because a frame is being received on any link
619 for (const auto id : GetStaMac()->GetLinkIds())
620 {
621 auto phy = GetStaMac()->GetWifiPhy(id);
622
623 if (!phy || !GetStaMac()->IsEmlsrLink(id))
624 {
625 continue;
626 }
627
628 if (!GetEhtFem(id)->VirtualCsMediumIdle() &&
629 GetEhtFem(id)->GetTxopHolder() != GetEhtFem(id)->GetBssid())
630 {
631 NS_LOG_DEBUG("NAV is set and TXOP holder is not the associated AP MLD on link " << +id);
632 continue;
633 }
634
635 const auto [maybeIcf, delay] = CheckPossiblyReceivingIcf(id);
636
637 if (maybeIcf)
638 {
639 extension = Max(extension, delay);
640 }
641 else if (id == linkId && phy->IsStateIdle())
642 {
643 // this is the link on which the main PHY is operating. If an AC with traffic is
644 // expected to get channel access soon (within a channel switch delay), restart
645 // the timer to have the main PHY stay a bit longer on this link
646 if (GetStaMac()->GetChannelAccessManager(linkId)->GetExpectedAccessWithin(
647 phy->GetChannelSwitchDelay()) == WifiExpectedAccessReason::ACCESS_EXPECTED)
648 {
649 extension = Max(extension, phy->GetChannelSwitchDelay());
650 }
651 }
652 }
653
654 if (extension.IsStrictlyPositive())
655 {
656 NS_LOG_DEBUG("Restarting the timer, check again in " << extension.As(Time::US));
658 Simulator::Schedule(extension,
660 this,
661 linkId,
662 stopReason);
663 return;
664 }
665
666 // no need to wait further, switch the main PHY back to the preferred link and unregister
667 // the PHY listener from the aux PHY
668 const auto elapsed = Simulator::Now() - m_mainPhySwitchInfo.start;
669 const auto isSwitching = GetStaMac()->GetDevice()->GetPhy(GetMainPhyId())->IsStateSwitching();
671 EmlsrSwitchMainPhyBackTrace(elapsed, stopReason, isSwitching));
672 // if scheduled, invoke CheckNavAndCcaLastPifs(), which will just restart channel access
673 if (m_ccaLastPifs.IsPending())
674 {
675 m_ccaLastPifs.PeekEventImpl()->Invoke();
676 m_ccaLastPifs.Cancel();
677 }
679}
680
681void
683 EmlsrMainPhySwitchTrace&& traceInfo)
684{
686 {
688 linkId,
689 std::forward<EmlsrMainPhySwitchTrace>(traceInfo));
690 return;
691 }
692
693 NS_LOG_FUNCTION(this << linkId << traceInfo.GetName());
694
695 NS_ABORT_MSG_IF(m_switchAuxPhy, "This method can only be called when SwitchAuxPhy is false");
696
698 {
699 return;
700 }
701
703 false,
705 std::forward<EmlsrMainPhySwitchTrace>(traceInfo));
706}
707
708std::pair<bool, WifiExpectedAccessReason>
710{
711 auto reason = GetStaMac()->GetChannelAccessManager(linkId)->GetExpectedAccessWithin(delay);
712
715 reason};
716}
717
718void
720{
721 NS_LOG_FUNCTION(this);
722
723 if (!m_switchMainPhyBackEvent.IsPending())
724 {
725 return; // nothing to do
726 }
727
728 // a busy event occurred, check if the main PHY has to switch back to the preferred link
729 auto mainPhy = GetStaMac()->GetDevice()->GetPhy(GetMainPhyId());
730 auto linkId = GetStaMac()->GetLinkForPhy(GetMainPhyId());
731
732 if (!linkId.has_value())
733 {
734 NS_ASSERT(m_mainPhySwitchInfo.disconnected);
735 linkId = m_mainPhySwitchInfo.to;
736 NS_LOG_DEBUG("Main PHY is switching to link " << +linkId.value());
737 }
738
739 const auto delay =
740 Simulator::GetDelayLeft(m_switchMainPhyBackEvent) + mainPhy->GetChannelSwitchDelay();
741 if (auto [accessExpected, reason] = GetAccessPossibleWithin(*linkId, delay); !accessExpected)
742 {
743 SwitchMainPhyBackDelayExpired(*linkId, reason);
744 }
745}
746
747void
749{
750 NS_LOG_FUNCTION(this << linkId);
752 m_ccaLastPifs.Cancel();
754}
755
756void
758{
759 NS_LOG_FUNCTION(this << linkId);
761 m_ccaLastPifs.Cancel();
763}
764
765bool
767{
768 NS_LOG_FUNCTION(this << linkId << aci << delay.As(Time::US));
769
770 // the aux PHY is not TX capable; check if main PHY has to switch to the aux PHY's link
771 auto mainPhy = GetStaMac()->GetDevice()->GetPhy(m_mainPhyId);
772
773 // if main PHY is not operating on a link and is trying to start a (DL or UL) TXOP, then do
774 // not request another switch
775 if (m_mainPhySwitchInfo.disconnected &&
776 (!m_interruptSwitching || m_mainPhySwitchInfo.reason == "DlTxopIcfReceivedByAuxPhy" ||
777 m_mainPhySwitchInfo.reason == "UlTxopAuxPhyNotTxCapable"))
778 {
779 NS_LOG_DEBUG("Main PHY is not operating on any link and cannot switch to another link");
780 return false;
781 }
782
783 // if the main PHY is already trying to get access on a link, do not request another switch
784 if (m_ccaLastPifs.IsPending() || m_switchMainPhyBackEvent.IsPending())
785 {
786 NS_LOG_DEBUG("Main PHY is trying to get access on another link");
787 return false;
788 }
789
790 // delay until the earliest time the main PHY can access medium on the aux PHY link
791 auto minDelay = mainPhy->GetChannelSwitchDelay();
792 if (!m_useAuxPhyCca && (GetChannelForAuxPhy(linkId).GetTotalWidth() <
793 GetChannelForMainPhy(linkId).GetTotalWidth()))
794 {
795 // cannot use aux PHY CCA
796 const auto pifs = GetStaMac()->GetWifiPhy(linkId)->GetPifs();
797 if (m_switchMainPhyBackDelay < pifs)
798 {
800 "Main PHY has to perform CCA but switch main PHY back delay is less than PIFS");
801 return false;
802 }
803 minDelay += pifs;
804 }
805 minDelay = std::max(delay, minDelay);
806
807 if (const auto elapsed = GetElapsedMediumSyncDelayTimer(linkId);
808 elapsed && MediumSyncDelayNTxopsExceeded(linkId) &&
809 (GetMediumSyncDuration() - *elapsed > minDelay))
810 {
811 NS_LOG_DEBUG("No more TXOP attempts allowed on aux PHY link and MSD timer still running");
812 return false;
813 }
814
815 // DoGetDelayUntilAccessRequest has already checked if the main PHY is receiving an ICF and
816 // above it is checked whether we can request another switch while already switching
817 if (const auto state = mainPhy->GetState()->GetState();
818 state != WifiPhyState::IDLE && state != WifiPhyState::CCA_BUSY &&
819 state != WifiPhyState::RX && state != WifiPhyState::SWITCHING)
820 {
821 NS_LOG_DEBUG("Cannot request main PHY to switch when in state " << state);
822 return false;
823 }
824
825 // if the AC that is about to get channel access on the aux PHY link has no frames to send on
826 // that link, do not request the main PHY to switch
827 if (!GetStaMac()->GetQosTxop(aci)->HasFramesToTransmit(linkId))
828 {
829 NS_LOG_DEBUG("No frames of " << aci << " to send on link " << +linkId);
830 return false;
831 }
832
833 // if user has configured to skip the check related to the expected channel access time on
834 // the main PHY link and the AC that is about to gain access on the aux PHY link has a priority
835 // greater than or equal to the minimum priority that has been configured, switch the main PHY
837 {
838 NS_LOG_DEBUG("Skipping check related to the expected channel access time on main PHY link");
839 return true;
840 }
841
842 const auto mainPhyLinkId = GetStaMac()->GetLinkForPhy(mainPhy);
843 if (!mainPhyLinkId.has_value())
844 {
845 NS_ASSERT(m_mainPhySwitchInfo.disconnected);
846 NS_LOG_DEBUG("The main PHY is not connected to any link");
847 // we don't know when the main PHY will be connected to the link it is switching to, nor
848 // which backoff value it will possibly generate; therefore, request it to switch to the
849 // aux PHY link
850 return true;
851 }
852
853 // let AC X be the AC that is about to gain channel access on the aux PHY link, request to
854 // switch the main PHY if we do not expect any AC, with priority higher than or equal to that
855 // of AC X and with frames to send on the main PHY link, to gain channel access on the main PHY
856 // link before AC X is able to start transmitting on the aux PHY link.
857
858 const auto now = Simulator::Now();
859
860 for (const auto& [acIndex, ac] : wifiAcList)
861 {
862 // ignore ACs with lower priority than the AC that is about to get access on aux PHY link
863 if (acIndex < aci)
864 {
865 continue;
866 }
867
868 const auto edca = GetStaMac()->GetQosTxop(acIndex);
869 const auto backoffEnd =
870 GetStaMac()->GetChannelAccessManager(*mainPhyLinkId)->GetBackoffEndFor(edca);
871 NS_LOG_DEBUG("Backoff end for " << acIndex
872 << " on main PHY link: " << backoffEnd.As(Time::US));
873
874 if ((backoffEnd <= now + minDelay) && edca->HasFramesToTransmit(*mainPhyLinkId))
875 {
876 NS_LOG_DEBUG(acIndex << " is expected to gain access on link " << +mainPhyLinkId.value()
877 << " sooner than " << aci << " on link " << +linkId);
878 return false;
879 }
880 }
881
882 return true;
883}
884
885void
887{
888 NS_LOG_FUNCTION(this << linkId << aci);
889
891 "This function should only be called if aux PHY is not TX capable");
892 auto mainPhy = GetStaMac()->GetDevice()->GetPhy(m_mainPhyId);
893
894 if (mainPhy->IsStateSwitching() && m_mainPhySwitchInfo.to == linkId)
895 {
896 // the main PHY is switching to the link on which the aux PHY gained a TXOP. This can
897 // happen, e.g., if the main PHY was requested to switch to that link before the backoff
898 // counter reached zero. Or, this can happen in case of internal collision: the first AC
899 // requests the main PHY to switch and the second one finds the main PHY to be switching.
900 // In both cases, we do nothing because we have already scheduled the necessary actions
901 NS_LOG_DEBUG("Main PHY is already switching to link " << +linkId);
902 return;
903 }
904
905 if (RequestMainPhyToSwitch(linkId, aci, Time{0}))
906 {
907 const auto auxPhy = GetStaMac()->GetWifiPhy(linkId);
908 const auto pifs = auxPhy->GetSifs() + auxPhy->GetSlot();
909
910 // schedule actions to take based on CCA sensing for a PIFS
911 if (m_useAuxPhyCca || GetChannelForAuxPhy(linkId).GetTotalWidth() >=
912 GetChannelForMainPhy(linkId).GetTotalWidth())
913 {
914 // use aux PHY CCA in the last PIFS interval before main PHY switch end
915 NS_LOG_DEBUG("Schedule CCA check at the end of main PHY switch");
916 m_ccaLastPifs = Simulator::Schedule(mainPhy->GetChannelSwitchDelay(),
918 this,
919 auxPhy,
920 linkId,
921 GetStaMac()->GetQosTxop(aci));
922 }
923 else
924 {
925 // use main PHY CCA in the last PIFS interval after main PHY switch end
926 NS_LOG_DEBUG("Schedule CCA check a PIFS after the end of main PHY switch");
927 m_ccaLastPifs = Simulator::Schedule(mainPhy->GetChannelSwitchDelay() + pifs,
929 this,
930 mainPhy,
931 linkId,
932 GetStaMac()->GetQosTxop(aci));
933 }
934
935 // switch main PHY
936 Time remNav{0};
937 if (const auto mainPhyLinkId = GetStaMac()->GetLinkForPhy(mainPhy))
938 {
939 auto mainPhyNavEnd = GetStaMac()->GetChannelAccessManager(*mainPhyLinkId)->GetNavEnd();
940 remNav = Max(remNav, mainPhyNavEnd - Simulator::Now());
941 }
942
943 SwitchMainPhy(linkId,
944 false,
947
948 // if SwitchAuxPhy is false, the main PHY must stay for some time on this link to check if
949 // it gets channel access. The timer is stopped if a DL or UL TXOP is started. When the
950 // timer expires, the main PHY switches back to the preferred link
951 if (!m_switchAuxPhy)
952 {
955 Simulator::Schedule(mainPhy->GetChannelSwitchDelay() + m_switchMainPhyBackDelay,
957 this,
958 linkId,
959 std::nullopt);
960 // start checking PHY activity on the link the main PHY is switching to
961 RegisterListener(auxPhy);
962 }
963 return;
964 }
965
966 // Determine if and when we need to request channel access again for the aux PHY based on
967 // the main PHY state.
968 // Note that, if we have requested the main PHY to switch (above), the function has returned
969 // and the EHT FEM will start a TXOP if medium is idle for a PIFS interval preceding/following
970 // the end of the main PHY channel switch.
971 // If the main PHY has been requested to switch by another aux PHY, this aux PHY will request
972 // channel access again when we have completed the CCA assessment on the other link.
973 // If the state is switching, CCA_BUSY or RX, then we request channel access again for the
974 // aux PHY when the main PHY state is back to IDLE.
975 // If the state is TX, it means that the main PHY is involved in a TXOP. Do nothing because
976 // the channel access will be requested when unblocking links at the end of the TXOP.
977 // If the state is IDLE, then either no AC has traffic to send or the backoff on the link
978 // of the main PHY is shorter than the channel switch delay. In the former case, do
979 // nothing because channel access will be triggered when new packets arrive; in the latter
980 // case, do nothing because the main PHY will start a TXOP and at the end of such TXOP
981 // links will be unblocked and the channel access requested on all links
982
983 std::optional<Time> delay;
984
985 if (m_ccaLastPifs.IsPending() || m_switchMainPhyBackEvent.IsPending())
986 {
987 delay = std::max(Simulator::GetDelayLeft(m_ccaLastPifs),
989 }
990 else if (mainPhy->GetState()->GetLastTime(
991 {WifiPhyState::SWITCHING, WifiPhyState::CCA_BUSY, WifiPhyState::RX}) ==
993 {
994 delay = mainPhy->GetDelayUntilIdle();
995 }
996
997 NS_LOG_DEBUG("Main PHY state is " << mainPhy->GetState()->GetState());
998 auto edca = GetStaMac()->GetQosTxop(aci);
999 edca->NotifyChannelReleased(linkId); // to set access to NOT_REQUESTED
1000
1001 if (!delay.has_value())
1002 {
1003 NS_LOG_DEBUG("Do nothing");
1004 return;
1005 }
1006
1007 NS_LOG_DEBUG("Schedule channel access request on link "
1008 << +linkId << " at time " << (Simulator::Now() + *delay).As(Time::NS));
1009 Simulator::Schedule(*delay, [=]() {
1010 edca->StartAccessAfterEvent(linkId,
1013 });
1014}
1015
1016void
1018 AcIndex aci,
1019 const Time& delay)
1020{
1021 NS_LOG_FUNCTION(this << linkId << aci << delay.As(Time::US));
1022
1024 {
1025 NS_LOG_DEBUG("Nothing to do if aux PHY is TX capable");
1026 return;
1027 }
1028
1029 if (!delay.IsStrictlyPositive())
1030 {
1031 NS_LOG_DEBUG("Do nothing if delay is not strictly positive");
1032 return;
1033 }
1034
1035 if (GetEhtFem(linkId)->UsingOtherEmlsrLink())
1036 {
1037 NS_LOG_DEBUG("Do nothing because another EMLSR link is being used");
1038 return;
1039 }
1040
1042 {
1043 NS_LOG_DEBUG("Do nothing because a frame is being received on another EMLSR link");
1044 return;
1045 }
1046
1047 auto mainPhy = GetStaMac()->GetDevice()->GetPhy(m_mainPhyId);
1048 auto phy = GetStaMac()->GetWifiPhy(linkId);
1049
1050 if (!phy || phy == mainPhy)
1051 {
1052 NS_LOG_DEBUG("No aux PHY is operating on link " << +linkId);
1053 return;
1054 }
1055
1056 if (!RequestMainPhyToSwitch(linkId, aci, delay))
1057 {
1058 NS_LOG_DEBUG("Chosen not to request the main PHY to switch");
1059 if (const auto untilIdle = mainPhy->GetDelayUntilIdle();
1060 untilIdle.IsStrictlyPositive() && untilIdle < delay)
1061 {
1062 NS_LOG_DEBUG("Retrying in " << untilIdle.As(Time::US));
1063 Simulator::Schedule(untilIdle,
1065 this,
1066 linkId,
1067 aci,
1068 delay - untilIdle);
1069 }
1070 return;
1071 }
1072
1073 // switch main PHY
1074
1075 // use aux PHY CCA (if allowed) if the backoff has already counted down to zero on the aux PHY
1076 // link when the main PHY completes the switch
1077 const auto edca = GetStaMac()->GetQosTxop(aci);
1078 const auto auxPhy = GetStaMac()->GetWifiPhy(linkId);
1079 const auto switchDelay = mainPhy->GetChannelSwitchDelay();
1080 const auto auxPhyCcaCanBeUsed =
1083
1084 // check expected channel access delay when switch is completed
1085 Simulator::Schedule(switchDelay, [=, this]() {
1086 // this is scheduled before starting the main PHY switch, hence it is executed before the
1087 // main PHY is connected to the aux PHY link
1088
1089 if (!m_switchAuxPhy && !m_switchMainPhyBackEvent.IsPending())
1090 {
1091 // if SwitchAuxPhy is false and the switch main PHY back timer is not running, it means
1092 // that the channel switch was interrupted, hence there is nothing to check
1093 return;
1094 }
1095
1096 const auto backoffEnd =
1097 GetStaMac()->GetChannelAccessManager(linkId)->GetBackoffEndFor(edca);
1098 const auto pifs = GetStaMac()->GetWifiPhy(linkId)->GetPifs();
1099 const auto now = Simulator::Now();
1100
1101 // In case aux PHY CCA can be used and the backoff has not yet reached zero, no NAV and CCA
1102 // check is needed. The channel width that will be used is the width of the aux PHY if less
1103 // than a PIFS remains until the backoff reaches zero, and the width of the main PHY,
1104 // otherwise. If aux PHY CCA can be used and the backoff has already reached zero, a NAV and
1105 // CCA check is needed.
1106
1107 if (auxPhyCcaCanBeUsed && backoffEnd < now)
1108 {
1109 /**
1110 * use aux PHY CCA in the last PIFS interval before main PHY switch end
1111 *
1112 * Backoff Switch
1113 * end end (now)
1114 * ──────────┴─────────┴──────────
1115 * |---- PIFS ----|
1116 */
1117 CheckNavAndCcaLastPifs(auxPhy, linkId, edca);
1118 }
1119 else if (!auxPhyCcaCanBeUsed && (backoffEnd - now <= pifs))
1120 {
1121 /**
1122 * the remaining backoff time (if any) when the main PHY completes the switch is shorter
1123 * than or equal to a PIFS, thus the main PHY performs CCA in the last PIFS interval
1124 * after switch end
1125 *
1126 * Switch Backoff Backoff Switch
1127 * end (now) end end end (now)
1128 * ──────────┴─────────┴────────── ──────────┴─────────┴──────────
1129 * |---- PIFS ----| |---- PIFS ----|
1130 */
1131 NS_LOG_DEBUG("Schedule CCA check a PIFS after the end of main PHY switch");
1134 this,
1135 mainPhy,
1136 linkId,
1137 edca);
1138 }
1139 else if (WifiExpectedAccessReason reason;
1140 !m_switchAuxPhy &&
1141 (reason = GetStaMac()->GetChannelAccessManager(linkId)->GetExpectedAccessWithin(
1143 mainPhy->GetChannelSwitchDelay())) !=
1145 {
1146 NS_LOG_DEBUG("No AC is expected to get backoff soon, switch main PHY back");
1147 SwitchMainPhyBackDelayExpired(linkId, reason);
1148 }
1149 });
1150
1151 Time remNav{0};
1152 if (const auto mainPhyLinkId = GetStaMac()->GetLinkForPhy(mainPhy))
1153 {
1154 auto mainPhyNavEnd = GetStaMac()->GetChannelAccessManager(*mainPhyLinkId)->GetNavEnd();
1155 remNav = Max(remNav, mainPhyNavEnd - Simulator::Now());
1156 }
1157
1158 SwitchMainPhy(linkId,
1159 false,
1161 EmlsrUlTxopAuxPhyNotTxCapableTrace(aci, delay, remNav));
1162
1163 // if SwitchAuxPhy is false, the main PHY must stay for some time on this link to check if it
1164 // gets channel access. The timer is stopped if a DL or UL TXOP is started. When the timer
1165 // expires, the main PHY switches back to the preferred link
1166 if (!m_switchAuxPhy)
1167 {
1168 m_switchMainPhyBackEvent.Cancel();
1172 this,
1173 linkId,
1174 std::nullopt);
1175 // start checking PHY activity on the link the main PHY is switching to
1176 RegisterListener(auxPhy);
1177 }
1178}
1179
1180} // namespace ns3
#define Max(a, b)
AdvancedEmlsrManager is an advanced EMLSR manager.
void SwitchMainPhyBackDelayExpired(uint8_t linkId, std::optional< WifiExpectedAccessReason > stopReason)
This method is called when the switch main PHY back timer (which is started when the main PHY switche...
std::pair< bool, WifiExpectedAccessReason > GetAccessPossibleWithin(linkId_t linkId, const Time &delay)
Check whether it is possible to gain channel access on the given link within the given delay.
std::pair< bool, Time > DoGetDelayUntilAccessRequest(uint8_t linkId) override
Subclasses have to provide an implementation for this method, that is called by the base class when t...
void InterruptSwitchMainPhyBackTimerIfNeeded()
This method is called by the PHY listener attached to the main PHY when a switch main PHY back timer ...
void DoNotifyDlTxopStart(uint8_t linkId) override
Notify the subclass of the reception of an initial Control frame on the given link.
std::pair< bool, Time > GetDelayUnlessMainPhyTakesOverUlTxop(uint8_t linkId) override
Subclasses have to provide an implementation for this method, that is called by the base class when t...
bool m_useAuxPhyCca
whether the CCA performed in the last PIFS interval by a non-TX capable aux PHY should be used when t...
bool RequestMainPhyToSwitch(uint8_t linkId, AcIndex aci, const Time &delay)
Determine whether the main PHY shall be requested to switch to the link of an aux PHY that is expecte...
void UnregisterListener()
Disconnect the PHY listener from the PHY it is connected to (if any).
void RegisterListener(Ptr< WifiPhy > phy)
Register a PHY listener so that this EMLSR Manager is notified of PHY events generated by the given P...
void SwitchMainPhyIfTxopToBeGainedByAuxPhy(uint8_t linkId, AcIndex aci, const Time &delay)
This method is called when the given AC of the EMLSR client is expected to get channel access in the ...
bool m_allowUlTxopInRx
whether a (main or aux) PHY is allowed to start an UL TXOP if another PHY is receiving a PPDU
void CheckNavAndCcaLastPifs(Ptr< WifiPhy > phy, uint8_t linkId, Ptr< QosTxop > edca)
Use information from NAV and CCA performed by the given PHY on the given link in the last PIFS interv...
Ptr< WifiPhy > m_auxPhyWithListener
aux PHY which a PHY listener is connected to
std::optional< WifiIcfDrop > CheckMainPhyTakesOverDlTxop(uint8_t linkId) const override
This method is called when an aux PHY has completed reception of an ICF to determine whether there is...
void NotifyEmlsrModeChanged() override
Notify subclass that EMLSR mode changed.
static TypeId GetTypeId()
Get the type ID.
void SwitchMainPhyBackToPreferredLink(uint8_t linkId, EmlsrMainPhySwitchTrace &&traceInfo) override
This method can only be called when aux PHYs do not switch link.
void DoNotifyUlTxopStart(uint8_t linkId) override
Notify the subclass of the start of an UL TXOP on the given link.
std::shared_ptr< WifiPhyListener > m_phyListener
PHY listener connected to an aux PHY (that is not TX capable and does not switch link) while the main...
Time m_switchMainPhyBackDelay
duration of the timer started in case of non-TX capable aux PHY when medium is sensed busy during the...
void DoDispose() override
Destructor implementation.
EventId m_switchMainPhyBackEvent
event scheduled in case of non-TX capable aux PHY when medium is sensed busy during the PIFS interval...
void DoNotifyTxopEnd(uint8_t linkId, Ptr< QosTxop > edca) override
Notify the subclass of the end of a TXOP on the given link.
AcIndex m_minAcToSkipCheckAccess
if m_checkAccessOnMainPhyLink is set to false, indicate the minimum priority AC for which it is allow...
void SwitchMainPhyIfTxopGainedByAuxPhy(uint8_t linkId, AcIndex aci) override
Subclasses have to provide an implementation for this method, that is called by the base class when t...
void DoSetWifiMac(Ptr< StaWifiMac > mac) override
Allow subclasses to take actions when the MAC is set.
bool m_keepMainPhyAfterDlTxop
whether the main PHY must stay, for a switch main PHY back delay, on an aux PHY link after a DL TXOP,...
void ReceivedMacHdr(Ptr< WifiPhy > phy, const WifiMacHeader &macHdr, const WifiTxVector &txVector, Time psduDuration)
Possibly take actions when notified of the MAC header of the MPDU being received by the given PHY.
EventId m_ccaLastPifs
event scheduled in case of non-TX capable aux PHY to determine whether TX can be started based on whe...
bool m_interruptSwitching
whether a main PHY switching can be interrupted to start switching to another link
bool m_checkAccessOnMainPhyLink
in case aux PHYs are not TX capable and an Access Category, say it AC X, is about to gain channel acc...
void NotifyEmlsrModeChanged() override
Notify subclass that EMLSR mode changed.
Ptr< WifiPhy > m_auxPhyToReconnect
Aux PHY the ChannelAccessManager of the link on which the main PHY is operating has to connect a list...
bool m_switchAuxPhy
whether Aux PHY should switch channel to operate on the link on which the Main PHY was operating befo...
Time GetTimeToCtsEnd(uint8_t linkId) const
This function is intended to be called when an aux PHY is about to transmit an RTS on the given link ...
std::map< uint8_t, std::pair< Time, bool > > m_rtsStartingUlTxop
link ID-indexed map indicating the time when an UL TXOP is going to start and whether it is starting ...
virtual void SwitchMainPhyBackToPreferredLink(uint8_t linkId, EmlsrMainPhySwitchTrace &&traceInfo)
This method can only be called when aux PHYs do not switch link.
std::pair< bool, Time > GetDelayUnlessMainPhyTakesOverUlTxop(uint8_t linkId) override
Subclasses have to provide an implementation for this method, that is called by the base class when t...
Time GetMediumSyncDuration() const
void SwitchMainPhy(uint8_t linkId, bool noSwitchDelay, bool requestAccess, EmlsrMainPhySwitchTrace &&traceInfo)
Switch channel on the Main PHY so that it operates on the given link.
bool m_useNotifiedMacHdr
whether to use the information about the MAC header of the MPDU being received (if notified by the PH...
bool m_auxPhyTxCapable
whether Aux PHYs are capable of transmitting PPDUs
bool MediumSyncDelayNTxopsExceeded(uint8_t linkId)
Return whether no more TXOP attempt is allowed on the given link.
Ptr< EhtFrameExchangeManager > GetEhtFem(uint8_t linkId) const
void NotifyUlTxopStart(uint8_t linkId)
Notify the start of an UL TXOP on the given link.
uint8_t m_mainPhyId
ID of main PHY (position in the vector of PHYs held by WifiNetDevice).
const std::set< uint8_t > & GetEmlsrLinks() const
void NotifyTxopEnd(uint8_t linkId, Ptr< QosTxop > edca=nullptr)
Notify the end of a TXOP on the given link.
std::optional< Time > GetElapsedMediumSyncDelayTimer(uint8_t linkId) const
Check whether the MediumSyncDelay timer is running for the STA operating on the given link.
virtual std::optional< WifiIcfDrop > CheckMainPhyTakesOverDlTxop(uint8_t linkId) const
This method is called when an aux PHY has completed reception of an ICF to determine whether there is...
const WifiPhyOperatingChannel & GetChannelForMainPhy(uint8_t linkId) const
MainPhySwitchInfo m_mainPhySwitchInfo
main PHY switch info
static constexpr bool REQUEST_ACCESS
request channel access when PHY switch ends
static constexpr bool DONT_REQUEST_ACCESS
do not request channel access when PHY switch ends
Ptr< StaWifiMac > GetStaMac() const
uint8_t GetMainPhyId() const
const WifiPhyOperatingChannel & GetChannelForAuxPhy(uint8_t linkId) const
std::pair< bool, Time > CheckPossiblyReceivingIcf(uint8_t linkId) const
Check whether a PPDU that may be an ICF is being received on the given link.
EmlsrPhyListener(Ptr< AdvancedEmlsrManager > emlsrManager)
Constructor.
void NotifyCcaBusyStart(Time, WifiChannelListType, const std::vector< Time > &) override
void NotifyWakeup() override
Notify listeners that we woke up.
void NotifyOff() override
Notify listeners that we went to switch off.
void NotifyTxStart(Time, dBm_u) override
void NotifyRxEndError(const WifiTxVector &) override
void NotifySwitchingStart(Time) override
void NotifyRxStart(Time) override
void NotifyRxEndOk() override
We have received the last bit of a packet for which NotifyRxStart was invoked first and,...
void NotifyOn() override
Notify listeners that we went to switch on.
void NotifySleep() override
Notify listeners that we went to sleep.
Ptr< AdvancedEmlsrManager > m_emlsrManager
the EMLSR manager
Hold variables of type enum.
Definition enum.h:52
virtual void DoDispose()
Destructor implementation.
Definition object.cc:431
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
bool StartTransmission(Ptr< Txop > edca, MHz_u allowedWidth) final
Request the FrameExchangeManager to start a frame exchange sequence.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:580
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:191
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition simulator.h:614
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition simulator.cc:200
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
@ US
microsecond
Definition nstime.h:108
@ MS
millisecond
Definition nstime.h:107
@ NS
nanosecond
Definition nstime.h:109
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition time.cc:422
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
Definition nstime.h:341
Time TimeStep(uint64_t ts)
Scheduler interface.
Definition nstime.h:1410
static constexpr bool DIDNT_HAVE_FRAMES_TO_TRANSMIT
no packet available for transmission was in the queue
Definition txop.h:417
static constexpr bool CHECK_MEDIUM_BUSY
generation of backoff (also) depends on the busy/idle state of the medium
Definition txop.h:419
a unique identifier for an interface.
Definition type-id.h:50
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1003
Implements the IEEE 802.11 MAC header.
bool IsBlockAckReq() const
Return true if the header is a BlockAckRequest header.
bool IsCts() const
Return true if the header is a CTS header.
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
bool IsTrigger() const
Return true if the header is a Trigger header.
bool IsBlockAck() const
Return true if the header is a BlockAck header.
bool IsData() const
Return true if the Type is DATA.
bool IsRts() const
Return true if the header is a RTS header.
receive notifications about PHY events.
MHz_u GetTotalWidth() const
Return the width of the whole 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,...
Definition assert.h:55
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:76
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...
Definition callback.h:690
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
Definition abort.h:136
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:99
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:201
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:267
#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.
Definition object-base.h:35
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1330
WifiExpectedAccessReason
Enumeration values for the outcome of the check whether channel access is expected to be gained withi...
WifiChannelListType
Enumeration of the possible channel-list parameter elements defined in Table 8-5 of IEEE 802....
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition qos-utils.h:64
@ AC_BE
Best Effort.
Definition qos-utils.h:66
@ AC_VO
Voice.
Definition qos-utils.h:72
@ AC_VI
Video.
Definition qos-utils.h:70
@ AC_BK
Background.
Definition qos-utils.h:68
Definition first.py:1
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition boolean.cc:113
@ SWITCHING
The PHY layer is switching to other channel.
@ IDLE
The PHY layer is IDLE.
@ CCA_BUSY
The PHY layer has sense the medium busy through the CCA mechanism.
@ RX
The PHY layer is receiving a packet.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition nstime.h:1416
double MHz_u
MHz weak type.
Definition wifi-units.h:31
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition enum.h:181
double dBm_u
dBm weak type
Definition wifi-units.h:27
@ LOG_FUNCTION
Function entry for non-trivial, non-getter methods.
Definition log.h:111
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition boolean.h:70
uint8_t linkId_t
IEEE 802.11be D7.0 Figure 9-207e—Link ID Info field format.
Definition wifi-utils.h:76
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition enum.h:223
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...
Definition qos-utils.cc:115
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1436
Base struct for EMLSR Main PHY switch traces.
Struct to trace that main PHY switched to leave a link on which an aux PHY was expected to gain a TXO...
Struct to trace that main PHY switched to operate on a link on which an aux PHY that is not TX capabl...