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 #include <ns3/lte-ue-mac.h>
25 
26 namespace ns3
27 {
28 
29 NS_LOG_COMPONENT_DEFINE("SimpleUeComponentCarrierManager");
30 
31 NS_OBJECT_ENSURE_REGISTERED(SimpleUeComponentCarrierManager);
32 
34 // SAP forwarders
36 
38 // MAC SAP PROVIDER SAP forwarders
40 
43 {
44  public:
51 
52  // inherited from LteMacSapProvider
55 
56  private:
58 };
59 
61  : m_mac(mac)
62 {
63 }
64 
65 void
67 {
69 }
70 
71 void
73 {
75 }
76 
78 // MAC SAP USER SAP forwarders
80 
83 {
84  public:
91 
92  // inherited from LteMacSapUser
94  void ReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) override;
95  void NotifyHarqDeliveryFailure() override;
96 
97  private:
99 };
100 
102  : m_mac(mac)
103 {
104 }
105 
106 void
108 {
109  NS_LOG_INFO("SimpleUeCcmMacSapUser::NotifyTxOpportunity for ccId:"
110  << (uint32_t)txOpParams.componentCarrierId);
111  m_mac->DoNotifyTxOpportunity(txOpParams);
112 }
113 
114 void
116 {
117  m_mac->DoReceivePdu(rxPduParams);
118 }
119 
120 void
122 {
124 }
125 
127 // SimpleUeComponentCarrierManager methods
129 
131 {
132  NS_LOG_FUNCTION(this);
136 }
137 
139 {
140  NS_LOG_FUNCTION(this);
141 }
142 
143 void
145 {
146  NS_LOG_FUNCTION(this);
147  delete m_ccmRrcSapProvider;
148  delete m_ccmMacSapUser;
149  delete m_ccmMacSapProvider;
150 }
151 
152 TypeId
154 {
155  static TypeId tid = TypeId("ns3::SimpleUeComponentCarrierManager")
157  .SetGroupName("Lte")
158  .AddConstructor<SimpleUeComponentCarrierManager>();
159  return tid;
160 }
161 
164 {
165  NS_LOG_FUNCTION(this);
166  return m_ccmMacSapProvider;
167 }
168 
169 void
171 {
172  NS_LOG_FUNCTION(this);
174 }
175 
176 void
178 {
179  NS_LOG_FUNCTION(this << rnti << (uint16_t)measResults.measId);
180 }
181 
182 void
184 {
185  NS_LOG_FUNCTION(this);
186  std::map<uint8_t, LteMacSapProvider*>::iterator it =
187  m_macSapProvidersMap.find(params.componentCarrierId);
189  "could not find Sap for ComponentCarrier "
190  << (uint16_t)params.componentCarrierId);
191  // with this algorithm all traffic is on Primary Carrier, is it?
192  it->second->TransmitPdu(params);
193 }
194 
195 void
198 {
199  NS_LOG_FUNCTION(this);
200  NS_LOG_DEBUG("BSR from RLC for LCID = " << (uint16_t)params.lcid);
201  std::map<uint8_t, LteMacSapProvider*>::iterator it = m_macSapProvidersMap.find(0);
202  NS_ABORT_MSG_IF(it == m_macSapProvidersMap.end(), "could not find Sap for ComponentCarrier");
203 
204  NS_LOG_DEBUG("Size of component carrier LC map " << m_componentCarrierLcMap.size());
205 
206  for (std::map<uint8_t, std::map<uint8_t, LteMacSapProvider*>>::iterator ccLcMapIt =
207  m_componentCarrierLcMap.begin();
208  ccLcMapIt != m_componentCarrierLcMap.end();
209  ccLcMapIt++)
210  {
211  NS_LOG_DEBUG("BSR from RLC for CC id = " << (uint16_t)ccLcMapIt->first);
212  std::map<uint8_t, LteMacSapProvider*>::iterator it = ccLcMapIt->second.find(params.lcid);
213  if (it != ccLcMapIt->second.end())
214  {
215  it->second->ReportBufferStatus(params);
216  }
217  }
218 }
219 
220 void
222 {
223  NS_LOG_FUNCTION(this);
224 }
225 
226 void
229 {
230  NS_LOG_FUNCTION(this);
231  std::map<uint8_t, LteMacSapUser*>::iterator lcidIt = m_lcAttached.find(txOpParams.lcid);
232  NS_ABORT_MSG_IF(lcidIt == m_lcAttached.end(),
233  "could not find LCID" << (uint16_t)txOpParams.lcid);
234  NS_LOG_DEBUG(this << " lcid = " << (uint32_t)txOpParams.lcid
235  << " layer= " << (uint16_t)txOpParams.layer << " componentCarierId "
236  << (uint16_t)txOpParams.componentCarrierId << " rnti " << txOpParams.rnti);
237 
238  NS_LOG_DEBUG(this << " MAC is asking component carrier id = "
239  << (uint16_t)txOpParams.componentCarrierId
240  << " with lcid = " << (uint32_t)txOpParams.lcid << " to transmit "
241  << txOpParams.bytes << " bytes");
242  (*lcidIt).second->NotifyTxOpportunity(txOpParams);
243 }
244 
245 void
247 {
248  NS_LOG_FUNCTION(this);
249  std::map<uint8_t, LteMacSapUser*>::iterator lcidIt = m_lcAttached.find(rxPduParams.lcid);
250  NS_ABORT_MSG_IF(lcidIt == m_lcAttached.end(),
251  "could not find LCID" << (uint16_t)rxPduParams.lcid);
252  if (lcidIt != m_lcAttached.end())
253  {
254  (*lcidIt).second->ReceivePdu(rxPduParams);
255  }
256 }
257 
259 // Ue CCM RRC SAP PROVIDER SAP forwarders
261 std::vector<uint16_t>
263 {
264  NS_LOG_FUNCTION(this << " lcId" << lcid);
265  std::vector<uint16_t> res;
266  NS_ABORT_MSG_IF(m_lcAttached.find(lcid) == m_lcAttached.end(), "could not find LCID " << lcid);
267  m_lcAttached.erase(lcid);
268  // send back all the configuration to the componentCarrier where we want to remove the Lc
269  std::map<uint8_t, std::map<uint8_t, LteMacSapProvider*>>::iterator it =
270  m_componentCarrierLcMap.begin();
271  while (it != m_componentCarrierLcMap.end())
272  {
273  std::map<uint8_t, LteMacSapProvider*>::iterator lcToRemove = it->second.find(lcid);
274  if (lcToRemove != it->second.end())
275  {
276  res.insert(res.end(), it->first);
277  }
278  it++;
279  }
280  NS_ABORT_MSG_IF(res.empty(),
281  "LCID " << lcid << " not found in the ComponentCarrierManager map");
282 
283  return res;
284 }
285 
286 void
288 {
289  NS_LOG_FUNCTION(this);
290  // same semantics as LteUeMac::DoRest
291  std::map<uint8_t, LteMacSapUser*>::iterator it = m_lcAttached.begin();
292  while (it != m_lcAttached.end())
293  {
294  // don't delete CCCH
295  if (it->first == 0)
296  {
297  ++it;
298  }
299  else
300  {
301  // note: use of postfix operator preserves validity of iterator
302  m_lcAttached.erase(it++);
303  }
304  }
305 }
306 
307 std::vector<LteUeCcmRrcSapProvider::LcsConfig>
310  LteMacSapUser* msu)
311 {
312  NS_LOG_FUNCTION(this);
313  std::vector<LteUeCcmRrcSapProvider::LcsConfig> res;
314  std::map<uint8_t, LteMacSapUser*>::iterator it = m_lcAttached.find(lcId);
315  NS_ABORT_MSG_IF(it != m_lcAttached.end(), "Warning, LCID " << lcId << " already exist");
316  m_lcAttached.insert(std::pair<uint8_t, LteMacSapUser*>(lcId, msu));
318  std::map<uint8_t, std::map<uint8_t, LteMacSapProvider*>>::iterator ccLcMapIt;
319  for (uint8_t ncc = 0; ncc < m_noOfComponentCarriers; ncc++)
320  {
321  elem.componentCarrierId = ncc;
322  elem.lcConfig = lcConfig;
323  elem.msu = m_ccmMacSapUser;
324  res.insert(res.end(), elem);
325 
326  ccLcMapIt = m_componentCarrierLcMap.find(ncc);
327  if (ccLcMapIt != m_componentCarrierLcMap.end())
328  {
329  ccLcMapIt->second.insert(
330  std::pair<uint8_t, LteMacSapProvider*>(lcId, m_macSapProvidersMap.at(ncc)));
331  }
332  else
333  {
334  std::map<uint8_t, LteMacSapProvider*> empty;
335  std::pair<std::map<uint8_t, std::map<uint8_t, LteMacSapProvider*>>::iterator, bool>
336  ret = m_componentCarrierLcMap.insert(
337  std::pair<uint8_t, std::map<uint8_t, LteMacSapProvider*>>(ncc, empty));
338  NS_ABORT_MSG_IF(!ret.second,
339  "element already present, ComponentCarrierId already exist");
340  ccLcMapIt = m_componentCarrierLcMap.find(ncc);
341  ccLcMapIt->second.insert(
342  std::pair<uint8_t, LteMacSapProvider*>(lcId, m_macSapProvidersMap.at(ncc)));
343  }
344  }
345 
346  return res;
347 }
348 
351  uint8_t lcid,
353  LteMacSapUser* msu)
354 {
355  NS_LOG_FUNCTION(this);
356  std::map<uint8_t, LteMacSapUser*>::iterator it = m_lcAttached.find(lcid);
357  // if the following assert is hit, e.g., in handover scenarios, it means
358  // the DoRest function is not called by UE RRC
359  NS_ABORT_MSG_IF(it != m_lcAttached.end(),
360  "Warning, LCID " << (uint8_t)lcid << " already exist");
361 
362  m_lcAttached.insert(std::pair<uint8_t, LteMacSapUser*>(lcid, msu));
363 
364  std::map<uint8_t, std::map<uint8_t, LteMacSapProvider*>>::iterator ccLcMapIt;
365  for (uint8_t ncc = 0; ncc < m_noOfComponentCarriers; ncc++)
366  {
367  ccLcMapIt = m_componentCarrierLcMap.find(ncc);
368  if (ccLcMapIt != m_componentCarrierLcMap.end())
369  {
370  ccLcMapIt->second.insert(
371  std::pair<uint8_t, LteMacSapProvider*>(lcid, m_macSapProvidersMap.at(ncc)));
372  }
373  else
374  {
375  std::map<uint8_t, LteMacSapProvider*> empty;
376  std::pair<std::map<uint8_t, std::map<uint8_t, LteMacSapProvider*>>::iterator, bool>
377  ret = m_componentCarrierLcMap.insert(
378  std::pair<uint8_t, std::map<uint8_t, LteMacSapProvider*>>(ncc, empty));
379  NS_ABORT_MSG_IF(!ret.second,
380  "element already present, ComponentCarrierId already existed");
381  ccLcMapIt = m_componentCarrierLcMap.find(ncc);
382  ccLcMapIt->second.insert(
383  std::pair<uint8_t, LteMacSapProvider*>(lcid, m_macSapProvidersMap.at(ncc)));
384  }
385  }
386 
387  return m_ccmMacSapUser;
388 }
389 
390 } // 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:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
#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:85
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