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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Danilo Abrignani <danilo.abrignani@unibo.it>
7 *
8 */
9
11
12#include <ns3/log.h>
13
14namespace ns3
15{
16
17NS_LOG_COMPONENT_DEFINE("SimpleUeComponentCarrierManager");
18
19NS_OBJECT_ENSURE_REGISTERED(SimpleUeComponentCarrierManager);
20
21///////////////////////////////////////////////////////////
22// SAP forwarders
23///////////////////////////////////////////////////////////
24
25///////////////////////////////////////////////////////////
26// MAC SAP PROVIDER SAP forwarders
27///////////////////////////////////////////////////////////
28
29/// SimpleUeCcmMacSapProvider class
31{
32 public:
33 /**
34 * Constructor
35 *
36 * @param mac the component carrier manager
37 */
39
40 // inherited from LteMacSapProvider
43
44 private:
45 SimpleUeComponentCarrierManager* m_mac; ///< the component carrier manager
46};
47
52
53void
58
59void
64
65///////////////////////////////////////////////////////////
66// MAC SAP USER SAP forwarders
67/////////////// ////////////////////////////////////////////
68
69/// SimpleUeCcmMacSapUser class
71{
72 public:
73 /**
74 * Constructor
75 *
76 * @param mac the component carrier manager
77 */
79
80 // inherited from LteMacSapUser
82 void ReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) override;
83 void NotifyHarqDeliveryFailure() override;
84
85 private:
86 SimpleUeComponentCarrierManager* m_mac; ///< the component carrier manager
87};
88
93
94void
96{
97 NS_LOG_INFO("SimpleUeCcmMacSapUser::NotifyTxOpportunity for ccId:"
98 << (uint32_t)txOpParams.componentCarrierId);
99 m_mac->DoNotifyTxOpportunity(txOpParams);
100}
101
102void
107
108void
113
114//////////////////////////////////////////////////////////
115// SimpleUeComponentCarrierManager methods
116///////////////////////////////////////////////////////////
117
125
130
131void
139
140TypeId
142{
143 static TypeId tid = TypeId("ns3::SimpleUeComponentCarrierManager")
145 .SetGroupName("Lte")
146 .AddConstructor<SimpleUeComponentCarrierManager>();
147 return tid;
148}
149
156
157void
163
164void
166{
167 NS_LOG_FUNCTION(this << rnti << (uint16_t)measResults.measId);
168}
169
170void
172{
173 NS_LOG_FUNCTION(this);
174 auto it = m_macSapProvidersMap.find(params.componentCarrierId);
176 "could not find Sap for ComponentCarrier "
177 << (uint16_t)params.componentCarrierId);
178 // with this algorithm all traffic is on Primary Carrier, is it?
179 it->second->TransmitPdu(params);
180}
181
182void
185{
186 NS_LOG_FUNCTION(this);
187 NS_LOG_DEBUG("BSR from RLC for LCID = " << (uint16_t)params.lcid);
188 auto it = m_macSapProvidersMap.find(0);
189 NS_ABORT_MSG_IF(it == m_macSapProvidersMap.end(), "could not find Sap for ComponentCarrier");
190
191 NS_LOG_DEBUG("Size of component carrier LC map " << m_componentCarrierLcMap.size());
192
193 for (auto ccLcMapIt = m_componentCarrierLcMap.begin();
194 ccLcMapIt != m_componentCarrierLcMap.end();
195 ccLcMapIt++)
196 {
197 NS_LOG_DEBUG("BSR from RLC for CC id = " << (uint16_t)ccLcMapIt->first);
198 auto it = ccLcMapIt->second.find(params.lcid);
199 if (it != ccLcMapIt->second.end())
200 {
201 it->second->ReportBufferStatus(params);
202 }
203 }
204}
205
206void
211
212void
215{
216 NS_LOG_FUNCTION(this);
217 auto lcidIt = m_lcAttached.find(txOpParams.lcid);
218 NS_ABORT_MSG_IF(lcidIt == m_lcAttached.end(),
219 "could not find LCID" << (uint16_t)txOpParams.lcid);
220 NS_LOG_DEBUG(this << " lcid = " << (uint32_t)txOpParams.lcid
221 << " layer= " << (uint16_t)txOpParams.layer << " componentCarrierId "
222 << (uint16_t)txOpParams.componentCarrierId << " rnti " << txOpParams.rnti);
223
224 NS_LOG_DEBUG(this << " MAC is asking component carrier id = "
225 << (uint16_t)txOpParams.componentCarrierId
226 << " with lcid = " << (uint32_t)txOpParams.lcid << " to transmit "
227 << txOpParams.bytes << " bytes");
228 (*lcidIt).second->NotifyTxOpportunity(txOpParams);
229}
230
231void
233{
234 NS_LOG_FUNCTION(this);
235 auto lcidIt = m_lcAttached.find(rxPduParams.lcid);
236 NS_ABORT_MSG_IF(lcidIt == m_lcAttached.end(),
237 "could not find LCID" << (uint16_t)rxPduParams.lcid);
238 if (lcidIt != m_lcAttached.end())
239 {
240 (*lcidIt).second->ReceivePdu(rxPduParams);
241 }
242}
243
244///////////////////////////////////////////////////////////
245// Ue CCM RRC SAP PROVIDER SAP forwarders
246///////////////////////////////////////////////////////////
247std::vector<uint16_t>
249{
250 NS_LOG_FUNCTION(this << " lcId" << lcid);
251 std::vector<uint16_t> res;
252 NS_ABORT_MSG_IF(m_lcAttached.find(lcid) == m_lcAttached.end(), "could not find LCID " << lcid);
253 m_lcAttached.erase(lcid);
254 // send back all the configuration to the componentCarrier where we want to remove the Lc
255 auto it = m_componentCarrierLcMap.begin();
256 while (it != m_componentCarrierLcMap.end())
257 {
258 auto lcToRemove = it->second.find(lcid);
259 if (lcToRemove != it->second.end())
260 {
261 res.insert(res.end(), it->first);
262 }
263 it++;
264 }
265 NS_ABORT_MSG_IF(res.empty(),
266 "LCID " << lcid << " not found in the ComponentCarrierManager map");
267
268 return res;
269}
270
271void
273{
274 NS_LOG_FUNCTION(this);
275 // same semantics as LteUeMac::DoRest
276 auto it = m_lcAttached.begin();
277 while (it != m_lcAttached.end())
278 {
279 // don't delete CCCH
280 if (it->first == 0)
281 {
282 ++it;
283 }
284 else
285 {
286 // note: use of postfix operator preserves validity of iterator
287 m_lcAttached.erase(it++);
288 }
289 }
290}
291
292std::vector<LteUeCcmRrcSapProvider::LcsConfig>
295 LteMacSapUser* msu)
296{
297 NS_LOG_FUNCTION(this);
298 std::vector<LteUeCcmRrcSapProvider::LcsConfig> res;
299 auto it = m_lcAttached.find(lcId);
300 NS_ABORT_MSG_IF(it != m_lcAttached.end(), "Warning, LCID " << lcId << " already exist");
301 m_lcAttached.insert(std::pair<uint8_t, LteMacSapUser*>(lcId, msu));
303 for (uint8_t ncc = 0; ncc < m_noOfComponentCarriers; ncc++)
304 {
305 elem.componentCarrierId = ncc;
306 elem.lcConfig = lcConfig;
307 elem.msu = m_ccmMacSapUser;
308 res.insert(res.end(), elem);
309
310 auto ccLcMapIt = m_componentCarrierLcMap.find(ncc);
311 if (ccLcMapIt != m_componentCarrierLcMap.end())
312 {
313 ccLcMapIt->second.insert(
314 std::pair<uint8_t, LteMacSapProvider*>(lcId, m_macSapProvidersMap.at(ncc)));
315 }
316 else
317 {
318 std::map<uint8_t, LteMacSapProvider*> empty;
319 auto ret = m_componentCarrierLcMap.insert(
320 std::pair<uint8_t, std::map<uint8_t, LteMacSapProvider*>>(ncc, empty));
321 NS_ABORT_MSG_IF(!ret.second,
322 "element already present, ComponentCarrierId already exist");
323 ccLcMapIt = m_componentCarrierLcMap.find(ncc);
324 ccLcMapIt->second.insert(
325 std::pair<uint8_t, LteMacSapProvider*>(lcId, m_macSapProvidersMap.at(ncc)));
326 }
327 }
328
329 return res;
330}
331
334 uint8_t lcid,
336 LteMacSapUser* msu)
337{
338 NS_LOG_FUNCTION(this);
339 auto it = m_lcAttached.find(lcid);
340 // if the following assert is hit, e.g., in handover scenarios, it means
341 // the DoRest function is not called by UE RRC
342 NS_ABORT_MSG_IF(it != m_lcAttached.end(),
343 "Warning, LCID " << (uint8_t)lcid << " already exist");
344
345 m_lcAttached.insert(std::pair<uint8_t, LteMacSapUser*>(lcid, msu));
346
347 for (uint8_t ncc = 0; ncc < m_noOfComponentCarriers; ncc++)
348 {
349 auto ccLcMapIt = m_componentCarrierLcMap.find(ncc);
350 if (ccLcMapIt != m_componentCarrierLcMap.end())
351 {
352 ccLcMapIt->second.insert(
353 std::pair<uint8_t, LteMacSapProvider*>(lcid, m_macSapProvidersMap.at(ncc)));
354 }
355 else
356 {
357 std::map<uint8_t, LteMacSapProvider*> empty;
358 auto ret = m_componentCarrierLcMap.insert(
359 std::pair<uint8_t, std::map<uint8_t, LteMacSapProvider*>>(ncc, empty));
360 NS_ABORT_MSG_IF(!ret.second,
361 "element already present, ComponentCarrierId already existed");
362 ccLcMapIt = m_componentCarrierLcMap.find(ncc);
363 ccLcMapIt->second.insert(
364 std::pair<uint8_t, LteMacSapProvider*>(lcid, m_macSapProvidersMap.at(ncc)));
365 }
366 }
367
368 return m_ccmMacSapUser;
369}
370
371} // 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:25
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition lte-mac-sap.h:85
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:440
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:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:97
#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_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:264
#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.
Parameters for LteMacSapProvider::ReportBufferStatus.
Definition lte-mac-sap.h:58
Parameters for LteMacSapProvider::TransmitPdu.
Definition lte-mac-sap.h:34
Parameters for LteMacSapUser::ReceivePdu.
uint8_t lcid
the logical channel id
Parameters for LteMacSapUser::NotifyTxOpportunity.
Definition lte-mac-sap.h:94
uint16_t rnti
the C-RNTI identifying the UE
uint32_t bytes
the number of bytes to transmit
uint8_t componentCarrierId
the component carrier id
uint8_t layer
the layer of transmission (MIMO)
uint8_t lcid
the logical channel id
MeasResults structure.
uint8_t measId
measure ID
uint8_t componentCarrierId
component carrier ID
LteUeCmacSapProvider::LogicalChannelConfig lcConfig
logical channel config