A Discrete-Event Network Simulator
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
19namespace ns3
20{
21
22NS_LOG_COMPONENT_DEFINE("SSManager");
23
25
26TypeId
28{
29 static TypeId tid = TypeId("ns3::SSManager").SetParent<Object>().SetGroupName("Wimax");
30 return tid;
31}
32
34{
35 m_ssRecords = new std::vector<SSRecord*>();
36}
37
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
50{
51 auto ssRecord = new SSRecord(macAddress);
52 m_ssRecords->push_back(ssRecord);
53 return ssRecord;
54}
55
57SSManager::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
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
98std::vector<SSRecord*>*
100{
101 return m_ssRecords;
102}
103
104bool
105SSManager::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
117bool
118SSManager::IsRegistered(const Mac48Address& macAddress) const
119{
120 SSRecord* ssRecord = GetSSRecord(macAddress);
121 return ssRecord != nullptr &&
123}
124
125void
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
153{
154 return GetSSRecord(cid)->GetMacAddress();
155}
156
159{
160 return m_ssRecords->size();
161}
162
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
Cid class.
Definition cid.h:26
an EUI-48 address
A base class which provides memory management and object aggregation.
Definition object.h:78
static TypeId GetTypeId()
Get the type ID.
Definition ss-manager.cc:27
uint32_t GetNRegisteredSSs() const
Get number of registered SSs.
bool IsInRecord(const Mac48Address &macAddress) const
Check if address is in record.
SSRecord * GetSSRecord(const Mac48Address &macAddress) const
Get SS record.
Definition ss-manager.cc:57
std::vector< SSRecord * > * GetSSRecords() const
Get SS records.
Definition ss-manager.cc:99
SSRecord * CreateSSRecord(const Mac48Address &macAddress)
Create SS record.
Definition ss-manager.cc:49
bool IsRegistered(const Mac48Address &macAddress) const
Check if address is registered.
uint32_t GetNSSs() const
Get number of SSs.
void DeleteSSRecord(Cid cid)
Delete SS record.
Mac48Address GetMacAddress(Cid cid) const
Get MAC address by CID.
std::vector< SSRecord * > * m_ssRecords
the SS records
Definition ss-manager.h:98
~SSManager() override
Definition ss-manager.cc:38
This class is used by the base station to store some information related to subscriber station in the...
Definition ss-record.h:35
Cid GetBasicCid() const
Get basic CID.
Definition ss-record.cc:84
WimaxNetDevice::RangingStatus GetRangingStatus() const
Get ranging status.
Definition ss-record.cc:168
std::vector< ServiceFlow * > GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const
Get service flows.
Definition ss-record.cc:222
Mac48Address GetMacAddress() const
Get MAC address.
Definition ss-record.cc:108
Cid GetPrimaryCid() const
Get primary CID.
Definition ss-record.cc:96
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.