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-phy.h"
27
28namespace ns3
29{
30
31NS_LOG_COMPONENT_DEFINE("DefaultEmlsrManager");
32
33NS_OBJECT_ENSURE_REGISTERED(DefaultEmlsrManager);
34
35TypeId
37{
38 static TypeId tid =
39 TypeId("ns3::DefaultEmlsrManager")
41 .SetGroupName("Wifi")
42 .AddConstructor<DefaultEmlsrManager>()
43 .AddAttribute("SwitchAuxPhy",
44 "Whether Aux PHY should switch channel to operate on the link on which "
45 "the Main PHY was operating before moving to the link of the Aux PHY.",
46 BooleanValue(true),
49 return tid;
50}
51
53{
54 NS_LOG_FUNCTION(this);
55}
56
58{
60}
61
62void
64{
65 NS_LOG_FUNCTION(this << *mpdu << linkId);
66}
67
68uint8_t
70{
71 NS_LOG_FUNCTION(this);
72 auto linkId = GetStaMac()->GetLinkForPhy(m_mainPhyId);
73 NS_ASSERT_MSG(linkId, "Link on which the main PHY is operating not found");
74 return *linkId;
75}
76
77std::optional<uint8_t>
79{
80 NS_LOG_FUNCTION(this);
81 auto linkId = GetStaMac()->GetLinkForPhy(m_mainPhyId);
82 NS_ASSERT_MSG(linkId, "Link on which the main PHY is operating not found");
83 return *linkId;
84}
85
86void
88{
89 NS_LOG_FUNCTION(this);
90}
91
92void
93DefaultEmlsrManager::NotifyMainPhySwitch(uint8_t currLinkId, uint8_t nextLinkId)
94{
95 NS_LOG_FUNCTION(this << currLinkId << nextLinkId);
96
97 if (!m_switchAuxPhy)
98 {
99 return; // nothing to do
100 }
101
102 // switch channel on Aux PHY so that it operates on the link on which the main PHY was operating
103 auto auxPhy = GetStaMac()->GetWifiPhy(nextLinkId);
104
105 auto newAuxPhyChannel = GetChannelForAuxPhy(currLinkId);
106
107 NS_LOG_DEBUG("Aux PHY (" << auxPhy << ") is about to switch to " << newAuxPhyChannel
108 << " to operate on link " << +currLinkId);
109
110 GetStaMac()
111 ->GetChannelAccessManager(nextLinkId)
112 ->NotifySwitchingEmlsrLink(auxPhy, newAuxPhyChannel, currLinkId);
113
115 Simulator::ScheduleNow(fp, auxPhy, newAuxPhyChannel);
116}
117
118} // namespace ns3
AttributeValue implementation for Boolean.
Definition: boolean.h:37
void NotifySwitchingEmlsrLink(Ptr< WifiPhy > phy, const WifiPhyOperatingChannel &channel, uint8_t linkId)
Notify that the given PHY is about to switch to the given operating channel, which is used by the giv...
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.
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.
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.
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
uint8_t m_mainPhyId
ID of main PHY (position in the vector of PHYs held by WifiNetDevice)
Ptr< StaWifiMac > GetStaMac() const
const WifiPhyOperatingChannel & GetChannelForAuxPhy(uint8_t linkId) const
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:592
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:930
Ptr< WifiPhy > GetWifiPhy(uint8_t linkId=SINGLE_LINK_OP_ID) const
Definition: wifi-mac.cc:1173
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:976
Ptr< ChannelAccessManager > GetChannelAccessManager(uint8_t linkId=SINGLE_LINK_OP_ID) const
Get the Channel Access Manager associated with the given link.
Definition: wifi-mac.cc:872
802.11 PHY layer model
Definition: wifi-phy.h:53
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
Definition: wifi-phy.cc:1082
Class that keeps track of all information about the current PHY operating channel.
#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:86
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_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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
Every class exported by the ns3 library is enclosed in the ns3 namespace.