A Discrete-Event Network Simulator
API
channel-manager.cc
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation;
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 *
15 * Author: Junling Bu <linlinjavaer@gmail.com>
16 */
17#include "channel-manager.h"
18
19#include "ns3/assert.h"
20#include "ns3/log.h"
21
22namespace ns3
23{
24
25NS_LOG_COMPONENT_DEFINE("ChannelManager");
26
27NS_OBJECT_ENSURE_REGISTERED(ChannelManager);
28
29TypeId
31{
32 static TypeId tid = TypeId("ns3::ChannelManager")
34 .SetGroupName("Wave")
35 .AddConstructor<ChannelManager>();
36 return tid;
37}
38
40{
41 NS_LOG_FUNCTION(this);
42 m_channels.insert(std::make_pair(CCH, new WaveChannel(CCH)));
43 m_channels.insert(std::make_pair(SCH1, new WaveChannel(SCH1)));
44 m_channels.insert(std::make_pair(SCH2, new WaveChannel(SCH2)));
45 m_channels.insert(std::make_pair(SCH3, new WaveChannel(SCH3)));
46 m_channels.insert(std::make_pair(SCH4, new WaveChannel(SCH4)));
47 m_channels.insert(std::make_pair(SCH5, new WaveChannel(SCH5)));
48 m_channels.insert(std::make_pair(SCH6, new WaveChannel(SCH6)));
49}
50
52{
53 NS_LOG_FUNCTION(this);
54}
55
58{
60 return CCH;
61}
62
63std::vector<uint32_t>
65{
67 std::vector<uint32_t> schs;
68 schs.push_back(SCH1);
69 schs.push_back(SCH2);
70 schs.push_back(SCH3);
71 schs.push_back(SCH4);
72 schs.push_back(SCH5);
73 schs.push_back(SCH6);
74 return schs;
75}
76
77std::vector<uint32_t>
79{
81 std::vector<uint32_t> channels;
82 channels.push_back(CCH);
83 channels.push_back(SCH1);
84 channels.push_back(SCH2);
85 channels.push_back(SCH3);
86 channels.push_back(SCH4);
87 channels.push_back(SCH5);
88 channels.push_back(SCH6);
89 return channels;
90}
91
94{
96 static uint32_t NumberOfWaveChannels = GetWaveChannels().size();
97 return NumberOfWaveChannels;
98}
99
100bool
102{
104 return channelNumber == CCH;
105}
106
107bool
109{
111 if (channelNumber < SCH1 || channelNumber > SCH6)
112 {
113 return false;
114 }
115 if (channelNumber % 2 == 1)
116 {
117 return false;
118 }
119 return (channelNumber != CCH);
120}
121
122bool
124{
126 if (channelNumber < SCH1 || channelNumber > SCH6)
127 {
128 return false;
129 }
130 if (channelNumber % 2 == 1)
131 {
132 return false;
133 }
134 return true;
135}
136
139{
140 NS_LOG_FUNCTION(this << channelNumber);
141 return m_channels[channelNumber]->operatingClass;
142}
143
144bool
146{
147 NS_LOG_FUNCTION(this << channelNumber);
148 return m_channels[channelNumber]->adaptable;
149}
150
153{
154 NS_LOG_FUNCTION(this << channelNumber);
155 return m_channels[channelNumber]->dataRate;
156}
157
160{
161 NS_LOG_FUNCTION(this << channelNumber);
162 return m_channels[channelNumber]->preamble;
163}
164
167{
168 NS_LOG_FUNCTION(this << channelNumber);
169 return m_channels[channelNumber]->txPowerLevel;
170}
171
172void
174{
175 NS_LOG_FUNCTION(this);
176 std::map<uint32_t, WaveChannel*>::iterator i;
177 for (i = m_channels.begin(); i != m_channels.end(); ++i)
178 {
179 delete (i->second);
180 }
181 m_channels.clear();
182}
183
184} // namespace ns3
#define SCH2
#define SCH5
#define SCH1
#define CCH
#define SCH6
#define SCH4
#define SCH3
manage 7 WaveChannels and the tx information such as data rate and txPowerLevel.
static TypeId GetTypeId()
Get the type ID.
static std::vector< uint32_t > GetSchs()
static bool IsCch(uint32_t channelNumber)
static std::vector< uint32_t > GetWaveChannels()
bool GetManagementAdaptable(uint32_t channelNumber)
static uint32_t GetNumberOfWaveChannels()
void DoDispose() override
Destructor implementation.
WifiPreamble GetManagementPreamble(uint32_t channelNumber)
static uint32_t GetCch()
uint32_t GetManagementPowerLevel(uint32_t channelNumber)
WifiMode GetManagementDataRate(uint32_t channelNumber)
static bool IsSch(uint32_t channelNumber)
uint32_t GetOperatingClass(uint32_t channelNumber)
std::map< uint32_t, WaveChannel * > m_channels
list of channels
static bool IsWaveChannel(uint32_t channelNumber)
~ChannelManager() override
A base class which provides memory management and object aggregation.
Definition: object.h:89
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
represent a single transmission mode
Definition: wifi-mode.h:50
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Every class exported by the ns3 library is enclosed in the ns3 namespace.