23 #include "ns3/assert.h" 
   24 #include "ns3/pointer.h" 
   40 #undef NS_LOG_APPEND_CONTEXT 
   41 #define NS_LOG_APPEND_CONTEXT if (m_low != 0) { std::clog << "[mac=" << m_low->GetAddress () << "] "; } 
  149     .AddAttribute (
"BlockAckThreshold", 
"If number of packets in this queue reaches this value,\ 
  150                                          block ack mechanism is used. If this value is 0, block ack is never used.",
 
  154                    MakeUintegerChecker<uint8_t> (0, 64))
 
  155     .AddAttribute (
"BlockAckInactivityTimeout", 
"Represents max time (blocks of 1024 micro seconds) allowed for block ack\ 
  156                                                  inactivity. If this value isn't equal to 0 a timer start after that a\ 
  157                                                  block ack setup is completed and will be reset every time that a block\ 
  158                                                  ack frame is received. If this value is 0, block ack inactivity timeout won't be used.",
 
  161                    MakeUintegerChecker<uint16_t> ())
 
  162     .AddAttribute (
"Queue", 
"The WifiMacQueue object",
 
  165                    MakePointerChecker<WifiMacQueue> ())
 
  180   m_queue = CreateObject<WifiMacQueue> ();
 
  438           m_low->StartTransmission (fragment, &hdr, params,
 
  451               Ptr<Packet> currentAggregatedPacket = Create<Packet> ();
 
  455               bool aggregated = 
false;
 
  456               bool isAmsdu = 
false;
 
  460               while (peekedPacket != 0)
 
  462                   aggregated = 
m_aggregator->Aggregate (peekedPacket, currentAggregatedPacket,
 
  468                       m_queue->Remove (peekedPacket);
 
  482                   currentAggregatedPacket = 0;
 
  565                                      packet, fullPacketSize);
 
  566   m_queue->Enqueue (packet, hdr);
 
  753   NS_LOG_DEBUG (
"a transmission that did not require an ACK just finished");
 
  875                                      packet, fullPacketSize);
 
  876   m_queue->PushFront (packet, hdr);
 
  884   NS_LOG_DEBUG (
"received ADDBA response from " << recipient);
 
  885   uint8_t tid = respHdr->
GetTid ();
 
  890           NS_LOG_DEBUG (
"block ack agreement established with " << recipient);
 
  906   NS_LOG_DEBUG (
"received DELBA frame from=" << recipient);
 
 1051                              uint16_t 
timeout, 
bool immediateBAck)
 
 1053   NS_LOG_FUNCTION (
this << dest << static_cast<uint32_t> (tid) << startSeq << timeout << immediateBAck);
 
 1074       reqHdr.SetImmediateBlockAck ();
 
 1078       reqHdr.SetDelayedBlockAck ();
 
 1080   reqHdr.SetTid (tid);
 
 1084   reqHdr.SetBufferSize (0);
 
 1085   reqHdr.SetTimeout (timeout);
 
 1086   reqHdr.SetStartingSequence (startSeq);
 
 1115   NS_LOG_FUNCTION (
this << addr << static_cast<uint32_t> (tid) << byOriginator);
 
Keep track of destination address - TID pairs that are waiting for a block ACK response. 
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer. 
void SetUnblockDestinationCallback(Callback< void, Mac48Address, uint8_t > callback)
virtual void SetMaxCw(uint32_t maxCw)
Set the maximum congestion window size. 
TransmissionListener * m_transmissionListener
Ptr< const Packet > m_currentPacket
smart pointer class similar to boost::intrusive_ptr 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void DoInitialize()
This method is called only once by Object::Initialize. 
TypeId AddConstructor(void)
TxFailed m_txFailedCallback
void SetBlockAckInactivityTimeout(uint16_t timeout)
uint32_t GetCwMin(void) const 
Return the minimum congestion window size. 
uint32_t GetFragmentSize(void)
Calculate the size of the current fragment. 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory. 
void NotifyGotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient)
uint16_t m_blockAckInactivityTimeout
void CreateAgreement(const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient)
void VerifyBlockAck(void)
Verifies if dequeued packet has to be transmitted with ack policy Block Ack. 
void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient)
Event handler when a Block ACK is received. 
void NotifyCollision(void)
Notify the EDCAF that collision has occurred. 
void SetTypeOfStation(enum TypeOfStation type)
Set type of station with the given type. 
void EnableBasicBlockAck(void)
Wait BASICBLOCKACKTimeout for a Basic Block Ack Response frame. 
void StorePacket(Ptr< const Packet > packet, const WifiMacHeader &hdr, Time tStamp)
bool NeedDataRetransmission(void)
Check if DATA should be re-transmitted if ACK was missed. 
void RequestAccess(DcfState *state)
virtual void EndTxNoAck(void)
Invoked upon the end of the transmission of a frame that does not require an ACK (e.g., broadcast and multicast frames). 
void SetTxFailedCallback(TxFailed callback)
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received. 
BlockAckEventListener(EdcaTxopN *txop)
bool IsNull(void) const 
Check for null implementation. 
virtual void MissedBlockAck(void)
ns3::MacLow did not receive an expected BLOCK_ACK within BlockAckTimeout. 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
virtual int64_t AssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
uint8_t m_blockAckThreshold
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this EdcaTxopN is associated to. 
bool HasBar(struct Bar &bar)
uint32_t GetSize(void) const 
Returns the the size in bytes of the packet (including the zero-filled initial payload). 
bool IsBroadcast(void) const 
void SetBlockAckType(enum BlockAckType bAckType)
WifiMacHeader m_currentHdr
#define NS_FATAL_ERROR(msg)
fatal error handling 
void SetAifsn(uint32_t aifsn)
virtual void Cancel(void)
Invoked if this transmission was canceled one way or another. 
bool HasPackets(void) const 
Returns true if there are packets that need of retransmission or at least a BAR is scheduled...
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
virtual void BlockAckInactivityTimeout(Mac48Address address, uint8_t tid)
Typically is called in order to notify EdcaTxopN that a block ack inactivity timeout occurs for the b...
friend class TransmissionListener
listen to events coming from ns3::MacLow. 
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
virtual void MissedAck(void)
ns3::MacLow did not receive an expected ACK within AckTimeout. 
void NextFragment(void)
Continue to the next fragment. 
void SetTxOkCallback(TxOk callback)
BlockAckManager * m_baManager
control how a packet is transmitted. 
bool NeedRtsRetransmission(void)
Check if RTS should be re-transmitted if CTS was missed. 
virtual void DoNotifyChannelSwitching(void)
Called by DcfManager to notify a DcfState subclass that a channel switching occured. 
virtual uint32_t GetAifsn(void) const 
Return the number of slots that make up an AIFS. 
Handles sequence numbering of IEEE 802.11 data frames. 
virtual void DoNotifyCollision(void)
Called by DcfManager to notify a DcfState subclass that a normal collision occured, that is, that the medium was busy when access was requested. 
void MissedAck(void)
Event handler when an ACK is received. 
enum TypeOfStation GetTypeOfStation(void) const 
Return type of station. 
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this EdcaTxopN. 
Ptr< MacLow > Low(void)
Return the MacLow associated with this EdcaTxopN. 
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const 
Create a new packet which contains a fragment of the original packet. 
Ptr< WifiRemoteStationManager > m_stationManager
This queue contains packets for a particular access class. 
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
void SetQueue(Ptr< WifiMacQueue > queue)
void NotifyAccessGranted(void)
Notify the EDCAF that access has been granted. 
void NotifyInternalCollision(void)
Notify the EDCAF that internal collision has occurred. 
void UpdateAgreement(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
virtual void SetMinCw(uint32_t minCw)
Set the minimum congestion window size. 
void SendAddBaRequest(Mac48Address recipient, uint8_t tid, uint16_t startSeq, uint16_t timeout, bool immediateBAck)
Sends an ADDBARequest to establish a block ack agreement with sta addressed by recipient for tid tid...
void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator)
virtual void GotAck(double snr, WifiMode txMode)
Hold an unsigned integer type. 
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ACK mechanism. 
void NotifyAgreementUnsuccessful(Mac48Address recipient, uint8_t tid)
void MissedCts(void)
Event handler when a CTS timeout has occurred. 
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
keep track of the state needed for a single DCF function. 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed. 
void SetTxMiddle(MacTxMiddle *txMiddle)
bool IsAccessRequested(void) const 
void SetBlockDestinationCallback(Callback< void, Mac48Address, uint8_t > callback)
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment. 
virtual void StartNext(void)
Invoked when ns3::MacLow wants to start a new transmission as configured by MacLowTransmissionParamet...
Time m_currentPacketTimestamp
uint32_t GetCwMax(void) const 
Return the maximum congestion window size. 
void SetCwMin(uint32_t minCw)
Set the minimum congestion window size. 
virtual void GotCts(double snr, WifiMode txMode)
Ptr< Packet > Copy(void) const 
performs a COW copy of the packet. 
uint32_t PeekHeader(Header &header) const 
Deserialize but does not remove the header from the internal buffer. 
virtual uint32_t GetMinCw(void) const 
Return the minimum congestion window size. 
void MissedBlockAck(void)
Event handler when a Block ACK timeout has occurred. 
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed. 
void StartBackoffNow(uint32_t nSlots)
bool NeedFragmentation(void) const 
Check if the current packet should be fragmented. 
void EnableCompressedBlockAck(void)
Wait COMPRESSEDBLOCKACKTimeout for a Compressed Block Ack Response frame. 
virtual void MissedCts(void)
ns3::MacLow did not receive an expected CTS within CtsTimeout. 
uint16_t GetNextSequenceNumberfor(const WifiMacHeader *hdr)
Return the next sequence number for the given header. 
Ptr< MsduAggregator > GetMsduAggregator(void) const 
listen for block ack events. 
void SetAccessCategory(enum AcIndex ac)
Set the access category of this EDCAF. 
void EnableAck(void)
Wait ACKTimeout for an ACK. 
Mac48Address MapDestAddressForAggregation(const WifiMacHeader &hdr)
bool ExistsAgreementInState(Mac48Address recipient, uint8_t tid, enum OriginatorBlockAckAgreement::State state) const 
bool SetupBlockAckIfNeeded()
If number of packets in the queue reaches m_blockAckThreshold value, an ADDBARequest frame is sent to...
virtual ~TransmissionListener()
void StartNext(void)
Start transmission for the next fragment. 
Ptr< const Packet > GetNextPacket(WifiMacHeader &hdr)
void Cancel(void)
Cancel the transmission. 
void SetManager(DcfManager *manager)
Set DcfManager this EdcaTxopN is associated to. 
void DisableRts(void)
Do not send rts and wait for cts before sending data. 
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
void SetMsduAggregator(Ptr< MsduAggregator > aggr)
void SetBlockAckInactivityCallback(Callback< void, Mac48Address, uint8_t, bool > callback)
void SetMaxPacketDelay(Time maxDelay)
void PushFront(Ptr< const Packet > packet, const WifiMacHeader &hdr)
bool SwitchToBlockAckIfNeeded(Mac48Address recipient, uint8_t tid, uint16_t startingSeq)
enum BlockAckType m_blockAckType
void SetCwMax(uint32_t maxCw)
Set the maximum congestion window size. 
virtual void DoNotifyAccessGranted(void)
Called by DcfManager to notify a DcfState subclass that access to the medium is granted and can start...
static TypeId GetTypeId(void)
BlockAckEventListener * m_blockAckListener
static TypeId GetTypeId(void)
uint32_t GetNextFragmentSize(void)
Calculate the size of the next fragment. 
void EnableRts(void)
Send a RTS, and wait CTSTimeout for a CTS. 
void CompleteConfig(void)
Complete block ACK configuration. 
uint32_t GetCw(void) const 
uint32_t GetAifsn(void) const 
Return the number of slots that make up an AIFS. 
void Unblock(Mac48Address dest, uint8_t tid)
Un-block the given destination address and TID (e.g. 
void RestartAccessIfNeeded(void)
Restart access request if needed. 
void SetBlockAckThreshold(uint8_t nPackets)
QosBlockedDestinations * m_qosBlockedDestinations
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
virtual ~BlockAckEventListener()
uint8_t GetBlockAckThreshold(void) const 
Return the current threshold for block ACK mechanism. 
void CompleteTx(void)
For now is typically invoked to complete transmission of a packets sent with ack policy Block Ack: th...
bool IsSuccess(void) const 
Return whether the status code is success. 
void SetTxMiddle(MacTxMiddle *txMiddle)
void GotCts(double snr, WifiMode txMode)
Event handler when a CTS is received. 
void EnableNextData(uint32_t size)
void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
void DisableOverrideDurationId(void)
Do not force the duration/id field of the packet: its value is automatically calculated by the MacLow...
bool IsLastFragment(void) const 
Check if the curren fragment is the last fragment. 
void Block(Mac48Address dest, uint8_t tid)
Block the given destination address and TID from sending (e.g. 
void DisableNextData(void)
Do not attempt to send data burst after current transmission. 
virtual uint32_t GetMaxCw(void) const 
Return the maximum congestion window size. 
Ptr< WifiMacQueue > m_queue
void StartAccessIfNeeded(void)
Request access from DCF manager if needed. 
virtual uint32_t GetNext(uint32_t min, uint32_t max)=0
Get integer between min and max (including min and max). 
bool NeedRts(void)
Check if the current packet should be sent with a RTS protection. 
void SendBlockAckRequest(const struct Bar &bar)
After that all packets, for which a block ack agreement was established, have been transmitted...
TypeOfStation
Enumeration for type of station. 
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure. 
Ptr< MsduAggregator > m_aggregator
Manages all block ack agreements for an originator station. 
bool ExistsAgreement(Mac48Address recipient, uint8_t tid) const 
virtual void DoNotifyInternalCollision(void)
Called by DcfManager to notify a DcfState subclass that an 'internal' collision occured, that is, that the backoff timer of a higher priority DcfState expired at the same time and that access was granted to this higher priority DcfState. 
void DisableAck(void)
Do not wait for Ack after data transmission. 
TransmissionListener(EdcaTxopN *txop)
Ptr< WifiMacQueue > GetQueue() const 
Return the packet queue associated with this EdcaTxopN. 
uint16_t GetNextSeqNumberByTidAndAddress(uint8_t tid, Mac48Address addr) const 
Return the next sequence number for the Traffic ID and destination. 
a unique identifier for an interface. 
bool NeedsAccess(void) const 
Check if the EDCAF requires access. 
TypeId SetParent(TypeId tid)
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
uint32_t GetFragmentOffset(void)
Calculate the offset for the current fragment. 
void NotifyMpduTransmission(Mac48Address recipient, uint8_t tid, uint16_t nextSeqNumber)
void AddHeader(const Header &header)
Add header to this packet. 
virtual void DoInitialize(void)
This method is called only once by Object::Initialize. 
void GotAddBaResponse(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
void TearDownBlockAck(Mac48Address recipient, uint8_t tid)
Implements the IEEE 802.11 MAC trailer. 
virtual void SetAifsn(uint32_t aifsn)
TypeOfStation m_typeOfStation
Mac48Address MapSrcAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set addresses in a-msdu subframe. 
virtual uint32_t GetSerializedSize(void) const 
virtual void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address source)