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 
28 TypeId
30 {
31  static TypeId tid = TypeId ("ns3::ChannelScheduler")
32  .SetParent<Object> ()
33  .SetGroupName ("Wave")
34  ;
35  return tid;
36 }
37 
39 {
40  NS_LOG_FUNCTION (this);
41 }
43 {
44  NS_LOG_FUNCTION (this);
45 }
46 
47 void
49 {
50  // assign default CCH access when the device is initialized
52 }
53 
54 void
56 {
57  NS_LOG_FUNCTION (this << device);
58  m_device = device;
59 }
60 
61 bool
62 ChannelScheduler::IsChannelAccessAssigned (uint32_t channelNumber) const
63 {
64  NS_LOG_FUNCTION (this << channelNumber);
65  return (GetAssignedAccessType (channelNumber) != NoAccess);
66 }
67 
68 bool
70 {
71  NS_LOG_FUNCTION (this);
72  return (GetAssignedAccessType (CCH) != NoAccess);
73 }
74 
75 bool
77 {
78  NS_LOG_FUNCTION (this);
82 }
83 
84 bool
85 ChannelScheduler::IsContinuousAccessAssigned (uint32_t channelNumber) const
86 {
87  NS_LOG_FUNCTION (this << channelNumber);
88  return (GetAssignedAccessType (channelNumber) == ContinuousAccess);
89 }
90 bool
91 ChannelScheduler::IsAlternatingAccessAssigned (uint32_t channelNumber) const
92 {
93  NS_LOG_FUNCTION (this << channelNumber);
94  return (GetAssignedAccessType (channelNumber) == AlternatingAccess);
95 }
96 bool
97 ChannelScheduler::IsExtendedAccessAssigned (uint32_t channelNumber) const
98 {
99  NS_LOG_FUNCTION (this << channelNumber);
100  return (GetAssignedAccessType (channelNumber) == ExtendedAccess);
101 }
102 bool
104 {
105  NS_LOG_FUNCTION (this);
107 }
108 bool
110 {
111  NS_LOG_FUNCTION (this << &schInfo);
112  uint32_t cn = schInfo.channelNumber;
113 
114  if (ChannelManager::IsCch (schInfo.channelNumber))
115  {
116  NS_LOG_DEBUG ("the channel access requirement for CCH is not allowed.");
117  return false;
118  }
119  uint32_t extends = schInfo.extendedAccess;
120  bool immediate = schInfo.immediateAccess;
122  for (EdcaParametersI i = schInfo.edcaParameters.begin (); i != schInfo.edcaParameters.end (); ++i)
123  {
124  EdcaParameter edca = i->second;
125  mac->ConfigureEdca (edca.cwmin, edca.cwmax, edca.aifsn, i->first);
126  }
127 
128  if (extends == EXTENDED_CONTINUOUS)
129  {
130  return AssignContinuousAccess (cn, immediate);
131  }
132  else if (extends == EXTENDED_ALTERNATING)
133  {
134  return AssignAlternatingAccess (cn, immediate);
135  }
136  else
137  {
138  return AssignExtendedAccess (cn, extends, immediate);
139  }
140 }
141 
142 bool
143 ChannelScheduler::StopSch (uint32_t channelNumber)
144 {
145  NS_LOG_FUNCTION (this << channelNumber);
146  if (ChannelManager::IsCch (channelNumber))
147  {
148  NS_LOG_DEBUG ("the channel access for CCH is not allowed to be released.");
149  return false;
150  }
151  if (!IsChannelAccessAssigned (channelNumber))
152  {
153  NS_LOG_DEBUG ("the channel access for channel " << channelNumber << " has already been released.");
154  return true;
155  }
156  return ReleaseAccess (channelNumber);
157 }
158 
159 } // namespace ns3
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void ConfigureEdca(uint32_t cwmin, uint32_t cwmax, uint32_t aifsn, enum AcIndex ac)
uint8_t extendedAccess
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
EdcaParameters edcaParameters
virtual bool AssignExtendedAccess(uint32_t channelNumber, uint32_t extends, bool immediate)=0
bool StartSch(const SchInfo &schInfo)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
virtual bool AssignDefaultCchAccess(void)=0
bool IsDefaultCchAccessAssigned(void) const
#define CCH
virtual void DoInitialize(void)
Initialize() implementation.
virtual void SetWaveNetDevice(Ptr< WaveNetDevice > device)
bool IsSchAccessAssigned(void) const
std::map< AcIndex, EdcaParameter >::const_iterator EdcaParametersI
#define EXTENDED_ALTERNATING
bool IsAlternatingAccessAssigned(uint32_t channelNumber) const
#define EXTENDED_CONTINUOUS
virtual bool AssignAlternatingAccess(uint32_t channelNumber, bool immediate)=0
#define SCH2
tuple mac
Definition: third.py:92
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.
Ptr< OcbWifiMac > GetMac(uint32_t channelNumber) const
uint32_t channelNumber
virtual bool AssignContinuousAccess(uint32_t channelNumber, bool immediate)=0
bool IsContinuousAccessAssigned(uint32_t channelNumber) const
bool StopSch(uint32_t channelNumber)
static TypeId GetTypeId(void)
Ptr< WaveNetDevice > m_device
bool IsCchAccessAssigned(void) const
#define SCH5
#define SCH3
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
bool IsExtendedAccessAssigned(uint32_t channelNumber) const
bool IsChannelAccessAssigned(uint32_t channelNumber) const
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:904
#define SCH1
#define SCH6
virtual bool ReleaseAccess(uint32_t channelNumber)=0