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 
22 namespace ns3 {
23 
24 NS_LOG_COMPONENT_DEFINE ("ChannelScheduler");
25 
26 NS_OBJECT_ENSURE_REGISTERED (ChannelScheduler);
27 
32 TypeId
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 
51 void
53 {
54  // assign default CCH access when the device is initialized
56 }
57 
58 void
60 {
61  NS_LOG_FUNCTION (this << device);
62  m_device = device;
63 }
64 
65 bool
66 ChannelScheduler::IsChannelAccessAssigned (uint32_t channelNumber) const
67 {
68  NS_LOG_FUNCTION (this << channelNumber);
69  return (GetAssignedAccessType (channelNumber) != NoAccess);
70 }
71 
72 bool
74 {
75  NS_LOG_FUNCTION (this);
76  return (GetAssignedAccessType (CCH) != NoAccess);
77 }
78 
79 bool
81 {
82  NS_LOG_FUNCTION (this);
86 }
87 
88 bool
89 ChannelScheduler::IsContinuousAccessAssigned (uint32_t channelNumber) const
90 {
91  NS_LOG_FUNCTION (this << channelNumber);
92  return (GetAssignedAccessType (channelNumber) == ContinuousAccess);
93 }
94 bool
95 ChannelScheduler::IsAlternatingAccessAssigned (uint32_t channelNumber) const
96 {
97  NS_LOG_FUNCTION (this << channelNumber);
98  return (GetAssignedAccessType (channelNumber) == AlternatingAccess);
99 }
100 bool
101 ChannelScheduler::IsExtendedAccessAssigned (uint32_t channelNumber) const
102 {
103  NS_LOG_FUNCTION (this << channelNumber);
104  return (GetAssignedAccessType (channelNumber) == ExtendedAccess);
105 }
106 bool
108 {
109  NS_LOG_FUNCTION (this);
111 }
112 bool
114 {
115  NS_LOG_FUNCTION (this << &schInfo);
116  uint32_t cn = schInfo.channelNumber;
117 
118  if (ChannelManager::IsCch (schInfo.channelNumber))
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 
146 bool
147 ChannelScheduler::StopSch (uint32_t channelNumber)
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 
163 } // namespace ns3
uint32_t cwmin
minimum
EdcaParameter structure.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint8_t extendedAccess
extended access
bool IsSchAccessAssigned(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
EdcaParameters edcaParameters
EDCA parameters.
virtual bool AssignExtendedAccess(uint32_t channelNumber, uint32_t extends, bool immediate)=0
bool StartSch(const SchInfo &schInfo)
bool immediateAccess
immediate access
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
bool IsDefaultCchAccessAssigned(void) const
virtual bool AssignDefaultCchAccess(void)=0
This method will assign default CCH access for CCH.
uint32_t cwmax
maximum
#define CCH
virtual void DoInitialize(void)
Initialize() implementation.
virtual void SetWaveNetDevice(Ptr< WaveNetDevice > device)
bool IsExtendedAccessAssigned(uint32_t channelNumber) const
#define EXTENDED_ALTERNATING
mac
Definition: third.py:99
bool IsContinuousAccessAssigned(uint32_t channelNumber) const
#define EXTENDED_CONTINUOUS
virtual bool AssignAlternatingAccess(uint32_t channelNumber, bool immediate)=0
#define SCH2
std::map< AcIndex, EdcaParameter >::const_iterator EdcaParametersI
EDCA parameters iterator typedef.
virtual enum ChannelAccess GetAssignedAccessType(uint32_t channelNumber) const =0
static bool IsCch(uint32_t channelNumber)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsAlternatingAccessAssigned(uint32_t channelNumber) const
bool IsCchAccessAssigned(void) const
uint32_t channelNumber
channel number
virtual bool AssignContinuousAccess(uint32_t channelNumber, bool immediate)=0
Ptr< OcbWifiMac > GetMac(uint32_t channelNumber) const
bool StopSch(uint32_t channelNumber)
static TypeId GetTypeId(void)
Get the type ID.
bool IsChannelAccessAssigned(uint32_t channelNumber) const
Ptr< WaveNetDevice > m_device
the device
#define SCH5
#define SCH3
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:272
A base class which provides memory management and object aggregation.
Definition: object.h:87
a unique identifier for an interface.
Definition: type-id.h:58
#define SCH4
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
#define SCH1
uint32_t aifsn
AIFSN.
#define SCH6
virtual bool ReleaseAccess(uint32_t channelNumber)=0