A Discrete-Event Network Simulator
API
channel-coordinator.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * Author: Junling Bu <linlinjavaer@gmail.com>
17  */
18 #ifndef CHANNEL_COORDINATOR_H
19 #define CHANNEL_COORDINATOR_H
20 #include "ns3/nstime.h"
21 #include "ns3/object.h"
22 #include "ns3/event-id.h"
23 
24 namespace ns3 {
25 
29 class ChannelCoordinationListener : public SimpleRefCount<ChannelCoordinationListener>
30 {
31 public:
32  virtual ~ChannelCoordinationListener (void);
36  virtual void NotifyCchSlotStart (Time duration) = 0;
40  virtual void NotifySchSlotStart (Time duration) = 0;
45  virtual void NotifyGuardSlotStart (Time duration, bool cchi) = 0;
46 };
70 class ChannelCoordinator : public Object
71 {
72 public:
73  static TypeId GetTypeId (void);
75  virtual ~ChannelCoordinator ();
76 
80  static Time GetDefaultCchInterval (void);
84  static Time GetDefaultSchInterval (void);
88  static Time GetDefaultSyncInterval (void);
92  static Time GetDefaultGuardInterval (void);
93 
97  void SetCchInterval (Time cchi);
101  Time GetCchInterval (void) const;
105  void SetSchInterval (Time schi);
109  Time GetSchInterval (void) const;
113  Time GetSyncInterval (void) const;
117  void SetGuardInterval (Time guardi);
121  Time GetGuardInterval (void) const;
128  bool IsValidConfig (void) const;
129 
134  bool IsCchInterval (Time duration = Seconds (0.0)) const;
139  bool IsSchInterval (Time duration = Seconds (0.0)) const;
144  bool IsGuardInterval (Time duration = Seconds (0.0)) const;
150  Time NeedTimeToCchInterval (Time duration = Seconds (0.0)) const;
156  Time NeedTimeToSchInterval (Time duration = Seconds (0.0)) const;
162  Time NeedTimeToGuardInterval (Time duration = Seconds (0.0)) const;
172  Time GetIntervalTime (Time duration = Seconds (0.0)) const;
182  Time GetRemainTime (Time duration = Seconds (0.0)) const;
199  void UnregisterAllListeners (void);
200 
201 private:
202  virtual void DoDispose (void);
203  virtual void DoInitialize (void);
204 
208  void StartChannelCoordination (void);
212  void StopChannelCoordination (void);
213 
214  void NotifySchSlot (void);
215  void NotifyCchSlot (void);
216  void NotifyGuardSlot (void);
220  Time GetSchSlot (void) const;
224  Time GetCchSlot (void) const;
225 
226  Time m_cchi; // CchInterval
227  Time m_schi; // SchInterval
228  Time m_gi; // GuardInterval
229 
230  typedef std::vector<Ptr<ChannelCoordinationListener> > Listeners;
231  typedef std::vector<Ptr<ChannelCoordinationListener> >::iterator ListenersI;
232  Listeners m_listeners;
233 
234  uint32_t m_guardCount;
236 };
237 
238 }
239 #endif /* CHANNEL_COORDINATOR_H */
bool IsGuardInterval(Time duration=Seconds(0.0)) const
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
ChannelCoordinator deals with channel coordination in data plane (see 1609.4 chapter 5...
Time GetRemainTime(Time duration=Seconds(0.0)) const
bool IsSchInterval(Time duration=Seconds(0.0)) const
bool IsValidConfig(void) const
virtual void NotifyGuardSlotStart(Time duration, bool cchi)=0
Time NeedTimeToGuardInterval(Time duration=Seconds(0.0)) const
static Time GetDefaultGuardInterval(void)
void UnregisterAllListeners(void)
Remove all listeners.
static Time GetDefaultSchInterval(void)
void StartChannelCoordination(void)
start to make channel coordination events
Time GetGuardInterval(void) const
void RegisterListener(Ptr< ChannelCoordinationListener > listener)
Time NeedTimeToCchInterval(Time duration=Seconds(0.0)) const
bool IsCchInterval(Time duration=Seconds(0.0)) const
void UnregisterListener(Ptr< ChannelCoordinationListener > listener)
virtual void NotifyCchSlotStart(Time duration)=0
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time GetIntervalTime(Time duration=Seconds(0.0)) const
Time GetCchInterval(void) const
virtual void DoInitialize(void)
Initialize() implementation.
std::vector< Ptr< ChannelCoordinationListener > >::iterator ListenersI
Time NeedTimeToSchInterval(Time duration=Seconds(0.0)) const
static Time GetDefaultCchInterval(void)
Time GetSchInterval(void) const
void StopChannelCoordination(void)
stop channel coordination events
virtual void DoDispose(void)
Destructor implementation.
virtual void NotifySchSlotStart(Time duration)=0
An identifier for simulation events.
Definition: event-id.h:53
receive notifications about channel coordination events.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
Time GetSyncInterval(void) const
static TypeId GetTypeId(void)
A base class which provides memory management and object aggregation.
Definition: object.h:87
A template-based reference counting class.
a unique identifier for an interface.
Definition: type-id.h:58
std::vector< Ptr< ChannelCoordinationListener > > Listeners
void SetGuardInterval(Time guardi)
static Time GetDefaultSyncInterval(void)