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 NotifyWakeupNow (void);
177  void NotifyNavResetNow (Time duration);
183  void NotifyNavStartNow (Time duration);
189  void NotifyAckTimeoutStartNow (Time duration);
193  void NotifyAckTimeoutResetNow ();
199  void NotifyCtsTimeoutStartNow (Time duration);
203  void NotifyCtsTimeoutResetNow ();
204 
205 protected:
206  // Inherited from ns3::Object
207  void DoDispose (void);
208 
209 private:
213  void UpdateBackoff (void);
222  Time MostRecent (Time a, Time b) const;
232  Time MostRecent (Time a, Time b, Time c) const;
243  Time MostRecent (Time a, Time b, Time c, Time d) const;
256  Time MostRecent (Time a, Time b, Time c, Time d, Time e, Time f) const;
270  Time MostRecent (Time a, Time b, Time c, Time d, Time e, Time f, Time g) const;
277  Time GetAccessGrantStart (void) const;
296 
297  void DoRestartAccessTimeoutIfNeeded (void);
298 
303  void AccessTimeout (void);
307  void DoGrantAccess (void);
315  bool IsBusy (void) const;
323  bool IsWithinAifs (Ptr<DcfState> state) const;
324 
328  typedef std::vector<Ptr<DcfState> > States;
329 
330  States m_states;
345  bool m_rxing;
346  bool m_sleeping;
349  uint32_t m_slotTimeUs;
352 };
353 
354 } //namespace ns3
355 
356 #endif /* DCF_MANAGER_H */
void NotifyWakeupNow(void)
Notify the DCF that the device has been resumed from sleep mode.
Definition: dcf-manager.cc:681
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:443
bool m_lastRxReceivedOk
the last receive OK
Definition: dcf-manager.h:337
Time m_eifsNoDifs
EIFS no DIFS time.
Definition: dcf-manager.h:347
Time m_lastBusyStart
the last busy start time
Definition: dcf-manager.h:341
Time m_lastAckTimeoutEnd
the last ACK timeout end time
Definition: dcf-manager.h:331
void UpdateBackoff(void)
Update backoff slots for all DcfStates.
Definition: dcf-manager.cc:463
Time m_lastCtsTimeoutEnd
the last CTS timeout end time
Definition: dcf-manager.h:332
Time m_lastSwitchingDuration
the last switching duration time
Definition: dcf-manager.h:344
Time GetBackoffEndFor(Ptr< DcfState > state)
Return the time when the backoff procedure ended (or will ended) for the given DcfState.
Definition: dcf-manager.cc:453
void DoGrantAccess(void)
Grant access to DCF.
Definition: dcf-manager.cc:340
void NotifyNavResetNow(Time duration)
Definition: dcf-manager.cc:701
virtual ~DcfManager()
Definition: dcf-manager.cc:113
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
Definition: dcf-manager.cc:750
std::vector< Ptr< DcfState > > States
typedef for a vector of DcfStates
Definition: dcf-manager.h:328
void NotifyRxEndOkNow(void)
Notify the DCF that a packet reception was just completed successfully.
Definition: dcf-manager.cc:552
tuple phy
Definition: third.py:86
PhyListener * m_phyListener
the phy listener
Definition: dcf-manager.h:351
Time m_sifs
the SIFS time
Definition: dcf-manager.h:350
Time GetAccessGrantStart(void) const
Access will never be granted to the medium before the time returned by this method.
Definition: dcf-manager.cc:404
void NotifyTxStartNow(Time duration)
Definition: dcf-manager.cc:572
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for Phy events.
Definition: dcf-manager.cc:143
void NotifyAckTimeoutStartNow(Time duration)
Notify that ACK timer has started for the given duration.
Definition: dcf-manager.cc:734
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for Phy events.
Definition: dcf-manager.cc:131
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:155
Listener for PHY events.
Definition: dcf-manager.cc:32
Time m_lastBusyDuration
the last busy duration time
Definition: dcf-manager.h:342
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:190
void NotifyRxEndErrorNow(void)
Notify the DCF that a packet reception was just completed unsuccessfully.
Definition: dcf-manager.cc:562
Time m_lastSwitchingStart
the last switching start time
Definition: dcf-manager.h:343
void SetEifsNoDifs(Time eifsNoDifs)
Definition: dcf-manager.cc:176
bool m_sleeping
flag whether it is in sleeping state
Definition: dcf-manager.h:346
Time m_lastRxEnd
the last receive end time
Definition: dcf-manager.h:338
void NotifyMaybeCcaBusyStartNow(Time duration)
Definition: dcf-manager.cc:592
void AccessTimeout(void)
Called when access timeout should occur (e.g.
Definition: dcf-manager.cc:395
Time m_lastNavStart
the last NAV start time
Definition: dcf-manager.h:333
Time m_lastNavDuration
the last NAV duration time
Definition: dcf-manager.h:334
void SetSlot(Time slotTime)
Definition: dcf-manager.cc:162
void NotifyAckTimeoutResetNow()
Notify that ACK timer has resetted.
Definition: dcf-manager.cc:742
void DoDispose(void)
Destructor implementation.
Definition: dcf-manager.cc:120
void NotifyNavStartNow(Time duration)
Definition: dcf-manager.cc:718
An identifier for simulation events.
Definition: event-id.h:53
void NotifyRxStartNow(Time duration)
Definition: dcf-manager.cc:541
bool m_rxing
flag whether it is in receiving state
Definition: dcf-manager.h:345
Time GetEifsNoDifs() const
Definition: dcf-manager.cc:183
void RequestAccess(Ptr< DcfState > state)
Definition: dcf-manager.cc:292
void NotifySleepNow(void)
Notify the DCF that the device has been put in sleep mode.
Definition: dcf-manager.cc:662
void NotifyCtsTimeoutResetNow()
Notify that CTS timer has resetted.
Definition: dcf-manager.cc:757
States m_states
the DCF states
Definition: dcf-manager.h:330
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV or CCA busy.
Definition: dcf-manager.cc:249
Time m_lastTxDuration
the last transmit duration time
Definition: dcf-manager.h:340
void DoRestartAccessTimeoutIfNeeded(void)
Definition: dcf-manager.cc:500
EventId m_accessTimeout
the access timeout ID
Definition: dcf-manager.h:348
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:339
bool IsWithinAifs(Ptr< DcfState > state) const
Check if the device is between frames (in DIFS or AIFS interval)
Definition: dcf-manager.cc:278
void NotifySwitchingStartNow(Time duration)
Definition: dcf-manager.cc:602
uint32_t m_slotTimeUs
the slot time in microseconds
Definition: dcf-manager.h:349
Time MostRecent(Time a, Time b) const
Return the most recent time.
Definition: dcf-manager.cc:197
void SetSifs(Time sifs)
Definition: dcf-manager.cc:169
Time m_lastRxDuration
the last receive duration time
Definition: dcf-manager.h:336
Time m_lastRxStart
the last receive start time
Definition: dcf-manager.h:335