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 <vector>
25 #include <algorithm>
26 #include "ns3/event-id.h"
27 #include "ns3/nstime.h"
28 
29 namespace ns3 {
30 
31 class WifiPhy;
32 class PhyListener;
33 class Txop;
34 class FrameExchangeManager;
35 
52 {
53 public:
55  virtual ~ChannelAccessManager ();
56 
75 
86  void Add (Ptr<Txop> txop);
87 
95  bool NeedBackoffUponAccess (Ptr<Txop> txop);
96 
105  void RequestAccess (Ptr<Txop> txop);
106 
115  Time GetAccessGrantStart (bool ignoreNav = false) const;
116 
123  void NotifyRxStartNow (Time duration);
128  void NotifyRxEndOkNow (void);
133  void NotifyRxEndErrorNow (void);
141  void NotifyTxStartNow (Time duration);
147  void NotifyMaybeCcaBusyStartNow (Time duration);
155  void NotifySwitchingStartNow (Time duration);
159  void NotifySleepNow (void);
163  void NotifyOffNow (void);
167  void NotifyWakeupNow (void);
171  void NotifyOnNow (void);
177  void NotifyNavResetNow (Time duration);
183  void NotifyNavStartNow (Time duration);
189  void NotifyAckTimeoutStartNow (Time duration);
193  void NotifyAckTimeoutResetNow (void);
199  void NotifyCtsTimeoutStartNow (Time duration);
203  void NotifyCtsTimeoutResetNow (void);
204 
212  bool IsBusy (void) const;
213 
214 
215 protected:
216  void DoDispose (void) override;
217 
218 
219 private:
223  void UpdateBackoff (void);
231  Time MostRecent (std::initializer_list<Time> list) const;
250 
251  void DoRestartAccessTimeoutIfNeeded (void);
252 
257  void AccessTimeout (void);
261  void DoGrantDcfAccess (void);
262 
268  virtual Time GetSifs (void) const;
274  virtual Time GetSlot (void) const;
280  virtual Time GetEifsNoDifs (void) const;
281 
285  typedef std::vector<Ptr<Txop>> Txops;
286 
301  bool m_sleeping;
302  bool m_off;
310 };
311 
312 } //namespace ns3
313 
314 #endif /* CHANNEL_ACCESS_MANAGER_H */
ns3::ChannelAccessManager::Txops
std::vector< Ptr< Txop > > Txops
typedef for a vector of Txops
Definition: channel-access-manager.h:285
ns3::ChannelAccessManager::GetEifsNoDifs
virtual Time GetEifsNoDifs(void) const
Return the EIFS duration minus a DIFS.
Definition: channel-access-manager.cc:186
ns3::ChannelAccessManager
Manage a set of ns3::Txop.
Definition: channel-access-manager.h:52
ns3::EventId
An identifier for simulation events.
Definition: event-id.h:54
ns3::ChannelAccessManager::m_lastSwitchingStart
Time m_lastSwitchingStart
the last switching start time
Definition: channel-access-manager.h:299
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::ChannelAccessManager::NotifyTxStartNow
void NotifyTxStartNow(Time duration)
Definition: channel-access-manager.cc:581
ns3::ChannelAccessManager::m_sifs
Time m_sifs
the SIFS time
Definition: channel-access-manager.h:306
ns3::ChannelAccessManager::m_lastTxDuration
Time m_lastTxDuration
the last transmit duration time
Definition: channel-access-manager.h:296
ns3::ChannelAccessManager::SetupPhyListener
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for PHY events.
Definition: channel-access-manager.cc:143
ns3::ChannelAccessManager::NotifyWakeupNow
void NotifyWakeupNow(void)
Notify the Txop that the device has been resumed from sleep mode.
Definition: channel-access-manager.cc:704
ns3::ChannelAccessManager::m_phyListener
PhyListener * m_phyListener
the PHY listener
Definition: channel-access-manager.h:307
ns3::ChannelAccessManager::m_feManager
Ptr< FrameExchangeManager > m_feManager
pointer to the Frame Exchange Manager
Definition: channel-access-manager.h:309
ns3::ChannelAccessManager::NotifyOffNow
void NotifyOffNow(void)
Notify the Txop that the device has been put in off mode.
Definition: channel-access-manager.cc:686
ns3::ChannelAccessManager::m_lastNavDuration
Time m_lastNavDuration
the last NAV duration time
Definition: channel-access-manager.h:291
ns3::ChannelAccessManager::m_sleeping
bool m_sleeping
flag whether it is in sleeping state
Definition: channel-access-manager.h:301
ns3::ChannelAccessManager::GetBackoffStartFor
Time GetBackoffStartFor(Ptr< Txop > txop)
Return the time when the backoff procedure started for the given Txop.
Definition: channel-access-manager.cc:449
ns3::ChannelAccessManager::DoGrantDcfAccess
void DoGrantDcfAccess(void)
Grant access to Txop using DCF/EDCF contention rules.
Definition: channel-access-manager.cc:328
ns3::ChannelAccessManager::NotifyRxEndErrorNow
void NotifyRxEndErrorNow(void)
Notify the Txop that a packet reception was just completed unsuccessfully.
Definition: channel-access-manager.cc:565
ns3::ChannelAccessManager::m_lastRxReceivedOk
bool m_lastRxReceivedOk
the last receive OK
Definition: channel-access-manager.h:294
ns3::ChannelAccessManager::GetSifs
virtual Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
Definition: channel-access-manager.cc:180
ns3::ChannelAccessManager::m_eifsNoDifs
Time m_eifsNoDifs
EIFS no DIFS time.
Definition: channel-access-manager.h:303
ns3::ChannelAccessManager::m_accessTimeout
EventId m_accessTimeout
the access timeout ID
Definition: channel-access-manager.h:304
ns3::ChannelAccessManager::m_lastRxDuration
Time m_lastRxDuration
the last receive duration time
Definition: channel-access-manager.h:293
ns3::ChannelAccessManager::NotifySleepNow
void NotifySleepNow(void)
Notify the Txop that the device has been put in sleep mode.
Definition: channel-access-manager.cc:668
ns3::ChannelAccessManager::MostRecent
Time MostRecent(std::initializer_list< Time > list) const
Return the most recent time.
Definition: channel-access-manager.cc:199
ns3::ChannelAccessManager::~ChannelAccessManager
virtual ~ChannelAccessManager()
Definition: channel-access-manager.cc:122
ns3::ChannelAccessManager::NotifySwitchingStartNow
void NotifySwitchingStartNow(Time duration)
Definition: channel-access-manager.cc:611
ns3::ChannelAccessManager::RequestAccess
void RequestAccess(Ptr< Txop > txop)
Definition: channel-access-manager.cc:293
ns3::ChannelAccessManager::m_slot
Time m_slot
the slot time
Definition: channel-access-manager.h:305
ns3::PhyListener
Listener for PHY events.
Definition: channel-access-manager.cc:37
ns3::ChannelAccessManager::DoRestartAccessTimeoutIfNeeded
void DoRestartAccessTimeoutIfNeeded(void)
Definition: channel-access-manager.cc:505
ns3::ChannelAccessManager::m_lastBusyDuration
Time m_lastBusyDuration
the last busy duration time
Definition: channel-access-manager.h:298
ns3::Ptr< WifiPhy >
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::ChannelAccessManager::m_lastBusyStart
Time m_lastBusyStart
the last busy start time
Definition: channel-access-manager.h:297
ns3::ChannelAccessManager::m_off
bool m_off
flag whether it is in off state
Definition: channel-access-manager.h:302
ns3::ChannelAccessManager::m_lastCtsTimeoutEnd
Time m_lastCtsTimeoutEnd
the last CTS timeout end time
Definition: channel-access-manager.h:289
ns3::ChannelAccessManager::NotifyNavStartNow
void NotifyNavStartNow(Time duration)
Definition: channel-access-manager.cc:759
ns3::ChannelAccessManager::ChannelAccessManager
ChannelAccessManager()
Definition: channel-access-manager.cc:101
ns3::ChannelAccessManager::NotifyAckTimeoutStartNow
void NotifyAckTimeoutStartNow(Time duration)
Notify that ack timer has started for the given duration.
Definition: channel-access-manager.cc:775
ns3::ChannelAccessManager::NotifyCtsTimeoutStartNow
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
Definition: channel-access-manager.cc:791
ns3::ChannelAccessManager::SetupFrameExchangeManager
void SetupFrameExchangeManager(Ptr< FrameExchangeManager > feManager)
Set up the Frame Exchange Manager.
Definition: channel-access-manager.cc:166
ns3::ChannelAccessManager::NeedBackoffUponAccess
bool NeedBackoffUponAccess(Ptr< Txop > txop)
Determine if a new backoff needs to be generated when a packet is queued for transmission.
Definition: channel-access-manager.cc:236
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::ChannelAccessManager::m_txops
Txops m_txops
the vector of managed Txops
Definition: channel-access-manager.h:287
ns3::ChannelAccessManager::Add
void Add(Ptr< Txop > txop)
Definition: channel-access-manager.cc:192
list
#define list
Definition: openflow-interface.h:47
ns3::ChannelAccessManager::IsBusy
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV or CCA busy.
Definition: channel-access-manager.cc:206
ns3::ChannelAccessManager::m_lastSwitchingDuration
Time m_lastSwitchingDuration
the last switching duration time
Definition: channel-access-manager.h:300
ns3::ChannelAccessManager::UpdateBackoff
void UpdateBackoff(void)
Update backoff slots for all Txops.
Definition: channel-access-manager.cc:470
ns3::ChannelAccessManager::GetBackoffEndFor
Time GetBackoffEndFor(Ptr< Txop > txop)
Return the time when the backoff procedure ended (or will ended) for the given Txop.
Definition: channel-access-manager.cc:460
ns3::ChannelAccessManager::m_phy
Ptr< WifiPhy > m_phy
pointer to the PHY
Definition: channel-access-manager.h:308
ns3::ChannelAccessManager::m_lastAckTimeoutEnd
Time m_lastAckTimeoutEnd
the last Ack timeout end time
Definition: channel-access-manager.h:288
ns3::ChannelAccessManager::NotifyRxStartNow
void NotifyRxStartNow(Time duration)
Definition: channel-access-manager.cc:545
ns3::ChannelAccessManager::NotifyCtsTimeoutResetNow
void NotifyCtsTimeoutResetNow(void)
Notify that CTS timer has reset.
Definition: channel-access-manager.cc:798
ns3::ChannelAccessManager::AccessTimeout
void AccessTimeout(void)
Called when access timeout should occur (e.g.
Definition: channel-access-manager.cc:394
ns3::ChannelAccessManager::GetSlot
virtual Time GetSlot(void) const
Return the slot duration for this PHY.
Definition: channel-access-manager.cc:174
ns3::ChannelAccessManager::m_lastRxStart
Time m_lastRxStart
the last receive start time
Definition: channel-access-manager.h:292
ns3::ChannelAccessManager::RemovePhyListener
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for PHY events.
Definition: channel-access-manager.cc:153
ns3::ChannelAccessManager::DoDispose
void DoDispose(void) override
Destructor implementation.
Definition: channel-access-manager.cc:130
ns3::ChannelAccessManager::NotifyRxEndOkNow
void NotifyRxEndOkNow(void)
Notify the Txop that a packet reception was just completed successfully.
Definition: channel-access-manager.cc:556
ns3::ChannelAccessManager::NotifyAckTimeoutResetNow
void NotifyAckTimeoutResetNow(void)
Notify that ack timer has reset.
Definition: channel-access-manager.cc:783
ns3::ChannelAccessManager::m_lastTxStart
Time m_lastTxStart
the last transmit start time
Definition: channel-access-manager.h:295
ns3::ChannelAccessManager::GetAccessGrantStart
Time GetAccessGrantStart(bool ignoreNav=false) const
Access will never be granted to the medium before the time returned by this method.
Definition: channel-access-manager.cc:403
ns3::ChannelAccessManager::NotifyNavResetNow
void NotifyNavResetNow(Time duration)
Definition: channel-access-manager.cc:742
ns3::ChannelAccessManager::NotifyOnNow
void NotifyOnNow(void)
Notify the Txop that the device has been resumed from off mode.
Definition: channel-access-manager.cc:723
third.phy
phy
Definition: third.py:93
ns3::ChannelAccessManager::NotifyMaybeCcaBusyStartNow
void NotifyMaybeCcaBusyStartNow(Time duration)
Definition: channel-access-manager.cc:601
ns3::ChannelAccessManager::m_lastNavStart
Time m_lastNavStart
the last NAV start time
Definition: channel-access-manager.h:290