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
23
24#include "ns3/boolean.h"
25#include "ns3/channel-access-manager.h"
26#include "ns3/log.h"
27#include "ns3/wifi-mpdu.h"
28#include "ns3/wifi-net-device.h"
29#include "ns3/wifi-phy.h"
30
31namespace ns3
32{
33
34NS_LOG_COMPONENT_DEFINE("DefaultEmlsrManager");
35
36NS_OBJECT_ENSURE_REGISTERED(DefaultEmlsrManager);
37
38TypeId
40{
41 static TypeId tid =
42 TypeId("ns3::DefaultEmlsrManager")
44 .SetGroupName("Wifi")
45 .AddConstructor<DefaultEmlsrManager>()
46 .AddAttribute("SwitchAuxPhy",
47 "Whether Aux PHY should switch channel to operate on the link on which "
48 "the Main PHY was operating before moving to the link of the Aux PHY. "
49 "Note that, if the Aux PHY does not switch channel, the main PHY will "
50 "switch back to its previous link once the TXOP terminates (otherwise, "
51 "no PHY will be listening on that EMLSR link).",
52 BooleanValue(true),
55 return tid;
56}
57
59{
60 NS_LOG_FUNCTION(this);
61}
62
64{
66}
67
68void
70{
71 NS_LOG_FUNCTION(this << *mpdu << linkId);
72}
73
74uint8_t
76{
77 NS_LOG_FUNCTION(this);
78 auto linkId = GetStaMac()->GetLinkForPhy(m_mainPhyId);
79 NS_ASSERT_MSG(linkId, "Link on which the main PHY is operating not found");
80 return *linkId;
81}
82
83std::optional<uint8_t>
85{
86 NS_LOG_FUNCTION(this);
87 auto linkId = GetStaMac()->GetLinkForPhy(m_mainPhyId);
88 NS_ASSERT_MSG(linkId, "Link on which the main PHY is operating not found");
89 return *linkId;
90}
91
92void
94{
95 NS_LOG_FUNCTION(this);
96}
97
98void
99DefaultEmlsrManager::NotifyMainPhySwitch(uint8_t currLinkId, uint8_t nextLinkId)
100{
101 NS_LOG_FUNCTION(this << currLinkId << nextLinkId);
102
103 if (m_switchAuxPhy)
104 {
105 // switch channel on Aux PHY so that it operates on the link on which the main PHY was
106 // operating
107 SwitchAuxPhy(nextLinkId, currLinkId);
108 return;
109 }
110
111 if (currLinkId != GetMainPhyId())
112 {
113 // the main PHY is leaving a non-primary link, hence an aux PHY needs to be reconnected
116 "There should be an aux PHY to reconnect when the main PHY leaves a non-primary link");
117
118 // the Aux PHY is not actually switching (hence no switching delay)
121 m_auxPhyToReconnect = nullptr;
122 }
123
124 if (nextLinkId != GetMainPhyId())
125 {
126 // the main PHY is moving to a non-primary link and the aux PHY does not switch link
128 }
129}
130
131void
133{
134 NS_LOG_FUNCTION(this << linkId);
135}
136
137void
139{
140 NS_LOG_FUNCTION(this << linkId);
141}
142
143void
145{
146 NS_LOG_FUNCTION(this << linkId);
147
148 // switch main PHY to the previous link, if needed
150 {
151 auto mainPhy = GetStaMac()->GetDevice()->GetPhy(m_mainPhyId);
152
153 // the main PHY may be switching at the end of a TXOP when, e.g., the main PHY starts
154 // switching to a link on which an aux PHY gained a TXOP and sent an RTS, but the CTS
155 // is not received and the UL TXOP ends before the main PHY channel switch is completed.
156 // In such cases, wait until the main PHY channel switch is completed before requesting
157 // a new channel switch.
158 // Backoff shall not be reset on the link left by the main PHY because a TXOP ended and
159 // a new backoff value must be generated.
160 if (!mainPhy->IsStateSwitching())
161 {
163 }
164 else
165 {
166 Simulator::Schedule(mainPhy->GetDelayUntilIdle(), [=, this]() {
167 // request the main PHY to switch back to the primary link only if in the meantime
168 // no TXOP started on another link (which will require the main PHY to switch link)
169 if (!GetEhtFem(linkId)->UsingOtherEmlsrLink())
170 {
171 SwitchMainPhy(GetMainPhyId(), false, DONT_RESET_BACKOFF, REQUEST_ACCESS);
172 }
173 });
174 }
175 return;
176 }
177}
178
179} // namespace ns3
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:1315
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
Definition: wifi-mac.cc:483
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:1113
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
#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.
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:81