16#include "ns3/qos-txop.h"
17#include "ns3/wifi-acknowledgment.h"
18#include "ns3/wifi-mac-trailer.h"
19#include "ns3/wifi-protection.h"
32 TypeId(
"ns3::MultiUserScheduler")
35 .AddAttribute(
"AccessReqInterval",
36 "Duration of the interval between two consecutive requests for "
37 "channel access made by the MultiUserScheduler. Such requests are "
38 "made independently of the presence of frames in the queues of the "
39 "AP and are intended to allow the AP to coordinate UL MU transmissions "
40 "even without DL traffic. A null duration indicates that such "
41 "requests shall not be made.",
46 .AddAttribute(
"AccessReqAc",
47 "The Access Category for which the MultiUserScheduler makes requests "
48 "for channel access.",
59 .AddAttribute(
"DelayAccessReqUponAccess",
60 "If enabled, the access request interval is measured starting "
61 "from the last time an EDCA function obtained channel access. "
62 "Otherwise, the access request interval is measured starting "
63 "from the last time the MultiUserScheduler made a request for "
68 .AddAttribute(
"DefaultTbPpduDuration",
69 "Default duration of TB PPDUs solicited via a Basic Trigger Frame. "
70 "This value is used to compute the Duration/ID field of BSRP Trigger "
71 "Frames sent when the TXOP Limit is zero and the FrameExchangeManager "
72 "continues the TXOP a SIFS after receiving response to the BSRP TF. "
73 "This value shall also be used by subclasses when they have no other "
74 "information available to determine the TX duration of solicited PPDUs. "
75 "The default value roughly corresponds to half the maximum PPDU TX "
84 : m_isUnprotectedEmlsrClient([this](uint8_t linkId,
Mac48Address address) {
85 return m_apMac->GetWifiRemoteStationManager(linkId)->GetEmlsrEnabled(address) &&
86 !
m_apMac->GetFrameExchangeManager(linkId)->GetProtectedStas().contains(address);
105 accessReqTimer.Cancel();
135 for (uint8_t
id = 0;
id <
m_apMac->GetNLinks(); ++id)
155 for (uint8_t
id = 0;
id <
m_apMac->GetNLinks(); ++id)
183 "MultiUserScheduler can only be installed on HE APs");
185 for (uint8_t linkId = 0; linkId <
m_apMac->GetNLinks(); linkId++)
189 heFem->SetMultiUserScheduler(
this);
196 return m_apMac->GetWifiRemoteStationManager(linkId);
221 m_apMac->GetChannelAccessManager(linkId)->RequestAccess(edca);
242 NS_LOG_FUNCTION(
this << edca << availableTime << initialFrame << allowedWidth << linkId);
276 if (txFormat !=
NO_TX)
294 "Next transmission is not DL MU");
296#ifdef NS3_BUILD_PROFILE_DEBUG
300 auto receiver = psdu.second->GetAddr1();
301 auto linkId =
m_apMac->IsAssociated(receiver);
302 NS_ABORT_MSG_IF(!linkId,
"Station " << receiver <<
" should be associated");
304 "Station " << psdu.second->GetAddr1() <<
" does not support HE");
315 "Next transmission is not UL MU");
326 packet->AddHeader(trigger);
331 auto aid = trigger.
begin()->GetAid12();
332 auto aidAddrMapIt =
m_apMac->GetStaList(linkId).find(aid);
334 receiver = aidAddrMapIt->second;
364 std::function<
bool(uint8_t,
Mac48Address)> predicate)
const
368 const auto& aidAddrMap =
m_apMac->GetStaList(linkId);
370 for (
auto userInfoIt = trigger.
begin(); userInfoIt != trigger.
end();)
372 const auto addressIt = aidAddrMap.find(userInfoIt->GetAid12());
374 "AID " << userInfoIt->GetAid12() <<
" not found");
375 const auto address = addressIt->second;
377 if (predicate(linkId, address))
379 NS_LOG_INFO(
"Removing User Info field addressed to " << address);
385 auto acknowledgment =
387 for (
auto it = acknowledgment->stationsReceivingMultiStaBa.begin();
388 it != acknowledgment->stationsReceivingMultiStaBa.end();)
390 if (it->first.first == address)
413 std::function<
bool(uint8_t,
Mac48Address)> predicate)
const
417 const auto& aidAddrMap =
m_apMac->GetStaList(linkId);
419 for (
auto psduMapIt = psduMap.begin(); psduMapIt != psduMap.end();)
421 const auto addressIt = aidAddrMap.find(psduMapIt->first);
422 NS_ASSERT_MSG(addressIt != aidAddrMap.cend(),
"AID " << psduMapIt->first <<
" not found");
423 const auto address = addressIt->second;
425 if (predicate(linkId, address))
427 NS_LOG_INFO(
"Removing PSDU addressed to " << address);
430 psduMapIt = psduMap.erase(psduMapIt);
434 auto acknowledgment =
437 acknowledgment->stationsReplyingWithBlockAck.erase(address);
438 acknowledgment->stationsSendBlockAckReqTo.erase(address);
442 auto acknowledgment =
448 auto acknowledgment =
479 if (
GetUlMuInfo(linkId).trigger.GetNUserInfoFields() == 0)
499 uint8_t maxNTids = 0;
500 for (
const auto& userInfo : trigger)
502 auto address =
m_apMac->GetMldOrLinkAddressByAid(userInfo.GetAid12());
503 NS_ASSERT_MSG(address,
"AID " << userInfo.GetAid12() <<
" not found");
505 uint8_t staNTids = 0;
506 for (uint8_t tid = 0; tid < 8; tid++)
508 if (
m_apMac->GetBaAgreementEstablishedAsRecipient(*address, tid))
513 maxNTids = std::max(maxNTids, staNTids);
523 for (uint8_t i = 0; i < maxNTids; i++)
AttributeValue implementation for Boolean.
Hold variables of type enum.
static Mac48Address GetBroadcast()
static uint32_t GetSizeIfAggregated(uint32_t mpduSize, uint32_t ampduSize)
Compute the size of the A-MPDU resulting from the aggregation of an MPDU of size mpduSize and an A-MP...
bool m_initialFrame
true if a TXOP is being started
void NotifyNewAggregate() override
Notify all Objects aggregated to this one of a new Object being aggregated.
~MultiUserScheduler() override
void DoInitialize() override
Initialize() implementation.
Ptr< ApWifiMac > m_apMac
the AP wifi MAC
std::vector< EventId > m_accessReqTimers
the per-link timer controlling additional channel access requests
void CheckTriggerFrame()
Ensure that the Trigger Frame returned in case of UL MU transmission is correct.
static TypeId GetTypeId()
Get the type ID.
Time m_availableTime
the time available for frame exchange
void RemoveRecipientsFromTf(uint8_t linkId, CtrlTriggerHeader &trigger, WifiTxParameters &txParams, std::function< bool(uint8_t, Mac48Address)> predicate) const
Remove the User Info fields for which the given predicate is true from the given Trigger Frame.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId) const
Get the station manager attached to the AP on the given link.
UlMuInfo & GetUlMuInfo(uint8_t linkId)
Get the information required to solicit an UL MU transmission on the given link.
uint8_t m_linkId
the ID of the link over which channel access has been granted
virtual TxFormat SelectTxFormat()=0
Select the format of the next transmission.
void SetAccessReqInterval(Time interval)
Set the duration of the interval between two consecutive requests for channel access made by the Mult...
uint32_t GetMaxSizeOfQosNullAmpdu(const CtrlTriggerHeader &trigger) const
Get the maximum size in bytes among the A-MPDUs containing QoS Null frames and solicited by the given...
virtual void UpdateTriggerFrameAfterProtection(uint8_t linkId, CtrlTriggerHeader &trigger, WifiTxParameters &txParams) const
Update the given Trigger Frame after protection is completed on the given link.
bool m_restartTimerUponAccess
whether the channel access timer has to be restarted upon channel access
virtual DlMuInfo ComputeDlMuInfo()=0
Compute the information required to perform a DL MU transmission.
Ptr< QosTxop > m_edca
the AC that gained channel access
Time GetAccessReqInterval() const
void NotifyProtectionCompleted(uint8_t linkId, WifiPsduMap &psduMap, WifiTxParameters &txParams)
This method is called when a protection mechanism for an MU transmission is completed and gives the M...
virtual UlMuInfo ComputeUlMuInfo()=0
Prepare the information required to solicit an UL MU transmission.
Time m_defaultTbPpduDuration
the default duration of TB PPDUs solicited by Basic TFs
TxFormat GetLastTxFormat(uint8_t linkId) const
Get the format of the last transmission on the given link, as determined by the last call to NotifyAc...
void DoDispose() override
Destructor implementation.
Ptr< WifiMpdu > GetTriggerFrame(const CtrlTriggerHeader &trigger, uint8_t linkId) const
Get an MPDU containing the given Trigger Frame.
AcIndex m_accessReqAc
AC we request channel access for.
DlMuInfo & GetDlMuInfo(uint8_t linkId)
Get the information required to perform a DL MU transmission on the given link.
MHz_u m_allowedWidth
the allowed width for the current transmission
Ptr< HeFrameExchangeManager > GetHeFem(uint8_t linkId) const
Get the HE Frame Exchange Manager attached to the AP on the given link.
Time m_accessReqInterval
duration of the interval between channel access requests
TxFormat NotifyAccessGranted(Ptr< QosTxop > edca, Time availableTime, bool initialFrame, MHz_u allowedWidth, uint8_t linkId)
Notify the Multi-user Scheduler that the given AC of the AP gained channel access.
void SetWifiMac(Ptr< ApWifiMac > mac)
Set the wifi MAC.
virtual Time GetExtraTimeForBsrpTfDurationId(uint8_t linkId) const
When the TXOP limit is zero and the TXOP continues a SIFS after receiving a response to a BSRP TF,...
TxFormat
Enumeration of the possible transmission formats.
virtual void UpdateDlMuAfterProtection(uint8_t linkId, WifiPsduMap &psduMap, WifiTxParameters &txParams) const
Update the given PSDU map after protection is completed on the given link.
std::map< uint8_t, LastTxInfo > m_lastTxInfo
Information about the last transmission.
void RemoveRecipientsFromDlMu(uint8_t linkId, WifiPsduMap &psduMap, WifiTxParameters &txParams, std::function< bool(uint8_t, Mac48Address)> predicate) const
Remove PSDUs for which the given predicate is true from the given PSDU map.
void AccessReqTimeout(uint8_t linkId)
Perform actions required on expiration of the channel access request timer associated with the given ...
A base class which provides memory management and object aggregation.
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
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.
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.
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
std::unique_ptr< WifiAcknowledgment > m_acknowledgment
acknowledgment method
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
const HeMuUserInfoMap & GetHeMuUserInfoMap() const
Get a const reference to the map HE MU user-specific transmission information indexed by STA-ID.
#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< 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.
#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_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_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octets of the IEEE 802.11 MAC FCS field.
bool IsTrigger(const WifiPsduMap &psduMap)
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
std::unordered_map< uint16_t, Ptr< WifiPsdu > > WifiPsduMap
Map of PSDUs indexed by STA-ID.
Information to be provided in case of DL MU transmission.
Information to be provided in case of UL MU transmission.
WifiMacHeader macHdr
the MAC header for the Trigger Frame
WifiDlMuAggregateTf specifies that a DL MU PPDU made of PSDUs including each a MU-BAR Trigger Frame i...
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
Set of stations replying with a BlockAck frame.
WifiDlMuBarBaSequence specifies that a DL MU PPDU is acknowledged through a sequence of BlockAckReq a...
std::map< Mac48Address, AckInfo > stationsReplyingWithNormalAck
Set of stations replying with an Ack frame (no more than one)
WifiDlMuTfMuBar specifies that a DL MU PPDU is followed after a SIFS duration by a MU-BAR Trigger Fra...
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
Set of stations replying with a BlockAck frame.
WifiUlMuMultiStaBa specifies that a Basic Trigger Frame is being sent to solicit TB PPDUs that will b...
std::map< std::pair< Mac48Address, uint8_t >, std::size_t > stationsReceivingMultiStaBa
Map (originator, tid) pairs to the their index in baType.