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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Author: 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 
29 #include "wifi-mode.h"
30 #include "wifi-mac-header.h"
32 #include "qos-utils.h"
33 #include "dcf.h"
34 #include "ctrl-headers.h"
35 #include "block-ack-manager.h"
36 
37 #include <map>
38 #include <list>
39 
40 namespace ns3 {
41 
42 class DcfState;
43 class DcfManager;
44 class MacLow;
45 class MacTxMiddle;
46 class WifiMac;
47 class WifiMacParameters;
48 class WifiMacQueue;
49 class RandomStream;
50 class QosBlockedDestinations;
51 class MsduAggregator;
52 class MgtAddBaResponseHeader;
53 class BlockAckManager;
54 class MgtDelBaHeader;
55 
60 {
61  STA,
62  AP,
69 };
70 
71 
84 class EdcaTxopN : public Dcf
85 {
86 public:
97 
98  static TypeId GetTypeId (void);
99  EdcaTxopN ();
100  virtual ~EdcaTxopN ();
101  void DoDispose ();
102 
108  void SetLow (Ptr<MacLow> low);
109  void SetTxMiddle (MacTxMiddle *txMiddle);
115  void SetManager (DcfManager *manager);
120  void SetTxOkCallback (TxOk callback);
125  void SetTxFailedCallback (TxFailed callback);
137  void SetTypeOfStation (enum TypeOfStation type);
143  enum TypeOfStation GetTypeOfStation (void) const;
150  virtual void SetMinCw (uint32_t minCw);
151  virtual void SetMaxCw (uint32_t maxCw);
152  virtual void SetAifsn (uint32_t aifsn);
153  virtual uint32_t GetMinCw (void) const;
154  virtual uint32_t GetMaxCw (void) const;
155  virtual uint32_t GetAifsn (void) const;
156 
162  Ptr<MacLow> Low (void);
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);
295  bool NeedRts (void);
301  bool NeedRtsRetransmission (void);
307  bool NeedDataRetransmission (void);
313  bool NeedBarRetransmission (void);
320  bool NeedFragmentation (void) const;
326  uint32_t GetNextFragmentSize (void);
332  uint32_t GetFragmentSize (void);
338  uint32_t GetFragmentOffset (void);
345  bool IsLastFragment (void) const;
351  void NextFragment (void);
365  void SetAccessCategory (enum AcIndex ac);
373  void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
382  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
386  void CompleteConfig (void);
393  void SetBlockAckThreshold (uint8_t threshold);
399  uint8_t GetBlockAckThreshold (void) const;
400 
401  void SetBlockAckInactivityTimeout (uint16_t timeout);
402  void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator);
403  void CompleteMpduTx (Ptr<const Packet> packet, WifiMacHeader hdr, Time tstamp);
404  bool GetAmpduExist (void);
405  void SetAmpduExist (bool ampdu);
412  uint16_t GetNextSequenceNumberfor (WifiMacHeader *hdr);
423  void RemoveRetransmitPacket (uint8_t tid, Mac48Address recipient, uint16_t seqnumber);
424  /*
425  * Peek in retransmit queue and get the next packet without removing it from the queue
426  */
427  Ptr<const Packet> PeekNextRetransmitPacket (WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp);
433  void BaTxOk (const WifiMacHeader &hdr);
439  void BaTxFailed (const WifiMacHeader &hdr);
440 
449  int64_t AssignStreams (int64_t stream);
450 
451 private:
452  void DoInitialize ();
467  EdcaTxopN &operator = (const EdcaTxopN &);
468  EdcaTxopN (const EdcaTxopN &);
469 
476  bool SetupBlockAckIfNeeded ();
487  void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq,
488  uint16_t timeout, bool immediateBAck);
495  void SendBlockAckRequest (const struct Bar &bar);
500  void CompleteTx (void);
505  void VerifyBlockAck (void);
506 
508  class Dcf;
509  class TransmissionListener;
511  friend class Dcf;
512  friend class TransmissionListener;
525 
526  /* current packet could be a simple MSDU or, if an aggregator for this queue is
527  present, could be an A-MSDU.
528  */
530 
536  /*
537  * Represents the minimum number of packets for use of block ack.
538  */
545 };
546 
547 } // namespace ns3
548 
549 #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:360
TransmissionListener * m_transmissionListener
Definition: edca-txop-n.h:520
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
Ptr< const Packet > m_currentPacket
Definition: edca-txop-n.h:529
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
void DoInitialize()
Initialize() implementation.
TxFailed m_txFailedCallback
Definition: edca-txop-n.h:517
void NotifyWakeUp(void)
When wake up operation occurs, restart channel access.
Definition: edca-txop-n.cc:680
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:542
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:619
void SetTypeOfStation(enum TypeOfStation type)
Set type of station with the given type.
Definition: edca-txop-n.cc:332
bool NeedDataRetransmission(void)
Check if DATA should be re-transmitted if ACK was missed.
Definition: edca-txop-n.cc:917
void CompleteMpduTx(Ptr< const Packet > packet, WifiMacHeader hdr, Time tstamp)
void SetTxFailedCallback(TxFailed callback)
Definition: edca-txop-n.cc:318
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:699
bool NeedBarRetransmission(void)
Check if Block ACK Request should be re-transmitted.
Definition: edca-txop-n.cc:925
bool GetAmpduExist(void)
uint8_t m_blockAckThreshold
Definition: edca-txop-n.h:539
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this EdcaTxopN is associated to.
Definition: edca-txop-n.cc:325
WifiMacHeader m_currentHdr
Definition: edca-txop-n.h:531
void NotifySleep(void)
When sleep operation occurs, re-insert pending packet into front of the queue.
Definition: edca-txop-n.cc:670
ns3::Time timeout
BlockAckType
Enumeration for different block ACK policies.
Definition: ctrl-headers.h:30
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:93
void NextFragment(void)
Continue to the next fragment.
Definition: edca-txop-n.cc:952
void SetTxOkCallback(TxOk callback)
Definition: edca-txop-n.cc:311
BlockAckManager * m_baManager
Definition: edca-txop-n.h:535
bool NeedRtsRetransmission(void)
Check if RTS should be re-transmitted if CTS was missed.
Definition: edca-txop-n.cc:909
struct Bar m_currentBar
Definition: edca-txop-n.h:543
virtual uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: edca-txop-n.cc:388
Handles sequence numbering of IEEE 802.11 data frames.
Definition: mac-tx-middle.h:39
DcfManager * m_manager
Definition: edca-txop-n.h:514
void MissedAck(void)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:745
enum TypeOfStation GetTypeOfStation(void) const
Return type of station.
Definition: edca-txop-n.cc:339
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:409
Ptr< MacLow > Low(void)
Return the MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:402
Ptr< WifiRemoteStationManager > m_stationManager
Definition: edca-txop-n.h:523
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:84
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
void NotifyAccessGranted(void)
Notify the EDCAF that access has been granted.
Definition: edca-txop-n.cc:445
RandomStream * m_rng
Definition: edca-txop-n.h:522
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:439
void NotifyInternalCollision(void)
Notify the EDCAF that internal collision has occurred.
Definition: edca-txop-n.cc:612
virtual void SetMinCw(uint32_t minCw)
Set the minimum congestion window size.
Definition: edca-txop-n.cc:353
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:433
void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator)
bool GetBaAgreementExists(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:279
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ACK mechanism.
MacTxMiddle * m_txMiddle
Definition: edca-txop-n.h:519
Callback< void, const WifiMacHeader & > TxOk
typedef for a callback to invoke when a packet transmission was completed successfully.
Definition: edca-txop-n.h:91
void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: edca-txop-n.cc:634
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:33
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:427
Headers for Block ack response.
Definition: ctrl-headers.h:183
void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: edca-txop-n.cc:663
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:250
uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
Definition: edca-txop-n.cc:291
uint8_t m_fragmentNumber
Definition: edca-txop-n.h:524
Time m_currentPacketTimestamp
Definition: edca-txop-n.h:541
virtual uint32_t GetMinCw(void) const
Return the minimum congestion window size.
Definition: edca-txop-n.cc:374
void MissedBlockAck(void)
Event handler when a Block ACK timeout has occurred.
Definition: edca-txop-n.cc:800
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
Definition: edca-txop-n.cc:990
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:871
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:96
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.
Definition: edca-txop-n.cc:959
an EUI-48 address
Definition: mac48-address.h:43
void Cancel(void)
Cancel the transmission.
Definition: edca-txop-n.cc:983
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:303
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:687
uint16_t GetNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: edca-txop-n.cc:422
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:540
static TypeId GetTypeId(void)
Definition: edca-txop-n.cc:200
BlockAckEventListener * m_blockAckListener
Definition: edca-txop-n.h:521
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:877
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:582
QosBlockedDestinations * m_qosBlockedDestinations
Definition: edca-txop-n.h:534
Implement the header for management frames of type del block ack.
Definition: mgt-headers.h:698
void CompleteAmpduTransfer(Mac48Address recipient, uint8_t tid)
Definition: edca-txop-n.cc:297
Ptr< MacLow > m_low
Definition: edca-txop-n.h:518
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:395
void GotCts(double snr, WifiMode txMode)
Event handler when a CTS is received.
Definition: edca-txop-n.cc:627
void DoDispose()
Destructor implementation.
Definition: edca-txop-n.cc:256
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:381
Ptr< WifiMacQueue > m_queue
Definition: edca-txop-n.h:515
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: edca-txop-n.cc:889
bool NeedRts(void)
Check if the current packet should be sent with a RTS protection.
Definition: edca-txop-n.cc:901
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:59
Ptr< MsduAggregator > m_aggregator
Definition: edca-txop-n.h:532
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:285
a unique identifier for an interface.
Definition: type-id.h:51
bool NeedsAccess(void) const
Check if the EDCAF requires access.
Definition: edca-txop-n.cc:416
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:35
uint32_t GetFragmentOffset(void)
Calculate the offset for the current fragment.
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:367
TypeOfStation m_typeOfStation
Definition: edca-txop-n.h:533
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:346