This documentation is not the Latest Release.
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 #ifndef EDCA_TXOP_N_H
23 #define EDCA_TXOP_N_H
24 
25 #include "ns3/object.h"
26 #include "ns3/mac48-address.h"
27 #include "ns3/packet.h"
28 #include "wifi-mode.h"
29 #include "wifi-mac-header.h"
31 #include "qos-utils.h"
32 #include "dcf.h"
33 #include "ctrl-headers.h"
34 #include "block-ack-manager.h"
35 #include <map>
36 #include <list>
37 
38 namespace ns3 {
39 
40 class DcfState;
41 class DcfManager;
42 class MacLow;
43 class MacTxMiddle;
44 class WifiMac;
45 class WifiMacParameters;
46 class WifiMacQueue;
47 class RandomStream;
48 class QosBlockedDestinations;
49 class MsduAggregator;
50 class MgtAddBaResponseHeader;
51 class BlockAckManager;
52 class MgtDelBaHeader;
53 
58 {
59  STA,
60  AP,
67 };
68 
69 
82 class EdcaTxopN : public Dcf
83 {
84 public:
95 
96  static TypeId GetTypeId (void);
97  EdcaTxopN ();
98  virtual ~EdcaTxopN ();
99  void DoDispose ();
100 
106  void SetLow (Ptr<MacLow> low);
107  void SetTxMiddle (MacTxMiddle *txMiddle);
113  void SetManager (DcfManager *manager);
118  void SetTxOkCallback (TxOk callback);
123  void SetTxFailedCallback (TxFailed callback);
135  void SetTypeOfStation (enum TypeOfStation type);
141  enum TypeOfStation GetTypeOfStation (void) const;
148 
149  virtual void SetMinCw (uint32_t minCw);
150  virtual void SetMaxCw (uint32_t maxCw);
151  virtual void SetAifsn (uint32_t aifsn);
152  virtual uint32_t GetMinCw (void) const;
153  virtual uint32_t GetMaxCw (void) const;
154  virtual uint32_t GetAifsn (void) const;
155 
161  Ptr<MacLow> Low (void);
162 
172  bool GetBaAgreementExists (Mac48Address address, uint8_t tid);
180  uint32_t GetNOutstandingPacketsInBa (Mac48Address address, uint8_t tid);
188  uint32_t GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const;
196  void CompleteAmpduTransfer (Mac48Address recipient, uint8_t tid);
197 
198  /* dcf notifications forwarded here */
205  bool NeedsAccess (void) const;
209  void NotifyAccessGranted (void);
213  void NotifyInternalCollision (void);
217  void NotifyCollision (void);
221  void NotifyChannelSwitching (void);
225  void NotifySleep (void);
229  void NotifyWakeUp (void);
230 
231  /* Event handlers */
238  void GotCts (double snr, WifiMode txMode);
242  void MissedCts (void);
249  void GotAck (double snr, WifiMode txMode);
257  void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, WifiMode txMode);
261  void MissedBlockAck (void);
262  void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
263  void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient);
267  void MissedAck (void);
272  void StartNext (void);
276  void Cancel (void);
281  void EndTxNoAck (void);
285  void RestartAccessIfNeeded (void);
289  void StartAccessIfNeeded (void);
296  bool NeedRts (void);
303  bool NeedRtsRetransmission (void);
310  bool NeedDataRetransmission (void);
317  bool NeedBarRetransmission (void);
324  bool NeedFragmentation (void) const;
330  uint32_t GetNextFragmentSize (void);
336  uint32_t GetFragmentSize (void);
342  uint32_t GetFragmentOffset (void);
349  bool IsLastFragment (void) const;
355  void NextFragment (void);
364 
370  void SetAccessCategory (enum AcIndex ac);
371 
379  void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
380 
382 
390  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
391 
395  void CompleteConfig (void);
396 
403  void SetBlockAckThreshold (uint8_t threshold);
409  uint8_t GetBlockAckThreshold (void) const;
410 
411  void SetBlockAckInactivityTimeout (uint16_t timeout);
412  void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator);
413  void CompleteMpduTx (Ptr<const Packet> packet, WifiMacHeader hdr, Time tstamp);
414  bool GetAmpduExist (void);
415  void SetAmpduExist (bool ampdu);
416 
424  uint16_t GetNextSequenceNumberfor (WifiMacHeader *hdr);
436  void RemoveRetransmitPacket (uint8_t tid, Mac48Address recipient, uint16_t seqnumber);
437  /*
438  * Peek in retransmit queue and get the next packet without removing it from the queue
439  */
440  Ptr<const Packet> PeekNextRetransmitPacket (WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp);
446  void BaTxOk (const WifiMacHeader &hdr);
452  void BaTxFailed (const WifiMacHeader &hdr);
453 
462  int64_t AssignStreams (int64_t stream);
463 
464 
465 private:
466  void DoInitialize ();
481  EdcaTxopN &operator = (const EdcaTxopN &);
482  EdcaTxopN (const EdcaTxopN &);
483 
490  bool SetupBlockAckIfNeeded ();
501  void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq,
502  uint16_t timeout, bool immediateBAck);
509  void SendBlockAckRequest (const struct Bar &bar);
514  void CompleteTx (void);
519  void VerifyBlockAck (void);
520 
522  class Dcf;
523  class TransmissionListener;
525  friend class Dcf;
526  friend class TransmissionListener;
539 
540  /* current packet could be a simple MSDU or, if an aggregator for this queue is
541  present, could be an A-MSDU.
542  */
544 
550  /*
551  * Represents the minimum number of packets for use of block ack.
552  */
559 };
560 
561 } //namespace ns3
562 
563 #endif /* EDCA_TXOP_N_H */
Keep track of destination address - TID pairs that are waiting for a block ACK response.
virtual void SetMaxCw(uint32_t maxCw)
Set the maximum congestion window size.
Definition: edca-txop-n.cc:388
TransmissionListener * m_transmissionListener
Definition: edca-txop-n.h:534
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Ptr< const Packet > m_currentPacket
Definition: edca-txop-n.h:543
void DoInitialize()
Initialize() implementation.
TxFailed m_txFailedCallback
Definition: edca-txop-n.h:531
void NotifyWakeUp(void)
When wake up operation occurs, restart channel access.
Definition: edca-txop-n.cc:752
void SetBlockAckInactivityTimeout(uint16_t timeout)
uint32_t GetFragmentSize(void)
Calculate the size of the current fragment.
uint16_t m_blockAckInactivityTimeout
Definition: edca-txop-n.h:556
void VerifyBlockAck(void)
Verifies if dequeued packet has to be transmitted with ack policy Block Ack.
void NotifyCollision(void)
Notify the EDCAF that collision has occurred.
Definition: edca-txop-n.cc:650
void SetTypeOfStation(enum TypeOfStation type)
Set type of station with the given type.
Definition: edca-txop-n.cc:360
bool NeedDataRetransmission(void)
Check if DATA should be re-transmitted if ACK was missed.
void CompleteMpduTx(Ptr< const Packet > packet, WifiMacHeader hdr, Time tstamp)
void SetTxFailedCallback(TxFailed callback)
Definition: edca-txop-n.cc:345
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:771
bool NeedBarRetransmission(void)
Check if Block ACK Request should be re-transmitted.
bool GetAmpduExist(void)
uint8_t m_blockAckThreshold
Definition: edca-txop-n.h:553
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this EdcaTxopN is associated to.
Definition: edca-txop-n.cc:352
WifiMacHeader m_currentHdr
Definition: edca-txop-n.h:545
void NotifySleep(void)
When sleep operation occurs, re-insert pending packet into front of the queue.
Definition: edca-txop-n.cc:741
ns3::Time timeout
BlockAckType
Enumeration for different block ACK policies.
Definition: ctrl-headers.h:31
void SetAmpduExist(bool ampdu)
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
void NextFragment(void)
Continue to the next fragment.
void SetTxOkCallback(TxOk callback)
Definition: edca-txop-n.cc:338
BlockAckManager * m_baManager
Definition: edca-txop-n.h:549
bool NeedRtsRetransmission(void)
Check if RTS should be re-transmitted if CTS was missed.
Definition: edca-txop-n.cc:996
struct Bar m_currentBar
Definition: edca-txop-n.h:557
virtual uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: edca-txop-n.cc:416
Handles sequence numbering of IEEE 802.11 data frames.
Definition: mac-tx-middle.h:39
DcfManager * m_manager
Definition: edca-txop-n.h:528
void MissedAck(void)
Event handler when an ACK is missed.
Definition: edca-txop-n.cc:817
enum TypeOfStation GetTypeOfStation(void) const
Return type of station.
Definition: edca-txop-n.cc:367
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:437
Ptr< MacLow > Low(void)
Return the MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:430
Ptr< WifiRemoteStationManager > m_stationManager
Definition: edca-txop-n.h:537
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:82
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
void NotifyAccessGranted(void)
Notify the EDCAF that access has been granted.
Definition: edca-txop-n.cc:473
RandomStream * m_rng
Definition: edca-txop-n.h:536
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:467
void NotifyInternalCollision(void)
Notify the EDCAF that internal collision has occurred.
Definition: edca-txop-n.cc:643
virtual void SetMinCw(uint32_t minCw)
Set the minimum congestion window size.
Definition: edca-txop-n.cc:381
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)
Definition: edca-txop-n.cc:461
void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator)
bool GetBaAgreementExists(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:306
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ACK mechanism.
MacTxMiddle * m_txMiddle
Definition: edca-txop-n.h:533
Callback< void, const WifiMacHeader & > TxOk
typedef for a callback to invoke when a packet transmission was completed successfully.
Definition: edca-txop-n.h:89
void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: edca-txop-n.cc:665
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:252
A simple wrapper around RngStream to make testing of the code easier.
Definition: random-stream.h:34
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:455
Headers for Block ack response.
Definition: ctrl-headers.h:186
void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: edca-txop-n.cc:733
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
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:277
uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
Definition: edca-txop-n.cc:318
uint8_t m_fragmentNumber
Definition: edca-txop-n.h:538
Time m_currentPacketTimestamp
Definition: edca-txop-n.h:555
virtual uint32_t GetMinCw(void) const
Return the minimum congestion window size.
Definition: edca-txop-n.cc:402
void MissedBlockAck(void)
Event handler when a Block ACK timeout has occurred.
Definition: edca-txop-n.cc:887
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< MsduAggregator > GetMsduAggregator(void) const
Definition: edca-txop-n.cc:958
void SetAccessCategory(enum AcIndex ac)
Set the access category of this EDCAF.
Callback< void, const WifiMacHeader & > TxFailed
typedef for a callback to invoke when a packet transmission was failed.
Definition: edca-txop-n.h:94
Mac48Address MapDestAddressForAggregation(const WifiMacHeader &hdr)
bool SetupBlockAckIfNeeded()
If number of packets in the queue reaches m_blockAckThreshold value, an ADDBA Request frame is sent t...
void StartNext(void)
Start transmission for the next fragment.
an EUI-48 address
Definition: mac48-address.h:43
void Cancel(void)
Cancel the transmission.
void BaTxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
void SetManager(DcfManager *manager)
Set DcfManager this EdcaTxopN is associated to.
Definition: edca-txop-n.cc:330
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:759
uint16_t GetNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: edca-txop-n.cc:450
void SetMsduAggregator(Ptr< MsduAggregator > aggr)
EdcaTxopN & operator=(const EdcaTxopN &)
void PushFront(Ptr< const Packet > packet, const WifiMacHeader &hdr)
enum BlockAckType m_blockAckType
Definition: edca-txop-n.h:554
static TypeId GetTypeId(void)
Definition: edca-txop-n.cc:222
void BaTxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
uint32_t GetNextFragmentSize(void)
Calculate the size of the next fragment.
void CompleteConfig(void)
Complete block ACK configuration.
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: edca-txop-n.cc:964
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:703
QosBlockedDestinations * m_qosBlockedDestinations
Definition: edca-txop-n.h:548
Implement the header for management frames of type del block ack.
Definition: mgt-headers.h:824
void CompleteAmpduTransfer(Mac48Address recipient, uint8_t tid)
Definition: edca-txop-n.cc:324
Ptr< MacLow > m_low
Definition: edca-txop-n.h:532
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...
void SetTxMiddle(MacTxMiddle *txMiddle)
Definition: edca-txop-n.cc:423
void GotCts(double snr, WifiMode txMode)
Event handler when a CTS is received.
Definition: edca-txop-n.cc:658
void DoDispose()
Destructor implementation.
Definition: edca-txop-n.cc:283
bool IsLastFragment(void) const
Check if the current fragment is the last fragment.
virtual uint32_t GetMaxCw(void) const
Return the maximum congestion window size.
Definition: edca-txop-n.cc:409
Ptr< WifiMacQueue > m_queue
Definition: edca-txop-n.h:529
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: edca-txop-n.cc:976
bool NeedRts(void)
Check if the current packet should be sent with a RTS protection.
Definition: edca-txop-n.cc:988
tuple address
Definition: first.py:37
void SendBlockAckRequest(const struct Bar &bar)
After that all packets, for which a block ack agreement was established, have been transmitted...
TypeOfStation
Enumeration for type of station.
Definition: edca-txop-n.h:57
Ptr< MsduAggregator > m_aggregator
Definition: edca-txop-n.h:546
Manages all block ack agreements for an originator station.
void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, WifiMode txMode)
Event handler when a Block ACK is received.
uint32_t GetNOutstandingPacketsInBa(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:312
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:444
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:36
uint32_t GetFragmentOffset(void)
Calculate the offset for the current fragment.
AggregationCapableTransmissionListener * m_blockAckListener
Definition: edca-txop-n.h:535
Implements the IEEE 802.11 MAC header.
void GotAddBaResponse(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
virtual void SetAifsn(uint32_t aifsn)
Definition: edca-txop-n.cc:395
TypeOfStation m_typeOfStation
Definition: edca-txop-n.h:547
Mac48Address MapSrcAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set addresses in a-msdu subframe.
Ptr< WifiMacQueue > GetEdcaQueue() const
Return the packet queue associated with this EdcaTxopN.
Definition: edca-txop-n.cc:374