A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
default-emlsr-manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Universita' degli Studi di Napoli Federico II
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Stefano Avallone <stavallo@unina.it>
18 */
19
21
22#include "ns3/boolean.h"
23#include "ns3/channel-access-manager.h"
24#include "ns3/log.h"
25#include "ns3/wifi-mpdu.h"
26#include "ns3/wifi-net-device.h"
27#include "ns3/wifi-phy.h"
28
29namespace ns3
30{
31
32NS_LOG_COMPONENT_DEFINE("DefaultEmlsrManager");
33
34NS_OBJECT_ENSURE_REGISTERED(DefaultEmlsrManager);
35
36TypeId
38{
39 static TypeId tid =
40 TypeId("ns3::DefaultEmlsrManager")
42 .SetGroupName("Wifi")
43 .AddConstructor<DefaultEmlsrManager>()
44 .AddAttribute("SwitchAuxPhy",
45 "Whether Aux PHY should switch channel to operate on the link on which "
46 "the Main PHY was operating before moving to the link of the Aux PHY. "
47 "Note that, if the Aux PHY does not switch channel, the main PHY will "
48 "switch back to its previous link once the TXOP terminates (otherwise, "
49 "no PHY will be listening on that EMLSR link).",
50 BooleanValue(true),
53 return tid;
54}
55
57{
58 NS_LOG_FUNCTION(this);
59}
60
62{
64}
65
66void
68{
69 NS_LOG_FUNCTION(this << *mpdu << linkId);
70}
71
72uint8_t
74{
75 NS_LOG_FUNCTION(this);
76 auto linkId = GetStaMac()->GetLinkForPhy(m_mainPhyId);
77 NS_ASSERT_MSG(linkId, "Link on which the main PHY is operating not found");
78 return *linkId;
79}
80
81std::optional<uint8_t>
83{
84 NS_LOG_FUNCTION(this);
85 auto linkId = GetStaMac()->GetLinkForPhy(m_mainPhyId);
86 NS_ASSERT_MSG(linkId, "Link on which the main PHY is operating not found");
87 return *linkId;
88}
89
90void
92{
93 NS_LOG_FUNCTION(this);
94}
95
96void
97DefaultEmlsrManager::NotifyMainPhySwitch(uint8_t currLinkId, uint8_t nextLinkId)
98{
99 NS_LOG_FUNCTION(this << currLinkId << nextLinkId);
100
101 if (m_switchAuxPhy)
102 {
103 // switch channel on Aux PHY so that it operates on the link on which the main PHY was
104 // operating
105 SwitchAuxPhy(nextLinkId, currLinkId);
106 return;
107 }
108
109 if (currLinkId != GetMainPhyId())
110 {
111 // the main PHY is leaving a non-primary link, hence an aux PHY needs to be reconnected
114 "There should be an aux PHY to reconnect when the main PHY leaves a non-primary link");
115
116 // the Aux PHY is not actually switching (hence no switching delay)
119 m_auxPhyToReconnect = nullptr;
120 }
121
122 if (nextLinkId != GetMainPhyId())
123 {
124 // the main PHY is moving to a non-primary link and the aux PHY does not switch link
126 }
127}
128
129void
131{
132 NS_LOG_FUNCTION(this << linkId);
133}
134
135void
137{
138 NS_LOG_FUNCTION(this << linkId);
139}
140
141void
143{
144 NS_LOG_FUNCTION(this << linkId);
145
146 // switch main PHY to the previous link, if needed
148 {
149 auto mainPhy = GetStaMac()->GetDevice()->GetPhy(m_mainPhyId);
150
151 // the main PHY may be switching at the end of a TXOP when, e.g., the main PHY starts
152 // switching to a link on which an aux PHY gained a TXOP and sent an RTS, but the CTS
153 // is not received and the UL TXOP ends before the main PHY channel switch is completed.
154 // In such cases, wait until the main PHY channel switch is completed before requesting
155 // a new channel switch.
156 // Backoff shall not be reset on the link left by the main PHY because a TXOP ended and
157 // a new backoff value must be generated.
158 if (!mainPhy->IsStateSwitching())
159 {
161 }
162 else
163 {
164 Simulator::Schedule(mainPhy->GetDelayUntilIdle(),
166 this,
167 GetMainPhyId(),
168 false,
171 }
172 return;
173 }
174}
175
176} // namespace ns3
AttributeValue implementation for Boolean.
Definition: boolean.h:37
DefaultEmlsrManager is the default EMLSR manager.
void DoNotifyMgtFrameReceived(Ptr< const WifiMpdu > mpdu, uint8_t linkId) override
Notify the subclass of the reception of a management frame addressed to us.
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...
void DoNotifyUlTxopStart(uint8_t linkId) override
Notify the subclass of the start of an UL TXOP on the given link.
bool m_switchAuxPhy
whether Aux PHY should switch channel to operate on the link on which the Main PHY was operating befo...
static TypeId GetTypeId()
Get the type ID.
void DoNotifyIcfReceived(uint8_t linkId) override
Notify the subclass of the reception of an initial Control frame on the given link.
std::optional< uint8_t > ResendNotification(Ptr< const WifiMpdu > mpdu) override
A previous EML Operating Mode Notification frame was dropped.
void NotifyMainPhySwitch(uint8_t currLinkId, uint8_t nextLinkId) override
Notify subclass that the main PHY is switching channel to operate on another link.
void DoNotifyTxopEnd(uint8_t linkId) override
Notify the subclass of the end of a TXOP on the given link.
uint8_t GetLinkToSendEmlOmn() override
EmlsrManager is an abstract base class defining the API that EHT non-AP MLDs with EMLSR activated can...
Definition: emlsr-manager.h:47
void SwitchMainPhy(uint8_t linkId, bool noSwitchDelay, bool resetBackoff, bool requestAccess)
Switch channel on the Main PHY so that it operates on the given link.
uint8_t m_mainPhyId
ID of main PHY (position in the vector of PHYs held by WifiNetDevice)
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...
static constexpr bool REQUEST_ACCESS
request channel access when PHY switch ends
Ptr< StaWifiMac > GetStaMac() const
void SwitchAuxPhy(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...
uint8_t GetMainPhyId() const
static constexpr bool DONT_RESET_BACKOFF
do not reset backoff on main PHY switch
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
void NotifySwitchingEmlsrLink(Ptr< WifiPhy > phy, uint8_t linkId, Time delay)
Notify that the given PHY switched channel to operate on another EMLSR link.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Ptr< WifiPhy > GetWifiPhy(uint8_t linkId=SINGLE_LINK_OP_ID) const
Definition: wifi-mac.cc:1185
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
Definition: wifi-mac.cc:453
std::optional< uint8_t > GetLinkForPhy(Ptr< const WifiPhy > phy) const
Get the ID of the link (if any) on which the given PHY is operating.
Definition: wifi-mac.cc:988
Ptr< WifiPhy > GetPhy() const
#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:86
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:81
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:46
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
Every class exported by the ns3 library is enclosed in the ns3 namespace.