Manages all block ack agreements for an originator station. More...
#include <block-ack-manager.h>
Classes | |
struct | Item |
Public Member Functions | |
void | CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient) |
void | DestroyAgreement (Mac48Address recipient, uint8_t tid) |
bool | ExistsAgreement (Mac48Address recipient, uint8_t tid) const |
bool | ExistsAgreementInState (Mac48Address recipient, uint8_t tid, enum OriginatorBlockAckAgreement::State state) const |
uint32_t | GetNBufferedPackets (Mac48Address recipient, uint8_t tid) const |
Ptr< const Packet > | GetNextPacket (WifiMacHeader &hdr) |
uint32_t | GetNextPacketSize (void) const |
uint32_t | GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const |
uint16_t | GetSeqNumOfNextRetryPacket (Mac48Address recipient, uint8_t tid) const |
bool | HasBar (struct Bar &bar) |
bool | HasOtherFragments (uint16_t sequenceNumber) const |
bool | HasPackets (void) const |
void | NotifyAgreementEstablished (Mac48Address recipient, uint8_t tid, uint16_t startingSeq) |
void | NotifyAgreementUnsuccessful (Mac48Address recipient, uint8_t tid) |
void | NotifyGotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient) |
void | NotifyMpduTransmission (Mac48Address recipient, uint8_t tid, uint16_t nextSeqNumber) |
void | SetBlockAckInactivityCallback (Callback< void, Mac48Address, uint8_t, bool > callback) |
void | SetBlockAckThreshold (uint8_t nPackets) |
void | SetBlockAckType (enum BlockAckType bAckType) |
void | SetBlockDestinationCallback (Callback< void, Mac48Address, uint8_t > callback) |
void | SetMaxPacketDelay (Time maxDelay) |
void | SetQueue (Ptr< WifiMacQueue > queue) |
void | SetTxMiddle (MacTxMiddle *txMiddle) |
void | SetUnblockDestinationCallback (Callback< void, Mac48Address, uint8_t > callback) |
void | StorePacket (Ptr< const Packet > packet, const WifiMacHeader &hdr, Time tStamp) |
bool | SwitchToBlockAckIfNeeded (Mac48Address recipient, uint8_t tid, uint16_t startingSeq) |
void | TearDownBlockAck (Mac48Address recipient, uint8_t tid) |
void | UpdateAgreement (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient) |
Private Types | |
typedef std::map< std::pair < Mac48Address, uint8_t > , std::pair < OriginatorBlockAckAgreement, PacketQueue > > | Agreements |
typedef std::map< std::pair < Mac48Address, uint8_t > , std::pair < OriginatorBlockAckAgreement, PacketQueue > >::const_iterator | AgreementsCI |
typedef std::map< std::pair < Mac48Address, uint8_t > , std::pair < OriginatorBlockAckAgreement, PacketQueue > >::iterator | AgreementsI |
typedef std::list< Item > | PacketQueue |
typedef std::list< Item > ::const_iterator | PacketQueueCI |
typedef std::list< Item >::iterator | PacketQueueI |
Private Member Functions | |
BlockAckManager (const BlockAckManager &) | |
void | CleanupBuffers (void) |
void | InactivityTimeout (Mac48Address, uint8_t) |
BlockAckManager & | operator= (const BlockAckManager &) |
Ptr< Packet > | ScheduleBlockAckReqIfNeeded (Mac48Address recipient, uint8_t tid) |
Private Attributes | |
Mac48Address | m_address |
Agreements | m_agreements |
std::list< Bar > | m_bars |
Callback< void, Mac48Address, uint8_t, bool > | m_blockAckInactivityTimeout |
uint8_t | m_blockAckThreshold |
enum BlockAckType | m_blockAckType |
Callback< void, Mac48Address, uint8_t > | m_blockPackets |
Time | m_maxDelay |
Ptr< WifiMacQueue > | m_queue |
std::list< PacketQueueI > | m_retryPackets |
MacTxMiddle * | m_txMiddle |
Callback< void, Mac48Address, uint8_t > | m_unblockPackets |
Manages all block ack agreements for an originator station.
Definition at line 64 of file block-ack-manager.h.
|
private |
This method removes packets whose lifetime was exceeded.
Definition at line 592 of file block-ack-manager.cc.
References m_agreements, m_retryPackets, ns3::Simulator::Now(), and NS_LOG_FUNCTION.
Referenced by GetNextPacket().
void ns3::BlockAckManager::CreateAgreement | ( | const MgtAddBaRequestHeader * | reqHdr, |
Mac48Address | recipient | ||
) |
reqHdr | Relative Add block ack request (action frame). |
recipient | Address of peer station involved in block ack mechanism. |
Creates a new block ack agreement in pending state. When a ADDBA response with a successful status code is received, the relative agreement becomes established.
Definition at line 112 of file block-ack-manager.cc.
References m_agreements, and NS_LOG_FUNCTION.
void ns3::BlockAckManager::DestroyAgreement | ( | Mac48Address | recipient, |
uint8_t | tid | ||
) |
recipient | Address of peer station involved in block ack mechanism. |
tid | Tid Traffic id of transmitted packet. |
Invoked when a recipient reject a block ack agreement or when a Delba frame is Received/Transmitted.
Definition at line 139 of file block-ack-manager.cc.
References m_agreements, m_retryPackets, and NS_LOG_FUNCTION.
Referenced by TearDownBlockAck().
bool ns3::BlockAckManager::ExistsAgreement | ( | Mac48Address | recipient, |
uint8_t | tid | ||
) | const |
recipient | Address of peer station involved in block ack mechanism. |
tid | Traffic ID. |
Checks if a block ack agreement exists with station addressed by recipient for tid tid.
Definition at line 79 of file block-ack-manager.cc.
References m_agreements, and NS_LOG_FUNCTION.
Referenced by GetNBufferedPackets(), GetNRetryNeededPackets(), and SwitchToBlockAckIfNeeded().
bool ns3::BlockAckManager::ExistsAgreementInState | ( | Mac48Address | recipient, |
uint8_t | tid, | ||
enum OriginatorBlockAckAgreement::State | state | ||
) | const |
recipient | Address of peer station involved in block ack mechanism. |
tid | Traffic ID. |
state | The state for block ack agreement |
Checks if a block ack agreement with a state equals to state exists with station addressed by recipient for tid tid.
Definition at line 86 of file block-ack-manager.cc.
References m_agreements, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Referenced by GetNextPacket(), NotifyGotBlockAck(), and SwitchToBlockAckIfNeeded().
uint32_t ns3::BlockAckManager::GetNBufferedPackets | ( | Mac48Address | recipient, |
uint8_t | tid | ||
) | const |
recipient | Address of peer station involved in block ack mechanism. |
tid | Traffic ID. |
Returns number of packets buffered for a specified agreement. This methods doesn't return number of buffered MPDUs but number of buffered MSDUs.
Definition at line 280 of file block-ack-manager.cc.
References ExistsAgreement(), m_agreements, and NS_LOG_FUNCTION.
Referenced by SwitchToBlockAckIfNeeded().
Ptr< const Packet > ns3::BlockAckManager::GetNextPacket | ( | WifiMacHeader & | hdr | ) |
hdr | 802.11 header of returned packet (if exists). |
This methods returns a packet (if exists) indicated as not received in corresponding block ack bitmap.
Definition at line 221 of file block-ack-manager.cc.
References CleanupBuffers(), ExistsAgreementInState(), m_agreements, m_retryPackets, NS_LOG_FUNCTION, NS_LOG_INFO, and SwitchToBlockAckIfNeeded().
uint32_t ns3::BlockAckManager::GetNextPacketSize | ( | void | ) | const |
Returns size of the next packet that needs retransmission.
Definition at line 579 of file block-ack-manager.cc.
References ns3::Packet::GetSize(), m_retryPackets, and NS_LOG_FUNCTION.
uint32_t ns3::BlockAckManager::GetNRetryNeededPackets | ( | Mac48Address | recipient, |
uint8_t | tid | ||
) | const |
recipient | Address of peer station involved in block ack mechanism. |
tid | Traffic ID. |
Returns number of packets for a specific agreement that need retransmission. This method doesn't return number of MPDUs that need retransmission but number of MSDUs.
Definition at line 305 of file block-ack-manager.cc.
References ExistsAgreement(), m_retryPackets, and NS_LOG_FUNCTION.
Referenced by NotifyMpduTransmission(), and ScheduleBlockAckReqIfNeeded().
uint16_t ns3::BlockAckManager::GetSeqNumOfNextRetryPacket | ( | Mac48Address | recipient, |
uint8_t | tid | ||
) | const |
Returns the sequence number of the next retry packet for a specific agreement. If there are no packets that need retransmission for the specified agreement or the agreement doesn't exist the function returns 4096;
Definition at line 669 of file block-ack-manager.cc.
References m_retryPackets, and NS_LOG_FUNCTION.
Referenced by NotifyMpduTransmission().
bool ns3::BlockAckManager::HasOtherFragments | ( | uint16_t | sequenceNumber | ) | const |
sequenceNumber | Sequence number of the packet which fragment is part of. |
Returns true if another fragment with sequence number sequenceNumber is scheduled for retransmission.
Definition at line 563 of file block-ack-manager.cc.
References m_retryPackets, and NS_LOG_FUNCTION.
bool ns3::BlockAckManager::HasPackets | ( | void | ) | const |
Returns true if there are packets that need of retransmission or at least a BAR is scheduled. Returns false otherwise.
Definition at line 273 of file block-ack-manager.cc.
References m_retryPackets, and NS_LOG_FUNCTION.
void ns3::BlockAckManager::NotifyAgreementEstablished | ( | Mac48Address | recipient, |
uint8_t | tid, | ||
uint16_t | startingSeq | ||
) |
recipient | Address of peer station involved in block ack mechanism. |
tid | Traffic ID of transmitted packet. |
startingSeq | starting sequence field |
Puts corresponding agreement in established state and updates number of packets and starting sequence field. Invoked typically after a block ack refresh.
Definition at line 482 of file block-ack-manager.cc.
References m_agreements, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by SwitchToBlockAckIfNeeded().
void ns3::BlockAckManager::NotifyAgreementUnsuccessful | ( | Mac48Address | recipient, |
uint8_t | tid | ||
) |
recipient | Address of peer station involved in block ack mechanism. |
tid | Traffic ID of transmitted packet. |
Marks an agreement as unsuccessful. This happens if recipient station reject block ack setup by an ADDBAResponse frame with a failure status code. FOr now we assume that every QoS station accepts a block ack setup.
Definition at line 493 of file block-ack-manager.cc.
References m_agreements, NS_ASSERT, and NS_LOG_FUNCTION.
void ns3::BlockAckManager::NotifyGotBlockAck | ( | const CtrlBAckResponseHeader * | blockAck, |
Mac48Address | recipient | ||
) |
blockAck | The received block ack frame. |
recipient | Sender of block ack frame. |
Invoked upon receipt of a block ack frame. Typically, this function, is called by ns3::EdcaTxopN object. Performs a check on which MPDUs, previously sent with ack policy set to Block Ack, were correctly received by the recipient. An acknowledged MPDU is removed from the buffer, retransmitted otherwise.
Definition at line 338 of file block-ack-manager.cc.
References ExistsAgreementInState(), m_agreements, m_retryPackets, ns3::MicroSeconds(), NS_FATAL_ERROR, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and SwitchToBlockAckIfNeeded().
void ns3::BlockAckManager::NotifyMpduTransmission | ( | Mac48Address | recipient, |
uint8_t | tid, | ||
uint16_t | nextSeqNumber | ||
) |
recipient | Address of peer station involved in block ack mechanism. |
tid | Traffic ID of transmitted packet. |
nextSeqNumber | Sequence number of the next packet that would be trasmitted by EdcaTxopN. |
This method is typically invoked by ns3::EdcaTxopN object every time that a MPDU with ack policy subfield in Qos Control field set to Block Ack is transmitted. The nextSeqNumber parameter is used to block transmission of packets that are out of bitmap.
Definition at line 505 of file block-ack-manager.cc.
References GetNRetryNeededPackets(), GetSeqNumOfNextRetryPacket(), m_agreements, NS_ASSERT, NS_LOG_FUNCTION, and ScheduleBlockAckReqIfNeeded().
|
private |
Checks if all packets, for which a block ack agreement was established or refreshed, have been transmitted. If yes, adds a pair in m_bAckReqs to indicate that at next channel access a block ack request (for established agreement recipient,tid) is needed.
Definition at line 434 of file block-ack-manager.cc.
References ns3::Packet::AddHeader(), GetNRetryNeededPackets(), m_agreements, NS_ASSERT, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Referenced by NotifyMpduTransmission().
void ns3::BlockAckManager::SetBlockAckThreshold | ( | uint8_t | nPackets | ) |
nPackets | Minimum number of packets for use of block ack. |
Upon receipt of a block ack frame, if total number of packets (packets in WifiMacQueue and buffered packets) is greater of nPackets, they are transmitted using block ack mechanism.
Definition at line 331 of file block-ack-manager.cc.
References NS_LOG_FUNCTION.
void ns3::BlockAckManager::SetBlockAckType | ( | enum BlockAckType | bAckType | ) |
bAckType | Type of block ack |
See ctrl-headers.h for more details.
Definition at line 427 of file block-ack-manager.cc.
References NS_LOG_FUNCTION.
void ns3::BlockAckManager::SetMaxPacketDelay | ( | Time | maxDelay | ) |
maxDelay | Max delay for a buffered packet. |
This method is always called by ns3::WifiMacQueue object and sets max delay equals to ns3:WifiMacQueue delay value.
Definition at line 634 of file block-ack-manager.cc.
References NS_LOG_FUNCTION.
void ns3::BlockAckManager::SetQueue | ( | Ptr< WifiMacQueue > | queue | ) |
queue | The WifiMacQueue object. |
Definition at line 531 of file block-ack-manager.cc.
References NS_LOG_FUNCTION.
void ns3::BlockAckManager::StorePacket | ( | Ptr< const Packet > | packet, |
const WifiMacHeader & | hdr, | ||
Time | tStamp | ||
) |
packet | Packet to store. |
hdr | 802.11 header for packet. |
tStamp | time stamp for packet |
Stores packet for a possible future retransmission. Retransmission occurs if the packet, in a block ack frame, is indicated by recipient as not received.
Definition at line 206 of file block-ack-manager.cc.
References m_agreements, NS_ASSERT, and NS_LOG_FUNCTION.
bool ns3::BlockAckManager::SwitchToBlockAckIfNeeded | ( | Mac48Address | recipient, |
uint8_t | tid, | ||
uint16_t | startingSeq | ||
) |
Checks if there are in the queue other packets that could be send under block ack. If yes adds these packets in current block ack exchange. However, number of packets exchanged in the current block ack, will not exceed the value of BufferSize in the corresponding OriginatorBlockAckAgreement object.
Definition at line 538 of file block-ack-manager.cc.
References ExistsAgreement(), ExistsAgreementInState(), GetNBufferedPackets(), NotifyAgreementEstablished(), NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by GetNextPacket(), and NotifyGotBlockAck().
void ns3::BlockAckManager::TearDownBlockAck | ( | Mac48Address | recipient, |
uint8_t | tid | ||
) |
recipient | Address of station involved in block ack mechanism. |
tid | Traffic ID. |
This method is invoked by EdcaTxopN object upon receipt of a DELBA frame from recipient. The relative block ack agreement is destroyed.
Definition at line 556 of file block-ack-manager.cc.
References DestroyAgreement(), and NS_LOG_FUNCTION.
void ns3::BlockAckManager::UpdateAgreement | ( | const MgtAddBaResponseHeader * | respHdr, |
Mac48Address | recipient | ||
) |
respHdr | Relative Add block ack response (action frame). |
recipient | Address of peer station involved in block ack mechanism. |
Invoked upon receipt of a ADDBA response frame from recipient.
Definition at line 173 of file block-ack-manager.cc.
References m_agreements, ns3::MicroSeconds(), NS_LOG_FUNCTION, and ns3::Simulator::Schedule().
|
private |
This data structure contains, for each block ack agreement (recipient, tid), a set of packets for which an ack by block ack is requested. Every packet or fragment indicated as correctly received in block ack frame is erased from this data structure. Pushed back in retransmission queue otherwise.
Definition at line 296 of file block-ack-manager.h.
Referenced by CleanupBuffers(), CreateAgreement(), DestroyAgreement(), ExistsAgreement(), ExistsAgreementInState(), GetNBufferedPackets(), GetNextPacket(), NotifyAgreementEstablished(), NotifyAgreementUnsuccessful(), NotifyGotBlockAck(), NotifyMpduTransmission(), ScheduleBlockAckReqIfNeeded(), StorePacket(), and UpdateAgreement().
|
private |
This list contains all iterators to stored packets that need to be retransmitted. A packet needs retransmission if it's indicated as not correctly received in a block ack frame.
Definition at line 302 of file block-ack-manager.h.
Referenced by CleanupBuffers(), DestroyAgreement(), GetNextPacket(), GetNextPacketSize(), GetNRetryNeededPackets(), GetSeqNumOfNextRetryPacket(), HasOtherFragments(), HasPackets(), and NotifyGotBlockAck().