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 "ns3/event-id.h"
26 #include "ns3/nstime.h"
27 
28 namespace ns3 {
29 
30 class WifiPhy;
31 class PhyListener;
32 class Txop;
33 class MacLow;
34 
51 {
52 public:
54  virtual ~ChannelAccessManager ();
55 
73  void SetupLow (Ptr<MacLow> low);
74 
81  void SetSlot (Time slotTime);
88  void SetSifs (Time sifs);
95  void SetEifsNoDifs (Time eifsNoDifs);
96 
100  Time GetEifsNoDifs () const;
101 
112  void Add (Ptr<Txop> dcf);
113 
123  void RequestAccess (Ptr<Txop> state, bool isCfPeriod = false);
124 
131  void NotifyRxStartNow (Time duration);
136  void NotifyRxEndOkNow (void);
141  void NotifyRxEndErrorNow (void);
149  void NotifyTxStartNow (Time duration);
155  void NotifyMaybeCcaBusyStartNow (Time duration);
163  void NotifySwitchingStartNow (Time duration);
167  void NotifySleepNow (void);
171  void NotifyOffNow (void);
175  void NotifyWakeupNow (void);
179  void NotifyOnNow (void);
185  void NotifyNavResetNow (Time duration);
191  void NotifyNavStartNow (Time duration);
197  void NotifyAckTimeoutStartNow (Time duration);
201  void NotifyAckTimeoutResetNow ();
207  void NotifyCtsTimeoutStartNow (Time duration);
211  void NotifyCtsTimeoutResetNow ();
212 
220  bool IsBusy (void) const;
221 
222 
223 protected:
224  // Inherited from ns3::Object
225  void DoDispose (void);
226 
227 
228 private:
232  void UpdateBackoff (void);
241  Time MostRecent (Time a, Time b) const;
254  Time MostRecent (Time a, Time b, Time c, Time d, Time e, Time f) const;
268  Time MostRecent (Time a, Time b, Time c, Time d, Time e, Time f, Time g) const;
277  Time GetAccessGrantStart (bool ignoreNav = false) const;
296 
297  void DoRestartAccessTimeoutIfNeeded (void);
298 
303  void AccessTimeout (void);
307  void DoGrantAccess (void);
315  bool IsWithinAifs (Ptr<Txop> state) const;
319  void GrantPcfAccess (Ptr<Txop> state);
320 
324  typedef std::vector<Ptr<Txop> > States;
325 
341  bool m_rxing;
342  bool m_sleeping;
343  bool m_off;
349 };
350 
351 } //namespace ns3
352 
353 #endif /* CHANNEL_ACCESS_MANAGER_H */
Time GetBackoffEndFor(Ptr< Txop > state)
Return the time when the backoff procedure ended (or will ended) for the given Txop.
void GrantPcfAccess(Ptr< Txop > state)
Grant access to PCF.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
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
Time m_lastRxDuration
the last receive duration time
Time m_lastCtsTimeoutEnd
the last CTS timeout end time
void NotifyOnNow(void)
Notify the DCF 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.
EventId m_accessTimeout
the access timeout ID
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for Phy events.
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
void NotifyRxStartNow(Time duration)
Time m_lastRxStart
the last receive start time
Time m_lastBusyDuration
the last busy duration time
phy
Definition: third.py:86
void NotifyRxEndErrorNow(void)
Notify the DCF 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.
void SetEifsNoDifs(Time eifsNoDifs)
void NotifyCtsTimeoutResetNow()
Notify that CTS timer has reset.
void NotifyOffNow(void)
Notify the DCF that the device has been put in off mode.
Time m_lastRxEnd
the last receive end time
Time m_lastSwitchingStart
the last switching start time
void NotifySleepNow(void)
Notify the DCF that the device has been put in sleep mode.
Listener for PHY events.
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.
void DoGrantAccess(void)
Grant access to DCF.
double f(double x, void *params)
Definition: 80211b.c:70
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void NotifyRxEndOkNow(void)
Notify the DCF 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 NotifyAckTimeoutResetNow()
Notify that ACK timer has reset.
An identifier for simulation events.
Definition: event-id.h:53
std::vector< Ptr< Txop > > States
typedef for a vector of Txops
Time m_lastNavStart
the last NAV start time
void NotifySwitchingStartNow(Time duration)
void NotifyNavStartNow(Time duration)
States m_states
the DCF states
Time m_lastSwitchingDuration
the last switching duration time
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
bool m_rxing
flag whether it is in receiving state
Time GetBackoffStartFor(Ptr< Txop > state)
Return the time when the backoff procedure started for the given Txop.
void SetupLow(Ptr< MacLow > low)
Set up listener for MacLow events.
void NotifyWakeupNow(void)
Notify the DCF that the device has been resumed from sleep mode.
void RequestAccess(Ptr< Txop > state, bool isCfPeriod=false)
Time m_lastAckTimeoutEnd
the last ACK timeout end time
bool IsWithinAifs(Ptr< Txop > state) const
Check if the device is between frames (in DIFS or AIFS interval)
Time MostRecent(Time a, Time b) const
Return the most recent time.
void DoDispose(void)
Destructor implementation.