|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
25 #include "ns3/pointer.h"
26 #include "ns3/simulator.h"
27 #include "ns3/random-variable-stream.h"
40 #include "ns3/ht-frame-exchange-manager.h"
43 #undef NS_LOG_APPEND_CONTEXT
44 #define NS_LOG_APPEND_CONTEXT if (m_mac != 0) { std::clog << "[mac=" << m_mac->GetAddress () << "] "; }
57 .SetGroupName (
"Wifi")
59 .AddAttribute (
"UseExplicitBarAfterMissedBlockAck",
60 "Specify whether explicit BlockAckRequest should be sent upon missed BlockAck Response.",
64 .AddAttribute (
"AddBaResponseTimeout",
65 "The timeout to wait for ADDBA response after the Ack to "
66 "ADDBA request is received.",
71 .AddAttribute (
"FailedAddBaTimeout",
72 "The timeout after a failed BA agreement. During this "
73 "timeout, the originator resumes sending packets using normal "
74 "MPDU. After that, BA agreement is reset and the originator "
75 "will retry BA negotiation.",
80 .AddAttribute (
"BlockAckManager",
81 "The BlockAckManager object.",
84 MakePointerChecker<BlockAckManager> ())
85 .AddTraceSource (
"TxopTrace",
86 "Trace source for TXOP start and duration times",
88 "ns3::TracedValueCallback::Time")
102 m_muEdcaTimerStartTime (
Seconds (0))
135 uint32_t bufferSize =
m_queue->GetNBytes (tid, receiver);
137 uint8_t queueSize =
static_cast<uint8_t
> (std::ceil (
std::min (bufferSize, 64769u) / 256.0));
138 NS_LOG_DEBUG (
"Buffer size=" << bufferSize <<
" Queue Size=" << +queueSize);
285 return Create<const WifiMacQueueItem> (bar, hdr);
291 m_baManager->ScheduleBar (bar, skipIfNoDataQueued);
306 bool baManagerHasPackets = (
m_baManager->GetBar (
false) != 0);
313 bool ret = (baManagerHasPackets || queueIsNotEmpty);
321 return m_txMiddle->GetNextSequenceNumberFor (hdr);
327 return m_txMiddle->PeekNextSequenceNumberFor (hdr);
335 if (!mpdu->GetHeader ().IsQosData ())
340 Mac48Address recipient = mpdu->GetHeader ().GetAddr1 ();
341 uint8_t tid = mpdu->GetHeader ().GetQosTid ();
349 mpdu->GetHeader ().GetSequenceNumber ()))
368 auto peek = [
this, &tid, &recipient, &queueIt] () -> WifiMacQueue::ConstIterator
370 if (tid == 8 && recipient.IsBroadcast ())
378 return m_queue->PeekByTidAndAddress (tid, recipient, queueIt);
384 while (queueIt !=
m_queue->end () && !(*queueIt)->IsFragment ())
386 if (((*queueIt)->GetHeader ().IsRetry () || (*queueIt)->IsInFlight ())
389 NS_LOG_DEBUG (
"Removing an old packet from EDCA queue: " << **queueIt);
394 queueIt =
m_queue->Remove (queueIt);
397 else if ((*queueIt)->IsInFlight ())
399 NS_LOG_DEBUG (
"Skipping in flight MPDU: " << **queueIt);
408 if (queueIt !=
m_queue->end ())
416 :
m_txMiddle->PeekNextSequenceNumberFor (&hdr));
425 NS_LOG_DEBUG (
"Packet beyond the end of the current transmit window");
431 if (!(*queueIt)->IsFragment () && !hdr.
IsRetry ())
435 NS_LOG_DEBUG (
"Packet peeked from EDCA queue: " << **queueIt);
448 NS_LOG_FUNCTION (
this << *peekedItem << &txParams << availableTime << initialFrame);
450 Mac48Address recipient = peekedItem->GetHeader ().GetAddr1 ();
455 Time actualAvailableTime = (initialFrame && txParams.
GetSize (recipient) == 0
458 if (!
m_qosFem->TryAddMpdu (peekedItem, txParams, actualAvailableTime))
465 NS_ASSERT ((*peekedIt)->GetPacket () == peekedItem->GetPacket ());
471 if (peekedItem->GetHeader ().IsQosData ())
473 uint8_t tid = peekedItem->GetHeader ().GetQosTid ();
479 ||
IsInWindow (peekedItem->GetHeader ().GetSequenceNumber (),
485 && !peekedItem->GetHeader ().IsRetry () && !peekedItem->IsFragment ()
486 && !peekedItem->IsInFlight ())
489 mpdu = htFem->GetMsduAggregator ()->GetNextAmsdu (peekedItem, txParams, availableTime, peekedIt);
528 return m_baManager->GetBlockAckReqType (recipient, tid);
534 return m_baManager->GetBlockAckType (recipient, tid);
580 return remainingTxop;
588 m_queue->PushFront (Create<WifiMacQueueItem> (packet, hdr));
599 uint8_t tid = respHdr->
GetTid ();
602 NS_LOG_DEBUG (
"block ack agreement established with " << recipient <<
" tid " << +tid);
610 uint16_t startingSeq =
m_txMiddle->GetNextSeqNumberByTidAndAddress (tid, recipient);
611 WifiMacQueue::ConstIterator peekedIt =
m_queue->PeekByTidAndAddress (tid, recipient);
612 if (peekedIt !=
m_queue->end () && (*peekedIt)->GetHeader ().IsRetry ())
614 startingSeq = (*peekedIt)->GetHeader ().GetSequenceNumber ();
616 m_baManager->UpdateAgreement (respHdr, recipient, startingSeq);
621 m_baManager->NotifyAgreementRejected (recipient, tid);
634 NS_LOG_DEBUG (
"received DELBA frame from=" << recipient);
692 m_baManager->NotifyAgreementNoReply (recipient, tid);
713 m_baManager->NotifyAgreementReset (recipient, tid);
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< MacTxMiddle > m_txMiddle
the MacTxMiddle
QosTxop(AcIndex ac=AC_UNDEF)
Constructor.
Ptr< BlockAckManager > m_baManager
the block ack manager
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
AttributeValue implementation for Boolean.
void DoDispose(void) override
Destructor implementation.
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
virtual void NotifyChannelReleased(void)
Called by the FrameExchangeManager to notify the completion of the transmissions.
void AddHeader(const Header &header)
Add header to this packet.
uint16_t GetBaBufferSize(Mac48Address address, uint8_t tid) const
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool m_useExplicitBarAfterMissedBlockAck
flag whether explicit BlockAckRequest should be sent upon missed BlockAck Response
Implements the IEEE 802.11 MAC trailer.
bool IsNull(void) const
Check for null implementation.
Ptr< QosBlockedDestinations > m_qosBlockedDestinations
the QoS blocked destinations
uint8_t GetBlockAckThreshold(void) const
Return the current threshold for block ack mechanism.
uint32_t m_muCwMax
the MU CW maximum
bool GetBaAgreementEstablished(Mac48Address address, uint8_t tid) const
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
void Unblock(Mac48Address dest, uint8_t tid)
Un-block the given destination address and TID (e.g.
void GotAddBaResponse(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
Event handler when an ADDBA response is received.
uint32_t GetSize(Mac48Address receiver) const
Get the size in bytes of the (A-)MPDU addressed to the given receiver.
Ptr< BlockAckManager > GetBaManager(void)
Get the Block Ack Manager associated with this QosTxop.
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
Event handler when a DELBA frame is received.
void SetBlockAckInactivityTimeout(uint16_t timeout)
Set the BlockAck inactivity timeout.
bool IsStrictlyPositive(void) const
Exactly equivalent to t > 0.
uint16_t PeekNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the Traffic ID and destination, but do not pick it (i....
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
bool UseExplicitBarAfterMissedBlockAck(void) const
Return true if an explicit BlockAckRequest is sent after a missed BlockAck.
Hold objects of type Ptr<T>.
uint32_t m_cwMin
the minimum contention window
uint8_t m_muAifsn
the MU AIFSN
uint16_t GetNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
Ptr< const WifiMacQueueItem > PeekNextMpdu(uint8_t tid=8, Mac48Address recipient=Mac48Address::GetBroadcast())
Peek the next frame to transmit to the given receiver and of the given TID from the block ack manager...
uint32_t m_cwMax
the maximum contention window
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
uint8_t GetQosQueueSize(uint8_t tid, Mac48Address receiver) const
Get the value for the Queue Size subfield of the QoS Control field of a QoS data frame of the given T...
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
const WifiMacHeader & GetHeader(void) const
Get the header stored in this item.
void AddBaResponseTimeout(Mac48Address recipient, uint8_t tid)
Callback when ADDBA response is not received after timeout.
virtual void NotifyChannelAccessed(Time txopDuration=Seconds(0))
Called by the FrameExchangeManager to notify that channel access has been granted for the given amoun...
void NotifyChannelAccessed(Time txopDuration) override
Called by the FrameExchangeManager to notify that channel access has been granted for the given amoun...
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void SetDroppedMpduCallback(DroppedMpdu callback) override
void Block(Mac48Address dest, uint8_t tid)
Block the given destination address and TID from sending (e.g.
uint16_t GetBlockAckInactivityTimeout(void) const
Get the BlockAck inactivity timeout.
void SetQosFrameExchangeManager(const Ptr< QosFrameExchangeManager > qosFem)
Set the Frame Exchange Manager associated with this QoS STA.
void DoInitialize(void) override
Initialize() implementation.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ack mechanism.
uint16_t GetBaStartingSequence(Mac48Address address, uint8_t tid) const
Ptr< RegularWifiMac > m_mac
the wifi MAC
virtual void GenerateBackoff(void)
Generate a new backoff now.
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
BlockAckReqType GetBlockAckReqType(Mac48Address recipient, uint8_t tid) const
Smart pointer class similar to boost::intrusive_ptr.
std::list< Ptr< WifiMacQueueItem > >::const_iterator ConstIterator
Const iterator typedef.
void SetMuCwMin(uint16_t cwMin)
Set the minimum contention window size to use while the MU EDCA Timer is running.
AcIndex GetAccessCategory(void) const
Get the access category of this object.
void SetMuEdcaTimer(Time timer)
Set the MU EDCA Timer.
The different BlockAckRequest variants.
Time m_muEdcaTimerStartTime
last start time of the MU EDCA Timer
uint8_t GetAifsn(void) const override
Return the number of slots that make up an AIFS according to the EDCA Parameter Set or the MU EDCA Pa...
void AssignSequenceNumber(Ptr< WifiMacQueueItem > mpdu) const
Assign a sequence number to the given MPDU, if it is not a fragment and it is not a retransmitted fra...
void ResetBa(Mac48Address recipient, uint8_t tid)
Reset BA agreement after BA negotiation failed.
bool QosUtilsIsOldPacket(uint16_t startingSeq, uint16_t seqNumber)
This function checks if packet with sequence number seqNumber is an "old" packet.
Time m_failedAddBaTimeout
timeout after failed BA agreement
bool IsZero(void) const
Exactly equivalent to t == 0.
Callback< R, T2, T3, T4, T5, T6, T7, T8, T9 > Bind(T a)
Bind the first arguments.
bool IsInFlight(void) const
Return true if this MPDU is in flight, false otherwise.
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
bool IsBroadcast(void) const
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
The different BlockAck variants.
bool HasFramesToTransmit(void) override
Check if the Txop has frames to transmit.
Ptr< QosFrameExchangeManager > m_qosFem
the QoS Frame Exchange Manager
Ptr< const AttributeChecker > MakeBooleanChecker(void)
void SetFailedAddBaTimeout(Time failedAddBaTimeout)
Set the timeout for failed BA agreement.
Simulation virtual time values and global simulation resolution.
bool IsSuccess(void) const
Return whether the status code is success.
void PushFront(Ptr< const Packet > packet, const WifiMacHeader &hdr)
uint16_t m_blockAckInactivityTimeout
the BlockAck inactivity timeout value (in TUs, i.e.
Time GetAddBaResponseTimeout(void) const
Get the timeout for ADDBA response.
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Time m_txopDuration
the duration of a TXOP
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< const WifiMacQueueItem > PrepareBlockAckRequest(Mac48Address recipient, uint8_t tid) const
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void SetAddBaResponseTimeout(Time addBaResponseTimeout)
Set the timeout to wait for ADDBA response.
bool IsInWindow(uint16_t seq, uint16_t winstart, uint16_t winsize)
Time m_addBaResponseTimeout
timeout for ADDBA response
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
uint32_t GetMinCw(void) const override
Return the minimum contention window size from the EDCA Parameter Set or the MU EDCA Parameter Set,...
static Time Min()
Minimum representable Time Not to be confused with Min(Time,Time).
bool IsStrictlyNegative(void) const
Exactly equivalent to t < 0.
void DoDispose(void) override
Destructor implementation.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
bool IsQosOldPacket(Ptr< const WifiMacQueueItem > mpdu)
Check if the given MPDU is to be considered old according to the current starting sequence number of ...
AcIndex m_ac
the access category
Ptr< WifiMacQueueItem > GetNextMpdu(Ptr< const WifiMacQueueItem > peekedItem, WifiTxParameters &txParams, Time availableTime, bool initialFrame, WifiMacQueueItem::ConstIterator &queueIt)
Prepare the frame to transmit starting from the MPDU that has been previously peeked by calling PeekN...
uint32_t m_muCwMin
the MU CW minimum
Time Seconds(double value)
Construct a Time in the indicated unit.
@ WIFI_MAC_DROP_QOS_OLD_PACKET
void NotifyChannelReleased(void) override
Called by the FrameExchangeManager to notify the completion of the transmissions.
uint32_t GetMaxCw(void) const override
Return the maximum contention window size from the EDCA Parameter Set or the MU EDCA Parameter Set,...
Time m_muEdcaTimer
the MU EDCA Timer
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
void StartMuEdcaTimerNow(void)
Start the MU EDCA Timer.
void NotifyDiscardedMpdu(Ptr< const WifiMacQueueItem > mpdu)
void ScheduleBar(Ptr< const WifiMacQueueItem > bar, bool skipIfNoDataQueued=false)
Time m_startTxop
the start TXOP time
ChannelAccessStatus m_access
channel access status
bool EdcaDisabled(void) const
Return true if the EDCA is disabled (the MU EDCA Timer is running and the MU AIFSN is zero),...
BlockAckType GetBlockAckType(Mac48Address recipient, uint8_t tid) const
bool IsFragment(void) const
Return true if this item contains an MSDU fragment, false otherwise.
uint8_t m_blockAckThreshold
the block ack threshold (use BA mechanism if number of packets in queue reaches this value.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
bool MuEdcaTimerRunning(void) const
Return true if the MU EDCA Timer is running, false otherwise.
void CompleteMpduTx(Ptr< WifiMacQueueItem > mpdu)
Stores an MPDU (part of an A-MPDU) in block ack agreement (i.e.
bool IsQosTxop(void) const override
Check for QoS TXOP.
void SetMuAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS while the MU EDCA Timer is running.
static const ConstIterator EMPTY
Invalid iterator to signal an empty queue.
void SetMuCwMax(uint16_t cwMax)
Set the maximum contention window size to use while the MU EDCA Timer is running.
virtual bool IsTxopStarted(void) const
Return true if a TXOP has started.
Time GetFailedAddBaTimeout(void) const
Get the timeout for failed BA agreement.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
static TypeId GetTypeId(void)
Get the type ID.
TracedCallback< Time, Time > m_txopTrace
TXOP trace callback.
virtual Time GetRemainingTxop(void) const
Return the remaining duration in the current TXOP.
Handle packet fragmentation and retransmissions for data and management frames.