20 #include "ns3/simulator.h"
21 #include "ns3/wifi-phy.h"
67 static TypeId tid =
TypeId (
"ns3::DefaultChannelScheduler")
69 .SetGroupName (
"Wave")
76 : m_channelNumber (0),
79 m_waitChannelNumber (0),
81 m_coordinationListener (0)
122 std::vector<Ptr<WifiPhy> > phys = device->
GetPhys ();
123 if (phys.size () > 1)
125 NS_LOG_WARN (
"The class is only in the context of single-PHY device, while there are more than one PHY devices");
151 uint32_t sch = channelNumber;
188 uint32_t sch = channelNumber;
246 uint32_t sch = channelNumber;
263 if (remainExtends > extends)
337 NS_LOG_DEBUG (
"channel access is already assigned for other SCHs, thus cannot assign default CCH access.");
342 if (
Now ().GetMilliSeconds() != 0)
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Ptr< WifiPhy > GetPhy(uint32_t index) const
uint8_t GetChannelNumber(void) const
Return current channel number.
Simulation virtual time values and global simulation resolution.
CoordinationListener(DefaultChannelScheduler *scheduler)
Constructor.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void DoDispose(void)
Destructor implementation.
CoordinationListener class.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
DefaultChannelScheduler()
uint32_t m_waitChannelNumber
wait channel number
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
virtual void DoDispose(void)
Destructor implementation.
virtual ~CoordinationListener()
virtual ~DefaultChannelScheduler()
bool IsSchInterval(Time duration=Seconds(0.0)) const
virtual void DoInitialize(void)
Initialize() implementation.
virtual void NotifyGuardSlotStart(Time duration, bool cchi)
virtual void SetWaveNetDevice(Ptr< WaveNetDevice > device)
Ptr< ChannelCoordinator > GetChannelCoordinator(void) const
uint32_t m_waitExtend
wait extend
DefaultChannelScheduler * m_scheduler
the scheduler
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
static TypeId GetTypeId(void)
Get the type ID.
void NotifySchSlotStart(Time duration)
Notify SCH slot start.
void RegisterListener(Ptr< ChannelCoordinationListener > listener)
Time NeedTimeToCchInterval(Time duration=Seconds(0.0)) const
void Suspend(void)
To support MAC extension for multiple channel operation, Suspend the activity in current MAC entity...
virtual void SetWaveNetDevice(Ptr< WaveNetDevice > device)
void MakeVirtualBusy(Time duration)
#define EXTENDED_CONTINUOUS
void ResetWifiPhy(void)
removes attached WifiPhy device from this MAC.
virtual void DoInitialize(void)
Initialize() implementation.
EventId m_waitEvent
wait event
virtual void NotifySchSlotStart(Time duration)
virtual bool AssignDefaultCchAccess(void)
This method will assign default CCH access for CCH.
This class uses a simple mechanism to assign channel access with following features: (1) only in the ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
EventId m_extendEvent
extend event
Ptr< ChannelCoordinator > m_coordinator
channel coordinator
void NotifyGuardSlotStart(Time duration, bool cchi)
Notify guard slot start.
Ptr< OcbWifiMac > GetMac(uint32_t channelNumber) const
virtual bool AssignAlternatingAccess(uint32_t channelNumber, bool immediate)
enum ChannelAccess m_channelAccess
channel access
Time NeedTimeToSchInterval(Time duration=Seconds(0.0)) const
virtual enum ChannelAccess GetAssignedAccessType(uint32_t channelNumber) const
virtual void SetChannelNumber(uint8_t id)
Set channel number.
ChannelAccess
ChannelAccess enumeration.
virtual bool ReleaseAccess(uint32_t channelNumber)
Ptr< WaveNetDevice > m_device
the device
void NotifyCchSlotStart(Time duration)
Notify CCH slot start.
virtual void NotifyCchSlotStart(Time duration)
std::vector< Ptr< WifiPhy > > GetPhys(void) const
Ptr< ChannelCoordinationListener > m_coordinationListener
coordination listener
uint32_t m_channelNumber
when m_channelAccess is ContinuousAccess, m_channelNumber is continuous channel number; when m_channe...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
receive notifications about channel coordination events.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time GetSyncInterval(void) const
Time GetChannelSwitchDelay(void) const
virtual bool AssignContinuousAccess(uint32_t channelNumber, bool immediate)
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
virtual bool AssignExtendedAccess(uint32_t channelNumber, uint32_t extends, bool immediate)
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
a unique identifier for an interface.
virtual void SetWifiPhy(const Ptr< WifiPhy > phy)
void Resume(void)
To support MAC extension for multiple channel operation, Resume the activity of suspended MAC entity...
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class will assign channel access for requests from higher layers.
void SwitchToNextChannel(uint32_t curChannelNumber, uint32_t nextChannelNumber)