14#include "ns3/nstime.h"
15#include "ns3/object.h"
16#include "ns3/traced-value.h"
17#include "ns3/uniform-random-bit-generator.h"
23#define WIFI_TXOP_NS_LOG_APPEND_CONTEXT \
26 std::clog << "[mac=" << m_mac->GetAddress() << "] "; \
35class ChannelAccessManager;
40class UniformRandomVariable;
41class CtrlBAckResponseHeader;
129 void SetMinCws(
const std::vector<uint32_t>& minCws);
153 void SetMaxCws(
const std::vector<uint32_t>& maxCws);
177 void SetAifsns(
const std::vector<uint8_t>& aifsns);
185 void SetAifsn(uint8_t aifsn, uint8_t linkId);
269 virtual uint8_t
GetAifsn(uint8_t linkId)
const;
421 void SwapLinks(std::map<uint8_t, uint8_t> links);
445 friend class ::EmlsrUlTxopTest;
544 LinkEntity&
GetLink(uint8_t linkId)
const;
549 const std::map<uint8_t, std::unique_ptr<LinkEntity>>&
GetLinks()
const;
574 std::map<uint8_t, std::unique_ptr<LinkEntity>>
Test the transmission of UL frames from EMLSR clients.
Manage a set of ns3::Txop.
An identifier for simulation events.
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Forward calls to a chain of Callback.
Handles the packet queue and stores DCF/EDCA access parameters (one Txop per AC).
Ptr< WifiMac > m_mac
the wifi MAC
Time GetTxopLimit() const
Return the TXOP limit.
virtual std::unique_ptr< LinkEntity > CreateLinkEntity() const
Create a LinkEntity object.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
virtual ChannelAccessStatus GetAccessStatus(uint8_t linkId) const
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
void StartAccessAfterEvent(uint8_t linkId, bool hadFramesToTransmit, bool checkMediumBusy)
Request channel access on the given link after the occurrence of an event that possibly requires to g...
virtual bool HasFramesToTransmit(uint8_t linkId)
Check if the Txop has frames to transmit over the given link.
virtual void NotifyOff()
When off operation occurs, the queue gets cleaned up.
UniformRandomBitGenerator m_shuffleLinkIdsGen
random number generator to shuffle link IDs
Ptr< UniformRandomVariable > m_rng
the random stream
CwValueTracedCallback m_cwTrace
CW trace value.
void DoDispose() override
Destructor implementation.
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
void SetMaxCws(const std::vector< uint32_t > &maxCws)
Set the maximum contention window size for each link.
uint32_t GetMinCw() const
Return the minimum contention window size.
ChannelAccessStatus
Enumeration for channel access status.
virtual void NotifyOn()
When on operation occurs, channel access will be started.
void UpdateFailedCw(uint8_t linkId)
Update the value of the CW variable for the given link to take into account a transmission failure.
void SetAifsns(const std::vector< uint8_t > &aifsns)
Set the number of slots that make up an AIFS for each link.
static constexpr bool DIDNT_HAVE_FRAMES_TO_TRANSMIT
no packet available for transmission was in the queue
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
virtual void SetWifiMac(const Ptr< WifiMac > mac)
Set the wifi MAC this Txop is associated to.
virtual void NotifyWakeUp(uint8_t linkId)
When wake up operation occurs on a link, channel access on that link will be restarted.
virtual void NotifyChannelReleased(uint8_t linkId)
Called by the FrameExchangeManager to notify the completion of the transmissions.
std::vector< uint32_t > GetMaxCws() const
Return the maximum contention window size for each link.
virtual void Queue(Ptr< WifiMpdu > mpdu)
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
virtual void CreateQueue(AcIndex aci)
Create a wifi MAC queue containing packets of the given AC.
TracedCallback< uint32_t, uint8_t > BackoffValueTracedCallback
TracedCallback for backoff trace value typedef.
void ResetCw(uint8_t linkId)
Update the value of the CW variable for the given link to take into account a transmission success or...
LinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
virtual bool IsQosTxop() const
Check for QoS TXOP.
std::vector< uint32_t > GetMinCws() const
Return the minimum contention window size for each link.
std::vector< uint8_t > GetAifsns() const
Return the number of slots that make up an AIFS for each link.
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound, uint8_t linkId)
Update backoff slots for the given link that nSlots has passed.
TracedCallback< uint32_t, uint8_t > CwValueTracedCallback
TracedCallback for CW trace value typedef.
Time GetBackoffStart(uint8_t linkId) const
Return the time when the backoff procedure started on the given link.
void SetTxopLimits(const std::vector< Time > &txopLimits)
Set the TXOP limit for each link.
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
void SwapLinks(std::map< uint8_t, uint8_t > links)
Swap the links based on the information included in the given map.
const UserDefinedAccessParams & GetUserAccessParams() const
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
std::vector< Time > GetTxopLimits() const
Return the TXOP limit for each link.
const std::map< uint8_t, std::unique_ptr< LinkEntity > > & GetLinks() const
static TypeId GetTypeId()
Get the type ID.
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
uint32_t GetCw(uint8_t linkId) const
Get the current value of the CW variable for the given link.
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
UserDefinedAccessParams m_userAccessParams
user-defined DCF/EDCA access parameters
virtual void GenerateBackoff(uint8_t linkId)
Generate a new backoff for the given link now.
BackoffValueTracedCallback m_backoffTrace
backoff trace value
virtual void NotifyAccessRequested(uint8_t linkId)
Notify that access request has been received for the given link.
Ptr< MacTxMiddle > m_txMiddle
the MacTxMiddle
static constexpr bool CHECK_MEDIUM_BUSY
generation of backoff (also) depends on the busy/idle state of the medium
void StartBackoffNow(uint32_t nSlots, uint8_t linkId)
virtual void NotifyChannelAccessed(uint8_t linkId, Time txopDuration=Seconds(0))
Called by the FrameExchangeManager to notify that channel access has been granted on the given link f...
std::map< uint8_t, std::unique_ptr< LinkEntity > > m_links
ID-indexed map of LinkEntity objects.
void SetMinCws(const std::vector< uint32_t > &minCws)
Set the minimum contention window size for each link.
void RequestAccess(uint8_t linkId)
Request access to the ChannelAccessManager associated with the given link.
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
uint8_t GetAifsn() const
Return the number of slots that make up an AIFS.
uint32_t GetBackoffSlots(uint8_t linkId) const
Return the current number of backoff slots on the given link.
virtual void NotifySleep(uint8_t linkId)
Notify that the given link switched to sleep mode.
static constexpr bool DONT_CHECK_MEDIUM_BUSY
generation of backoff is independent of the busy/idle state of the medium
uint32_t GetMaxCw() const
Return the maximum contention window size.
static constexpr bool HAD_FRAMES_TO_TRANSMIT
packets available for transmission were in the queue
Callback< void, WifiMacDropReason, Ptr< const WifiMpdu > > DroppedMpdu
typedef for a callback to invoke when an MPDU is dropped.
void DoInitialize() override
Initialize() implementation.
a unique identifier for an interface.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiMacDropReason
The reason why an MPDU was dropped.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Structure holding information specific to a single link.
class ns3::Txop::LinkEntity::@72 accessRequest
access request event, to be used by Txop::Queue() only
ChannelAccessStatus access
channel access status
uint32_t cw
the current contention window
virtual ~LinkEntity()=default
Destructor (a virtual method is needed to make this struct polymorphic)
uint32_t cwMax
the maximum contention window
Time txopLimit
the TXOP limit time
Time backoffStart
the backoffStart variable is used to keep track of the time at which a backoff was started or the tim...
uint32_t cwMin
the minimum contention window
uint32_t backoffSlots
the number of backoff slots
DCF/EDCA access parameters for all the links provided by users via this class' attributes or the corr...
std::vector< uint32_t > cwMins
the minimum contention window values for all the links
std::vector< uint8_t > aifsns
the AIFSN values for all the links
std::vector< uint32_t > cwMaxs
the maximum contention window values for all the links
std::vector< Time > txopLimits
TXOP limit values for all the links.