A Discrete-Event Network Simulator
API
channel-access-manager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005,2006 INRIA
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18  */
19 
20 #ifndef CHANNEL_ACCESS_MANAGER_H
21 #define CHANNEL_ACCESS_MANAGER_H
22 
23 #include "wifi-phy-common.h"
24 
25 #include "ns3/event-id.h"
26 #include "ns3/nstime.h"
27 #include "ns3/object.h"
28 
29 #include <algorithm>
30 #include <map>
31 #include <vector>
32 
33 namespace ns3
34 {
35 
36 class WifiPhy;
37 class PhyListener;
38 class Txop;
39 class FrameExchangeManager;
40 
57 {
58  public:
60  ~ChannelAccessManager() override;
61 
79  void SetLinkId(uint8_t linkId);
86 
97  void Add(Ptr<Txop> txop);
98 
106  bool NeedBackoffUponAccess(Ptr<Txop> txop);
107 
116  void RequestAccess(Ptr<Txop> txop);
117 
126  Time GetAccessGrantStart(bool ignoreNav = false) const;
127 
137  void DisableEdcaFor(Ptr<Txop> qosTxop, Time duration);
138 
150  uint16_t GetLargestIdlePrimaryChannel(Time interval, Time end);
151 
157  bool GetPer20MHzBusy(const std::set<uint8_t>& indices) const;
158 
165  void NotifyRxStartNow(Time duration);
170  void NotifyRxEndOkNow();
175  void NotifyRxEndErrorNow();
183  void NotifyTxStartNow(Time duration);
194  void NotifyCcaBusyStartNow(Time duration,
195  WifiChannelListType channelType,
196  const std::vector<Time>& per20MhzDurations);
204  void NotifySwitchingStartNow(Time duration);
208  void NotifySleepNow();
212  void NotifyOffNow();
216  void NotifyWakeupNow();
220  void NotifyOnNow();
226  void NotifyNavResetNow(Time duration);
232  void NotifyNavStartNow(Time duration);
238  void NotifyAckTimeoutStartNow(Time duration);
248  void NotifyCtsTimeoutStartNow(Time duration);
253 
261  bool IsBusy() const;
262 
263  protected:
264  void DoDispose() override;
265 
266  private:
271  void InitLastBusyStructs();
275  void UpdateBackoff();
303  void UpdateLastIdlePeriod();
304 
306 
311  void AccessTimeout();
315  void DoGrantDcfAccess();
316 
322  virtual Time GetSifs() const;
328  virtual Time GetSlot() const;
334  virtual Time GetEifsNoDifs() const;
335 
339  struct Timespan
340  {
341  Time start{0};
342  Time end{0};
343  };
344 
348  typedef std::vector<Ptr<Txop>> Txops;
349 
357  std::map<WifiChannelListType, Time>
359  std::vector<Time> m_lastPer20MHzBusyEnd;
361  std::map<WifiChannelListType, Timespan>
364  bool m_sleeping;
365  bool m_off;
371  uint8_t m_linkId;
372 };
373 
374 } // namespace ns3
375 
376 #endif /* CHANNEL_ACCESS_MANAGER_H */
Manage a set of ns3::Txop.
uint16_t GetLargestIdlePrimaryChannel(Time interval, Time end)
Return the width of the largest primary channel that has been idle for the given time interval before...
std::vector< Time > m_lastPer20MHzBusyEnd
the last busy end time per 20 MHz channel (HE stations and channel width > 20 MHz only)
bool IsBusy() const
Check if the device is busy sending or receiving, or NAV or CCA busy.
void NotifyRxEndErrorNow()
Notify the Txop that a packet reception was just completed unsuccessfuly.
bool m_off
flag whether it is in off state
void NotifyRxStartNow(Time duration)
Time GetBackoffEndFor(Ptr< Txop > txop)
Return the time when the backoff procedure ended (or will ended) for the given Txop.
void NotifyWakeupNow()
Notify the Txop that the device has been resumed from sleep mode.
bool m_lastRxReceivedOk
the last receive OK
std::map< WifiChannelListType, Timespan > m_lastIdle
the last idle start and end time for each channel type
Ptr< WifiPhy > m_phy
pointer to the PHY
void NotifyAckTimeoutResetNow()
Notify that ack timer has reset.
void NotifyTxStartNow(Time duration)
void NotifyRxEndOkNow()
Notify the Txop that a packet reception was just completed successfully.
virtual Time GetEifsNoDifs() const
Return the EIFS duration minus a DIFS.
uint8_t m_linkId
the ID of the link this object is associated with
void NotifyCcaBusyStartNow(Time duration, WifiChannelListType channelType, const std::vector< Time > &per20MhzDurations)
Time m_lastAckTimeoutEnd
the last Ack timeout end time
Time m_eifsNoDifs
EIFS no DIFS time.
virtual Time GetSlot() const
Return the slot duration for this PHY.
void NotifyAckTimeoutStartNow(Time duration)
Notify that ack timer has started for the given duration.
void AccessTimeout()
Called when access timeout should occur (e.g.
void UpdateBackoff()
Update backoff slots for all Txops.
bool m_sleeping
flag whether it is in sleeping state
void SetLinkId(uint8_t linkId)
Set the ID of the link this Channel Access Manager is associated with.
void SetupFrameExchangeManager(Ptr< FrameExchangeManager > feManager)
Set up the Frame Exchange Manager.
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
void RequestAccess(Ptr< Txop > txop)
Time m_lastSwitchingEnd
the last switching end time
Timespan m_lastRx
the last receive start and end time
std::map< WifiChannelListType, Time > m_lastBusyEnd
the last busy end time for each channel type
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for PHY events.
Time m_lastTxEnd
the last transmit end time
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for PHY events.
Time m_lastCtsTimeoutEnd
the last CTS timeout end time
void DoDispose() override
Destructor implementation.
void NotifySleepNow()
Notify the Txop that the device has been put in sleep mode.
Ptr< FrameExchangeManager > m_feManager
pointer to the Frame Exchange Manager
PhyListener * m_phyListener
the PHY listener
void UpdateLastIdlePeriod()
This method determines whether the medium has been idle during a period (of non-null duration) immedi...
std::vector< Ptr< Txop > > Txops
typedef for a vector of Txops
void NotifySwitchingStartNow(Time duration)
void DisableEdcaFor(Ptr< Txop > qosTxop, Time duration)
Txops m_txops
the vector of managed Txops
bool GetPer20MHzBusy(const std::set< uint8_t > &indices) const
void DoGrantDcfAccess()
Grant access to Txop using DCF/EDCF contention rules.
Time m_lastNavEnd
the last NAV end time
void NotifyCtsTimeoutResetNow()
Notify that CTS timer has reset.
void NotifyOffNow()
Notify the Txop that the device has been put in off mode.
void NotifyNavResetNow(Time duration)
Time GetAccessGrantStart(bool ignoreNav=false) const
Access will never be granted to the medium before the time returned by this method.
bool NeedBackoffUponAccess(Ptr< Txop > txop)
Determine if a new backoff needs to be generated when a packet is queued for transmission.
void NotifyOnNow()
Notify the Txop that the device has been resumed from off mode.
Time GetBackoffStartFor(Ptr< Txop > txop)
Return the time when the backoff procedure started for the given Txop.
virtual Time GetSifs() const
Return the Short Interframe Space (SIFS) for this PHY.
void NotifyNavStartNow(Time duration)
EventId m_accessTimeout
the access timeout ID
void InitLastBusyStructs()
Initialize the structures holding busy end times per channel type (primary, secondary,...
An identifier for simulation events.
Definition: event-id.h:55
A base class which provides memory management and object aggregation.
Definition: object.h:89
Listener for PHY events.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
WifiChannelListType
Enumeration of the possible channel-list parameter elements defined in Table 8-5 of IEEE 802....
Every class exported by the ns3 library is enclosed in the ns3 namespace.
phy
Definition: third.py:82
Structure defining start time and end time for a given state.
Declaration of the following enums: