A Discrete-Event Network Simulator
API
channel-scheduler.cc
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
19#include "channel-scheduler.h"
20#include "ns3/log.h"
21
22namespace ns3 {
23
24NS_LOG_COMPONENT_DEFINE ("ChannelScheduler");
25
26NS_OBJECT_ENSURE_REGISTERED (ChannelScheduler);
27
32TypeId
34{
35 static TypeId tid = TypeId ("ns3::ChannelScheduler")
36 .SetParent<Object> ()
37 .SetGroupName ("Wave")
38 ;
39 return tid;
40}
41
43{
44 NS_LOG_FUNCTION (this);
45}
47{
48 NS_LOG_FUNCTION (this);
49}
50
51void
53{
54 // assign default CCH access when the device is initialized
56}
57
58void
60{
61 NS_LOG_FUNCTION (this << device);
62 m_device = device;
63}
64
65bool
67{
68 NS_LOG_FUNCTION (this << channelNumber);
69 return (GetAssignedAccessType (channelNumber) != NoAccess);
70}
71
72bool
74{
75 NS_LOG_FUNCTION (this);
77}
78
79bool
81{
82 NS_LOG_FUNCTION (this);
86}
87
88bool
90{
91 NS_LOG_FUNCTION (this << channelNumber);
92 return (GetAssignedAccessType (channelNumber) == ContinuousAccess);
93}
94bool
96{
97 NS_LOG_FUNCTION (this << channelNumber);
98 return (GetAssignedAccessType (channelNumber) == AlternatingAccess);
99}
100bool
102{
103 NS_LOG_FUNCTION (this << channelNumber);
104 return (GetAssignedAccessType (channelNumber) == ExtendedAccess);
105}
106bool
108{
109 NS_LOG_FUNCTION (this);
111}
112bool
114{
115 NS_LOG_FUNCTION (this << &schInfo);
116 uint32_t cn = schInfo.channelNumber;
117
119 {
120 NS_LOG_DEBUG ("the channel access requirement for CCH is not allowed.");
121 return false;
122 }
123 uint32_t extends = schInfo.extendedAccess;
124 bool immediate = schInfo.immediateAccess;
126 for (EdcaParametersI i = schInfo.edcaParameters.begin (); i != schInfo.edcaParameters.end (); ++i)
127 {
128 EdcaParameter edca = i->second;
129 mac->ConfigureEdca (edca.cwmin, edca.cwmax, edca.aifsn, i->first);
130 }
131
132 if (extends == EXTENDED_CONTINUOUS)
133 {
134 return AssignContinuousAccess (cn, immediate);
135 }
136 else if (extends == EXTENDED_ALTERNATING)
137 {
138 return AssignAlternatingAccess (cn, immediate);
139 }
140 else
141 {
142 return AssignExtendedAccess (cn, extends, immediate);
143 }
144}
145
146bool
148{
149 NS_LOG_FUNCTION (this << channelNumber);
150 if (ChannelManager::IsCch (channelNumber))
151 {
152 NS_LOG_DEBUG ("the channel access for CCH is not allowed to be released.");
153 return false;
154 }
155 if (!IsChannelAccessAssigned (channelNumber))
156 {
157 NS_LOG_DEBUG ("the channel access for channel " << channelNumber << " has already been released.");
158 return true;
159 }
160 return ReleaseAccess (channelNumber);
161}
162
163void
165{
166 NS_LOG_FUNCTION (this);
167 m_device = 0;
168}
169
170} // namespace ns3
#define SCH2
#define SCH5
#define SCH1
#define CCH
#define SCH6
#define SCH4
#define SCH3
#define EXTENDED_ALTERNATING
#define EXTENDED_CONTINUOUS
static bool IsCch(uint32_t channelNumber)
bool IsSchAccessAssigned(void) const
bool StopSch(uint32_t channelNumber)
virtual void DoInitialize(void)
Initialize() implementation.
static TypeId GetTypeId(void)
Get the type ID.
bool StartSch(const SchInfo &schInfo)
virtual enum ChannelAccess GetAssignedAccessType(uint32_t channelNumber) const =0
virtual void DoDispose(void)
Destructor implementation.
bool IsAlternatingAccessAssigned(uint32_t channelNumber) const
bool IsContinuousAccessAssigned(uint32_t channelNumber) const
virtual bool AssignDefaultCchAccess(void)=0
This method will assign default CCH access for CCH.
bool IsCchAccessAssigned(void) const
virtual void SetWaveNetDevice(Ptr< WaveNetDevice > device)
bool IsChannelAccessAssigned(uint32_t channelNumber) const
Ptr< WaveNetDevice > m_device
the device
virtual bool ReleaseAccess(uint32_t channelNumber)=0
bool IsDefaultCchAccessAssigned(void) const
virtual bool AssignContinuousAccess(uint32_t channelNumber, bool immediate)=0
virtual bool AssignExtendedAccess(uint32_t channelNumber, uint32_t extends, bool immediate)=0
bool IsExtendedAccessAssigned(uint32_t channelNumber) const
virtual bool AssignAlternatingAccess(uint32_t channelNumber, bool immediate)=0
A base class which provides memory management and object aggregation.
Definition: object.h:88
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Ptr< OcbWifiMac > GetMac(uint32_t channelNumber) const
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
std::map< AcIndex, EdcaParameter >::const_iterator EdcaParametersI
EDCA parameters iterator typedef.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ AlternatingAccess
@ ContinuousAccess
@ ExtendedAccess
@ DefaultCchAccess
mac
Definition: third.py:96
EdcaParameter structure.
uint32_t cwmin
minimum
uint32_t aifsn
AIFSN.
uint32_t cwmax
maximum
uint8_t extendedAccess
extended access
EdcaParameters edcaParameters
EDCA parameters.
uint32_t channelNumber
channel number
bool immediateAccess
immediate access