A Discrete-Event Network Simulator
API
qos-txop.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 QOS_TXOP_H
24 #define QOS_TXOP_H
25 
26 #include "ns3/traced-value.h"
27 #include "block-ack-manager.h"
28 #include "txop.h"
29 #include "qos-utils.h"
30 
32 
33 namespace ns3 {
34 
35 class QosBlockedDestinations;
36 class MsduAggregator;
37 class MpduAggregator;
38 class MgtAddBaResponseHeader;
39 class MgtDelBaHeader;
40 class AggregationCapableTransmissionListener;
41 
46 {
47  STA,
48  AP,
55 };
56 
90 class QosTxop : public Txop
91 {
92 public:
94  friend class ::AmpduAggregationTest;
95 
96  std::map<Mac48Address, bool> m_aMpduEnabled;
97 
102  static TypeId GetTypeId (void);
103 
104  QosTxop ();
105  virtual ~QosTxop ();
106 
112  bool IsQosTxop () const;
113 
125  void SetTypeOfStation (TypeOfStation type);
131  TypeOfStation GetTypeOfStation (void) const;
132 
145 
155  bool GetBaAgreementExists (Mac48Address address, uint8_t tid) const;
163  void CompleteAmpduTransfer (Mac48Address recipient, uint8_t tid);
164 
165  /* dcf notifications forwarded here */
169  void NotifyAccessGranted (void);
173  void NotifyInternalCollision (void);
177  void NotifyCollision (void);
178 
179  /* Event handlers */
183  void MissedCts (void);
187  void GotAck (void);
197  void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr);
202  void MissedBlockAck (uint8_t nMpdus);
209  void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
216  void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient);
220  void MissedAck (void);
221 
225  void StartNextPacket (void);
229  void EndTxNoAck (void);
233  void RestartAccessIfNeeded (void);
237  void StartAccessIfNeeded (void);
238 
245  bool NeedBarRetransmission (void);
246 
253  bool NeedFragmentation (void) const;
254 
264 
270  void SetAccessCategory (AcIndex ac);
271 
277  void SetMsduAggregator (const Ptr<MsduAggregator> aggr);
283  void SetMpduAggregator (const Ptr<MpduAggregator> aggr);
284 
292  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
293 
297  void CompleteConfig (void);
298 
305  void SetBlockAckThreshold (uint8_t threshold);
311  uint8_t GetBlockAckThreshold (void) const;
312 
318  void SetBlockAckInactivityTimeout (uint16_t timeout);
327  void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator);
337  void CompleteMpduTx (Ptr<const Packet> packet, WifiMacHeader hdr, Time tstamp);
344  bool GetAmpduExist (Mac48Address dest) const;
351  void SetAmpduExist (Mac48Address dest, bool enableAmpdu);
352 
360  uint16_t GetNextSequenceNumberFor (WifiMacHeader *hdr);
376  void RemoveRetransmitPacket (uint8_t tid, Mac48Address recipient, uint16_t seqnumber);
385  Ptr<const Packet> PeekNextRetransmitPacket (WifiMacHeader &header, uint8_t tid, Time *timestamp);
391  void BaTxOk (const WifiMacHeader &hdr);
397  void BaTxFailed (const WifiMacHeader &hdr);
398 
421 
422 
423 private:
426 
433  bool SetupBlockAckIfNeeded ();
444  void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq,
445  uint16_t timeout, bool immediateBAck);
452  void SendBlockAckRequest (const Bar &bar);
457  void CompleteTx (void);
462  void VerifyBlockAck (void);
468  Time GetTxopRemaining (void) const;
475  bool HasTxop (void) const;
476 
482  uint32_t GetNextFragmentSize (void) const;
488  uint32_t GetFragmentSize (void) const;
494  uint32_t GetFragmentOffset (void) const;
501  bool IsLastFragment (void) const;
502 
509  bool IsTxopFragmentation () const;
515  uint32_t GetTxopFragmentSize () const;
521  uint32_t GetNTxopFragment () const;
528  uint32_t GetNextTxopFragmentSize (uint32_t fragmentNumber) const;
535  uint32_t GetTxopFragmentOffset (uint32_t fragmentNumber) const;
536 
537  void DoDispose (void);
538  void DoInitialize (void);
539 
554 
558 };
559 
560 } //namespace ns3
561 
562 #endif /* QOS_TXOP_H */
bool GetBaAgreementExists(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:109
AcIndex m_ac
the access category
Definition: qos-txop.h:540
void MissedAck(void)
Event handler when an ACK is missed.
Definition: qos-txop.cc:556
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Time GetTxopRemaining(void) const
Return the remaining duration in the current TXOP.
Definition: qos-txop.cc:882
bool GetAmpduExist(Mac48Address dest) const
Return whether A-MPDU is used to transmit data to a peer station.
Definition: qos-txop.cc:1298
void VerifyBlockAck(void)
Verifies if dequeued packet has to be transmitted with ack policy Block Ack.
Definition: qos-txop.cc:1281
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: qos-txop.cc:708
BlockAckType m_blockAckType
the Block ACK type
Definition: qos-txop.h:547
Ptr< MpduAggregator > GetMpduAggregator(void) const
Returns the aggregator used to construct A-MPDU subframes.
Definition: qos-txop.cc:702
Time m_startTxop
the start TXOP time
Definition: qos-txop.h:551
Mac48Address MapDestAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set destination address in A-MSDU subframes.
Definition: qos-txop.cc:1186
bool m_isAccessRequestedForRts
flag whether access is requested to transmit a RTS frame
Definition: qos-txop.h:552
bool SetupBlockAckIfNeeded()
If number of packets in the queue reaches m_blockAckThreshold value, an ADDBA Request frame is sent t...
Definition: qos-txop.cc:1342
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:90
void MissedBlockAck(uint8_t nMpdus)
Event handler when a Block ACK timeout has occurred.
Definition: qos-txop.cc:622
bool NeedBarRetransmission(void)
Check if Block ACK Request should be re-transmitted.
Definition: qos-txop.cc:785
uint32_t GetTxopFragmentSize() const
Calculate the size of the current TXOP fragment.
Definition: qos-txop.cc:989
Ptr< MpduAggregator > m_mpduAggregator
A-MPDU aggregator.
Definition: qos-txop.h:542
void SetBlockAckInactivityTimeout(uint16_t timeout)
Set the Block Ack inactivity timeout.
Definition: qos-txop.cc:1421
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...
Definition: qos-txop.cc:1496
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
Event handler when a DELBA frame is received.
Definition: qos-txop.cc:1248
virtual ~QosTxop()
Definition: qos-txop.cc:92
ns3::Time timeout
void SetAccessCategory(AcIndex ac)
Set the access category of this EDCAF.
Definition: qos-txop.cc:1163
uint16_t GetNextSequenceNumberFor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: qos-txop.cc:142
static TypeId GetTypeId(void)
Get the type ID.
Definition: qos-txop.cc:49
uint8_t GetBlockAckThreshold(void) const
Return the current threshold for block ACK mechanism.
Definition: qos-txop.cc:1428
Block Ack Request.
void DoDispose(void)
Destructor implementation.
Definition: qos-txop.cc:98
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
bool IsLastFragment(void) const
Check if the current fragment is the last fragment.
Definition: qos-txop.cc:1126
void SetMsduAggregator(const Ptr< MsduAggregator > aggr)
Set the aggregator used to construct A-MSDU subframes.
Definition: qos-txop.cc:1202
bool IsTxopFragmentation() const
Check if the current packet is fragmented because of an exceeded TXOP duration.
Definition: qos-txop.cc:974
Ptr< MsduAggregator > m_msduAggregator
A-MSDU aggregator.
Definition: qos-txop.h:541
uint32_t GetFragmentOffset(void) const
Calculate the offset for the current fragment.
Definition: qos-txop.cc:1110
friend class AggregationCapableTransmissionListener
allow AggregationCapableTransmissionListener class access
Definition: qos-txop.h:425
uint32_t GetNextFragmentSize(void) const
Calculate the size of the next fragment.
Definition: qos-txop.cc:1095
void SetAmpduExist(Mac48Address dest, bool enableAmpdu)
Set indication whether A-MPDU is used to transmit data to a peer station.
Definition: qos-txop.cc:1309
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: qos-txop.cc:749
void SendBlockAckRequest(const Bar &bar)
After that all packets, for which a block ack agreement was established, have been transmitted...
Definition: qos-txop.cc:1362
Ptr< BlockAckManager > m_baManager
the Block ACK manager
Definition: qos-txop.h:545
void CompleteAmpduTransfer(Mac48Address recipient, uint8_t tid)
Definition: qos-txop.cc:115
Headers for Block ack response.
Definition: ctrl-headers.h:181
TracedValue< uint32_t > m_backoffTrace
backoff trace value
Definition: qos-txop.h:555
void GotAddBaResponse(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
Event handler when an ADDBA response is received.
Definition: qos-txop.cc:1226
void SetTypeOfStation(TypeOfStation type)
Set type of station with the given type.
Definition: qos-txop.cc:129
void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: qos-txop.cc:427
uint32_t GetFragmentSize(void) const
Calculate the size of the current fragment.
Definition: qos-txop.cc:1080
void PushFront(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: qos-txop.cc:1216
uint32_t GetNTxopFragment() const
Calculate the number of TXOP fragments needed for the transmission of the current packet...
Definition: qos-txop.cc:1022
bool IsQosTxop() const
Check for QoS TXOP.
Definition: qos-txop.cc:1563
void SetMpduAggregator(const Ptr< MpduAggregator > aggr)
Set the aggregator used to construct A-MPDU subframes.
Definition: qos-txop.cc:1209
Every class exported by the ns3 library is enclosed in the ns3 namespace.
address
Definition: first.py:37
void BaTxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
Definition: qos-txop.cc:1553
Bar m_currentBar
the current BAR
Definition: qos-txop.h:550
an EUI-48 address
Definition: mac48-address.h:43
void BaTxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
Definition: qos-txop.cc:1543
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
Definition: qos-txop.cc:933
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ACK mechanism.
Definition: qos-txop.cc:1413
TracedValue< uint32_t > m_cwTrace
CW trace value.
Definition: qos-txop.h:556
uint8_t m_blockAckThreshold
the Block ACK threshold
Definition: qos-txop.h:546
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this QosTxop is associated to.
Definition: qos-txop.cc:121
uint32_t GetTxopFragmentOffset(uint32_t fragmentNumber) const
Calculate the offset for the fragment.
Definition: qos-txop.cc:1035
Ampdu Aggregation Test.
void NotifyCollision(void)
Notify the EDCAF that collision has occurred.
Definition: qos-txop.cc:418
void RemoveRetransmitPacket(uint8_t tid, Mac48Address recipient, uint16_t seqnumber)
Remove a packet after you peek in the retransmit queue and get it.
Definition: qos-txop.cc:160
Ptr< const Packet > PeekNextRetransmitPacket(WifiMacHeader &header, uint8_t tid, Time *timestamp)
Peek in retransmit queue and get the next packet without removing it from the queue.
Definition: qos-txop.cc:154
void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr)
Event handler when a Block ACK is received.
Definition: qos-txop.cc:1256
void GotAck(void)
Event handler when an ACK is received.
Definition: qos-txop.cc:490
void StartNextPacket(void)
Start transmission for the next packet if allowed by the TxopLimit.
Definition: qos-txop.cc:812
void CompleteTx(void)
For now is typically invoked to complete transmission of a packets sent with ack policy Block Ack: th...
Definition: qos-txop.cc:1316
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:1129
Implement the header for management frames of type del block ack.
Definition: mgt-headers.h:1250
Mac48Address MapSrcAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set source address in A-MSDU subframes. ...
Definition: qos-txop.cc:1170
TypeOfStation GetTypeOfStation(void) const
Return type of station.
Definition: qos-txop.cc:136
Ptr< QosBlockedDestinations > m_qosBlockedDestinations
QOS blocked destinations.
Definition: qos-txop.h:544
void NotifyAccessGranted(void)
Notify the EDCAF that access has been granted.
Definition: qos-txop.cc:166
void CompleteMpduTx(Ptr< const Packet > packet, WifiMacHeader hdr, Time tstamp)
Stores an MPDU (part of an A-MPDU) in blockackagreement (i.e.
Definition: qos-txop.cc:1332
void CompleteConfig(void)
Complete block ACK configuration.
Definition: qos-txop.cc:1404
bool m_currentIsFragmented
flag whether current packet is fragmented
Definition: qos-txop.h:553
TracedCallback< Time, Time > m_txopTrace
TXOP trace callback.
Definition: qos-txop.h:557
void DoInitialize(void)
Initialize() implementation.
Definition: qos-txop.cc:1533
bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
Definition: qos-txop.cc:950
TypeOfStation
Enumeration for type of station.
Definition: qos-txop.h:45
Time m_currentPacketTimestamp
the current packet timestamp
Definition: qos-txop.h:548
Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment.
Definition: qos-txop.cc:1142
uint16_t m_blockAckInactivityTimeout
the Block ACK inactivity timeout
Definition: qos-txop.h:549
bool HasTxop(void) const
Check if the station has TXOP granted for the next MPDU.
Definition: qos-txop.cc:895
void NotifyInternalCollision(void)
Notify the EDCAF that internal collision has occurred.
Definition: qos-txop.cc:328
uint32_t GetNextTxopFragmentSize(uint32_t fragmentNumber) const
Calculate the size of the next TXOP fragment.
Definition: qos-txop.cc:1061
TypeOfStation m_typeOfStation
the type of station
Definition: qos-txop.h:543
a unique identifier for an interface.
Definition: type-id.h:58
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:37
Implements the IEEE 802.11 MAC header.
std::map< Mac48Address, bool > m_aMpduEnabled
list containing flags whether A-MPDU is enabled for a given destination address
Definition: qos-txop.h:96
Ptr< MsduAggregator > GetMsduAggregator(void) const
Returns the aggregator used to construct A-MSDU subframes.
Definition: qos-txop.cc:696
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...
Definition: qos-txop.cc:1435
BlockAckType
The different block ACK policies.
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:64
uint16_t PeekNextSequenceNumberFor(WifiMacHeader *hdr)
Return the next sequence number for the Traffic ID and destination, but do not pick it (i...
Definition: qos-txop.cc:148