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 
30 class ChannelCoordinationListener : public SimpleRefCount<ChannelCoordinationListener>
31 {
32 public:
33  virtual ~ChannelCoordinationListener (void);
37  virtual void NotifyCchSlotStart (Time duration) = 0;
41  virtual void NotifySchSlotStart (Time duration) = 0;
46  virtual void NotifyGuardSlotStart (Time duration, bool cchi) = 0;
47 };
71 class ChannelCoordinator : public Object
72 {
73 public:
78  static TypeId GetTypeId (void);
80  virtual ~ChannelCoordinator ();
81 
85  static Time GetDefaultCchInterval (void);
89  static Time GetDefaultSchInterval (void);
93  static Time GetDefaultSyncInterval (void);
97  static Time GetDefaultGuardInterval (void);
98 
102  void SetCchInterval (Time cchi);
106  Time GetCchInterval (void) const;
110  void SetSchInterval (Time schi);
114  Time GetSchInterval (void) const;
118  Time GetSyncInterval (void) const;
122  void SetGuardInterval (Time guardi);
126  Time GetGuardInterval (void) const;
133  bool IsValidConfig (void) const;
134 
139  bool IsCchInterval (Time duration = Seconds (0.0)) const;
144  bool IsSchInterval (Time duration = Seconds (0.0)) const;
149  bool IsGuardInterval (Time duration = Seconds (0.0)) const;
155  Time NeedTimeToCchInterval (Time duration = Seconds (0.0)) const;
161  Time NeedTimeToSchInterval (Time duration = Seconds (0.0)) const;
167  Time NeedTimeToGuardInterval (Time duration = Seconds (0.0)) const;
177  Time GetIntervalTime (Time duration = Seconds (0.0)) const;
187  Time GetRemainTime (Time duration = Seconds (0.0)) const;
204  void UnregisterAllListeners (void);
205 
206 private:
207  virtual void DoDispose (void);
208  virtual void DoInitialize (void);
209 
213  void StartChannelCoordination (void);
217  void StopChannelCoordination (void);
221  void NotifySchSlot (void);
225  void NotifyCchSlot (void);
229  void NotifyGuardSlot (void);
233  Time GetSchSlot (void) const;
237  Time GetCchSlot (void) const;
238 
242 
244  typedef std::vector<Ptr<ChannelCoordinationListener> > Listeners;
246  typedef std::vector<Ptr<ChannelCoordinationListener> >::iterator ListenersI;
248 
249  uint32_t m_guardCount;
251 };
252 
253 }
254 #endif /* CHANNEL_COORDINATOR_H */
receive notifications about channel coordination events.
virtual void NotifyGuardSlotStart(Time duration, bool cchi)=0
virtual void NotifyCchSlotStart(Time duration)=0
virtual void NotifySchSlotStart(Time duration)=0
ChannelCoordinator deals with channel coordination in data plane (see 1609.4 chapter 5....
static Time GetDefaultGuardInterval(void)
void StopChannelCoordination(void)
stop channel coordination events
Listeners m_listeners
listeners
virtual void DoInitialize(void)
Initialize() implementation.
void StartChannelCoordination(void)
start to make channel coordination events
Time NeedTimeToCchInterval(Time duration=Seconds(0.0)) const
std::vector< Ptr< ChannelCoordinationListener > >::iterator ListenersI
Listeners iterator typedef.
bool IsSchInterval(Time duration=Seconds(0.0)) const
void NotifySchSlot(void)
notify listeners of a SCH slot start
void UnregisterAllListeners(void)
Remove all listeners.
bool IsGuardInterval(Time duration=Seconds(0.0)) const
uint32_t m_guardCount
guard count
void SetGuardInterval(Time guardi)
Time GetSyncInterval(void) const
EventId m_coordination
coordination event
Time NeedTimeToSchInterval(Time duration=Seconds(0.0)) const
static Time GetDefaultSchInterval(void)
Time NeedTimeToGuardInterval(Time duration=Seconds(0.0)) const
void UnregisterListener(Ptr< ChannelCoordinationListener > listener)
void NotifyGuardSlot(void)
notify listeners of a guard slot start
Time GetGuardInterval(void) const
static TypeId GetTypeId(void)
Get the type ID.
std::vector< Ptr< ChannelCoordinationListener > > Listeners
Listeners typdef.
Time GetRemainTime(Time duration=Seconds(0.0)) const
static Time GetDefaultCchInterval(void)
virtual void DoDispose(void)
Destructor implementation.
Time GetIntervalTime(Time duration=Seconds(0.0)) const
static Time GetDefaultSyncInterval(void)
void NotifyCchSlot(void)
notify listeners of a CCH slot start
bool IsCchInterval(Time duration=Seconds(0.0)) const
void RegisterListener(Ptr< ChannelCoordinationListener > listener)
An identifier for simulation events.
Definition: event-id.h:54
A base class which provides memory management and object aggregation.
Definition: object.h:88
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
a unique identifier for an interface.
Definition: type-id.h:59
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
Every class exported by the ns3 library is enclosed in the ns3 namespace.