A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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"
25
26#include "ns3/event-id.h"
27#include "ns3/nstime.h"
28#include "ns3/object.h"
29
30#include <algorithm>
31#include <map>
32#include <memory>
33#include <unordered_map>
34#include <vector>
35
36namespace ns3
37{
38
39class WifiPhy;
40class PhyListener;
41class Txop;
42class FrameExchangeManager;
43
60{
61 public:
63 ~ChannelAccessManager() override;
64
91 void SetLinkId(uint8_t linkId);
98
109 void Add(Ptr<Txop> txop);
110
119
128 void RequestAccess(Ptr<Txop> txop);
129
138 Time GetAccessGrantStart(bool ignoreNav = false) const;
139
149 void DisableEdcaFor(Ptr<Txop> qosTxop, Time duration);
150
162 uint16_t GetLargestIdlePrimaryChannel(Time interval, Time end);
163
169 bool GetPer20MHzBusy(const std::set<uint8_t>& indices) const;
170
177 void NotifyRxStartNow(Time duration);
182 void NotifyRxEndOkNow();
187 void NotifyRxEndErrorNow();
195 void NotifyTxStartNow(Time duration);
206 void NotifyCcaBusyStartNow(Time duration,
207 WifiChannelListType channelType,
208 const std::vector<Time>& per20MhzDurations);
217 void NotifySwitchingStartNow(PhyListener* phyListener, Time duration);
221 void NotifySleepNow();
225 void NotifyOffNow();
229 void NotifyWakeupNow();
233 void NotifyOnNow();
239 void NotifyNavResetNow(Time duration);
245 void NotifyNavStartNow(Time duration);
251 void NotifyAckTimeoutStartNow(Time duration);
261 void NotifyCtsTimeoutStartNow(Time duration);
266
275
283 bool IsBusy() const;
284
288 void ResetState();
294 void ResetBackoff(Ptr<Txop> txop);
295
306 const WifiPhyOperatingChannel& channel,
307 uint8_t linkId);
308
309 protected:
310 void DoInitialize() override;
311 void DoDispose() override;
312
313 private:
325 void InitLastBusyStructs();
329 void UpdateBackoff();
358
360
365 void AccessTimeout();
369 void DoGrantDcfAccess();
370
376 virtual Time GetSifs() const;
382 virtual Time GetSlot() const;
388 virtual Time GetEifsNoDifs() const;
389
393 struct Timespan
394 {
397 };
398
402 typedef std::vector<Ptr<Txop>> Txops;
403
411 std::map<WifiChannelListType, Time>
413 std::vector<Time> m_lastPer20MHzBusyEnd;
415 std::map<WifiChannelListType, Timespan>
422 bool m_off;
425
428 {
430 uint8_t linkId;
431 };
432
434 std::unordered_map<Ptr<WifiPhy>, EmlsrLinkSwitchInfo> m_switchingEmlsrLinks;
435
437 using PhyListenerMap = std::unordered_map<Ptr<WifiPhy>, std::unique_ptr<PhyListener>>;
438
442 uint8_t m_linkId;
443};
444
445} // namespace ns3
446
447#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 ResetBackoff(Ptr< Txop > txop)
Reset the backoff for the given DCF/EDCAF.
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)
void NotifySwitchingStartNow(PhyListener *phyListener, Time duration)
Time GetBackoffEndFor(Ptr< Txop > txop)
Return the time when the backoff procedure ended (or will ended) for the given Txop.
void ResetState()
Reset the state variables of this channel access manager.
void NotifySwitchingEmlsrLink(Ptr< WifiPhy > phy, const WifiPhyOperatingChannel &channel, uint8_t linkId)
Notify that the given PHY is about to switch to the given operating channel, which is used by the giv...
void NotifyStopUsingOtherEmlsrLink()
Notify that another EMLSR link is no longer being used, hence medium access can be resumed.
void NotifyWakeupNow()
Notify the Txop that the device has been resumed from sleep mode.
bool m_lastRxReceivedOk
the last receive OK
std::unordered_map< Ptr< WifiPhy >, EmlsrLinkSwitchInfo > m_switchingEmlsrLinks
Store information about the PHY objects that are going to operate on another EMLSR link.
std::map< WifiChannelListType, Timespan > m_lastIdle
the last idle start and end time for each channel type
Ptr< WifiPhy > m_phy
pointer to the unique active 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
std::unordered_map< Ptr< WifiPhy >, std::unique_ptr< PhyListener > > PhyListenerMap
Maps each PHY listener to the associated PHY.
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.
void DeactivatePhyListener(Ptr< WifiPhy > phy)
Deactivate current registered listener for PHY events on the given PHY.
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 on the given PHY.
Time m_lastTxEnd
the last transmit end time
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up (or reactivate) listener for PHY events on the given PHY.
void NotifyStartUsingOtherEmlsrLink()
Notify that another EMLSR link is being used, hence medium access should be disabled.
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
bool m_usingOtherEmlsrLink
whether another EMLSR link is being used
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 DisableEdcaFor(Ptr< Txop > qosTxop, Time duration)
void DoInitialize() override
Initialize() implementation.
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.
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.
PhyListener * GetPhyListener(Ptr< WifiPhy > phy) const
Get current registered listener for PHY events on the given PHY.
Time m_lastUsingOtherEmlsrLinkEnd
the last time we were blocked because using another EMLSR link
PhyListenerMap m_phyListeners
the PHY listeners
virtual Time GetSifs() const
Return the Short Interframe Space (SIFS) for this PHY.
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.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Class that keeps track of all information about the current PHY operating channel.
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.
Structure defining start time and end time for a given state.
Declaration of the following enums: