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 
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<RegularWifiMac> 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 
203  virtual void NotifyChannelSwitching (void);
208  virtual void NotifySleep (void);
212  virtual void NotifyOff (void);
216  virtual void NotifyWakeUp (void);
220  virtual void NotifyOn (void);
221 
222  /* Event handlers */
230  virtual void Queue (Ptr<Packet> packet, const WifiMacHeader &hdr);
231 
238  virtual void NotifyChannelAccessed (Time txopDuration = Seconds (0));
243  virtual void NotifyChannelReleased (void);
244 
254  int64_t AssignStreams (int64_t stream);
255 
259  virtual ChannelAccessStatus GetAccessStatus (void) const;
260 
267  void StartBackoffNow (uint32_t nSlots);
268 
269 protected:
271  friend class ChannelAccessManager;
272 
273  void DoDispose (void) override;
274  void DoInitialize (void) override;
275 
276  /* Txop notifications forwarded here */
280  virtual void NotifyAccessRequested (void);
281 
286  virtual bool HasFramesToTransmit (void);
290  virtual void GenerateBackoff (void);
294  virtual void StartAccessIfNeeded (void);
298  void RequestAccess (void);
299 
304  uint32_t GetCw (void) const;
310  uint32_t GetBackoffSlots (void) const;
316  Time GetBackoffStart (void) const;
323  void UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound);
324 
331 
332  uint32_t m_cwMin;
333  uint32_t m_cwMax;
334  uint32_t m_cw;
335  uint32_t m_backoff;
337  uint32_t m_backoffSlots;
338 
344 
345  uint8_t m_aifsn;
347 
350 };
351 
352 } //namespace ns3
353 
354 #endif /* TXOP_H */
ns3::Txop::SetDroppedMpduCallback
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
Definition: txop.cc:143
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:328
ns3::Txop::m_cw
uint32_t m_cw
the current contention window
Definition: txop.h:334
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:355
ns3::Txop::SetMaxCw
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:173
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:122
ns3::Txop::m_cwTrace
TracedValue< uint32_t > m_cwTrace
CW trace value.
Definition: txop.h:349
ns3::Txop::m_channelAccessManager
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
Definition: txop.h:325
ns3::Txop::GetAccessStatus
virtual ChannelAccessStatus GetAccessStatus(void) const
Definition: txop.cc:335
ns3::Txop::m_backoff
uint32_t m_backoff
the current backoff
Definition: txop.h:335
ns3::Txop::NotifyWakeUp
virtual void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
Definition: txop.cc:405
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:191
ns3::Txop::GRANTED
@ GRANTED
Definition: txop.h:96
ns3::Txop::m_cwMin
uint32_t m_cwMin
the minimum contention window
Definition: txop.h:332
ns3::Txop::m_cwMax
uint32_t m_cwMax
the maximum contention window
Definition: txop.h:333
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:309
ns3::Txop::StartBackoffNow
void StartBackoffNow(uint32_t nSlots)
Definition: txop.cc:231
ns3::Txop::m_rng
Ptr< UniformRandomVariable > m_rng
the random stream
Definition: txop.h:330
ns3::Txop::GetTxopLimit
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: txop.cc:280
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:348
ns3::Txop::UpdateFailedCw
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
Definition: txop.cc:199
wifi-mac-header.h
ns3::Txop::NotifyChannelSwitching
virtual void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: txop.cc:385
ns3::Txop::m_mac
Ptr< RegularWifiMac > m_mac
the wifi MAC
Definition: txop.h:329
ns3::Txop::SetMinCw
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:161
ns3::Txop::GenerateBackoff
virtual void GenerateBackoff(void)
Generate a new backoff now.
Definition: txop.cc:376
ns3::Txop::m_queue
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
Definition: txop.h:327
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:398
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:345
ns3::Txop::m_backoffSlots
uint32_t m_backoffSlots
the number of backoff slots
Definition: txop.h:337
ns3::Txop::NotifyOn
virtual void NotifyOn(void)
When on operation occurs, channel access will be started.
Definition: txop.cc:412
ns3::Txop::GetMinCw
virtual uint32_t GetMinCw(void) const
Return the minimum contention window size.
Definition: txop.cc:262
ns3::Txop::StartAccessIfNeeded
virtual void StartAccessIfNeeded(void)
Request access from Txop if needed.
Definition: txop.cc:317
ns3::Txop::REQUESTED
@ REQUESTED
Definition: txop.h:95
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:392
ns3::Txop::GetWifiMacQueue
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Definition: txop.cc:154
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:419
ns3::Txop::UpdateBackoffSlotsNow
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
Definition: txop.cc:222
ns3::Txop::GetMaxCw
virtual uint32_t GetMaxCw(void) const
Return the maximum contention window size.
Definition: txop.cc:268
ns3::Txop::m_droppedMpduCallback
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
Definition: txop.h:326
ns3::Txop::m_txopLimit
Time m_txopLimit
the TXOP limit time
Definition: txop.h:346
ns3::Txop::DoDispose
void DoDispose(void) override
Destructor implementation.
Definition: txop.cc:111
ns3::Txop::ChannelAccessStatus
ChannelAccessStatus
Enumeration for channel access status.
Definition: txop.h:93
ns3::Txop::~Txop
virtual ~Txop()
Definition: txop.cc:105
ns3::Txop::SetWifiMac
virtual void SetWifiMac(const Ptr< RegularWifiMac > mac)
Set the wifi MAC this Txop is associated to.
Definition: txop.cc:136
ns3::Txop::DoInitialize
void DoInitialize(void) override
Initialize() implementation.
Definition: txop.cc:327
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:348
ns3::Txop::SetTxopLimit
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:254
ns3::Txop::GetBackoffStart
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
Definition: txop.cc:216
ns3::Txop::GetAifsn
virtual uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: txop.cc:274
ns3::Txop::NotifyAccessRequested
virtual void NotifyAccessRequested(void)
Notify that access request has been received.
Definition: txop.cc:341
ns3::Txop::GetCw
uint32_t GetCw(void) const
Definition: txop.cc:185
ns3::Txop::m_access
ChannelAccessStatus m_access
channel access status
Definition: txop.h:336
ns3::TracedCallback< uint32_t >
ns3::Txop::HasFramesToTransmit
virtual bool HasFramesToTransmit(void)
Check if the Txop has frames to transmit.
Definition: txop.cc:286
ns3::Txop::RequestAccess
void RequestAccess(void)
Request access to the ChannelAccessManager.
Definition: txop.cc:367
ns3::Txop::SetTxMiddle
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Definition: txop.cc:129
ns3::Txop::DroppedMpdu
Callback< void, WifiMacDropReason, Ptr< const WifiMacQueueItem > > DroppedMpdu
typedef for a callback to invoke when an MPDU is dropped.
Definition: txop.h:87
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:343
ns3::Txop::NOT_REQUESTED
@ NOT_REQUESTED
Definition: txop.h:94
ns3::Txop::Queue
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:294
ns3::Txop::SetAifsn
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:247
ns3::Txop::GetBackoffSlots
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Definition: txop.cc:210
ns3::Txop
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:65