A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
channel-manager.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
#include "
channel-manager.h
"
19
#include "ns3/log.h"
20
#include "ns3/assert.h"
21
22
namespace
ns3
{
23
24
NS_LOG_COMPONENT_DEFINE
(
"ChannelManager"
);
25
26
NS_OBJECT_ENSURE_REGISTERED
(ChannelManager);
27
28
TypeId
29
ChannelManager::GetTypeId
(
void
)
30
{
31
static
TypeId
tid =
TypeId
(
"ns3::ChannelManager"
)
32
.
SetParent
<
Object
> ()
33
.SetGroupName (
"Wave"
)
34
.AddConstructor<
ChannelManager
> ()
35
;
36
return
tid;
37
}
38
39
ChannelManager::ChannelManager
()
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
51
ChannelManager::~ChannelManager
()
52
{
53
NS_LOG_FUNCTION
(
this
);
54
}
55
56
uint32_t
57
ChannelManager::GetCch
(
void
)
58
{
59
NS_LOG_FUNCTION_NOARGS
();
60
return
CCH
;
61
}
62
63
std::vector<uint32_t>
64
ChannelManager::GetSchs
(
void
)
65
{
66
NS_LOG_FUNCTION_NOARGS
();
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
77
std::vector<uint32_t>
78
ChannelManager::GetWaveChannels
(
void
)
79
{
80
NS_LOG_FUNCTION_NOARGS
();
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
92
uint32_t
93
ChannelManager::GetNumberOfWaveChannels
(
void
)
94
{
95
NS_LOG_FUNCTION_NOARGS
();
96
static
uint32_t NumberOfWaveChannels =
GetWaveChannels
().size ();
97
return
NumberOfWaveChannels;
98
}
99
100
bool
101
ChannelManager::IsCch
(uint32_t channelNumber)
102
{
103
NS_LOG_FUNCTION_NOARGS
();
104
return
channelNumber ==
CCH
;
105
}
106
107
bool
108
ChannelManager::IsSch
(uint32_t channelNumber)
109
{
110
NS_LOG_FUNCTION_NOARGS
();
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
122
bool
123
ChannelManager::IsWaveChannel
(uint32_t channelNumber)
124
{
125
NS_LOG_FUNCTION_NOARGS
();
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
137
uint32_t
138
ChannelManager::GetOperatingClass
(uint32_t channelNumber)
139
{
140
NS_LOG_FUNCTION
(
this
<< channelNumber);
141
return
m_channels
[channelNumber]->operatingClass;
142
}
143
144
bool
145
ChannelManager::GetManagementAdaptable
(uint32_t channelNumber)
146
{
147
NS_LOG_FUNCTION
(
this
<< channelNumber);
148
return
m_channels
[channelNumber]->adaptable;
149
}
150
151
WifiMode
152
ChannelManager::GetManagementDataRate
(uint32_t channelNumber)
153
{
154
NS_LOG_FUNCTION
(
this
<< channelNumber);
155
return
m_channels
[channelNumber]->dataRate;
156
}
157
158
WifiPreamble
159
ChannelManager::GetManagementPreamble
(uint32_t channelNumber)
160
{
161
NS_LOG_FUNCTION
(
this
<< channelNumber);
162
return
m_channels
[channelNumber]->preamble;
163
}
164
165
uint32_t
166
ChannelManager::GetManagementPowerLevel
(uint32_t channelNumber)
167
{
168
NS_LOG_FUNCTION
(
this
<< channelNumber);
169
return
m_channels
[channelNumber]->txPowerLevel;
170
}
171
172
void
173
ChannelManager::DoDispose
(
void
)
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
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
ns3::ChannelManager::GetWaveChannels
static std::vector< uint32_t > GetWaveChannels(void)
Definition:
channel-manager.cc:78
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
ns3::ChannelManager::GetNumberOfWaveChannels
static uint32_t GetNumberOfWaveChannels(void)
Definition:
channel-manager.cc:93
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
CCH
#define CCH
Definition:
channel-manager.h:52
ns3::ChannelManager
manage 7 WaveChannels and the tx information such as data rate and txPowerLevel.
Definition:
channel-manager.h:63
ns3::ChannelManager::IsWaveChannel
static bool IsWaveChannel(uint32_t channelNumber)
Definition:
channel-manager.cc:123
ns3::ChannelManager::~ChannelManager
virtual ~ChannelManager()
Definition:
channel-manager.cc:51
SCH1
#define SCH1
Definition:
channel-manager.h:49
ns3::ChannelManager::GetSchs
static std::vector< uint32_t > GetSchs(void)
Definition:
channel-manager.cc:64
SCH4
#define SCH4
Definition:
channel-manager.h:53
ns3::ChannelManager::GetCch
static uint32_t GetCch(void)
Definition:
channel-manager.cc:57
ns3::ChannelManager::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
channel-manager.cc:29
ns3::ChannelManager::WaveChannel
WaveChannel structure.
Definition:
channel-manager.h:144
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:923
SCH3
#define SCH3
Definition:
channel-manager.h:51
channel-manager.h
ns3::WifiMode
represent a single transmission mode
Definition:
wifi-mode.h:48
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:88
ns3::ChannelManager::m_channels
std::map< uint32_t, WaveChannel * > m_channels
list of channels
Definition:
channel-manager.h:166
ns3::ChannelManager::GetOperatingClass
uint32_t GetOperatingClass(uint32_t channelNumber)
Definition:
channel-manager.cc:138
ns3::WifiPreamble
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition:
wifi-phy-common.h:68
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log-macros-enabled.h:209
ns3::ChannelManager::IsSch
static bool IsSch(uint32_t channelNumber)
Definition:
channel-manager.cc:108
SCH6
#define SCH6
Definition:
channel-manager.h:55
ns3::ChannelManager::GetManagementPowerLevel
uint32_t GetManagementPowerLevel(uint32_t channelNumber)
Definition:
channel-manager.cc:166
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:244
SCH5
#define SCH5
Definition:
channel-manager.h:54
SCH2
#define SCH2
Definition:
channel-manager.h:50
ns3::ChannelManager::GetManagementAdaptable
bool GetManagementAdaptable(uint32_t channelNumber)
Definition:
channel-manager.cc:145
ns3::ChannelManager::ChannelManager
ChannelManager()
Definition:
channel-manager.cc:39
ns3::ChannelManager::GetManagementPreamble
WifiPreamble GetManagementPreamble(uint32_t channelNumber)
Definition:
channel-manager.cc:159
ns3::ChannelManager::GetManagementDataRate
WifiMode GetManagementDataRate(uint32_t channelNumber)
Definition:
channel-manager.cc:152
ns3::ChannelManager::IsCch
static bool IsCch(uint32_t channelNumber)
Definition:
channel-manager.cc:101
ns3::ChannelManager::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition:
channel-manager.cc:173
src
wave
model
channel-manager.cc
Generated on Fri Oct 1 2021 17:03:41 for ns-3 by
1.8.20