A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
ss-manager.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007,2008,2009 INRIA, UDcast
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
20
* <amine.ismail@UDcast.com>
21
*/
22
23
#include <stdint.h>
24
#include "
ss-manager.h
"
25
#include "ns3/log.h"
26
#include "
service-flow.h
"
27
28
namespace
ns3
{
29
30
NS_LOG_COMPONENT_DEFINE
(
"SSManager"
);
31
32
NS_OBJECT_ENSURE_REGISTERED
(SSManager);
33
34
TypeId
SSManager::GetTypeId
(
void
)
35
{
36
static
TypeId
tid =
TypeId
(
"ns3::SSManager"
)
37
.
SetParent
<
Object
> ()
38
.SetGroupName(
"Wimax"
);
39
return
tid;
40
}
41
42
SSManager::SSManager
(
void
)
43
{
44
m_ssRecords
=
new
std::vector<SSRecord*> ();
45
}
46
47
SSManager::~SSManager
(
void
)
48
{
49
for
(std::vector<SSRecord*>::iterator iter =
m_ssRecords
->begin (); iter !=
m_ssRecords
->end (); ++iter)
50
{
51
delete
*iter;
52
}
53
delete
m_ssRecords
;
54
m_ssRecords
= 0;
55
}
56
57
SSRecord
*
58
SSManager::CreateSSRecord
(
const
Mac48Address
&macAddress)
59
{
60
SSRecord
*ssRecord =
new
SSRecord
(macAddress);
61
m_ssRecords
->push_back (ssRecord);
62
return
ssRecord;
63
}
64
65
SSRecord
*
66
SSManager::GetSSRecord
(
const
Mac48Address
&macAddress)
const
67
{
68
for
(std::vector<SSRecord*>::iterator iter =
m_ssRecords
->begin (); iter !=
m_ssRecords
->end (); ++iter)
69
{
70
if
((*iter)->GetMacAddress () == macAddress)
71
{
72
return
*iter;
73
}
74
}
75
76
NS_LOG_DEBUG
(
"GetSSRecord: SSRecord not found!"
);
77
return
0;
78
}
79
80
SSRecord
*
81
SSManager::GetSSRecord
(
Cid
cid)
const
82
{
83
for
(std::vector<SSRecord*>::iterator iter1 =
m_ssRecords
->begin (); iter1 !=
m_ssRecords
->end (); ++iter1)
84
{
85
SSRecord
*ssRecord = *iter1;
86
if
(ssRecord->
GetBasicCid
() == cid || ssRecord->
GetPrimaryCid
() == cid)
87
{
88
return
ssRecord;
89
}
90
else
91
{
92
std::vector<ServiceFlow*> sf = ssRecord->
GetServiceFlows
(
ServiceFlow::SF_TYPE_ALL
);
93
for
(std::vector<ServiceFlow*>::iterator iter2 = sf.begin (); iter2 != sf.end (); ++iter2)
94
{
95
if
((*iter2)->GetConnection ()->GetCid () == cid)
96
{
97
return
ssRecord;
98
}
99
}
100
}
101
}
102
103
NS_LOG_DEBUG
(
"GetSSRecord: SSRecord not found!"
);
104
return
0;
105
}
106
107
std::vector<SSRecord*>*
108
SSManager::GetSSRecords
(
void
)
const
109
{
110
return
m_ssRecords
;
111
}
112
113
bool
114
SSManager::IsInRecord
(
const
Mac48Address
&macAddress)
const
115
{
116
for
(std::vector<SSRecord*>::iterator iter =
m_ssRecords
->begin (); iter !=
m_ssRecords
->end (); ++iter)
117
{
118
if
((*iter)->GetMacAddress () == macAddress)
119
{
120
return
true
;
121
}
122
}
123
return
false
;
124
}
125
126
bool
127
SSManager::IsRegistered
(
const
Mac48Address
&macAddress)
const
128
{
129
SSRecord
*ssRecord =
GetSSRecord
(macAddress);
130
return
ssRecord != 0 && ssRecord->
GetRangingStatus
() ==
WimaxNetDevice::RANGING_STATUS_SUCCESS
;
131
}
132
133
void
134
SSManager::DeleteSSRecord
(
Cid
cid)
135
{
136
for
(std::vector<SSRecord*>::iterator iter1 =
m_ssRecords
->begin (); iter1 !=
m_ssRecords
->end (); ++iter1)
137
{
138
SSRecord
*ssRecord = *iter1;
139
if
(ssRecord->
GetBasicCid
() == cid || ssRecord->
GetPrimaryCid
() == cid)
140
{
141
m_ssRecords
->erase (iter1);
142
return
;
143
}
144
else
145
{
146
std::vector<ServiceFlow*> sf = ssRecord->
GetServiceFlows
(
ServiceFlow::SF_TYPE_ALL
);
147
for
(std::vector<ServiceFlow*>::const_iterator iter2 = sf.begin (); iter2 != sf.end (); ++iter2)
148
{
149
if
((*iter2)->GetConnection ()->GetCid () == cid)
150
{
151
m_ssRecords
->erase (iter1);
152
return
;
153
}
154
}
155
}
156
}
157
}
158
159
Mac48Address
160
SSManager::GetMacAddress
(
Cid
cid)
const
161
{
162
return
GetSSRecord
(cid)->
GetMacAddress
();
163
}
164
165
uint32_t
166
SSManager::GetNSSs
(
void
)
const
167
{
168
return
m_ssRecords
->size ();
169
}
170
171
uint32_t
172
SSManager::GetNRegisteredSSs
(
void
)
const
173
{
174
uint32_t nrSS = 0;
175
for
(std::vector<SSRecord*>::iterator iter =
m_ssRecords
->begin (); iter !=
m_ssRecords
->end (); ++iter)
176
{
177
if
((*iter)->GetRangingStatus () ==
WimaxNetDevice::RANGING_STATUS_SUCCESS
)
178
{
179
nrSS++;
180
}
181
}
182
return
nrSS;
183
}
184
185
}
// namespace ns3
186
187
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
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
ns3::Cid
Cid class.
Definition:
cid.h:38
ns3::SSManager::DeleteSSRecord
void DeleteSSRecord(Cid cid)
Delete SS record.
Definition:
ss-manager.cc:134
ns3::SSManager::CreateSSRecord
SSRecord * CreateSSRecord(const Mac48Address &macAddress)
Create SS record.
Definition:
ss-manager.cc:58
ns3::SSManager::IsRegistered
bool IsRegistered(const Mac48Address &macAddress) const
Check if address is registered.
Definition:
ss-manager.cc:127
ns3::SSManager::GetNSSs
uint32_t GetNSSs(void) const
Get number of SSs.
Definition:
ss-manager.cc:166
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SSManager::GetMacAddress
Mac48Address GetMacAddress(Cid cid) const
Get MAC address by CID.
Definition:
ss-manager.cc:160
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:44
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:923
ns3::SSRecord::GetPrimaryCid
Cid GetPrimaryCid(void) const
Get primary CID.
Definition:
ss-record.cc:104
ns3::WimaxNetDevice::RANGING_STATUS_SUCCESS
@ RANGING_STATUS_SUCCESS
Definition:
wimax-net-device.h:84
ns3::SSManager::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
ss-manager.cc:34
ns3::SSManager::GetSSRecord
SSRecord * GetSSRecord(const Mac48Address &macAddress) const
Get SS record.
Definition:
ss-manager.cc:66
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:88
ns3::SSRecord
This class is used by the base station to store some information related to subscriber station in the...
Definition:
ss-record.h:44
ns3::SSRecord::GetRangingStatus
WimaxNetDevice::RangingStatus GetRangingStatus(void) const
Get ranging status.
Definition:
ss-record.cc:176
ns3::SSRecord::GetServiceFlows
std::vector< ServiceFlow * > GetServiceFlows(enum ServiceFlow::SchedulingType schedulingType) const
Get service flows.
Definition:
ss-record.cc:229
ns3::SSManager::GetSSRecords
std::vector< SSRecord * > * GetSSRecords(void) const
Get SS records.
Definition:
ss-manager.cc:108
service-flow.h
ns3::SSManager::SSManager
SSManager(void)
Definition:
ss-manager.cc:42
ns3::SSManager::IsInRecord
bool IsInRecord(const Mac48Address &macAddress) const
Check if address is in record.
Definition:
ss-manager.cc:114
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition:
log.h:273
ns3::SSManager::~SSManager
~SSManager(void)
Definition:
ss-manager.cc:47
ns3::SSManager::m_ssRecords
std::vector< SSRecord * > * m_ssRecords
the SS records
Definition:
ss-manager.h:107
ns3::SSRecord::GetMacAddress
Mac48Address GetMacAddress(void) const
Get MAC address.
Definition:
ss-record.cc:116
ss-manager.h
ns3::SSManager::GetNRegisteredSSs
uint32_t GetNRegisteredSSs(void) const
Get number of registered SSs.
Definition:
ss-manager.cc:172
ns3::ServiceFlow::SF_TYPE_ALL
@ SF_TYPE_ALL
Definition:
service-flow.h:66
ns3::SSRecord::GetBasicCid
Cid GetBasicCid(void) const
Get basic CID.
Definition:
ss-record.cc:92
src
wimax
model
ss-manager.cc
Generated on Fri Oct 1 2021 17:03:54 for ns-3 by
1.8.20