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
36class EmlsrUlTxopTest;
37
38namespace ns3
39{
40
41class WifiPhy;
42class PhyListener;
43class Txop;
44class FrameExchangeManager;
45
62{
64 friend class ::EmlsrUlTxopTest;
65
66 public:
68 ~ChannelAccessManager() override;
69
74 static TypeId GetTypeId();
75
102 void SetLinkId(uint8_t linkId);
109
120 void Add(Ptr<Txop> txop);
121
138 bool NeedBackoffUponAccess(Ptr<Txop> txop, bool hadFramesToTransmit, bool checkMediumBusy);
139
148 void RequestAccess(Ptr<Txop> txop);
149
158 Time GetAccessGrantStart(bool ignoreNav = false) const;
159
169 void DisableEdcaFor(Ptr<Txop> qosTxop, Time duration);
170
178 void SetGenerateBackoffOnNoTx(bool enable);
179
185 bool GetGenerateBackoffOnNoTx() const;
186
198 uint16_t GetLargestIdlePrimaryChannel(Time interval, Time end);
199
205 bool GetPer20MHzBusy(const std::set<uint8_t>& indices) const;
206
213 void NotifyRxStartNow(Time duration);
218 void NotifyRxEndOkNow();
223 void NotifyRxEndErrorNow();
231 void NotifyTxStartNow(Time duration);
242 void NotifyCcaBusyStartNow(Time duration,
243 WifiChannelListType channelType,
244 const std::vector<Time>& per20MhzDurations);
253 void NotifySwitchingStartNow(PhyListener* phyListener, Time duration);
257 void NotifySleepNow();
261 void NotifyOffNow();
265 void NotifyWakeupNow();
269 void NotifyOnNow();
275 void NotifyNavResetNow(Time duration);
281 void NotifyNavStartNow(Time duration);
287 void NotifyAckTimeoutStartNow(Time duration);
297 void NotifyCtsTimeoutStartNow(Time duration);
302
311
319 bool IsBusy() const;
320
324 void ResetState();
330 void ResetBackoff(Ptr<Txop> txop);
331
335 void ResetAllBackoffs();
336
347 const WifiPhyOperatingChannel& channel,
348 uint8_t linkId);
349
350 protected:
351 void DoInitialize() override;
352 void DoDispose() override;
353
354 private:
361 std::shared_ptr<PhyListener> GetPhyListener(Ptr<WifiPhy> phy) const;
366 void InitLastBusyStructs();
370 void UpdateBackoff();
399
401
406 void AccessTimeout();
410 void DoGrantDcfAccess();
411
417 virtual Time GetSifs() const;
423 virtual Time GetSlot() const;
429 virtual Time GetEifsNoDifs() const;
430
434 struct Timespan
435 {
438 };
439
443 typedef std::vector<Ptr<Txop>> Txops;
444
452 std::map<WifiChannelListType, Time>
454 std::vector<Time> m_lastPer20MHzBusyEnd;
456 std::map<WifiChannelListType, Timespan>
461 bool m_off;
468
471 {
473 uint8_t linkId;
474 };
475
477 std::unordered_map<Ptr<WifiPhy>, EmlsrLinkSwitchInfo> m_switchingEmlsrLinks;
478
480 using PhyListenerMap = std::unordered_map<Ptr<WifiPhy>, std::shared_ptr<PhyListener>>;
481
485 uint8_t m_linkId;
486};
487
488} // namespace ns3
489
490#endif /* CHANNEL_ACCESS_MANAGER_H */
Test the transmission of UL frames from EMLSR clients.
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 ResetAllBackoffs()
Reset the backoff for all the DCF/EDCAF.
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 SetGenerateBackoffOnNoTx(bool enable)
Set the member variable indicating whether the backoff should be invoked when an AC gains the right t...
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.
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.
bool NeedBackoffUponAccess(Ptr< Txop > txop, bool hadFramesToTransmit, bool checkMediumBusy)
Determine if a new backoff needs to be generated as per letter a) of Section 10.23....
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.
bool m_generateBackoffOnNoTx
whether the backoff should be invoked when the AC gains the right to start a TXOP but it does not tra...
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
static TypeId GetTypeId()
Get the type ID.
void DoGrantDcfAccess()
Grant access to Txop using DCF/EDCF contention rules.
std::shared_ptr< PhyListener > GetPhyListener(Ptr< WifiPhy > phy) const
Get current registered listener for PHY events on the given PHY.
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.
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.
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,...
std::unordered_map< Ptr< WifiPhy >, std::shared_ptr< PhyListener > > PhyListenerMap
Maps each PHY listener to the associated PHY.
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:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
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: