A Discrete-Event Network Simulator
API
txop.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #ifndef TXOP_H
22 #define TXOP_H
23 
24 #include "ns3/traced-value.h"
25 #include "wifi-mac-header.h"
26 
27 namespace ns3 {
28 
29 class Packet;
30 class ChannelAccessManager;
31 class MacTxMiddle;
32 class WifiMode;
33 class WifiMacQueue;
34 class WifiMacQueueItem;
35 class UniformRandomVariable;
36 class CtrlBAckResponseHeader;
37 class WifiMac;
38 enum WifiMacDropReason : uint8_t; // opaque enum declaration
39 
64 class Txop : public Object
65 {
66 public:
67  Txop ();
68 
74  Txop (Ptr<WifiMacQueue> queue);
75 
76  virtual ~Txop ();
77 
82  static TypeId GetTypeId (void);
83 
88 
93  {
96  GRANTED
97  };
98 
104  virtual bool IsQosTxop () const;
105 
117  virtual void SetWifiMac (const Ptr<WifiMac> mac);
123  void SetTxMiddle (const Ptr<MacTxMiddle> txMiddle);
124 
128  virtual void SetDroppedMpduCallback (DroppedMpdu callback);
129 
136 
142  void SetMinCw (uint32_t minCw);
148  void SetMaxCw (uint32_t maxCw);
154  void SetAifsn (uint8_t aifsn);
161  void SetTxopLimit (Time txopLimit);
167  virtual uint32_t GetMinCw (void) const;
173  virtual uint32_t GetMaxCw (void) const;
179  virtual uint8_t GetAifsn (void) const;
185  Time GetTxopLimit (void) const;
192  void ResetCw (void);
198  void UpdateFailedCw (void);
199 
204  virtual void NotifySleep (void);
208  virtual void NotifyOff (void);
212  virtual void NotifyWakeUp (void);
216  virtual void NotifyOn (void);
217 
218  /* Event handlers */
226  virtual void Queue (Ptr<Packet> packet, const WifiMacHeader &hdr);
227 
234  virtual void NotifyChannelAccessed (Time txopDuration = Seconds (0));
239  virtual void NotifyChannelReleased (void);
240 
250  int64_t AssignStreams (int64_t stream);
251 
255  virtual ChannelAccessStatus GetAccessStatus (void) const;
256 
263  void StartBackoffNow (uint32_t nSlots);
264 
265 protected:
267  friend class ChannelAccessManager;
268 
269  void DoDispose (void) override;
270  void DoInitialize (void) override;
271 
272  /* Txop notifications forwarded here */
276  virtual void NotifyAccessRequested (void);
277 
282  virtual bool HasFramesToTransmit (void);
286  virtual void GenerateBackoff (void);
290  virtual void StartAccessIfNeeded (void);
294  void RequestAccess (void);
295 
300  uint32_t GetCw (void) const;
306  uint32_t GetBackoffSlots (void) const;
312  Time GetBackoffStart (void) const;
319  void UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound);
320 
327 
328  uint32_t m_cwMin;
329  uint32_t m_cwMax;
330  uint32_t m_cw;
331  uint32_t m_backoff;
333  uint32_t m_backoffSlots;
340 
341  uint8_t m_aifsn;
343 
346 };
347 
348 } //namespace ns3
349 
350 #endif /* TXOP_H */
Callback template class.
Definition: callback.h:1279
Manage a set of ns3::Txop.
A base class which provides memory management and object aggregation.
Definition: object.h:88
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:65
Ptr< WifiMac > m_mac
the wifi MAC
Definition: txop.h:325
void DoInitialize(void) override
Initialize() implementation.
Definition: txop.cc:327
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: txop.cc:309
virtual ChannelAccessStatus GetAccessStatus(void) const
Definition: txop.cc:335
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
Definition: txop.cc:199
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
Definition: txop.h:323
virtual void NotifyChannelReleased(void)
Called by the FrameExchangeManager to notify the completion of the transmissions.
Definition: txop.cc:355
Ptr< UniformRandomVariable > m_rng
the random stream
Definition: txop.h:326
uint32_t m_backoff
the current backoff
Definition: txop.h:331
uint32_t GetCw(void) const
Definition: txop.cc:185
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:173
virtual void NotifySleep(void)
When sleep operation occurs, if there is a pending packet transmission, it will be reinserted to the ...
Definition: txop.cc:385
uint32_t m_cw
the current contention window
Definition: txop.h:330
ChannelAccessStatus m_access
channel access status
Definition: txop.h:332
TracedValue< uint32_t > m_cwTrace
CW trace value.
Definition: txop.h:345
ChannelAccessStatus
Enumeration for channel access status.
Definition: txop.h:93
@ GRANTED
Definition: txop.h:96
@ NOT_REQUESTED
Definition: txop.h:94
@ REQUESTED
Definition: txop.h:95
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Definition: txop.cc:154
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: txop.cc:280
virtual void SetWifiMac(const Ptr< WifiMac > mac)
Set the wifi MAC this Txop is associated to.
Definition: txop.cc:136
TracedCallback< uint32_t > m_backoffTrace
backoff trace value
Definition: txop.h:344
uint8_t m_aifsn
the AIFSN
Definition: txop.h:341
virtual void NotifyAccessRequested(void)
Notify that access request has been received.
Definition: txop.cc:341
uint32_t m_cwMin
the minimum contention window
Definition: txop.h:328
Time m_backoffStart
the backoffStart variable is used to keep track of the time at which a backoff was started or the tim...
Definition: txop.h:339
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:254
virtual void NotifyOn(void)
When on operation occurs, channel access will be started.
Definition: txop.cc:405
static TypeId GetTypeId(void)
Get the type ID.
Definition: txop.cc:43
Txop()
Definition: txop.cc:85
virtual bool IsQosTxop() const
Check for QoS TXOP.
Definition: txop.cc:412
virtual void NotifyChannelAccessed(Time txopDuration=Seconds(0))
Called by the FrameExchangeManager to notify that channel access has been granted for the given amoun...
Definition: txop.cc:348
Time m_txopLimit
the TXOP limit time
Definition: txop.h:342
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
Definition: txop.h:322
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Definition: txop.cc:129
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:247
Callback< void, WifiMacDropReason, Ptr< const WifiMacQueueItem > > DroppedMpdu
typedef for a callback to invoke when an MPDU is dropped.
Definition: txop.h:87
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
Definition: txop.h:321
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
Definition: txop.cc:143
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
Definition: txop.cc:222
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
Definition: txop.cc:191
uint32_t m_backoffSlots
the number of backoff slots
Definition: txop.h:333
void RequestAccess(void)
Request access to the ChannelAccessManager.
Definition: txop.cc:367
Ptr< MacTxMiddle > m_txMiddle
the MacTxMiddle
Definition: txop.h:324
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
Definition: txop.cc:216
virtual ~Txop()
Definition: txop.cc:105
virtual uint32_t GetMaxCw(void) const
Return the maximum contention window size.
Definition: txop.cc:268
uint32_t m_cwMax
the maximum contention window
Definition: txop.h:329
virtual void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
Definition: txop.cc:398
void StartBackoffNow(uint32_t nSlots)
Definition: txop.cc:231
virtual void NotifyOff(void)
When off operation occurs, the queue gets cleaned up.
Definition: txop.cc:391
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:161
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Definition: txop.cc:210
void SetChannelAccessManager(const Ptr< ChannelAccessManager > manager)
Set ChannelAccessManager this Txop is associated to.
Definition: txop.cc:122
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:294
virtual void GenerateBackoff(void)
Generate a new backoff now.
Definition: txop.cc:376
virtual bool HasFramesToTransmit(void)
Check if the Txop has frames to transmit.
Definition: txop.cc:286
virtual uint32_t GetMinCw(void) const
Return the minimum contention window size.
Definition: txop.cc:262
virtual uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: txop.cc:274
void DoDispose(void) override
Destructor implementation.
Definition: txop.cc:111
virtual void StartAccessIfNeeded(void)
Request access from Txop if needed.
Definition: txop.cc:317
a unique identifier for an interface.
Definition: type-id.h:59
Implements the IEEE 802.11 MAC header.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
WifiMacDropReason
The reason why an MPDU was dropped.
Definition: wifi-mac.h:66
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mac
Definition: third.py:99