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 WifiRemoteStationManager;
38 enum WifiMacDropReason : uint8_t; // opaque enum declaration
39 enum AcIndex : uint8_t;
40 
65 class Txop : public Object
66 {
67 public:
70 
71  Txop ();
72  virtual ~Txop ();
73 
78  static TypeId GetTypeId (void);
79 
84 
89  {
93  };
94 
100  virtual bool IsQosTxop () const;
106  virtual AcIndex GetAccessCategory (void) const;
107 
119  virtual void SetWifiRemoteStationManager (const Ptr<WifiRemoteStationManager> remoteManager);
125  void SetTxMiddle (const Ptr<MacTxMiddle> txMiddle);
126 
130  virtual void SetDroppedMpduCallback (DroppedMpdu callback);
131 
138 
144  void SetMinCw (uint32_t minCw);
150  void SetMaxCw (uint32_t maxCw);
156  void SetAifsn (uint8_t aifsn);
163  void SetTxopLimit (Time txopLimit);
169  uint32_t GetMinCw (void) const;
175  uint32_t GetMaxCw (void) const;
181  uint8_t GetAifsn (void) const;
187  Time GetTxopLimit (void) const;
194  void ResetCw (void);
200  void UpdateFailedCw (void);
201 
205  virtual void NotifyChannelSwitching (void);
210  virtual void NotifySleep (void);
214  virtual void NotifyOff (void);
218  virtual void NotifyWakeUp (void);
222  virtual void NotifyOn (void);
223 
224  /* Event handlers */
232  virtual void Queue (Ptr<Packet> packet, const WifiMacHeader &hdr);
233 
240  virtual void NotifyChannelAccessed (Time txopDuration = Seconds (0));
245  virtual void NotifyChannelReleased (void);
246 
256  int64_t AssignStreams (int64_t stream);
257 
261  virtual ChannelAccessStatus GetAccessStatus (void) const;
262 
269  void StartBackoffNow (uint32_t nSlots);
270 
271 protected:
273  friend class ChannelAccessManager;
274 
275  void DoDispose (void) override;
276  void DoInitialize (void) override;
277 
278  /* Txop notifications forwarded here */
282  virtual void NotifyAccessRequested (void);
286  virtual void NotifyInternalCollision (void);
287 
292  virtual bool HasFramesToTransmit (void);
296  virtual void GenerateBackoff (void);
300  virtual void StartAccessIfNeeded (void);
304  void RequestAccess (void);
305 
310  uint32_t GetCw (void) const;
316  uint32_t GetBackoffSlots (void) const;
322  Time GetBackoffStart (void) const;
329  void UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound);
330 
337 
338  uint32_t m_cwMin;
339  uint32_t m_cwMax;
340  uint32_t m_cw;
341  uint32_t m_backoff;
343  uint32_t m_backoffSlots;
344 
350 
351  uint8_t m_aifsn;
353 
356 };
357 
358 } //namespace ns3
359 
360 #endif /* TXOP_H */
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
uint8_t m_aifsn
the AIFSN
Definition: txop.h:351
Ptr< MacTxMiddle > m_txMiddle
the MacTxMiddle
Definition: txop.h:334
Callback template class.
Definition: callback.h:1278
TracedCallback< uint32_t > m_backoffTrace
backoff trace value
Definition: txop.h:354
TracedValue< uint32_t > m_cwTrace
CW trace value.
Definition: txop.h:355
void DoInitialize(void) override
Initialize() implementation.
Definition: txop.cc:321
Time m_txopLimit
the TXOP limit time
Definition: txop.h:352
virtual void StartAccessIfNeeded(void)
Request access from Txop if needed.
Definition: txop.cc:311
uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: txop.cc:268
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:70
uint32_t m_backoffSlots
the number of backoff slots
Definition: txop.h:343
Callback< void, WifiMacDropReason, Ptr< const WifiMacQueueItem > > DroppedMpdu
typedef for a callback to invoke when an MPDU is dropped.
Definition: txop.h:83
virtual bool HasFramesToTransmit(void)
Check if the Txop has frames to transmit.
Definition: txop.cc:280
uint32_t m_backoff
the current backoff
Definition: txop.h:341
void RequestAccess(void)
Request access to the ChannelAccessManager.
Definition: txop.cc:361
void SetChannelAccessManager(const Ptr< ChannelAccessManager > manager)
Set ChannelAccessManager this Txop is associated to.
Definition: txop.cc:118
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
Definition: txop.h:331
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
Definition: txop.cc:210
Manage a set of ns3::TxopHandle a set of independent ns3::Txop, each of which represents a single DCF...
Ptr< UniformRandomVariable > m_rng
the random stream
Definition: txop.h:336
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
Definition: txop.cc:216
virtual void GenerateBackoff(void)
Generate a new backoff now.
Definition: txop.cc:370
virtual ChannelAccessStatus GetAccessStatus(void) const
Definition: txop.cc:329
uint32_t GetMinCw(void) const
Return the minimum contention window size.
Definition: txop.cc:256
uint32_t m_cwMax
the maximum contention window
Definition: txop.h:339
virtual void NotifyOff(void)
When off operation occurs, the queue gets cleaned up.
Definition: txop.cc:400
ChannelAccessStatus
Enumeration for channel access status.
Definition: txop.h:88
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
Definition: txop.cc:195
virtual AcIndex GetAccessCategory(void) const
Get the access category.
Definition: txop.cc:427
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: txop.cc:303
virtual void NotifyChannelReleased(void)
Called by the FrameExchangeManager to notify the completion of the transmissions. ...
Definition: txop.cc:349
static TypeId GetTypeId(void)
Get the type ID.
Definition: txop.cc:44
ChannelAccessStatus m_access
channel access status
Definition: txop.h:342
virtual bool IsQosTxop() const
Check for QoS TXOP.
Definition: txop.cc:421
uint32_t m_cwMin
the minimum contention window
Definition: txop.h:338
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetCw(void) const
Definition: txop.cc:181
virtual void NotifySleep(void)
When sleep operation occurs, if there is a pending packet transmission, it will be reinserted to the ...
Definition: txop.cc:394
uint32_t GetMaxCw(void) const
Return the maximum contention window size.
Definition: txop.cc:262
virtual void NotifyOn(void)
When on operation occurs, channel access will be started.
Definition: txop.cc:414
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
Definition: txop.h:333
void DoDispose(void) override
Destructor implementation.
Definition: txop.cc:107
virtual void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: txop.cc:387
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
Definition: txop.h:332
virtual void NotifyInternalCollision(void)
Notify the Txop that internal collision has occurred.
Definition: txop.cc:379
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:342
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
Definition: txop.cc:139
uint32_t m_cw
the current contention window
Definition: txop.h:340
Txop()
Definition: txop.cc:86
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:157
friend class MacLowTransmissionListener
allow MacLowTransmissionListener class access
Definition: txop.h:69
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:169
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:248
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:349
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Definition: txop.cc:125
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Definition: txop.cc:204
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Definition: txop.cc:150
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this Txop is associated to.
Definition: txop.cc:132
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:241
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual void NotifyAccessRequested(void)
Notify that access request has been received.
Definition: txop.cc:335
virtual ~Txop()
Definition: txop.cc:101
Ptr< WifiRemoteStationManager > m_stationManager
the wifi remote station manager
Definition: txop.h:335
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:288
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
Definition: txop.cc:187
a unique identifier for an interface.
Definition: type-id.h:58
void StartBackoffNow(uint32_t nSlots)
Definition: txop.cc:225
WifiMacDropReason
The reason why an MPDU was dropped.
Definition: wifi-mac.h:54
Implements the IEEE 802.11 MAC header.
virtual void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
Definition: txop.cc:407
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:65
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: txop.cc:274