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;
141  void CompleteAmpduTransfer (Mac48Address recipient, uint8_t tid);
142 
143  /* dcf notifications forwarded here */
147  void NotifyAccessGranted (void);
151  void NotifyInternalCollision (void);
155  void NotifyCollision (void);
156 
157  /* Event handlers */
161  void MissedCts (void);
165  void GotAck (void);
175  void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr);
180  void MissedBlockAck (uint8_t nMpdus);
187  void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
194  void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient);
198  void MissedAck (void);
199 
203  void StartNextPacket (void);
207  void EndTxNoAck (void);
211  void RestartAccessIfNeeded (void);
215  void StartAccessIfNeeded (void);
216 
223  bool NeedBarRetransmission (void);
224 
231  bool NeedFragmentation (void) const;
232 
242 
248  void SetAccessCategory (AcIndex ac);
249 
255  void SetMsduAggregator (const Ptr<MsduAggregator> aggr);
261  void SetMpduAggregator (const Ptr<MpduAggregator> aggr);
262 
270  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
271 
275  void CompleteConfig (void);
276 
283  void SetBlockAckThreshold (uint8_t threshold);
289  uint8_t GetBlockAckThreshold (void) const;
290 
296  void SetBlockAckInactivityTimeout (uint16_t timeout);
305  void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator);
315  void CompleteMpduTx (Ptr<const Packet> packet, WifiMacHeader hdr, Time tstamp);
322  bool GetAmpduExist (Mac48Address dest) const;
329  void SetAmpduExist (Mac48Address dest, bool enableAmpdu);
330 
338  uint16_t GetNextSequenceNumberFor (WifiMacHeader *hdr);
354  void RemoveRetransmitPacket (uint8_t tid, Mac48Address recipient, uint16_t seqnumber);
364  Ptr<const Packet> PeekNextRetransmitPacket (WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp);
370  void BaTxOk (const WifiMacHeader &hdr);
376  void BaTxFailed (const WifiMacHeader &hdr);
377 
400 
401 
402 private:
405 
412  bool SetupBlockAckIfNeeded ();
423  void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq,
424  uint16_t timeout, bool immediateBAck);
431  void SendBlockAckRequest (const Bar &bar);
436  void CompleteTx (void);
441  void VerifyBlockAck (void);
447  Time GetTxopRemaining (void) const;
454  bool HasTxop (void) const;
455 
461  uint32_t GetNextFragmentSize (void) const;
467  uint32_t GetFragmentSize (void) const;
473  uint32_t GetFragmentOffset (void) const;
480  bool IsLastFragment (void) const;
481 
488  bool IsTxopFragmentation () const;
494  uint32_t GetTxopFragmentSize () const;
500  uint32_t GetNTxopFragment () const;
507  uint32_t GetNextTxopFragmentSize (uint32_t fragmentNumber) const;
514  uint32_t GetTxopFragmentOffset (uint32_t fragmentNumber) const;
515 
516  void DoDispose (void);
517  void DoInitialize (void);
518 
533 
537 };
538 
539 } //namespace ns3
540 
541 #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:528
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:804
void NotifyCollision(void)
Notify the EDCAF that collision has occurred.
Definition: edca-txop-n.cc:411
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:889
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:777
uint8_t m_blockAckThreshold
the Block ACK threshold
Definition: edca-txop-n.h:525
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:876
Ptr< MsduAggregator > m_msduAggregator
A-MSDU aggregator.
Definition: edca-txop-n.h:520
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this EdcaTxopN is associated to.
Definition: edca-txop-n.cc:116
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.
Definition: edca-txop-n.cc:984
void MissedBlockAck(uint8_t nMpdus)
Event handler when a Block ACK timeout has occurred.
Definition: edca-txop-n.cc:614
bool m_isAccessRequestedForRts
flag whether access is requested to transmit a RTS frame
Definition: edca-txop-n.h:531
Ptr< MpduAggregator > m_mpduAggregator
A-MPDU aggregator.
Definition: edca-txop-n.h:521
AcIndex m_ac
the access category
Definition: edca-txop-n.h:519
void MissedAck(void)
Event handler when an ACK is missed.
Definition: edca-txop-n.cc:549
TracedCallback< Time, Time > m_txopTrace
TXOP trace callback.
Definition: edca-txop-n.h:536
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:160
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:154
void NotifyInternalCollision(void)
Notify the EDCAF that internal collision has occurred.
Definition: edca-txop-n.cc:321
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:535
TracedValue< uint32_t > m_backoffTrace
backoff trace value
Definition: edca-txop-n.h:534
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:148
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:420
void SetTypeOfStation(TypeOfStation type)
Set type of station with the given type.
Definition: edca-txop-n.cc:124
bool IsTxopFragmentation() const
Check if the current packet is fragmented because of an exceeded TXOP duration.
Definition: edca-txop-n.cc:969
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
Time m_currentPacketTimestamp
the current packet timestamp
Definition: edca-txop-n.h:527
friend class AggregationCapableTransmissionListener
allow AggregationCapableTransmissionListener class access
Definition: edca-txop-n.h:404
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
Definition: edca-txop-n.cc:928
bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
Definition: edca-txop-n.cc:945
void GotAck(void)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:483
Ptr< MpduAggregator > GetMpduAggregator(void) const
Returns the aggregator used to construct A-MPDU subframes.
Definition: edca-txop-n.cc:694
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:688
Bar m_currentBar
the current BAR
Definition: edca-txop-n.h:529
bool IsEdca()
Check for EDCA.
TypeOfStation GetTypeOfStation(void) const
Return type of station.
Definition: edca-txop-n.cc:131
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:530
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:523
void CompleteConfig(void)
Complete block ACK configuration.
BlockAckType m_blockAckType
the Block ACK type
Definition: edca-txop-n.h:526
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: edca-txop-n.cc:700
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:1115
Implement the header for management frames of type del block ack.
Definition: mgt-headers.h:1236
void CompleteAmpduTransfer(Mac48Address recipient, uint8_t tid)
Definition: edca-txop-n.cc:110
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:142
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: edca-txop-n.cc:741
bool m_currentIsFragmented
flag whether current packet is fragmented
Definition: edca-txop-n.h:532
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:524
handle packet fragmentation and retransmissions.
Definition: dca-txop.h:58
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: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:522
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:137