A Discrete-Event Network Simulator
API
channel-access-manager.h
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2005,2006 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 CHANNEL_ACCESS_MANAGER_H
22#define CHANNEL_ACCESS_MANAGER_H
23
24#include <map>
25#include <vector>
26#include <algorithm>
27#include "ns3/event-id.h"
28#include "ns3/nstime.h"
29#include "ns3/object.h"
30#include "wifi-phy-common.h"
31
32namespace ns3 {
33
34class WifiPhy;
35class PhyListener;
36class Txop;
37class FrameExchangeManager;
38
55{
56public:
58 virtual ~ChannelAccessManager ();
59
77 void SetLinkId (uint8_t linkId);
84
95 void Add (Ptr<Txop> txop);
96
105
114 void RequestAccess (Ptr<Txop> txop);
115
124 Time GetAccessGrantStart (bool ignoreNav = false) const;
125
135 void DisableEdcaFor (Ptr<Txop> qosTxop, Time duration);
136
148 uint16_t GetLargestIdlePrimaryChannel (Time interval, Time end);
149
156 void NotifyRxStartNow (Time duration);
161 void NotifyRxEndOkNow (void);
166 void NotifyRxEndErrorNow (void);
174 void NotifyTxStartNow (Time duration);
185 void NotifyCcaBusyStartNow (Time duration,
186 WifiChannelListType channelType,
187 const std::vector<Time>& per20MhzDurations);
195 void NotifySwitchingStartNow (Time duration);
199 void NotifySleepNow (void);
203 void NotifyOffNow (void);
207 void NotifyWakeupNow (void);
211 void NotifyOnNow (void);
217 void NotifyNavResetNow (Time duration);
223 void NotifyNavStartNow (Time duration);
229 void NotifyAckTimeoutStartNow (Time duration);
233 void NotifyAckTimeoutResetNow (void);
239 void NotifyCtsTimeoutStartNow (Time duration);
243 void NotifyCtsTimeoutResetNow (void);
244
252 bool IsBusy (void) const;
253
254
255protected:
256 void DoDispose (void) override;
257
258
259private:
264 void InitLastBusyStructs (void);
268 void UpdateBackoff (void);
296 void UpdateLastIdlePeriod (void);
297
299
304 void AccessTimeout (void);
308 void DoGrantDcfAccess (void);
309
315 virtual Time GetSifs (void) const;
321 virtual Time GetSlot (void) const;
327 virtual Time GetEifsNoDifs (void) const;
328
332 struct Timespan
333 {
335 Time end {0};
336 };
337
341 typedef std::vector<Ptr<Txop>> Txops;
342
350 std::map<WifiChannelListType, Time> m_lastBusyEnd;
351 std::vector<Time> m_lastPer20MHzBusyEnd;
353 std::map<WifiChannelListType, Timespan> m_lastIdle;
356 bool m_off;
362 uint8_t m_linkId;
363};
364
365} //namespace ns3
366
367#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)
void AccessTimeout(void)
Called when access timeout should occur (e.g.
bool m_off
flag whether it is in off state
void NotifyRxStartNow(Time duration)
void UpdateBackoff(void)
Update backoff slots for all Txops.
Time GetBackoffEndFor(Ptr< Txop > txop)
Return the time when the backoff procedure ended (or will ended) for the given Txop.
void DoDispose(void) override
Destructor implementation.
bool m_lastRxReceivedOk
the last receive OK
void NotifyCtsTimeoutResetNow(void)
Notify that CTS timer has reset.
void NotifyOnNow(void)
Notify the Txop that the device has been resumed from off mode.
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 NotifyTxStartNow(Time duration)
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.
void NotifyAckTimeoutStartNow(Time duration)
Notify that ack timer has started for the given duration.
bool m_sleeping
flag whether it is in sleeping state
void NotifyRxEndOkNow(void)
Notify the Txop that a packet reception was just completed successfully.
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)
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV or CCA busy.
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 NotifySleepNow(void)
Notify the Txop that the device has been put in sleep mode.
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for PHY events.
Time m_lastCtsTimeoutEnd
the last CTS timeout end time
void NotifyWakeupNow(void)
Notify the Txop that the device has been resumed from sleep mode.
Ptr< FrameExchangeManager > m_feManager
pointer to the Frame Exchange Manager
void UpdateLastIdlePeriod(void)
This method determines whether the medium has been idle during a period (of non-null duration) immedi...
void NotifyOffNow(void)
Notify the Txop that the device has been put in off mode.
PhyListener * m_phyListener
the PHY listener
virtual Time GetSlot(void) const
Return the slot duration for this PHY.
void InitLastBusyStructs(void)
Initialize the structures holding busy end times per channel type (primary, secondary,...
std::vector< Ptr< Txop > > Txops
typedef for a vector of Txops
void NotifySwitchingStartNow(Time duration)
void DisableEdcaFor(Ptr< Txop > qosTxop, Time duration)
void DoGrantDcfAccess(void)
Grant access to Txop using DCF/EDCF contention rules.
Txops m_txops
the vector of managed Txops
Time m_lastNavEnd
the last NAV end time
virtual Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
void NotifyAckTimeoutResetNow(void)
Notify that ack timer has reset.
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.
virtual Time GetEifsNoDifs(void) const
Return the EIFS duration minus a DIFS.
Time GetBackoffStartFor(Ptr< Txop > txop)
Return the time when the backoff procedure started for the given Txop.
void NotifyNavStartNow(Time duration)
EventId m_accessTimeout
the access timeout ID
void NotifyRxEndErrorNow(void)
Notify the Txop that a packet reception was just completed unsuccessfully.
An identifier for simulation events.
Definition: event-id.h:54
A base class which provides memory management and object aggregation.
Definition: object.h:88
Listener for PHY events.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
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:84
Structure defining start time and end time for a given state.
Declaration of the following enums: