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