A Discrete-Event Network Simulator
API
edca-txop-n.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006, 2009 INRIA
4  * Copyright (c) 2009 MIRKO BANCHI
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Mirko Banchi <mk.banchi@gmail.com>
21  */
22 
23 #ifndef EDCA_TXOP_N_H
24 #define EDCA_TXOP_N_H
25 
26 #include "ns3/traced-value.h"
27 #include "block-ack-manager.h"
28 #include "dca-txop.h"
29 
31 
32 namespace ns3 {
33 
34 class QosBlockedDestinations;
35 class MsduAggregator;
36 class MpduAggregator;
37 class MgtAddBaResponseHeader;
38 class MgtDelBaHeader;
39 class AggregationCapableTransmissionListener;
40 
45 {
46  STA,
47  AP,
54 };
55 
68 class EdcaTxopN : public DcaTxop
69 {
70 public:
72  friend class ::AmpduAggregationTest;
73 
74  std::map<Mac48Address, bool> m_aMpduEnabled;
75 
80  static TypeId GetTypeId (void);
81 
82  EdcaTxopN ();
83  virtual ~EdcaTxopN ();
84 
90  bool IsEdca ();
91 
103  void SetTypeOfStation (TypeOfStation type);
109  TypeOfStation GetTypeOfStation (void) const;
110 
123 
133  bool GetBaAgreementExists (Mac48Address address, uint8_t tid) const;
142  uint32_t GetNOutstandingPacketsInBa (Mac48Address address, uint8_t tid) const;
151  uint32_t GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const;
159  void CompleteAmpduTransfer (Mac48Address recipient, uint8_t tid);
160 
161  /* dcf notifications forwarded here */
168  bool NeedsAccess (void) const;
172  void NotifyAccessGranted (void);
176  void NotifyInternalCollision (void);
180  void NotifyCollision (void);
181 
182  /* Event handlers */
186  void MissedCts (void);
190  void GotAck (void);
200  void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr);
205  void MissedBlockAck (uint8_t nMpdus);
212  void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
219  void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient);
223  void MissedAck (void);
224 
228  void StartNextPacket (void);
232  void EndTxNoAck (void);
236  void RestartAccessIfNeeded (void);
240  void StartAccessIfNeeded (void);
241 
248  bool NeedBarRetransmission (void);
249 
256  bool NeedFragmentation (void) const;
257 
267 
273  void SetAccessCategory (AcIndex ac);
274 
280  void SetMsduAggregator (const Ptr<MsduAggregator> aggr);
286  void SetMpduAggregator (const Ptr<MpduAggregator> aggr);
287 
295  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
296 
300  void CompleteConfig (void);
301 
308  void SetBlockAckThreshold (uint8_t threshold);
314  uint8_t GetBlockAckThreshold (void) const;
315 
321  void SetBlockAckInactivityTimeout (uint16_t timeout);
330  void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator);
340  void CompleteMpduTx (Ptr<const Packet> packet, WifiMacHeader hdr, Time tstamp);
347  bool GetAmpduExist (Mac48Address dest) const;
354  void SetAmpduExist (Mac48Address dest, bool enableAmpdu);
355 
363  uint16_t GetNextSequenceNumberFor (WifiMacHeader *hdr);
379  void RemoveRetransmitPacket (uint8_t tid, Mac48Address recipient, uint16_t seqnumber);
389  Ptr<const Packet> PeekNextRetransmitPacket (WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp);
395  void BaTxOk (const WifiMacHeader &hdr);
401  void BaTxFailed (const WifiMacHeader &hdr);
402 
425 
426 
427 private:
430 
437  bool SetupBlockAckIfNeeded ();
448  void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq,
449  uint16_t timeout, bool immediateBAck);
456  void SendBlockAckRequest (const Bar &bar);
461  void CompleteTx (void);
466  void VerifyBlockAck (void);
472  Time GetTxopRemaining (void) const;
479  bool HasTxop (void) const;
480 
486  uint32_t GetNextFragmentSize (void) const;
492  uint32_t GetFragmentSize (void) const;
498  uint32_t GetFragmentOffset (void) const;
505  bool IsLastFragment (void) const;
506 
513  bool IsTxopFragmentation () const;
519  uint32_t GetTxopFragmentSize () const;
525  uint32_t GetNTxopFragment () const;
532  uint32_t GetNextTxopFragmentSize (uint32_t fragmentNumber) const;
539  uint32_t GetTxopFragmentOffset (uint32_t fragmentNumber) const;
540 
541  void DoDispose (void);
542  void DoInitialize (void);
543 
558 
562 };
563 
564 } //namespace ns3
565 
566 #endif /* EDCA_TXOP_N_H */
void DoDispose(void)
Destructor implementation.
Definition: edca-txop-n.cc:93
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void SetBlockAckInactivityTimeout(uint16_t timeout)
Set the Block Ack inactivity timeout.
uint16_t m_blockAckInactivityTimeout
the Block ACK inactivity timeout
Definition: edca-txop-n.h:553
uint32_t GetFragmentOffset(void) const
Calculate the offset for the current fragment.
uint32_t GetTxopFragmentOffset(uint32_t fragmentNumber) const
Calculate the offset for the fragment.
void VerifyBlockAck(void)
Verifies if dequeued packet has to be transmitted with ack policy Block Ack.
void StartNextPacket(void)
Start transmission for the next packet if allowed by the TxopLimit.
Definition: edca-txop-n.cc:829
void NotifyCollision(void)
Notify the EDCAF that collision has occurred.
Definition: edca-txop-n.cc:431
void CompleteMpduTx(Ptr< const Packet > packet, WifiMacHeader hdr, Time tstamp)
Stores an MPDU (part of an A-MPDU) in blockackagreement (i.e.
bool HasTxop(void) const
Check if the station has TXOP granted for the next MPDU.
Definition: edca-txop-n.cc:915
void SendBlockAckRequest(const Bar &bar)
After that all packets, for which a block ack agreement was established, have been transmitted...
void SetAccessCategory(AcIndex ac)
Set the access category of this EDCAF.
bool NeedBarRetransmission(void)
Check if Block ACK Request should be re-transmitted.
Definition: edca-txop-n.cc:802
uint8_t m_blockAckThreshold
the Block ACK threshold
Definition: edca-txop-n.h:550
uint32_t GetNextFragmentSize(void) const
Calculate the size of the next fragment.
Time GetTxopRemaining(void) const
Return the remaining duration in the current TXOP.
Definition: edca-txop-n.cc:902
Ptr< MsduAggregator > m_msduAggregator
A-MSDU aggregator.
Definition: edca-txop-n.h:545
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this EdcaTxopN is associated to.
Definition: edca-txop-n.cc:128
ns3::Time timeout
BlockAckType
Enumeration for different block ACK policies.
Definition: ctrl-headers.h:31
uint32_t GetFragmentSize(void) const
Calculate the size of the current fragment.
Block Ack Request.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
uint32_t GetTxopFragmentSize() const
Calculate the size of the current TXOP fragment.
void MissedBlockAck(uint8_t nMpdus)
Event handler when a Block ACK timeout has occurred.
Definition: edca-txop-n.cc:634
bool m_isAccessRequestedForRts
flag whether access is requested to transmit a RTS frame
Definition: edca-txop-n.h:556
Ptr< MpduAggregator > m_mpduAggregator
A-MPDU aggregator.
Definition: edca-txop-n.h:546
AcIndex m_ac
the access category
Definition: edca-txop-n.h:544
void MissedAck(void)
Event handler when an ACK is missed.
Definition: edca-txop-n.cc:569
TracedCallback< Time, Time > m_txopTrace
TXOP trace callback.
Definition: edca-txop-n.h:561
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:68
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
Event handler when a DELBA frame is received.
void NotifyAccessGranted(void)
Notify the EDCAF that access has been granted.
Definition: edca-txop-n.cc:179
void RemoveRetransmitPacket(uint8_t tid, Mac48Address recipient, uint16_t seqnumber)
Remove a packet after you peek in the retransmit queue and get it.
Definition: edca-txop-n.cc:173
void NotifyInternalCollision(void)
Notify the EDCAF that internal collision has occurred.
Definition: edca-txop-n.cc:341
std::map< Mac48Address, bool > m_aMpduEnabled
list containing flags whether A-MPDU is enabled for a given destination address
Definition: edca-txop-n.h:74
TracedValue< uint32_t > m_cwTrace
CW trace value.
Definition: edca-txop-n.h:560
TracedValue< uint32_t > m_backoffTrace
backoff trace value
Definition: edca-txop-n.h:559
uint32_t GetNTxopFragment() const
Calculate the number of TXOP fragments needed for the transmission of the current packet...
void SendAddBaRequest(Mac48Address recipient, uint8_t tid, uint16_t startSeq, uint16_t timeout, bool immediateBAck)
Sends an ADDBA Request to establish a block ack agreement with sta addressed by recipient for tid tid...
Ptr< const Packet > PeekNextRetransmitPacket(WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp)
Peek in retransmit queue and get the next packet without removing it from the queue.
Definition: edca-txop-n.cc:167
void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator)
Sends DELBA frame to cancel a block ack agreement with sta addressed by addr for tid tid...
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ACK mechanism.
void SetMsduAggregator(const Ptr< MsduAggregator > aggr)
Set the aggregator used to construct A-MSDU subframes.
void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: edca-txop-n.cc:440
void SetTypeOfStation(TypeOfStation type)
Set type of station with the given type.
Definition: edca-txop-n.cc:136
bool IsTxopFragmentation() const
Check if the current packet is fragmented because of an exceeded TXOP duration.
Definition: edca-txop-n.cc:995
Headers for Block ack response.
Definition: ctrl-headers.h:190
Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment.
virtual ~EdcaTxopN()
Definition: edca-txop-n.cc:87
uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
Definition: edca-txop-n.cc:116
Time m_currentPacketTimestamp
the current packet timestamp
Definition: edca-txop-n.h:552
friend class AggregationCapableTransmissionListener
allow AggregationCapableTransmissionListener class access
Definition: edca-txop-n.h:429
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
Definition: edca-txop-n.cc:954
bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
Definition: edca-txop-n.cc:971
void GotAck(void)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:503
Ptr< MpduAggregator > GetMpduAggregator(void) const
Returns the aggregator used to construct A-MPDU subframes.
Definition: edca-txop-n.cc:714
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< MsduAggregator > GetMsduAggregator(void) const
Returns the aggregator used to construct A-MSDU subframes.
Definition: edca-txop-n.cc:708
Bar m_currentBar
the current BAR
Definition: edca-txop-n.h:554
bool IsEdca()
Check for EDCA.
TypeOfStation GetTypeOfStation(void) const
Return type of station.
Definition: edca-txop-n.cc:143
Mac48Address MapDestAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set destination address in A-MSDU subframes.
bool SetupBlockAckIfNeeded()
If number of packets in the queue reaches m_blockAckThreshold value, an ADDBA Request frame is sent t...
bool GetBaAgreementExists(Mac48Address address, uint8_t tid) const
Definition: edca-txop-n.cc:104
an EUI-48 address
Definition: mac48-address.h:43
void SetAmpduExist(Mac48Address dest, bool enableAmpdu)
Set indication whether A-MPDU is used to transmit data to a peer station.
void BaTxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
Time m_startTxop
the start TXOP time
Definition: edca-txop-n.h:555
uint32_t GetNextTxopFragmentSize(uint32_t fragmentNumber) const
Calculate the size of the next TXOP fragment.
bool GetAmpduExist(Mac48Address dest) const
Return whether A-MPDU is used to transmit data to a peer station.
void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr)
Event handler when a Block ACK is received.
void DoInitialize(void)
Initialize() implementation.
Ampdu Aggregation Test.
void PushFront(Ptr< const Packet > packet, const WifiMacHeader &hdr)
static TypeId GetTypeId(void)
Get the type ID.
Definition: edca-txop-n.cc:44
void BaTxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
Ptr< QosBlockedDestinations > m_qosBlockedDestinations
QOS blocked destinations.
Definition: edca-txop-n.h:548
void CompleteConfig(void)
Complete block ACK configuration.
BlockAckType m_blockAckType
the Block ACK type
Definition: edca-txop-n.h:551
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: edca-txop-n.cc:720
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:890
Implement the header for management frames of type del block ack.
Definition: mgt-headers.h:1011
void CompleteAmpduTransfer(Mac48Address recipient, uint8_t tid)
Definition: edca-txop-n.cc:122
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 IsLastFragment(void) const
Check if the current fragment is the last fragment.
uint16_t PeekNextSequenceNumberFor(WifiMacHeader *hdr)
Return the next sequence number for the Traffic ID and destination, but do not pick it (i...
Definition: edca-txop-n.cc:161
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: edca-txop-n.cc:761
bool m_currentIsFragmented
flag whether current packet is fragmented
Definition: edca-txop-n.h:557
tuple address
Definition: first.py:37
TypeOfStation
Enumeration for type of station.
Definition: edca-txop-n.h:44
Ptr< BlockAckManager > m_baManager
the Block ACK manager
Definition: edca-txop-n.h:549
handle packet fragmentation and retransmissions.
Definition: dca-txop.h:58
uint32_t GetNOutstandingPacketsInBa(Mac48Address address, uint8_t tid) const
Definition: edca-txop-n.cc:110
a unique identifier for an interface.
Definition: type-id.h:58
bool NeedsAccess(void) const
Check if the EDCAF requires access.
Definition: edca-txop-n.cc:150
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:38
void SetMpduAggregator(const Ptr< MpduAggregator > aggr)
Set the aggregator used to construct A-MPDU subframes.
Implements the IEEE 802.11 MAC header.
void GotAddBaResponse(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
Event handler when an ADDBA response is received.
TypeOfStation m_typeOfStation
the type of station
Definition: edca-txop-n.h:547
Mac48Address MapSrcAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set source address in A-MSDU subframes. ...
uint16_t GetNextSequenceNumberFor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: edca-txop-n.cc:156