A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
simple-ue-component-carrier-manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Danilo Abrignani
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Danilo Abrignani <danilo.abrignani@unibo.it>
18 *
19 */
20
22
23#include <ns3/log.h>
24
25namespace ns3
26{
27
28NS_LOG_COMPONENT_DEFINE("SimpleUeComponentCarrierManager");
29
30NS_OBJECT_ENSURE_REGISTERED(SimpleUeComponentCarrierManager);
31
33// SAP forwarders
35
37// MAC SAP PROVIDER SAP forwarders
39
42{
43 public:
50
51 // inherited from LteMacSapProvider
54
55 private:
57};
58
60 : m_mac(mac)
61{
62}
63
64void
66{
67 m_mac->DoTransmitPdu(params);
68}
69
70void
72{
74}
75
77// MAC SAP USER SAP forwarders
79
82{
83 public:
90
91 // inherited from LteMacSapUser
93 void ReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) override;
94 void NotifyHarqDeliveryFailure() override;
95
96 private:
98};
99
101 : m_mac(mac)
102{
103}
104
105void
107{
108 NS_LOG_INFO("SimpleUeCcmMacSapUser::NotifyTxOpportunity for ccId:"
109 << (uint32_t)txOpParams.componentCarrierId);
110 m_mac->DoNotifyTxOpportunity(txOpParams);
111}
112
113void
115{
116 m_mac->DoReceivePdu(rxPduParams);
117}
118
119void
121{
123}
124
126// SimpleUeComponentCarrierManager methods
128
130{
131 NS_LOG_FUNCTION(this);
135}
136
138{
139 NS_LOG_FUNCTION(this);
140}
141
142void
144{
145 NS_LOG_FUNCTION(this);
146 delete m_ccmRrcSapProvider;
147 delete m_ccmMacSapUser;
148 delete m_ccmMacSapProvider;
149}
150
151TypeId
153{
154 static TypeId tid = TypeId("ns3::SimpleUeComponentCarrierManager")
156 .SetGroupName("Lte")
157 .AddConstructor<SimpleUeComponentCarrierManager>();
158 return tid;
159}
160
163{
164 NS_LOG_FUNCTION(this);
165 return m_ccmMacSapProvider;
166}
167
168void
170{
171 NS_LOG_FUNCTION(this);
173}
174
175void
177{
178 NS_LOG_FUNCTION(this << rnti << (uint16_t)measResults.measId);
179}
180
181void
183{
184 NS_LOG_FUNCTION(this);
185 std::map<uint8_t, LteMacSapProvider*>::iterator it =
186 m_macSapProvidersMap.find(params.componentCarrierId);
188 "could not find Sap for ComponentCarrier "
189 << (uint16_t)params.componentCarrierId);
190 // with this algorithm all traffic is on Primary Carrier, is it?
191 it->second->TransmitPdu(params);
192}
193
194void
197{
198 NS_LOG_FUNCTION(this);
199 NS_LOG_DEBUG("BSR from RLC for LCID = " << (uint16_t)params.lcid);
200 std::map<uint8_t, LteMacSapProvider*>::iterator it = m_macSapProvidersMap.find(0);
201 NS_ABORT_MSG_IF(it == m_macSapProvidersMap.end(), "could not find Sap for ComponentCarrier");
202
203 NS_LOG_DEBUG("Size of component carrier LC map " << m_componentCarrierLcMap.size());
204
205 for (std::map<uint8_t, std::map<uint8_t, LteMacSapProvider*>>::iterator ccLcMapIt =
207 ccLcMapIt != m_componentCarrierLcMap.end();
208 ccLcMapIt++)
209 {
210 NS_LOG_DEBUG("BSR from RLC for CC id = " << (uint16_t)ccLcMapIt->first);
211 std::map<uint8_t, LteMacSapProvider*>::iterator it = ccLcMapIt->second.find(params.lcid);
212 if (it != ccLcMapIt->second.end())
213 {
214 it->second->ReportBufferStatus(params);
215 }
216 }
217}
218
219void
221{
222 NS_LOG_FUNCTION(this);
223}
224
225void
228{
229 NS_LOG_FUNCTION(this);
230 std::map<uint8_t, LteMacSapUser*>::iterator lcidIt = m_lcAttached.find(txOpParams.lcid);
231 NS_ABORT_MSG_IF(lcidIt == m_lcAttached.end(),
232 "could not find LCID" << (uint16_t)txOpParams.lcid);
233 NS_LOG_DEBUG(this << " lcid = " << (uint32_t)txOpParams.lcid
234 << " layer= " << (uint16_t)txOpParams.layer << " componentCarierId "
235 << (uint16_t)txOpParams.componentCarrierId << " rnti " << txOpParams.rnti);
236
237 NS_LOG_DEBUG(this << " MAC is asking component carrier id = "
238 << (uint16_t)txOpParams.componentCarrierId
239 << " with lcid = " << (uint32_t)txOpParams.lcid << " to transmit "
240 << txOpParams.bytes << " bytes");
241 (*lcidIt).second->NotifyTxOpportunity(txOpParams);
242}
243
244void
246{
247 NS_LOG_FUNCTION(this);
248 std::map<uint8_t, LteMacSapUser*>::iterator lcidIt = m_lcAttached.find(rxPduParams.lcid);
249 NS_ABORT_MSG_IF(lcidIt == m_lcAttached.end(),
250 "could not find LCID" << (uint16_t)rxPduParams.lcid);
251 if (lcidIt != m_lcAttached.end())
252 {
253 (*lcidIt).second->ReceivePdu(rxPduParams);
254 }
255}
256
258// Ue CCM RRC SAP PROVIDER SAP forwarders
260std::vector<uint16_t>
262{
263 NS_LOG_FUNCTION(this << " lcId" << lcid);
264 std::vector<uint16_t> res;
265 NS_ABORT_MSG_IF(m_lcAttached.find(lcid) == m_lcAttached.end(), "could not find LCID " << lcid);
266 m_lcAttached.erase(lcid);
267 // send back all the configuration to the componentCarrier where we want to remove the Lc
268 std::map<uint8_t, std::map<uint8_t, LteMacSapProvider*>>::iterator it =
270 while (it != m_componentCarrierLcMap.end())
271 {
272 std::map<uint8_t, LteMacSapProvider*>::iterator lcToRemove = it->second.find(lcid);
273 if (lcToRemove != it->second.end())
274 {
275 res.insert(res.end(), it->first);
276 }
277 it++;
278 }
279 NS_ABORT_MSG_IF(res.empty(),
280 "LCID " << lcid << " not found in the ComponentCarrierManager map");
281
282 return res;
283}
284
285void
287{
288 NS_LOG_FUNCTION(this);
289 // same semantics as LteUeMac::DoRest
290 std::map<uint8_t, LteMacSapUser*>::iterator it = m_lcAttached.begin();
291 while (it != m_lcAttached.end())
292 {
293 // don't delete CCCH
294 if (it->first == 0)
295 {
296 ++it;
297 }
298 else
299 {
300 // note: use of postfix operator preserves validity of iterator
301 m_lcAttached.erase(it++);
302 }
303 }
304}
305
306std::vector<LteUeCcmRrcSapProvider::LcsConfig>
309 LteMacSapUser* msu)
310{
311 NS_LOG_FUNCTION(this);
312 std::vector<LteUeCcmRrcSapProvider::LcsConfig> res;
313 std::map<uint8_t, LteMacSapUser*>::iterator it = m_lcAttached.find(lcId);
314 NS_ABORT_MSG_IF(it != m_lcAttached.end(), "Warning, LCID " << lcId << " already exist");
315 m_lcAttached.insert(std::pair<uint8_t, LteMacSapUser*>(lcId, msu));
317 std::map<uint8_t, std::map<uint8_t, LteMacSapProvider*>>::iterator ccLcMapIt;
318 for (uint8_t ncc = 0; ncc < m_noOfComponentCarriers; ncc++)
319 {
320 elem.componentCarrierId = ncc;
321 elem.lcConfig = lcConfig;
322 elem.msu = m_ccmMacSapUser;
323 res.insert(res.end(), elem);
324
325 ccLcMapIt = m_componentCarrierLcMap.find(ncc);
326 if (ccLcMapIt != m_componentCarrierLcMap.end())
327 {
328 ccLcMapIt->second.insert(
329 std::pair<uint8_t, LteMacSapProvider*>(lcId, m_macSapProvidersMap.at(ncc)));
330 }
331 else
332 {
333 std::map<uint8_t, LteMacSapProvider*> empty;
334 std::pair<std::map<uint8_t, std::map<uint8_t, LteMacSapProvider*>>::iterator, bool>
335 ret = m_componentCarrierLcMap.insert(
336 std::pair<uint8_t, std::map<uint8_t, LteMacSapProvider*>>(ncc, empty));
337 NS_ABORT_MSG_IF(!ret.second,
338 "element already present, ComponentCarrierId already exist");
339 ccLcMapIt = m_componentCarrierLcMap.find(ncc);
340 ccLcMapIt->second.insert(
341 std::pair<uint8_t, LteMacSapProvider*>(lcId, m_macSapProvidersMap.at(ncc)));
342 }
343 }
344
345 return res;
346}
347
350 uint8_t lcid,
352 LteMacSapUser* msu)
353{
354 NS_LOG_FUNCTION(this);
355 std::map<uint8_t, LteMacSapUser*>::iterator it = m_lcAttached.find(lcid);
356 // if the following assert is hit, e.g., in handover scenarios, it means
357 // the DoRest function is not called by UE RRC
358 NS_ABORT_MSG_IF(it != m_lcAttached.end(),
359 "Warning, LCID " << (uint8_t)lcid << " already exist");
360
361 m_lcAttached.insert(std::pair<uint8_t, LteMacSapUser*>(lcid, msu));
362
363 std::map<uint8_t, std::map<uint8_t, LteMacSapProvider*>>::iterator ccLcMapIt;
364 for (uint8_t ncc = 0; ncc < m_noOfComponentCarriers; ncc++)
365 {
366 ccLcMapIt = m_componentCarrierLcMap.find(ncc);
367 if (ccLcMapIt != m_componentCarrierLcMap.end())
368 {
369 ccLcMapIt->second.insert(
370 std::pair<uint8_t, LteMacSapProvider*>(lcid, m_macSapProvidersMap.at(ncc)));
371 }
372 else
373 {
374 std::map<uint8_t, LteMacSapProvider*> empty;
375 std::pair<std::map<uint8_t, std::map<uint8_t, LteMacSapProvider*>>::iterator, bool>
376 ret = m_componentCarrierLcMap.insert(
377 std::pair<uint8_t, std::map<uint8_t, LteMacSapProvider*>>(ncc, empty));
378 NS_ABORT_MSG_IF(!ret.second,
379 "element already present, ComponentCarrierId already existed");
380 ccLcMapIt = m_componentCarrierLcMap.find(ncc);
381 ccLcMapIt->second.insert(
382 std::pair<uint8_t, LteMacSapProvider*>(lcid, m_macSapProvidersMap.at(ncc)));
383 }
384 }
385
386 return m_ccmMacSapUser;
387}
388
389} // end of namespace ns3
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition: lte-mac-sap.h:36
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition: lte-mac-sap.h:96
The abstract base class of a Component Carrier Manager* for UE that operates using the component carr...
LteUeCcmRrcSapProvider * m_ccmRrcSapProvider
Receive API calls from the UE RRC instance.
std::map< uint8_t, LteMacSapUser * > m_lcAttached
Map of pointers to SAP interfaces of the RLC instance of the flows of this UE.
std::map< uint8_t, std::map< uint8_t, LteMacSapProvider * > > m_componentCarrierLcMap
Flow configuration per flow Id of this UE.
std::map< uint8_t, LteMacSapProvider * > m_macSapProvidersMap
Map of pointers to SAP to interfaces of the MAC instance if the flows of this UE.
uint8_t m_noOfComponentCarriers
The number of component carriers that this UE can support.
virtual void DoInitialize()
Initialize() implementation.
Definition: object.cc:360
SimpleUeCcmMacSapProvider(SimpleUeComponentCarrierManager *mac)
Constructor.
void TransmitPdu(LteMacSapProvider::TransmitPduParameters params) override
send an RLC PDU to the MAC for transmission.
SimpleUeComponentCarrierManager * m_mac
the component carrier manager
void ReportBufferStatus(LteMacSapProvider::ReportBufferStatusParameters params) override
Report the RLC buffer status to the MAC.
void NotifyHarqDeliveryFailure() override
Called by the MAC to notify the RLC that an HARQ process related to this RLC instance has failed.
SimpleUeCcmMacSapUser(SimpleUeComponentCarrierManager *mac)
Constructor.
SimpleUeComponentCarrierManager * m_mac
the component carrier manager
void ReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) override
Called by the MAC to notify the RLC of the reception of a new PDU.
void NotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParams) override
Called by the MAC to notify the RLC that the scheduler granted a transmission opportunity to this RLC...
Component carrier manager implementation which simply does nothing.
std::vector< uint16_t > DoRemoveLc(uint8_t lcid)
Remove LC function.
virtual void DoReportBufferStatus(LteMacSapProvider::ReportBufferStatusParameters params)
Report buffer status function.
LteMacSapUser * m_ccmMacSapUser
Interface to the UE RLC instance.
friend class SimpleUeCcmMacSapProvider
allow SimpleUeCcmMacSapProvider class friend access
void DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measResults)
Report Ue Measure function.
friend class SimpleUeCcmMacSapUser
allow SimpleUeCcmMacSapUser class friend access
void DoDispose() override
Destructor implementation.
LteMacSapProvider * GetLteMacSapProvider() override
Returns the MAC sap provider interface that if forwarding calls to the instance of the LteUeComponent...
void DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params)
Transmit PDU function.
void DoNotifyHarqDeliveryFailure()
Notify HARQ deliver failure.
friend class MemberLteUeCcmRrcSapProvider< SimpleUeComponentCarrierManager >
let the forwarder class access the protected and private members
void DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParams)
Notify TX opportunity function.
virtual std::vector< LteUeCcmRrcSapProvider::LcsConfig > DoAddLc(uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser *msu)
Add LC function.
void DoInitialize() override
Initialize() implementation.
SimpleUeComponentCarrierManager()
Creates a No-op CCS algorithm instance.
LteMacSapProvider * m_ccmMacSapProvider
Receive API calls from the UE RLC instance.
void DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams)
Receive PDU function.
virtual LteMacSapUser * DoConfigureSignalBearer(uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser *msu)
Configure signal bearer function.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:936
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Parameters for LteMacSapProvider::ReportBufferStatus.
Definition: lte-mac-sap.h:69
Parameters for LteMacSapProvider::TransmitPdu.
Definition: lte-mac-sap.h:45
Parameters for LteMacSapUser::ReceivePdu.
Definition: lte-mac-sap.h:166
uint8_t lcid
the logical channel id
Definition: lte-mac-sap.h:189
Parameters for LteMacSapUser::NotifyTxOpportunity.
Definition: lte-mac-sap.h:105
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-mac-sap.h:141
uint32_t bytes
the number of bytes to transmit
Definition: lte-mac-sap.h:137
uint8_t componentCarrierId
the component carrier id
Definition: lte-mac-sap.h:140
uint8_t layer
the layer of transmission (MIMO)
Definition: lte-mac-sap.h:138
uint8_t lcid
the logical channel id
Definition: lte-mac-sap.h:142
MeasResults structure.
Definition: lte-rrc-sap.h:717
uint8_t measId
measure ID
Definition: lte-rrc-sap.h:718
uint8_t componentCarrierId
component carrier ID
LteUeCmacSapProvider::LogicalChannelConfig lcConfig
logical channel config