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 MacLow;
35 
52 {
53 public:
55  virtual ~ChannelAccessManager ();
56 
74  void SetupLow (Ptr<MacLow> low);
75 
86  void Add (Ptr<Txop> txop);
87 
95  bool NeedBackoffUponAccess (Ptr<Txop> txop);
96 
106  void RequestAccess (Ptr<Txop> txop, bool isCfPeriod = false);
107 
114  void NotifyRxStartNow (Time duration);
119  void NotifyRxEndOkNow (void);
124  void NotifyRxEndErrorNow (void);
132  void NotifyTxStartNow (Time duration);
138  void NotifyMaybeCcaBusyStartNow (Time duration);
146  void NotifySwitchingStartNow (Time duration);
150  void NotifySleepNow (void);
154  void NotifyOffNow (void);
158  void NotifyWakeupNow (void);
162  void NotifyOnNow (void);
168  void NotifyNavResetNow (Time duration);
174  void NotifyNavStartNow (Time duration);
180  void NotifyAckTimeoutStartNow (Time duration);
184  void NotifyAckTimeoutResetNow (void);
190  void NotifyCtsTimeoutStartNow (Time duration);
194  void NotifyCtsTimeoutResetNow (void);
195 
203  bool IsBusy (void) const;
204 
205 
206 protected:
207  // Inherited from ns3::Object
208  void DoDispose (void);
209 
210 
211 private:
215  void UpdateBackoff (void);
223  Time MostRecent (std::initializer_list<Time> list) const;
232  Time GetAccessGrantStart (bool ignoreNav = false) const;
251 
252  void DoRestartAccessTimeoutIfNeeded (void);
253 
258  void AccessTimeout (void);
262  void DoGrantDcfAccess (void);
268  void DoGrantPcfAccess (Ptr<Txop> txop);
269 
275  virtual Time GetSifs (void) const;
281  virtual Time GetSlot (void) const;
287  virtual Time GetEifsNoDifs (void) const;
288 
292  typedef std::vector<Ptr<Txop>> Txops;
293 
308  bool m_sleeping;
309  bool m_off;
316 };
317 
318 } //namespace ns3
319 
320 #endif /* CHANNEL_ACCESS_MANAGER_H */
virtual Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Time m_eifsNoDifs
EIFS no DIFS time.
void UpdateBackoff(void)
Update backoff slots for all Txops.
bool m_off
flag whether it is in off state
std::vector< Ptr< Txop > > Txops
typedef for a vector of Txops
Time m_lastRxDuration
the last receive duration time
Time m_lastCtsTimeoutEnd
the last CTS timeout end time
void NotifyOnNow(void)
Notify the Txop that the device has been resumed from off mode.
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for PHY events.
void NotifyMaybeCcaBusyStartNow(Time duration)
Time m_lastBusyStart
the last busy start time
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV or CCA busy.
void RequestAccess(Ptr< Txop > txop, bool isCfPeriod=false)
EventId m_accessTimeout
the access timeout ID
Time MostRecent(std::initializer_list< Time > list) const
Return the most recent time.
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for PHY events.
Time GetBackoffStartFor(Ptr< Txop > txop)
Return the time when the backoff procedure started for the given Txop.
Manage a set of ns3::TxopHandle a set of independent ns3::Txop, each of which represents a single DCF...
bool m_sleeping
flag whether it is in sleeping state
Time m_lastTxDuration
the last transmit duration time
bool NeedBackoffUponAccess(Ptr< Txop > txop)
Determine if a new backoff needs to be generated when a packet is queued for transmission.
void NotifyRxStartNow(Time duration)
Time m_lastRxStart
the last receive start time
Time m_lastBusyDuration
the last busy duration time
phy
Definition: third.py:93
void NotifyRxEndErrorNow(void)
Notify the Txop that a packet reception was just completed unsuccessfully.
Time m_lastNavDuration
the last NAV duration time
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
Ptr< WifiPhy > m_phy
pointer to the PHY
virtual Time GetEifsNoDifs(void) const
Return the EIFS duration minus a DIFS.
void NotifyOffNow(void)
Notify the Txop that the device has been put in off mode.
Time m_lastSwitchingStart
the last switching start time
void NotifySleepNow(void)
Notify the Txop that the device has been put in sleep mode.
Listener for PHY events.
#define list
Time m_lastTxStart
the last transmit start time
void NotifyNavResetNow(Time duration)
void NotifyAckTimeoutStartNow(Time duration)
Notify that ack timer has started for the given duration.
Txops m_txops
the vector of managed Txops
void DoGrantPcfAccess(Ptr< Txop > txop)
Grant access to Txop using PCF preemption.
virtual Time GetSlot(void) const
Return the slot duration for this PHY.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void NotifyRxEndOkNow(void)
Notify the Txop that a packet reception was just completed successfully.
Time GetAccessGrantStart(bool ignoreNav=false) const
Access will never be granted to the medium before the time returned by this method.
bool m_lastRxReceivedOk
the last receive OK
PhyListener * m_phyListener
the PHY listener
void NotifyCtsTimeoutResetNow(void)
Notify that CTS timer has reset.
void DoGrantDcfAccess(void)
Grant access to Txop using DCF/EDCF contention rules.
An identifier for simulation events.
Definition: event-id.h:53
Time m_lastNavStart
the last NAV start time
void NotifySwitchingStartNow(Time duration)
void NotifyNavStartNow(Time duration)
Time m_lastSwitchingDuration
the last switching duration time
Time GetBackoffEndFor(Ptr< Txop > txop)
Return the time when the backoff procedure ended (or will ended) for the given Txop.
void AccessTimeout(void)
Called when access timeout should occur (e.g.
void NotifyTxStartNow(Time duration)
A base class which provides memory management and object aggregation.
Definition: object.h:87
void SetupLow(Ptr< MacLow > low)
Set up listener for MacLow events.
void NotifyWakeupNow(void)
Notify the Txop that the device has been resumed from sleep mode.
Time m_lastAckTimeoutEnd
the last Ack timeout end time
void DoDispose(void)
Destructor implementation.
void NotifyAckTimeoutResetNow(void)
Notify that ack timer has reset.