This documentation is not the Latest Release.
A Discrete-Event Network Simulator
API
dcf-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 DCF_MANAGER_H
22 #define DCF_MANAGER_H
23 
24 #include "ns3/nstime.h"
25 #include "ns3/event-id.h"
26 #include <vector>
27 
28 namespace ns3 {
29 
30 class WifiPhy;
31 class WifiMac;
32 class MacLow;
33 class PhyListener;
34 class LowDcfListener;
35 
46 class DcfState
47 {
48 public:
49  DcfState ();
50  virtual ~DcfState ();
51 
58  void SetAifsn (uint32_t aifsn);
64  void SetCwMin (uint32_t minCw);
70  void SetCwMax (uint32_t maxCw);
76  uint32_t GetAifsn (void) const;
82  uint32_t GetCwMin (void) const;
88  uint32_t GetCwMax (void) const;
95  void ResetCw (void);
101  void UpdateFailedCw (void);
108  void StartBackoffNow (uint32_t nSlots);
113  uint32_t GetCw (void) const;
118  bool IsAccessRequested (void) const;
119 
120 
121 private:
122  friend class DcfManager;
123 
129  uint32_t GetBackoffSlots (void) const;
135  Time GetBackoffStart (void) const;
142  void UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound);
146  void NotifyAccessRequested (void);
150  void NotifyAccessGranted (void);
154  void NotifyCollision (void);
158  void NotifyInternalCollision (void);
162  void NotifyChannelSwitching (void);
166  void NotifySleep (void);
170  void NotifyWakeUp (void);
171 
177  virtual void DoNotifyAccessGranted (void) = 0;
189  virtual void DoNotifyInternalCollision (void) = 0;
199  virtual void DoNotifyCollision (void) = 0;
206  virtual void DoNotifyChannelSwitching (void) = 0;
213  virtual void DoNotifySleep (void) = 0;
222  virtual void DoNotifyWakeUp (void) = 0;
223 
224  uint32_t m_aifsn;
225  uint32_t m_backoffSlots;
226  //the backoffStart variable is used to keep track of the
227  //time at which a backoff was started or the time at which
228  //the backoff counter was last updated.
230  uint32_t m_cwMin;
231  uint32_t m_cwMax;
232  uint32_t m_cw;
234 };
235 
236 
253 {
254 public:
255  DcfManager ();
256  ~DcfManager ();
257 
269  void RemovePhyListener (Ptr<WifiPhy> phy);
275  void SetupLowListener (Ptr<MacLow> low);
276 
283  void SetSlot (Time slotTime);
290  void SetSifs (Time sifs);
297  void SetEifsNoDifs (Time eifsNoDifs);
298 
302  Time GetEifsNoDifs () const;
303 
314  void Add (DcfState *dcf);
315 
324  void RequestAccess (DcfState *state);
325 
332  void NotifyRxStartNow (Time duration);
337  void NotifyRxEndOkNow (void);
342  void NotifyRxEndErrorNow (void);
350  void NotifyTxStartNow (Time duration);
356  void NotifyMaybeCcaBusyStartNow (Time duration);
364  void NotifySwitchingStartNow (Time duration);
368  void NotifySleepNow (void);
372  void NotifyWakeupNow (void);
378  void NotifyNavResetNow (Time duration);
384  void NotifyNavStartNow (Time duration);
390  void NotifyAckTimeoutStartNow (Time duration);
394  void NotifyAckTimeoutResetNow ();
400  void NotifyCtsTimeoutStartNow (Time duration);
404  void NotifyCtsTimeoutResetNow ();
405 
406 
407 private:
411  void UpdateBackoff (void);
420  Time MostRecent (Time a, Time b) const;
430  Time MostRecent (Time a, Time b, Time c) const;
441  Time MostRecent (Time a, Time b, Time c, Time d) const;
454  Time MostRecent (Time a, Time b, Time c, Time d, Time e, Time f) const;
468  Time MostRecent (Time a, Time b, Time c, Time d, Time e, Time f, Time g) const;
475  Time GetAccessGrantStart (void) const;
493  Time GetBackoffEndFor (DcfState *state);
494 
495  void DoRestartAccessTimeoutIfNeeded (void);
496 
501  void AccessTimeout (void);
505  void DoGrantAccess (void);
513  bool IsBusy (void) const;
514 
518  typedef std::vector<DcfState *> States;
519 
520  States m_states;
535  bool m_rxing;
539  uint32_t m_slotTimeUs;
543 };
544 
545 } //namespace ns3
546 
547 #endif /* DCF_MANAGER_H */
uint32_t m_cwMin
Definition: dcf-manager.h:230
void NotifyWakeupNow(void)
Notify the DCF that the device has been resumed from sleep mode.
Definition: dcf-manager.cc:829
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void NotifySleep(void)
Notify that the device has started to sleep.
Definition: dcf-manager.cc:179
void NotifyInternalCollision(void)
Notify that internal collision has occurred.
Definition: dcf-manager.cc:167
bool m_lastRxReceivedOk
Definition: dcf-manager.h:527
uint32_t GetCwMin(void) const
Return the minimum congestion window size.
Definition: dcf-manager.cc:82
void NotifyAccessGranted(void)
Notify that access has been granted.
Definition: dcf-manager.cc:153
void RequestAccess(DcfState *state)
Definition: dcf-manager.cc:479
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
Definition: dcf-manager.cc:136
void SetupLowListener(Ptr< MacLow > low)
Set up listener for MacLow events.
Definition: dcf-manager.cc:357
Time m_lastAckTimeoutEnd
Definition: dcf-manager.h:521
void NotifyWakeUp(void)
Notify that the device has started to wake up.
Definition: dcf-manager.cc:185
void UpdateBackoff(void)
Update backoff slots for all DcfStates.
Definition: dcf-manager.cc:627
virtual void DoNotifyCollision(void)=0
Called by DcfManager to notify a DcfState subclass that a normal collision occured, that is, that the medium was busy when access was requested.
Time m_lastCtsTimeoutEnd
Definition: dcf-manager.h:522
bool m_accessRequested
Definition: dcf-manager.h:233
void SetAifsn(uint32_t aifsn)
Definition: dcf-manager.cc:56
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
Definition: dcf-manager.cc:94
Time m_lastSwitchingDuration
Definition: dcf-manager.h:534
void Add(DcfState *dcf)
Definition: dcf-manager.cc:397
void DoGrantAccess(void)
Grant access to DCF.
Definition: dcf-manager.cc:508
void NotifyNavResetNow(Time duration)
Definition: dcf-manager.cc:849
Time GetBackoffStartFor(DcfState *state)
Return the time when the backoff procedure started for the given DcfState.
Definition: dcf-manager.cc:611
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
Definition: dcf-manager.cc:899
void NotifyRxEndOkNow(void)
Notify the DCF that a packet reception was just completed successfully.
Definition: dcf-manager.cc:700
uint32_t m_backoffSlots
Definition: dcf-manager.h:225
tuple phy
Definition: third.py:86
PhyListener * m_phyListener
Definition: dcf-manager.h:541
Time GetAccessGrantStart(void) const
Access will never be granted to the medium before the time returned by this method.
Definition: dcf-manager.cc:572
Time GetBackoffEndFor(DcfState *state)
Return the time when the backoff procedure ended (or will ended) for the given DcfState.
Definition: dcf-manager.cc:621
void NotifyTxStartNow(Time duration)
Definition: dcf-manager.cc:720
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for Phy events.
Definition: dcf-manager.cc:345
void NotifyAckTimeoutStartNow(Time duration)
Notify that ACK timer has started for the given duration.
Definition: dcf-manager.cc:883
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for Phy events.
Definition: dcf-manager.cc:333
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:252
keep track of the state needed for a single DCF function.
Definition: dcf-manager.h:46
bool IsAccessRequested(void) const
Definition: dcf-manager.cc:142
Listener for PHY events.
Definition: dcf-manager.cc:242
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Definition: dcf-manager.cc:130
virtual ~DcfState()
Definition: dcf-manager.cc:51
uint32_t GetCwMax(void) const
Return the maximum congestion window size.
Definition: dcf-manager.cc:88
Time m_lastBusyDuration
Definition: dcf-manager.h:532
void SetCwMin(uint32_t minCw)
Set the minimum congestion window size.
Definition: dcf-manager.cc:62
void StartBackoffNow(uint32_t nSlots)
Definition: dcf-manager.cc:115
virtual void DoNotifyWakeUp(void)=0
Called by DcfManager to notify a DcfState subclass that the device has begun to wake up...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t m_cwMax
Definition: dcf-manager.h:231
virtual void DoNotifyAccessGranted(void)=0
Called by DcfManager to notify a DcfState subclass that access to the medium is granted and can start...
std::vector< DcfState * > States
typedef for a vector of DcfStates
Definition: dcf-manager.h:518
void NotifyAccessRequested(void)
Notify that access request has been received.
Definition: dcf-manager.cc:147
void NotifyRxEndErrorNow(void)
Notify the DCF that a packet reception was just completed unsuccessfully.
Definition: dcf-manager.cc:710
uint32_t m_cw
Definition: dcf-manager.h:232
Time m_lastSwitchingStart
Definition: dcf-manager.h:533
void SetEifsNoDifs(Time eifsNoDifs)
Definition: dcf-manager.cc:383
virtual void DoNotifyInternalCollision(void)=0
Called by DcfManager to notify a DcfState subclass that an 'internal' collision occured, that is, that the backoff timer of a higher priority DcfState expired at the same time and that access was granted to this higher priority DcfState.
void NotifyMaybeCcaBusyStartNow(Time duration)
Definition: dcf-manager.cc:740
void AccessTimeout(void)
Called when access timeout should occur (e.g.
Definition: dcf-manager.cc:563
Time m_lastNavDuration
Definition: dcf-manager.h:524
void SetSlot(Time slotTime)
Definition: dcf-manager.cc:369
void SetCwMax(uint32_t maxCw)
Set the maximum congestion window size.
Definition: dcf-manager.cc:69
void NotifyAckTimeoutResetNow()
Notify that ACK timer has resetted.
Definition: dcf-manager.cc:891
LowDcfListener * m_lowListener
Definition: dcf-manager.h:542
void NotifyNavStartNow(Time duration)
Definition: dcf-manager.cc:867
An identifier for simulation events.
Definition: event-id.h:53
void NotifyChannelSwitching(void)
Notify that the device is switching channel.
Definition: dcf-manager.cc:173
uint32_t GetCw(void) const
Definition: dcf-manager.cc:124
uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: dcf-manager.cc:76
uint32_t m_aifsn
Definition: dcf-manager.h:224
virtual void DoNotifyChannelSwitching(void)=0
Called by DcfManager to notify a DcfState subclass that a channel switching occured.
void NotifyRxStartNow(Time duration)
Definition: dcf-manager.cc:689
virtual void DoNotifySleep(void)=0
Called by DcfManager to notify a DcfState subclass that the device has begun to sleep.
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
Definition: dcf-manager.cc:107
Time GetEifsNoDifs() const
Definition: dcf-manager.cc:390
void NotifySleepNow(void)
Notify the DCF that the device has been put in sleep mode.
Definition: dcf-manager.cc:810
void NotifyCtsTimeoutResetNow()
Notify that CTS timer has resetted.
Definition: dcf-manager.cc:906
void NotifyCollision(void)
Notify that collision has occurred.
Definition: dcf-manager.cc:161
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV busy.
Definition: dcf-manager.cc:456
Time m_backoffStart
Definition: dcf-manager.h:229
void DoRestartAccessTimeoutIfNeeded(void)
Definition: dcf-manager.cc:649
EventId m_accessTimeout
Definition: dcf-manager.h:538
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
Definition: dcf-manager.cc:100
Listener for NAV events.
Definition: dcf-manager.cc:194
void NotifySwitchingStartNow(Time duration)
Definition: dcf-manager.cc:750
uint32_t m_slotTimeUs
Definition: dcf-manager.h:539
Time MostRecent(Time a, Time b) const
Return the most recent time.
Definition: dcf-manager.cc:404
void SetSifs(Time sifs)
Definition: dcf-manager.cc:376