handle RTS/CTS/DATA/ACK transactions. More...
#include <mac-low.h>
Public Types | |
typedef Callback< void, Ptr < Packet >, const WifiMacHeader * > | MacLowRxCallback |
Public Member Functions | |
Time | CalculateTransmissionTime (Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters ¶meters) const |
void | CreateBlockAckAgreement (const MgtAddBaResponseHeader *respHdr, Mac48Address originator, uint16_t startingSeq) |
void | DestroyBlockAckAgreement (Mac48Address originator, uint8_t tid) |
Time | GetAckTimeout (void) const |
Mac48Address | GetAddress (void) const |
Time | GetBasicBlockAckTimeout () const |
Mac48Address | GetBssid (void) const |
Time | GetCompressedBlockAckTimeout () const |
Time | GetCtsTimeout (void) const |
Ptr< WifiPhy > | GetPhy (void) |
Time | GetPifs (void) const |
Time | GetSifs (void) const |
Time | GetSlotTime (void) const |
bool | IsRxRadio (void) |
bool | IsTxRadio (void) |
void | NotifySensingStartNow (Time duration) |
void | NotifySwitchingStartNow (Time duration) |
void | ReceiveError (Ptr< const Packet > packet, double rxSnr) |
void | ReceiveOk (Ptr< Packet > packet, double rxSnr, WifiMode txMode, WifiPreamble preamble) |
void | RegisterBlockAckListenerForAc (enum AcIndex ac, MacLowBlockAckEventListener *listener) |
void | RegisterDcfListener (MacLowDcfListener *listener) |
void | SetAckTimeout (Time ackTimeout) |
void | SetAddress (Mac48Address ad) |
void | SetBasicBlockAckTimeout (Time blockAckTimeout) |
void | SetBssid (Mac48Address ad) |
void | SetCompressedBlockAckTimeout (Time blockAckTimeout) |
void | SetCtsTimeout (Time ctsTimeout) |
void | SetPhy (Ptr< WifiPhy > phy) |
void | SetPifs (Time pifs) |
void | SetPromisc (void) |
void | SetRxCallback (Callback< void, Ptr< Packet >, const WifiMacHeader * > callback) |
void | SetRxRadio (bool isRx) |
void | SetSifs (Time sifs) |
void | SetSlotTime (Time slotTime) |
void | SetTxRadio (bool isTx) |
void | SetWifiRemoteStationManager (Ptr< WifiRemoteStationManager > manager) |
void | StartTransmission (Ptr< const Packet > packet, const WifiMacHeader *hdr, MacLowTransmissionParameters parameters, MacLowTransmissionListener *listener) |
Public Member Functions inherited from ns3::Object | |
void | AggregateObject (Ptr< Object > other) |
void | Dispose (void) |
AggregateIterator | GetAggregateIterator (void) const |
virtual TypeId | GetInstanceTypeId (void) const |
template<typename T > | |
Ptr< T > | GetObject (void) const |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
void | Initialize (void) |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount (const SimpleRefCount &o) | |
uint32_t | GetReferenceCount (void) const |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
void | Ref (void) const |
void | Unref (void) const |
Public Member Functions inherited from ns3::ObjectBase | |
void | GetAttribute (std::string name, AttributeValue &value) const |
bool | GetAttributeFailSafe (std::string name, AttributeValue &attribute) const |
void | SetAttribute (std::string name, const AttributeValue &value) |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Private Types | |
typedef std::pair < Mac48Address, uint8_t > | AgreementKey |
typedef std::map< AgreementKey, AgreementValue > | Agreements |
typedef std::map< AgreementKey, AgreementValue >::iterator | AgreementsI |
typedef std::pair < BlockAckAgreement, std::list < BufferedPacket > > | AgreementValue |
typedef std::map< AgreementKey, BlockAckCache > | BlockAckCaches |
typedef std::map< AgreementKey, BlockAckCache >::iterator | BlockAckCachesI |
typedef std::pair< Ptr< Packet > , WifiMacHeader > | BufferedPacket |
typedef std::list < BufferedPacket >::iterator | BufferedPacketI |
typedef std::vector < MacLowDcfListener * > | DcfListeners |
typedef std::vector < MacLowDcfListener * > ::const_iterator | DcfListenersCI |
typedef std::map< AcIndex, MacLowBlockAckEventListener * > | QueueListeners |
Private Member Functions | |
void | BlockAckTimeout (void) |
Time | CalculateOverallTxTime (Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters ¶ms) const |
void | CancelAllEvents (void) |
void | CtsTimeout (void) |
virtual void | DoDispose (void) |
void | DoNavResetNow (Time duration) |
bool | DoNavStartNow (Time duration) |
void | EndTxNoAck (void) |
void | FastAckFailedTimeout (void) |
void | FastAckTimeout (void) |
void | ForwardDown (Ptr< const Packet > packet, const WifiMacHeader *hdr, WifiMode txMode) |
Time | GetAckDuration (Mac48Address to, WifiMode dataTxMode) const |
uint32_t | GetAckSize (void) const |
WifiMode | GetAckTxModeForData (Mac48Address to, WifiMode dataTxMode) const |
Time | GetBlockAckDuration (Mac48Address to, WifiMode blockAckReqTxMode, enum BlockAckType type) const |
uint32_t | GetBlockAckSize (enum BlockAckType type) const |
Time | GetCtsDuration (Mac48Address to, WifiMode rtsTxMode) const |
uint32_t | GetCtsSize (void) const |
WifiMode | GetCtsTxModeForRts (Mac48Address to, WifiMode rtsTxMode) const |
WifiMode | GetDataTxMode (Ptr< const Packet > packet, const WifiMacHeader *hdr) const |
uint32_t | GetRtsSize (void) const |
WifiMode | GetRtsTxMode (Ptr< const Packet > packet, const WifiMacHeader *hdr) const |
uint32_t | GetSize (Ptr< const Packet > packet, const WifiMacHeader *hdr) const |
bool | IsNavZero (void) const |
void | MaybeCancelPrevious (void) |
void | NavCounterResetCtsMissed (Time rtsEndRxTime) |
void | NormalAckTimeout (void) |
void | NotifyAckTimeoutResetNow () |
void | NotifyAckTimeoutStartNow (Time duration) |
void | NotifyCtsTimeoutResetNow () |
void | NotifyCtsTimeoutStartNow (Time duration) |
void | NotifyNav (const WifiMacHeader &hdr, WifiMode txMode, WifiPreamble preamble) |
Time | NowUs (void) const |
void | ResetBlockAckInactivityTimerIfNeeded (BlockAckAgreement &agreement) |
void | RxCompleteBufferedPacketsUntilFirstLost (Mac48Address originator, uint8_t tid) |
void | RxCompleteBufferedPacketsWithSmallerSequence (uint16_t seq, Mac48Address originator, uint8_t tid) |
void | SendAckAfterData (Mac48Address source, Time duration, WifiMode txMode, double rtsSnr) |
void | SendBlockAckAfterBlockAckRequest (const CtrlBAckRequestHeader reqHdr, Mac48Address originator, Time duration, WifiMode blockAckReqTxMode) |
void | SendBlockAckResponse (const CtrlBAckResponseHeader *blockAck, Mac48Address originator, bool immediate, Time duration, WifiMode blockAckReqTxMode) |
void | SendCtsAfterRts (Mac48Address source, Time duration, WifiMode txMode, double rtsSnr) |
void | SendCurrentTxPacket (void) |
void | SendDataAfterCts (Mac48Address source, Time duration, WifiMode txMode) |
void | SendDataPacket (void) |
void | SendRtsForPacket (void) |
void | SetupPhyMacLowListener (Ptr< WifiPhy > phy) |
void | StartDataTxTimers (void) |
bool | StoreMpduIfNeeded (Ptr< Packet > packet, WifiMacHeader hdr) |
void | SuperFastAckTimeout (void) |
void | WaitSifsAfterEndTx (void) |
Private Attributes | |
Time | m_ackTimeout |
Agreements | m_bAckAgreements |
BlockAckCaches | m_bAckCaches |
Time | m_basicBlockAckTimeout |
EventId | m_blockAckTimeoutEvent |
Mac48Address | m_bssid |
Time | m_compressedBlockAckTimeout |
Time | m_ctsTimeout |
EventId | m_ctsTimeoutEvent |
WifiMacHeader | m_currentHdr |
Ptr< Packet > | m_currentPacket |
DcfListeners | m_dcfListeners |
QueueListeners | m_edcaListeners |
EventId | m_endTxNoAckEvent |
EventId | m_fastAckFailedTimeoutEvent |
EventId | m_fastAckTimeoutEvent |
Time | m_lastNavDuration |
Time | m_lastNavStart |
MacLowTransmissionListener * | m_listener |
EventId | m_navCounterResetCtsMissed |
EventId | m_normalAckTimeoutEvent |
Ptr< WifiPhy > | m_phy |
class PhyMacLowListener * | m_phyMacLowListener |
Time | m_pifs |
bool | m_promisc |
bool | m_rx |
MacLowRxCallback | m_rxCallback |
Mac48Address | m_self |
EventId | m_sendAckEvent |
EventId | m_sendCtsEvent |
EventId | m_sendDataEvent |
Time | m_sifs |
Time | m_slotTime |
Ptr< WifiRemoteStationManager > | m_stationManager |
EventId | m_superFastAckTimeoutEvent |
bool | m_tx |
MacLowTransmissionParameters | m_txParams |
EventId | m_waitSifsEvent |
Additional Inherited Members | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId (void) |
Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
static void | Cleanup (void) |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId (void) |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
virtual void | DoInitialize (void) |
virtual void | NotifyNewAggregate (void) |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
virtual void | NotifyConstructionCompleted (void) |
Time ns3::MacLow::CalculateTransmissionTime | ( | Ptr< const Packet > | packet, |
const WifiMacHeader * | hdr, | ||
const MacLowTransmissionParameters & | parameters | ||
) | const |
packet | to send (does not include the 802.11 MAC header and checksum) |
hdr | header associated to the packet to send. |
parameters | transmission parameters of packet. |
This transmission time includes the time required for the next packet transmission if one was selected.
Definition at line 1015 of file mac-low.cc.
References ns3::WifiPhy::CalculateTxDuration(), ns3::MacLowTransmissionParameters::GetNextPacketSize(), and ns3::MacLowTransmissionParameters::HasNextPacket().
void ns3::MacLow::CreateBlockAckAgreement | ( | const MgtAddBaResponseHeader * | respHdr, |
Mac48Address | originator, | ||
uint16_t | startingSeq | ||
) |
respHdr | Add block ack response from originator (action frame). |
originator | Address of peer station involved in block ack mechanism. |
startingSeq | Sequence number of the first MPDU of all packets for which block ack was negotiated. |
This function is typically invoked only by ns3::RegularWifiMac when the STA (which may be non-AP in ESS, or in an IBSS) has received an ADDBA Request frame and is transmitting an ADDBA Response frame. At this point MacLow must allocate buffers to collect all correctly received packets belonging to the category for which Block Ack was negotiated.
Definition at line 1542 of file mac-low.cc.
References ns3::MacLowBlockAckEventListener::BlockAckInactivityTimeout(), ns3::MicroSeconds(), ns3::QosUtilsMapTidToAc(), and ns3::Simulator::Schedule().
void ns3::MacLow::DestroyBlockAckAgreement | ( | Mac48Address | originator, |
uint8_t | tid | ||
) |
originator | Address of peer participating in Block Ack mechanism. |
tid | TID for which Block Ack was created. |
Checks if exists an established block ack agreement with originator for tid tid. If the agreement exists, tears down it. This function is typically invoked when a DELBA frame is received from originator.
Definition at line 1584 of file mac-low.cc.
References NS_ASSERT, RxCompleteBufferedPacketsUntilFirstLost(), and RxCompleteBufferedPacketsWithSmallerSequence().
|
privatevirtual |
This method is called by Object::Dispose or by the object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.
It is safe to call GetObject from within this method.
Reimplemented from ns3::Object.
Definition at line 326 of file mac-low.cc.
References ns3::EventId::Cancel(), and NS_LOG_FUNCTION.
|
private |
A STA that used information from an RTS frame as the most recent basis to update its NAV setting is permitted to reset its NAV if no PHY-RXSTART.indication is detected from the PHY during a period with a duration of (2 * aSIFSTime) + (CTS_Time) + (2 * aSlotTime) starting at the PHY-RXEND.indication corresponding to the detection of the RTS frame. The “CTS_Time” shall be calculated using the length of the CTS frame and the data rate at which the RTS frame used for the most recent NAV update was received.
Definition at line 1030 of file mac-low.cc.
References ns3::WifiPhy::CalculateTxDuration(), ns3::WifiMacHeader::GetSerializedSize(), ns3::Simulator::Now(), NS_ASSERT, and ns3::Simulator::Schedule().
Referenced by ReceiveOk().
void ns3::MacLow::NotifySensingStartNow | ( | Time | duration | ) |
duration | sensing delay duration |
When channel sensing occurs, pending mac transmissions are canceled
Definition at line 616 of file mac-low.cc.
References ns3::EventId::Cancel(), ns3::EventId::IsRunning(), ns3::Simulator::Now(), NS_LOG_DEBUG, and ns3::Seconds().
Referenced by ns3::PhyMacLowListener::NotifySensingStart().
void ns3::MacLow::NotifySwitchingStartNow | ( | Time | duration | ) |
duration | switching delay duration. |
This method is typically invoked by the PhyMacLowListener to notify the MAC layer that a channel switching occured. When a channel switching occurs, pending MAC transmissions (RTS, CTS, DATA and ACK) are cancelled.
Definition at line 600 of file mac-low.cc.
References ns3::EventId::Cancel(), ns3::EventId::IsRunning(), ns3::Simulator::Now(), NS_LOG_DEBUG, and ns3::Seconds().
Referenced by ns3::PhyMacLowListener::NotifySwitchingStart().
packet | packet received. |
rxSnr | snr of packet received. |
This method is typically invoked by the lower PHY layer to notify the MAC layer that a packet was unsuccessfully received.
Definition at line 586 of file mac-low.cc.
References ns3::EventId::IsExpired(), ns3::MacLowTransmissionParameters::MustWaitFastAck(), NS_ASSERT, NS_LOG_DEBUG, NS_LOG_FUNCTION, and ns3::Simulator::Schedule().
void ns3::MacLow::ReceiveOk | ( | Ptr< Packet > | packet, |
double | rxSnr, | ||
WifiMode | txMode, | ||
WifiPreamble | preamble | ||
) |
packet | packet received |
rxSnr | snr of packet received |
txMode | transmission mode of packet received |
preamble | type of preamble used for the packet received |
This method is typically invoked by the lower PHY layer to notify the MAC layer that a packet was successfully received.
Definition at line 632 of file mac-low.cc.
References ns3::EventId::Cancel(), ns3::MacLowTransmissionListener::GotAck(), ns3::MacLowTransmissionListener::GotBlockAck(), ns3::MacLowTransmissionListener::GotCts(), ns3::MacLowTransmissionParameters::HasNextPacket(), ns3::EventId::IsExpired(), ns3::Mac48Address::IsGroup(), ns3::EventId::IsRunning(), ns3::MacLowTransmissionParameters::MustWaitAck(), ns3::MacLowTransmissionParameters::MustWaitBasicBlockAck(), ns3::MacLowTransmissionParameters::MustWaitCompressedBlockAck(), ns3::MacLowTransmissionParameters::MustWaitFastAck(), ns3::MacLowTransmissionParameters::MustWaitNormalAck(), NotifyNav(), NS_ASSERT, NS_FATAL_ERROR, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::QosUtilsMapTidToAc(), ns3::Packet::RemoveHeader(), ns3::Packet::RemovePacketTag(), ns3::Packet::RemoveTrailer(), RxCompleteBufferedPacketsUntilFirstLost(), RxCompleteBufferedPacketsWithSmallerSequence(), and ns3::Simulator::Schedule().
void ns3::MacLow::RegisterBlockAckListenerForAc | ( | enum AcIndex | ac, |
MacLowBlockAckEventListener * | listener | ||
) |
ac | Access class managed by the queue. |
listener | The listener for the queue. |
The lifetime of the registered listener is typically equal to the lifetime of the queue associated to this AC.
Definition at line 1820 of file mac-low.cc.
void ns3::MacLow::RegisterDcfListener | ( | MacLowDcfListener * | listener | ) |
listener | listen to NAV events for every incoming and outgoing packet. |
Definition at line 534 of file mac-low.cc.
|
private |
originator | Address of peer participating in Block Ack mechanism. |
tid | TID for which Block Ack was created. |
This method is typically invoked when a MPDU with ack policy subfield set to Normal Ack is received and a block ack agreement for that packet exists. This happens when the originator of block ack has only few MPDUs to send. All completed MSDUs starting with starting sequence number of block ack agreement are forward up to WifiMac until there is an incomplete or missing MSDU. See section 9.10.4 in IEEE802.11 standard for more details.
Definition at line 1660 of file mac-low.cc.
Referenced by DestroyBlockAckAgreement(), and ReceiveOk().
|
private |
originator | Address of peer participating in Block Ack mechanism. |
tid | TID for which Block Ack was created. |
seq | Starting sequence |
This function forward up all completed "old" packets with sequence number smaller than seq. All comparison are performed circularly mod 4096.
Definition at line 1600 of file mac-low.cc.
References ns3::QosUtilsMapSeqControlToUniqueInteger().
Referenced by DestroyBlockAckAgreement(), and ReceiveOk().
void ns3::MacLow::SetRxCallback | ( | Callback< void, Ptr< Packet >, const WifiMacHeader * > | callback | ) |
callback | the callback which receives every incoming packet. |
This callback typically forwards incoming packets to an instance of ns3::MacRxMiddle.
Definition at line 529 of file mac-low.cc.
void ns3::MacLow::StartTransmission | ( | Ptr< const Packet > | packet, |
const WifiMacHeader * | hdr, | ||
MacLowTransmissionParameters | parameters, | ||
MacLowTransmissionListener * | listener | ||
) |
packet | packet to send |
hdr | 802.11 header for packet to send |
parameters | the transmission parameters to use for this packet. |
listener | listen to transmission events. |
Start the transmission of the input packet and notify the listener of transmission events.
Definition at line 541 of file mac-low.cc.
References ns3::Packet::Copy(), ns3::WifiPhy::IsStateTx(), ns3::MacLowTransmissionParameters::MustSendRts(), NS_ASSERT, NS_LOG_DEBUG, and NS_LOG_FUNCTION.