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 "mac-low.h"
25 #include "ns3/event-id.h"
26 #include "ns3/nstime.h"
27 #include <vector>
28 
29 namespace ns3 {
30 
31 class WifiPhy;
32 class PhyListener;
33 class DcfState;
34 class MacLow;
35 
51 class DcfManager : public Object
52 {
53 public:
54  DcfManager ();
55  virtual ~DcfManager ();
56 
74  void SetupLow (Ptr<MacLow> low);
75 
82  void SetSlot (Time slotTime);
89  void SetSifs (Time sifs);
96  void SetEifsNoDifs (Time eifsNoDifs);
97 
101  Time GetEifsNoDifs () const;
102 
113  void Add (Ptr<DcfState> dcf);
114 
123  void RequestAccess (Ptr<DcfState> state);
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 
213 protected:
214  // Inherited from ns3::Object
215  void DoDispose (void);
216 
217 private:
221  void UpdateBackoff (void);
230  Time MostRecent (Time a, Time b) const;
240  Time MostRecent (Time a, Time b, Time c) const;
251  Time MostRecent (Time a, Time b, Time c, Time d) const;
264  Time MostRecent (Time a, Time b, Time c, Time d, Time e, Time f) const;
278  Time MostRecent (Time a, Time b, Time c, Time d, Time e, Time f, Time g) const;
285  Time GetAccessGrantStart (void) const;
304 
305  void DoRestartAccessTimeoutIfNeeded (void);
306 
311  void AccessTimeout (void);
315  void DoGrantAccess (void);
323  bool IsBusy (void) const;
331  bool IsWithinAifs (Ptr<DcfState> state) const;
332 
336  typedef std::vector<Ptr<DcfState> > States;
337 
338  States m_states;
353  bool m_rxing;
354  bool m_sleeping;
355  bool m_off;
358  uint32_t m_slotTimeUs;
361 };
362 
363 } //namespace ns3
364 
365 #endif /* DCF_MANAGER_H */
void NotifyWakeupNow(void)
Notify the DCF that the device has been resumed from sleep mode.
Definition: dcf-manager.cc:710
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Time GetBackoffStartFor(Ptr< DcfState > state)
Return the time when the backoff procedure started for the given DcfState.
Definition: dcf-manager.cc:453
bool m_lastRxReceivedOk
the last receive OK
Definition: dcf-manager.h:345
bool m_off
flag whether it is in off state
Definition: dcf-manager.h:355
Time m_eifsNoDifs
EIFS no DIFS time.
Definition: dcf-manager.h:356
Time m_lastBusyStart
the last busy start time
Definition: dcf-manager.h:349
Time m_lastAckTimeoutEnd
the last ACK timeout end time
Definition: dcf-manager.h:339
void UpdateBackoff(void)
Update backoff slots for all DcfStates.
Definition: dcf-manager.cc:473
Time m_lastCtsTimeoutEnd
the last CTS timeout end time
Definition: dcf-manager.h:340
Time m_lastSwitchingDuration
the last switching duration time
Definition: dcf-manager.h:352
Time GetBackoffEndFor(Ptr< DcfState > state)
Return the time when the backoff procedure ended (or will ended) for the given DcfState.
Definition: dcf-manager.cc:463
void DoGrantAccess(void)
Grant access to DCF.
Definition: dcf-manager.cc:350
void NotifyNavResetNow(Time duration)
Definition: dcf-manager.cc:750
virtual ~DcfManager()
Definition: dcf-manager.cc:122
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
Definition: dcf-manager.cc:799
std::vector< Ptr< DcfState > > States
typedef for a vector of DcfStates
Definition: dcf-manager.h:336
void NotifyRxEndOkNow(void)
Notify the DCF that a packet reception was just completed successfully.
Definition: dcf-manager.cc:562
tuple phy
Definition: third.py:86
PhyListener * m_phyListener
the phy listener
Definition: dcf-manager.h:360
Time m_sifs
the SIFS time
Definition: dcf-manager.h:359
Time GetAccessGrantStart(void) const
Access will never be granted to the medium before the time returned by this method.
Definition: dcf-manager.cc:414
void NotifyTxStartNow(Time duration)
Definition: dcf-manager.cc:582
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for Phy events.
Definition: dcf-manager.cc:153
void NotifyAckTimeoutStartNow(Time duration)
Notify that ACK timer has started for the given duration.
Definition: dcf-manager.cc:783
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for Phy events.
Definition: dcf-manager.cc:141
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:51
void SetupLow(Ptr< MacLow > low)
Set up listener for MacLow events.
Definition: dcf-manager.cc:165
Listener for PHY events.
Definition: dcf-manager.cc:32
Time m_lastBusyDuration
the last busy duration time
Definition: dcf-manager.h:350
double f(double x, void *params)
Definition: 80211b.c:72
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Add(Ptr< DcfState > dcf)
Definition: dcf-manager.cc:200
void NotifyRxEndErrorNow(void)
Notify the DCF that a packet reception was just completed unsuccessfully.
Definition: dcf-manager.cc:572
Time m_lastSwitchingStart
the last switching start time
Definition: dcf-manager.h:351
void SetEifsNoDifs(Time eifsNoDifs)
Definition: dcf-manager.cc:186
bool m_sleeping
flag whether it is in sleeping state
Definition: dcf-manager.h:354
Time m_lastRxEnd
the last receive end time
Definition: dcf-manager.h:346
void NotifyMaybeCcaBusyStartNow(Time duration)
Definition: dcf-manager.cc:602
void AccessTimeout(void)
Called when access timeout should occur (e.g.
Definition: dcf-manager.cc:405
Time m_lastNavStart
the last NAV start time
Definition: dcf-manager.h:341
Time m_lastNavDuration
the last NAV duration time
Definition: dcf-manager.h:342
void SetSlot(Time slotTime)
Definition: dcf-manager.cc:172
void NotifyAckTimeoutResetNow()
Notify that ACK timer has resetted.
Definition: dcf-manager.cc:791
void DoDispose(void)
Destructor implementation.
Definition: dcf-manager.cc:130
void NotifyOnNow(void)
Notify the DCF that the device has been resumed from off mode.
Definition: dcf-manager.cc:730
void NotifyNavStartNow(Time duration)
Definition: dcf-manager.cc:767
An identifier for simulation events.
Definition: event-id.h:53
void NotifyRxStartNow(Time duration)
Definition: dcf-manager.cc:551
bool m_rxing
flag whether it is in receiving state
Definition: dcf-manager.h:353
Time GetEifsNoDifs() const
Definition: dcf-manager.cc:193
void RequestAccess(Ptr< DcfState > state)
Definition: dcf-manager.cc:302
void NotifySleepNow(void)
Notify the DCF that the device has been put in sleep mode.
Definition: dcf-manager.cc:672
void NotifyCtsTimeoutResetNow()
Notify that CTS timer has resetted.
Definition: dcf-manager.cc:806
States m_states
the DCF states
Definition: dcf-manager.h:338
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV or CCA busy.
Definition: dcf-manager.cc:259
Time m_lastTxDuration
the last transmit duration time
Definition: dcf-manager.h:348
void DoRestartAccessTimeoutIfNeeded(void)
Definition: dcf-manager.cc:510
EventId m_accessTimeout
the access timeout ID
Definition: dcf-manager.h:357
A base class which provides memory management and object aggregation.
Definition: object.h:87
Time m_lastTxStart
the last transmit start time
Definition: dcf-manager.h:347
void NotifyOffNow(void)
Notify the DCF that the device has been put in off mode.
Definition: dcf-manager.cc:691
bool IsWithinAifs(Ptr< DcfState > state) const
Check if the device is between frames (in DIFS or AIFS interval)
Definition: dcf-manager.cc:288
void NotifySwitchingStartNow(Time duration)
Definition: dcf-manager.cc:612
uint32_t m_slotTimeUs
the slot time in microseconds
Definition: dcf-manager.h:358
Time MostRecent(Time a, Time b) const
Return the most recent time.
Definition: dcf-manager.cc:207
void SetSifs(Time sifs)
Definition: dcf-manager.cc:179
Time m_lastRxDuration
the last receive duration time
Definition: dcf-manager.h:344
Time m_lastRxStart
the last receive start time
Definition: dcf-manager.h:343