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 */
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Time GetIntervalTime(Time duration=Seconds(0.0)) const
ChannelCoordinator deals with channel coordination in data plane (see 1609.4 chapter 5...
Time NeedTimeToCchInterval(Time duration=Seconds(0.0)) const
bool IsCchInterval(Time duration=Seconds(0.0)) const
void NotifySchSlot(void)
notify listeners of a SCH slot start
EventId m_coordination
coordination event
Listeners m_listeners
listeners
Time NeedTimeToGuardInterval(Time duration=Seconds(0.0)) const
uint32_t m_guardCount
guard count
bool IsGuardInterval(Time duration=Seconds(0.0)) const
virtual void NotifyGuardSlotStart(Time duration, bool cchi)=0
void NotifyGuardSlot(void)
notify listeners of a guard slot start
static Time GetDefaultGuardInterval(void)
void UnregisterAllListeners(void)
Remove all listeners.
static Time GetDefaultSchInterval(void)
void StartChannelCoordination(void)
start to make channel coordination events
void RegisterListener(Ptr< ChannelCoordinationListener > listener)
Time m_gi
GuardInterval.
void UnregisterListener(Ptr< ChannelCoordinationListener > listener)
virtual void NotifyCchSlotStart(Time duration)=0
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void DoInitialize(void)
Initialize() implementation.
std::vector< Ptr< ChannelCoordinationListener > >::iterator ListenersI
Listeners iterator typedef.
static Time GetDefaultCchInterval(void)
void NotifyCchSlot(void)
notify listeners of a CCH slot start
void StopChannelCoordination(void)
stop channel coordination events
virtual void DoDispose(void)
Destructor implementation.
bool IsSchInterval(Time duration=Seconds(0.0)) const
Time GetRemainTime(Time duration=Seconds(0.0)) const
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:1014
Time NeedTimeToSchInterval(Time duration=Seconds(0.0)) const
static TypeId GetTypeId(void)
Get the type ID.
A base class which provides memory management and object aggregation.
Definition: object.h:87
Time GetSyncInterval(void) const
A template-based reference counting class.
a unique identifier for an interface.
Definition: type-id.h:58
std::vector< Ptr< ChannelCoordinationListener > > Listeners
Listeners typdef.
Time GetGuardInterval(void) const
void SetGuardInterval(Time guardi)
static Time GetDefaultSyncInterval(void)