A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
ss-manager.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007,2008,2009 INRIA, UDcast
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
7
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
8
* <amine.ismail@UDcast.com>
9
*/
10
11
#include "
ss-manager.h
"
12
13
#include "
service-flow.h
"
14
15
#include "ns3/log.h"
16
17
#include <stdint.h>
18
19
namespace
ns3
20
{
21
22
NS_LOG_COMPONENT_DEFINE
(
"SSManager"
);
23
24
NS_OBJECT_ENSURE_REGISTERED
(SSManager);
25
26
TypeId
27
SSManager::GetTypeId
()
28
{
29
static
TypeId
tid =
TypeId
(
"ns3::SSManager"
).
SetParent
<
Object
>().SetGroupName(
"Wimax"
);
30
return
tid;
31
}
32
33
SSManager::SSManager
()
34
{
35
m_ssRecords
=
new
std::vector<SSRecord*>();
36
}
37
38
SSManager::~SSManager
()
39
{
40
for
(
auto
iter =
m_ssRecords
->begin(); iter !=
m_ssRecords
->end(); ++iter)
41
{
42
delete
*iter;
43
}
44
delete
m_ssRecords
;
45
m_ssRecords
=
nullptr
;
46
}
47
48
SSRecord
*
49
SSManager::CreateSSRecord
(
const
Mac48Address
& macAddress)
50
{
51
auto
ssRecord =
new
SSRecord
(macAddress);
52
m_ssRecords
->push_back(ssRecord);
53
return
ssRecord;
54
}
55
56
SSRecord
*
57
SSManager::GetSSRecord
(
const
Mac48Address
& macAddress)
const
58
{
59
for
(
auto
iter =
m_ssRecords
->begin(); iter !=
m_ssRecords
->end(); ++iter)
60
{
61
if
((*iter)->GetMacAddress() == macAddress)
62
{
63
return
*iter;
64
}
65
}
66
67
NS_LOG_DEBUG
(
"GetSSRecord: SSRecord not found!"
);
68
return
nullptr
;
69
}
70
71
SSRecord
*
72
SSManager::GetSSRecord
(
Cid
cid)
const
73
{
74
for
(
auto
iter1 =
m_ssRecords
->begin(); iter1 !=
m_ssRecords
->end(); ++iter1)
75
{
76
SSRecord
* ssRecord = *iter1;
77
if
(ssRecord->
GetBasicCid
() == cid || ssRecord->
GetPrimaryCid
() == cid)
78
{
79
return
ssRecord;
80
}
81
else
82
{
83
std::vector<ServiceFlow*> sf = ssRecord->
GetServiceFlows
(
ServiceFlow::SF_TYPE_ALL
);
84
for
(
auto
iter2 = sf.begin(); iter2 != sf.end(); ++iter2)
85
{
86
if
((*iter2)->GetConnection()->GetCid() == cid)
87
{
88
return
ssRecord;
89
}
90
}
91
}
92
}
93
94
NS_LOG_DEBUG
(
"GetSSRecord: SSRecord not found!"
);
95
return
nullptr
;
96
}
97
98
std::vector<SSRecord*>*
99
SSManager::GetSSRecords
()
const
100
{
101
return
m_ssRecords
;
102
}
103
104
bool
105
SSManager::IsInRecord
(
const
Mac48Address
& macAddress)
const
106
{
107
for
(
auto
iter =
m_ssRecords
->begin(); iter !=
m_ssRecords
->end(); ++iter)
108
{
109
if
((*iter)->GetMacAddress() == macAddress)
110
{
111
return
true
;
112
}
113
}
114
return
false
;
115
}
116
117
bool
118
SSManager::IsRegistered
(
const
Mac48Address
& macAddress)
const
119
{
120
SSRecord
* ssRecord =
GetSSRecord
(macAddress);
121
return
ssRecord !=
nullptr
&&
122
ssRecord->
GetRangingStatus
() ==
WimaxNetDevice::RANGING_STATUS_SUCCESS
;
123
}
124
125
void
126
SSManager::DeleteSSRecord
(
Cid
cid)
127
{
128
for
(
auto
iter1 =
m_ssRecords
->begin(); iter1 !=
m_ssRecords
->end(); ++iter1)
129
{
130
SSRecord
* ssRecord = *iter1;
131
if
(ssRecord->
GetBasicCid
() == cid || ssRecord->
GetPrimaryCid
() == cid)
132
{
133
m_ssRecords
->erase(iter1);
134
return
;
135
}
136
else
137
{
138
std::vector<ServiceFlow*> sf = ssRecord->
GetServiceFlows
(
ServiceFlow::SF_TYPE_ALL
);
139
for
(
auto
iter2 = sf.begin(); iter2 != sf.end(); ++iter2)
140
{
141
if
((*iter2)->GetConnection()->GetCid() == cid)
142
{
143
m_ssRecords
->erase(iter1);
144
return
;
145
}
146
}
147
}
148
}
149
}
150
151
Mac48Address
152
SSManager::GetMacAddress
(
Cid
cid)
const
153
{
154
return
GetSSRecord
(cid)->
GetMacAddress
();
155
}
156
157
uint32_t
158
SSManager::GetNSSs
()
const
159
{
160
return
m_ssRecords
->size();
161
}
162
163
uint32_t
164
SSManager::GetNRegisteredSSs
()
const
165
{
166
uint32_t
nrSS = 0;
167
for
(
auto
iter =
m_ssRecords
->begin(); iter !=
m_ssRecords
->end(); ++iter)
168
{
169
if
((*iter)->GetRangingStatus() ==
WimaxNetDevice::RANGING_STATUS_SUCCESS
)
170
{
171
nrSS++;
172
}
173
}
174
return
nrSS;
175
}
176
177
}
// namespace ns3
ns3::Cid
Cid class.
Definition
cid.h:26
ns3::Mac48Address
an EUI-48 address
Definition
mac48-address.h:35
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::SSManager::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
ss-manager.cc:27
ns3::SSManager::GetNRegisteredSSs
uint32_t GetNRegisteredSSs() const
Get number of registered SSs.
Definition
ss-manager.cc:164
ns3::SSManager::IsInRecord
bool IsInRecord(const Mac48Address &macAddress) const
Check if address is in record.
Definition
ss-manager.cc:105
ns3::SSManager::GetSSRecord
SSRecord * GetSSRecord(const Mac48Address &macAddress) const
Get SS record.
Definition
ss-manager.cc:57
ns3::SSManager::SSManager
SSManager()
Definition
ss-manager.cc:33
ns3::SSManager::GetSSRecords
std::vector< SSRecord * > * GetSSRecords() const
Get SS records.
Definition
ss-manager.cc:99
ns3::SSManager::CreateSSRecord
SSRecord * CreateSSRecord(const Mac48Address &macAddress)
Create SS record.
Definition
ss-manager.cc:49
ns3::SSManager::IsRegistered
bool IsRegistered(const Mac48Address &macAddress) const
Check if address is registered.
Definition
ss-manager.cc:118
ns3::SSManager::GetNSSs
uint32_t GetNSSs() const
Get number of SSs.
Definition
ss-manager.cc:158
ns3::SSManager::DeleteSSRecord
void DeleteSSRecord(Cid cid)
Delete SS record.
Definition
ss-manager.cc:126
ns3::SSManager::GetMacAddress
Mac48Address GetMacAddress(Cid cid) const
Get MAC address by CID.
Definition
ss-manager.cc:152
ns3::SSManager::m_ssRecords
std::vector< SSRecord * > * m_ssRecords
the SS records
Definition
ss-manager.h:98
ns3::SSManager::~SSManager
~SSManager() override
Definition
ss-manager.cc:38
ns3::SSRecord
This class is used by the base station to store some information related to subscriber station in the...
Definition
ss-record.h:35
ns3::SSRecord::GetBasicCid
Cid GetBasicCid() const
Get basic CID.
Definition
ss-record.cc:84
ns3::SSRecord::GetRangingStatus
WimaxNetDevice::RangingStatus GetRangingStatus() const
Get ranging status.
Definition
ss-record.cc:168
ns3::SSRecord::GetServiceFlows
std::vector< ServiceFlow * > GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const
Get service flows.
Definition
ss-record.cc:222
ns3::SSRecord::GetMacAddress
Mac48Address GetMacAddress() const
Get MAC address.
Definition
ss-record.cc:108
ns3::SSRecord::GetPrimaryCid
Cid GetPrimaryCid() const
Get primary CID.
Definition
ss-record.cc:96
ns3::ServiceFlow::SF_TYPE_ALL
@ SF_TYPE_ALL
Definition
service-flow.h:58
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::WimaxNetDevice::RANGING_STATUS_SUCCESS
@ RANGING_STATUS_SUCCESS
Definition
wimax-net-device.h:75
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition
log.h:257
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
service-flow.h
ss-manager.h
src
wimax
model
ss-manager.cc
Generated on Fri Nov 8 2024 13:59:09 for ns-3 by
1.11.0