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 RegularWifiMac;
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  {
92  GRANTED
93  };
94 
100  virtual bool IsQosTxop () const;
106  virtual AcIndex GetAccessCategory (void) const;
107 
119  virtual void SetWifiMac (const Ptr<RegularWifiMac> mac);
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);
283 
288  virtual bool HasFramesToTransmit (void);
292  virtual void GenerateBackoff (void);
296  virtual void StartAccessIfNeeded (void);
300  void RequestAccess (void);
301 
306  uint32_t GetCw (void) const;
312  uint32_t GetBackoffSlots (void) const;
318  Time GetBackoffStart (void) const;
325  void UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound);
326 
333 
334  uint32_t m_cwMin;
335  uint32_t m_cwMax;
336  uint32_t m_cw;
337  uint32_t m_backoff;
339  uint32_t m_backoffSlots;
340 
346 
347  uint8_t m_aifsn;
349 
352 };
353 
354 } //namespace ns3
355 
356 #endif /* TXOP_H */
ns3::Txop::SetDroppedMpduCallback
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
Definition: txop.cc:138
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::Txop::m_txMiddle
Ptr< MacTxMiddle > m_txMiddle
the MacTxMiddle
Definition: txop.h:330
ns3::Txop::m_cw
uint32_t m_cw
the current contention window
Definition: txop.h:336
ns3::ChannelAccessManager
Manage a set of ns3::Txop.
Definition: channel-access-manager.h:52
ns3::Txop::NotifyChannelReleased
virtual void NotifyChannelReleased(void)
Called by the FrameExchangeManager to notify the completion of the transmissions.
Definition: txop.cc:348
ns3::Txop::SetMaxCw
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:168
ns3::WifiMacDropReason
WifiMacDropReason
The reason why an MPDU was dropped.
Definition: wifi-mac.h:55
ns3::Callback
Callback template class.
Definition: callback.h:1279
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Txop::SetChannelAccessManager
void SetChannelAccessManager(const Ptr< ChannelAccessManager > manager)
Set ChannelAccessManager this Txop is associated to.
Definition: txop.cc:117
ns3::Txop::MacLowTransmissionListener
friend class MacLowTransmissionListener
allow MacLowTransmissionListener class access
Definition: txop.h:69
ns3::Txop::m_cwTrace
TracedValue< uint32_t > m_cwTrace
CW trace value.
Definition: txop.h:351
ns3::Txop::m_channelAccessManager
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
Definition: txop.h:327
ns3::Txop::GetAccessStatus
virtual ChannelAccessStatus GetAccessStatus(void) const
Definition: txop.cc:328
ns3::Txop::m_backoff
uint32_t m_backoff
the current backoff
Definition: txop.h:337
ns3::Txop::NotifyWakeUp
virtual void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
Definition: txop.cc:398
ns3::Txop::ResetCw
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
Definition: txop.cc:186
ns3::Txop::GRANTED
@ GRANTED
Definition: txop.h:92
ns3::Txop::m_cwMin
uint32_t m_cwMin
the minimum contention window
Definition: txop.h:334
ns3::Txop::m_cwMax
uint32_t m_cwMax
the maximum contention window
Definition: txop.h:335
third.mac
mac
Definition: third.py:99
ns3::Txop::AssignStreams
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: txop.cc:302
ns3::Txop::StartBackoffNow
void StartBackoffNow(uint32_t nSlots)
Definition: txop.cc:224
ns3::Txop::m_rng
Ptr< UniformRandomVariable > m_rng
the random stream
Definition: txop.h:332
ns3::Txop::GetTxopLimit
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: txop.cc:273
ns3::Txop::NotifyChannelAccessed
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:341
ns3::Txop::UpdateFailedCw
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
Definition: txop.cc:194
ns3::Txop::GetAccessCategory
virtual AcIndex GetAccessCategory(void) const
Get the access category.
Definition: txop.cc:418
wifi-mac-header.h
ns3::Txop::NotifyChannelSwitching
virtual void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: txop.cc:378
ns3::Txop::m_mac
Ptr< RegularWifiMac > m_mac
the wifi MAC
Definition: txop.h:331
ns3::Txop::SetMinCw
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:156
ns3::Txop::GenerateBackoff
virtual void GenerateBackoff(void)
Generate a new backoff now.
Definition: txop.cc:369
ns3::Txop::m_queue
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
Definition: txop.h:329
ns3::WifiMacHeader
Implements the IEEE 802.11 MAC header.
Definition: wifi-mac-header.h:85
ns3::Txop::NotifyOff
virtual void NotifyOff(void)
When off operation occurs, the queue gets cleaned up.
Definition: txop.cc:391
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::Txop::m_aifsn
uint8_t m_aifsn
the AIFSN
Definition: txop.h:347
ns3::Txop::m_backoffSlots
uint32_t m_backoffSlots
the number of backoff slots
Definition: txop.h:339
ns3::Txop::NotifyOn
virtual void NotifyOn(void)
When on operation occurs, channel access will be started.
Definition: txop.cc:405
ns3::Txop::GetMinCw
uint32_t GetMinCw(void) const
Return the minimum contention window size.
Definition: txop.cc:255
ns3::Txop::StartAccessIfNeeded
virtual void StartAccessIfNeeded(void)
Request access from Txop if needed.
Definition: txop.cc:310
ns3::Txop::REQUESTED
@ REQUESTED
Definition: txop.h:91
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::Txop::Txop
Txop()
Definition: txop.cc:85
ns3::Txop::NotifySleep
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
ns3::Txop::GetWifiMacQueue
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Definition: txop.cc:149
ns3::Txop::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: txop.cc:43
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::Txop::IsQosTxop
virtual bool IsQosTxop() const
Check for QoS TXOP.
Definition: txop.cc:412
ns3::Txop::UpdateBackoffSlotsNow
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
Definition: txop.cc:215
ns3::Txop::GetMaxCw
uint32_t GetMaxCw(void) const
Return the maximum contention window size.
Definition: txop.cc:261
ns3::Txop::m_droppedMpduCallback
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
Definition: txop.h:328
ns3::Txop::m_txopLimit
Time m_txopLimit
the TXOP limit time
Definition: txop.h:348
ns3::Txop::DoDispose
void DoDispose(void) override
Destructor implementation.
Definition: txop.cc:106
ns3::Txop::ChannelAccessStatus
ChannelAccessStatus
Enumeration for channel access status.
Definition: txop.h:89
ns3::Txop::~Txop
virtual ~Txop()
Definition: txop.cc:100
ns3::Txop::SetWifiMac
virtual void SetWifiMac(const Ptr< RegularWifiMac > mac)
Set the wifi MAC this Txop is associated to.
Definition: txop.cc:131
ns3::Txop::DoInitialize
void DoInitialize(void) override
Initialize() implementation.
Definition: txop.cc:320
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::TracedValue< uint32_t >
ns3::Txop::m_backoffTrace
TracedCallback< uint32_t > m_backoffTrace
backoff trace value
Definition: txop.h:350
ns3::AcIndex
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:71
ns3::Txop::SetTxopLimit
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:247
ns3::Txop::GetBackoffStart
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
Definition: txop.cc:209
ns3::Txop::GetAifsn
uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: txop.cc:267
ns3::Txop::NotifyAccessRequested
virtual void NotifyAccessRequested(void)
Notify that access request has been received.
Definition: txop.cc:334
ns3::Txop::GetCw
uint32_t GetCw(void) const
Definition: txop.cc:180
ns3::Txop::m_access
ChannelAccessStatus m_access
channel access status
Definition: txop.h:338
ns3::TracedCallback< uint32_t >
ns3::Txop::HasFramesToTransmit
virtual bool HasFramesToTransmit(void)
Check if the Txop has frames to transmit.
Definition: txop.cc:279
ns3::Txop::RequestAccess
void RequestAccess(void)
Request access to the ChannelAccessManager.
Definition: txop.cc:360
ns3::Txop::SetTxMiddle
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Definition: txop.cc:124
ns3::Txop::DroppedMpdu
Callback< void, WifiMacDropReason, Ptr< const WifiMacQueueItem > > DroppedMpdu
typedef for a callback to invoke when an MPDU is dropped.
Definition: txop.h:83
ns3::Txop::m_backoffStart
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:345
ns3::Txop::NOT_REQUESTED
@ NOT_REQUESTED
Definition: txop.h:90
ns3::Txop::Queue
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:287
ns3::Txop::SetAifsn
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:240
ns3::Txop::GetBackoffSlots
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Definition: txop.cc:203
ns3::Txop
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:66