A Discrete-Event Network Simulator
API
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 
25 namespace ns3
26 {
27 
28 NS_LOG_COMPONENT_DEFINE("SimpleUeComponentCarrierManager");
29 
30 NS_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 
64 void
66 {
68 }
69 
70 void
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 
105 void
107 {
108  NS_LOG_INFO("SimpleUeCcmMacSapUser::NotifyTxOpportunity for ccId:"
109  << (uint32_t)txOpParams.componentCarrierId);
110  m_mac->DoNotifyTxOpportunity(txOpParams);
111 }
112 
113 void
115 {
116  m_mac->DoReceivePdu(rxPduParams);
117 }
118 
119 void
121 {
123 }
124 
126 // SimpleUeComponentCarrierManager methods
128 
130 {
131  NS_LOG_FUNCTION(this);
135 }
136 
138 {
139  NS_LOG_FUNCTION(this);
140 }
141 
142 void
144 {
145  NS_LOG_FUNCTION(this);
146  delete m_ccmRrcSapProvider;
147  delete m_ccmMacSapUser;
148  delete m_ccmMacSapProvider;
149 }
150 
151 TypeId
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 
168 void
170 {
171  NS_LOG_FUNCTION(this);
173 }
174 
175 void
177 {
178  NS_LOG_FUNCTION(this << rnti << (uint16_t)measResults.measId);
179 }
180 
181 void
183 {
184  NS_LOG_FUNCTION(this);
185  auto it = m_macSapProvidersMap.find(params.componentCarrierId);
187  "could not find Sap for ComponentCarrier "
188  << (uint16_t)params.componentCarrierId);
189  // with this algorithm all traffic is on Primary Carrier, is it?
190  it->second->TransmitPdu(params);
191 }
192 
193 void
196 {
197  NS_LOG_FUNCTION(this);
198  NS_LOG_DEBUG("BSR from RLC for LCID = " << (uint16_t)params.lcid);
199  auto it = m_macSapProvidersMap.find(0);
200  NS_ABORT_MSG_IF(it == m_macSapProvidersMap.end(), "could not find Sap for ComponentCarrier");
201 
202  NS_LOG_DEBUG("Size of component carrier LC map " << m_componentCarrierLcMap.size());
203 
204  for (auto ccLcMapIt = m_componentCarrierLcMap.begin();
205  ccLcMapIt != m_componentCarrierLcMap.end();
206  ccLcMapIt++)
207  {
208  NS_LOG_DEBUG("BSR from RLC for CC id = " << (uint16_t)ccLcMapIt->first);
209  auto it = ccLcMapIt->second.find(params.lcid);
210  if (it != ccLcMapIt->second.end())
211  {
212  it->second->ReportBufferStatus(params);
213  }
214  }
215 }
216 
217 void
219 {
220  NS_LOG_FUNCTION(this);
221 }
222 
223 void
226 {
227  NS_LOG_FUNCTION(this);
228  auto lcidIt = m_lcAttached.find(txOpParams.lcid);
229  NS_ABORT_MSG_IF(lcidIt == m_lcAttached.end(),
230  "could not find LCID" << (uint16_t)txOpParams.lcid);
231  NS_LOG_DEBUG(this << " lcid = " << (uint32_t)txOpParams.lcid
232  << " layer= " << (uint16_t)txOpParams.layer << " componentCarrierId "
233  << (uint16_t)txOpParams.componentCarrierId << " rnti " << txOpParams.rnti);
234 
235  NS_LOG_DEBUG(this << " MAC is asking component carrier id = "
236  << (uint16_t)txOpParams.componentCarrierId
237  << " with lcid = " << (uint32_t)txOpParams.lcid << " to transmit "
238  << txOpParams.bytes << " bytes");
239  (*lcidIt).second->NotifyTxOpportunity(txOpParams);
240 }
241 
242 void
244 {
245  NS_LOG_FUNCTION(this);
246  auto lcidIt = m_lcAttached.find(rxPduParams.lcid);
247  NS_ABORT_MSG_IF(lcidIt == m_lcAttached.end(),
248  "could not find LCID" << (uint16_t)rxPduParams.lcid);
249  if (lcidIt != m_lcAttached.end())
250  {
251  (*lcidIt).second->ReceivePdu(rxPduParams);
252  }
253 }
254 
256 // Ue CCM RRC SAP PROVIDER SAP forwarders
258 std::vector<uint16_t>
260 {
261  NS_LOG_FUNCTION(this << " lcId" << lcid);
262  std::vector<uint16_t> res;
263  NS_ABORT_MSG_IF(m_lcAttached.find(lcid) == m_lcAttached.end(), "could not find LCID " << lcid);
264  m_lcAttached.erase(lcid);
265  // send back all the configuration to the componentCarrier where we want to remove the Lc
266  auto it = m_componentCarrierLcMap.begin();
267  while (it != m_componentCarrierLcMap.end())
268  {
269  auto lcToRemove = it->second.find(lcid);
270  if (lcToRemove != it->second.end())
271  {
272  res.insert(res.end(), it->first);
273  }
274  it++;
275  }
276  NS_ABORT_MSG_IF(res.empty(),
277  "LCID " << lcid << " not found in the ComponentCarrierManager map");
278 
279  return res;
280 }
281 
282 void
284 {
285  NS_LOG_FUNCTION(this);
286  // same semantics as LteUeMac::DoRest
287  auto it = m_lcAttached.begin();
288  while (it != m_lcAttached.end())
289  {
290  // don't delete CCCH
291  if (it->first == 0)
292  {
293  ++it;
294  }
295  else
296  {
297  // note: use of postfix operator preserves validity of iterator
298  m_lcAttached.erase(it++);
299  }
300  }
301 }
302 
303 std::vector<LteUeCcmRrcSapProvider::LcsConfig>
306  LteMacSapUser* msu)
307 {
308  NS_LOG_FUNCTION(this);
309  std::vector<LteUeCcmRrcSapProvider::LcsConfig> res;
310  auto it = m_lcAttached.find(lcId);
311  NS_ABORT_MSG_IF(it != m_lcAttached.end(), "Warning, LCID " << lcId << " already exist");
312  m_lcAttached.insert(std::pair<uint8_t, LteMacSapUser*>(lcId, msu));
314  for (uint8_t ncc = 0; ncc < m_noOfComponentCarriers; ncc++)
315  {
316  elem.componentCarrierId = ncc;
317  elem.lcConfig = lcConfig;
318  elem.msu = m_ccmMacSapUser;
319  res.insert(res.end(), elem);
320 
321  auto ccLcMapIt = m_componentCarrierLcMap.find(ncc);
322  if (ccLcMapIt != m_componentCarrierLcMap.end())
323  {
324  ccLcMapIt->second.insert(
325  std::pair<uint8_t, LteMacSapProvider*>(lcId, m_macSapProvidersMap.at(ncc)));
326  }
327  else
328  {
329  std::map<uint8_t, LteMacSapProvider*> empty;
330  auto ret = m_componentCarrierLcMap.insert(
331  std::pair<uint8_t, std::map<uint8_t, LteMacSapProvider*>>(ncc, empty));
332  NS_ABORT_MSG_IF(!ret.second,
333  "element already present, ComponentCarrierId already exist");
334  ccLcMapIt = m_componentCarrierLcMap.find(ncc);
335  ccLcMapIt->second.insert(
336  std::pair<uint8_t, LteMacSapProvider*>(lcId, m_macSapProvidersMap.at(ncc)));
337  }
338  }
339 
340  return res;
341 }
342 
345  uint8_t lcid,
347  LteMacSapUser* msu)
348 {
349  NS_LOG_FUNCTION(this);
350  auto it = m_lcAttached.find(lcid);
351  // if the following assert is hit, e.g., in handover scenarios, it means
352  // the DoRest function is not called by UE RRC
353  NS_ABORT_MSG_IF(it != m_lcAttached.end(),
354  "Warning, LCID " << (uint8_t)lcid << " already exist");
355 
356  m_lcAttached.insert(std::pair<uint8_t, LteMacSapUser*>(lcid, msu));
357 
358  for (uint8_t ncc = 0; ncc < m_noOfComponentCarriers; ncc++)
359  {
360  auto ccLcMapIt = m_componentCarrierLcMap.find(ncc);
361  if (ccLcMapIt != m_componentCarrierLcMap.end())
362  {
363  ccLcMapIt->second.insert(
364  std::pair<uint8_t, LteMacSapProvider*>(lcid, m_macSapProvidersMap.at(ncc)));
365  }
366  else
367  {
368  std::map<uint8_t, LteMacSapProvider*> empty;
369  auto ret = m_componentCarrierLcMap.insert(
370  std::pair<uint8_t, std::map<uint8_t, LteMacSapProvider*>>(ncc, empty));
371  NS_ABORT_MSG_IF(!ret.second,
372  "element already present, ComponentCarrierId already existed");
373  ccLcMapIt = m_componentCarrierLcMap.find(ncc);
374  ccLcMapIt->second.insert(
375  std::pair<uint8_t, LteMacSapProvider*>(lcid, m_macSapProvidersMap.at(ncc)));
376  }
377  }
378 
379  return m_ccmMacSapUser;
380 }
381 
382 } // 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:359
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:931
#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.
mac
Definition: third.py:92
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
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