A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
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
25 #include "ns3/object.h"
26 #include "ns3/mac48-address.h"
27 #include "ns3/packet.h"
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"
37 #include <map>
38 #include <list>
40 namespace ns3 {
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;
60 {
61  STA,
62  AP,
69 };
84 class EdcaTxopN : public Dcf
85 {
86 public:
98  static TypeId GetTypeId (void);
99  EdcaTxopN ();
100  virtual ~EdcaTxopN ();
101  void DoDispose ();
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  Ptr<WifiMacQueue > GetQueue () const;
151  virtual void SetMinCw (uint32_t minCw);
152  virtual void SetMaxCw (uint32_t maxCw);
153  virtual void SetAifsn (uint32_t aifsn);
154  virtual uint32_t GetMinCw (void) const;
155  virtual uint32_t GetMaxCw (void) const;
156  virtual uint32_t GetAifsn (void) const;
163  Ptr<MacLow> Low (void);
166  /* dcf notifications forwarded here */
173  bool NeedsAccess (void) const;
177  void NotifyAccessGranted (void);
181  void NotifyInternalCollision (void);
185  void NotifyCollision (void);
189  void NotifyChannelSwitching (void);
191  /* Event handlers */
198  void GotCts (double snr, WifiMode txMode);
202  void MissedCts (void);
209  void GotAck (double snr, WifiMode txMode);
216  void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient);
220  void MissedBlockAck (void);
221  void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
222  void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient);
226  void MissedAck (void);
231  void StartNext (void);
235  void Cancel (void);
240  void EndTxNoAck (void);
245  void RestartAccessIfNeeded (void);
249  void StartAccessIfNeeded (void);
255  bool NeedRts (void);
261  bool NeedRtsRetransmission (void);
267  bool NeedDataRetransmission (void);
274  bool NeedFragmentation (void) const;
280  uint32_t GetNextFragmentSize (void);
286  uint32_t GetFragmentSize (void);
292  uint32_t GetFragmentOffset (void);
299  bool IsLastFragment (void) const;
305  void NextFragment (void);
320  void SetAccessCategory (enum AcIndex ac);
328  void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
337  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
341  void CompleteConfig (void);
348  void SetBlockAckThreshold (uint8_t threshold);
354  uint8_t GetBlockAckThreshold (void) const;
355  void SetBlockAckInactivityTimeout (uint16_t timeout);
356  void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator);
366  int64_t AssignStreams (int64_t stream);
368 private:
369  void DoInitialize ();
384  EdcaTxopN &operator = (const EdcaTxopN &);
385  EdcaTxopN (const EdcaTxopN &);
393  bool SetupBlockAckIfNeeded ();
404  void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq,
405  uint16_t timeout, bool immediateBAck);
412  void SendBlockAckRequest (const struct Bar &bar);
417  void CompleteTx (void);
422  void VerifyBlockAck (void);
425  class Dcf;
426  class TransmissionListener;
428  friend class Dcf;
429  friend class TransmissionListener;
443  /* current packet could be a simple MSDU or, if an aggregator for this queue is
444  present, could be an A-MSDU.
445  */
453  /*
454  * Represents the minimum number of packets for use of block ack.
455  */
461 };
463 } // namespace ns3
465 #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:276
TransmissionListener * m_transmissionListener
Definition: edca-txop-n.h:437
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
Ptr< const Packet > m_currentPacket
Definition: edca-txop-n.h:446
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
void DoInitialize()
This method is called only once by Object::Initialize.
TxFailed m_txFailedCallback
Definition: edca-txop-n.h:434
void SetBlockAckInactivityTimeout(uint16_t timeout)
uint32_t GetFragmentSize(void)
Calculate the size of the current fragment.
Definition: edca-txop-n.cc:769
uint16_t m_blockAckInactivityTimeout
Definition: edca-txop-n.h:459
void VerifyBlockAck(void)
Verifies if dequeued packet has to be transmitted with ack policy Block Ack.
Definition: edca-txop-n.cc:923
void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient)
Event handler when a Block ACK is received.
Definition: edca-txop-n.cc:911
void NotifyCollision(void)
Notify the EDCAF that collision has occurred.
Definition: edca-txop-n.cc:511
void SetTypeOfStation(enum TypeOfStation type)
Set type of station with the given type.
Definition: edca-txop-n.cc:248
bool NeedDataRetransmission(void)
Check if DATA should be re-transmitted if ACK was missed.
Definition: edca-txop-n.cc:704
void SetTxFailedCallback(TxFailed callback)
Definition: edca-txop-n.cc:235
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:571
uint8_t m_blockAckThreshold
Definition: edca-txop-n.h:456
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this EdcaTxopN is associated to.
Definition: edca-txop-n.cc:242
WifiMacHeader m_currentHdr
Definition: edca-txop-n.h:448
ns3::Time timeout
Enumeration for different block ACK policies.
Definition: ctrl-headers.h:30
Block Ack Request.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:91
void NextFragment(void)
Continue to the next fragment.
Definition: edca-txop-n.cc:712
void SetTxOkCallback(TxOk callback)
Definition: edca-txop-n.cc:228
BlockAckManager * m_baManager
Definition: edca-txop-n.h:452
bool NeedRtsRetransmission(void)
Check if RTS should be re-transmitted if CTS was missed.
Definition: edca-txop-n.cc:696
struct Bar m_currentBar
Definition: edca-txop-n.h:460
virtual uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: edca-txop-n.cc:304
Handles sequence numbering of IEEE 802.11 data frames.
Definition: mac-tx-middle.h:39
DcfManager * m_manager
Definition: edca-txop-n.h:431
void MissedAck(void)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:617
enum TypeOfStation GetTypeOfStation(void) const
Return type of station.
Definition: edca-txop-n.cc:255
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:325
Ptr< MacLow > Low(void)
Return the MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:318
Ptr< WifiRemoteStationManager > m_stationManager
Definition: edca-txop-n.h:440
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:84
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
Definition: edca-txop-n.cc:903
void NotifyAccessGranted(void)
Notify the EDCAF that access has been granted.
Definition: edca-txop-n.cc:339
RandomStream * m_rng
Definition: edca-txop-n.h:439
void NotifyInternalCollision(void)
Notify the EDCAF that internal collision has occurred.
Definition: edca-txop-n.cc:504
virtual void SetMinCw(uint32_t minCw)
Set the minimum congestion window size.
Definition: edca-txop-n.cc:269
void SendAddBaRequest(Mac48Address recipient, uint8_t tid, uint16_t startSeq, uint16_t timeout, bool immediateBAck)
Sends an ADDBARequest to establish a block ack agreement with sta addressed by recipient for tid tid...
void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator)
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ACK mechanism.
MacTxMiddle * m_txMiddle
Definition: edca-txop-n.h:436
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:526
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:229
A simple wrapper around RngStream to make testing of the code easier.
Definition: random-stream.h:33
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:551
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.
Definition: edca-txop-n.cc:802
virtual ~EdcaTxopN()
Definition: edca-txop-n.cc:191
uint8_t m_fragmentNumber
Definition: edca-txop-n.h:441
Time m_currentPacketTimestamp
Definition: edca-txop-n.h:458
virtual uint32_t GetMinCw(void) const
Return the minimum congestion window size.
Definition: edca-txop-n.cc:290
void MissedBlockAck(void)
Event handler when a Block ACK timeout has occurred.
Definition: edca-txop-n.cc:644
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
Definition: edca-txop-n.cc:750
bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
Definition: edca-txop-n.cc:761
Ptr< MsduAggregator > GetMsduAggregator(void) const
Definition: edca-txop-n.cc:658
void SetAccessCategory(enum AcIndex ac)
Set the access category of this EDCAF.
Definition: edca-txop-n.cc:823
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)
Definition: edca-txop-n.cc:846
bool SetupBlockAckIfNeeded()
If number of packets in the queue reaches m_blockAckThreshold value, an ADDBARequest frame is sent to...
Definition: edca-txop-n.cc:956
void StartNext(void)
Start transmission for the next fragment.
Definition: edca-txop-n.cc:719
an EUI-48 address
Definition: mac48-address.h:41
void Cancel(void)
Cancel the transmission.
Definition: edca-txop-n.cc:743
void SetManager(DcfManager *manager)
Set DcfManager this EdcaTxopN is associated to.
Definition: edca-txop-n.cc:220
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:559
void SetMsduAggregator(Ptr< MsduAggregator > aggr)
Definition: edca-txop-n.cc:862
EdcaTxopN & operator=(const EdcaTxopN &)
void PushFront(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:869
enum BlockAckType m_blockAckType
Definition: edca-txop-n.h:457
static TypeId GetTypeId(void)
Definition: edca-txop-n.cc:144
BlockAckEventListener * m_blockAckListener
Definition: edca-txop-n.h:438
uint32_t GetNextFragmentSize(void)
Calculate the size of the next fragment.
Definition: edca-txop-n.cc:777
void CompleteConfig(void)
Complete block ACK configuration.
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: edca-txop-n.cc:664
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:451
Implement the header for management frames of type del block ack.
Definition: mgt-headers.h:698
Ptr< MacLow > m_low
Definition: edca-txop-n.h:435
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...
Definition: edca-txop-n.cc:940
void SetTxMiddle(MacTxMiddle *txMiddle)
Definition: edca-txop-n.cc:311
void GotCts(double snr, WifiMode txMode)
Event handler when a CTS is received.
Definition: edca-txop-n.cc:519
void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: edca-txop-n.cc:197
bool IsLastFragment(void) const
Check if the curren fragment is the last fragment.
Definition: edca-txop-n.cc:794
virtual uint32_t GetMaxCw(void) const
Return the maximum congestion window size.
Definition: edca-txop-n.cc:297
Ptr< WifiMacQueue > m_queue
Definition: edca-txop-n.h:432
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: edca-txop-n.cc:676
bool NeedRts(void)
Check if the current packet should be sent with a RTS protection.
Definition: edca-txop-n.cc:688
void SendBlockAckRequest(const struct Bar &bar)
After that all packets, for which a block ack agreement was established, have been transmitted...
Definition: edca-txop-n.cc:975
Enumeration for type of station.
Definition: edca-txop-n.h:59
Ptr< MsduAggregator > m_aggregator
Definition: edca-txop-n.h:449
Manages all block ack agreements for an originator station.
Ptr< WifiMacQueue > GetQueue() const
Return the packet queue associated with this EdcaTxopN.
Definition: edca-txop-n.cc:262
a unique identifier for an interface.
Definition: type-id.h:49
bool NeedsAccess(void) const
Check if the EDCAF requires access.
Definition: edca-txop-n.cc:332
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.
Definition: edca-txop-n.cc:785
Implements the IEEE 802.11 MAC header.
void GotAddBaResponse(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
Definition: edca-txop-n.cc:881
virtual void SetAifsn(uint32_t aifsn)
Definition: edca-txop-n.cc:283
TypeOfStation m_typeOfStation
Definition: edca-txop-n.h:450
Mac48Address MapSrcAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set addresses in a-msdu subframe.
Definition: edca-txop-n.cc:830