20#include "ns3/simulator.h"
46 .AddAttribute(
"CchInterval",
47 "CCH Interval, default value is 50ms.",
51 .AddAttribute(
"SchInterval",
52 "SCH Interval, default value is 50ms.",
56 .AddAttribute(
"GuardInterval",
57 "Guard Interval, default value is 4ms.",
95 const static uint8_t DEFAULT_CCH_INTERVAL = 50;
104 const static uint8_t DEFAULT_SCH_INTERVAL = 50;
120 const static uint8_t SyncTolerance = 2;
121 const static uint8_t MaxChSwitchTime = 2;
122 const static uint8_t DEFAULT_GUARD_INTERVAL = SyncTolerance + MaxChSwitchTime;
211 return interval <
m_gi;
221 NS_LOG_WARN(
"the channel interval should not be zero");
227 NS_LOG_WARN(
"every UTC second shall be an integer number of SyncInterval");
232 NS_LOG_WARN(
"CCH Interval should be large than GuardInterval");
237 NS_LOG_WARN(
"SCH Interval should be large than GuardInterval");
288 Time future =
Now() + duration;
316 if ((*i) == listener)
339 NS_FATAL_ERROR(
"the coordination event order should start with the beginning of 1 second");
344 "the channel intervals configured for channel coordination events are invalid");
398 (*i)->NotifyGuardSlotStart(guardSlot, inCchi);
virtual ~ChannelCoordinationListener()
ChannelCoordinator deals with channel coordination in data plane (see 1609.4 chapter 5....
static TypeId GetTypeId()
Get the type ID.
void StartChannelCoordination()
start to make channel coordination events
Time GetSyncInterval() const
~ChannelCoordinator() override
Listeners m_listeners
listeners
void SetSchInterval(Time schi)
bool IsValidConfig() const
Time NeedTimeToCchInterval(Time duration=Seconds(0.0)) const
bool IsSchInterval(Time duration=Seconds(0.0)) const
static Time GetDefaultCchInterval()
bool IsGuardInterval(Time duration=Seconds(0.0)) const
uint32_t m_guardCount
guard count
Time GetSchInterval() const
void SetGuardInterval(Time guardi)
void UnregisterAllListeners()
Remove all listeners.
void StopChannelCoordination()
stop channel coordination events
Time GetCchInterval() const
void NotifySchSlot()
notify listeners of a SCH slot start
Time GetGuardInterval() const
static Time GetDefaultGuardInterval()
EventId m_coordination
coordination event
Time NeedTimeToSchInterval(Time duration=Seconds(0.0)) const
static Time GetDefaultSchInterval()
void DoInitialize() override
Initialize() implementation.
Time NeedTimeToGuardInterval(Time duration=Seconds(0.0)) const
static Time GetDefaultSyncInterval()
void UnregisterListener(Ptr< ChannelCoordinationListener > listener)
void NotifyCchSlot()
notify listeners of a CCH slot start
void DoDispose() override
Destructor implementation.
void SetCchInterval(Time cchi)
void NotifyGuardSlot()
notify listeners of a guard slot start
Time GetRemainTime(Time duration=Seconds(0.0)) const
std::vector< Ptr< ChannelCoordinationListener > >::iterator ListenersI
Listeners iterator typedef.
Time GetIntervalTime(Time duration=Seconds(0.0)) const
bool IsCchInterval(Time duration=Seconds(0.0)) const
void RegisterListener(Ptr< ChannelCoordinationListener > listener)
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsExpired() const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
A base class which provides memory management and object aggregation.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Simulation virtual time values and global simulation resolution.
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.