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
93  virtual void NotifyTxOpportunity (uint32_t bytes, uint8_t layer, uint8_t harqId, uint8_t componentCarrierId, uint16_t rnti, uint8_t lcid);
94  virtual void ReceivePdu (Ptr<Packet> p, uint16_t rnti, uint8_t lcid);
95  virtual void NotifyHarqDeliveryFailure ();
96 
97 
98 private:
100 };
101 
103  : m_mac (mac)
104 {
105 }
106 
107 void
108 SimpleUeCcmMacSapUser::NotifyTxOpportunity (uint32_t bytes, uint8_t layer, uint8_t harqId, uint8_t componentCarrierId, uint16_t rnti, uint8_t lcid)
109 {
110  NS_LOG_INFO ("SimpleUeCcmMacSapUser::NotifyTxOpportunity for ccId:"<<(uint32_t)componentCarrierId);
111  m_mac->DoNotifyTxOpportunity (bytes, layer, harqId, componentCarrierId, rnti, lcid);
112 }
113 
114 
115 void
116 SimpleUeCcmMacSapUser::ReceivePdu (Ptr<Packet> p, uint16_t rnti, uint8_t lcid)
117 {
118  m_mac->DoReceivePdu (p, rnti, lcid);
119 }
120 
121 void
123 {
125 }
126 
128 // SimpleUeComponentCarrierManager methods
130 
132 : m_ccmRrcSapUser (0)
133 {
134  NS_LOG_FUNCTION (this);
139 }
140 
141 
143 {
144  NS_LOG_FUNCTION (this);
145 
146 }
147 
148 
149 void
151 {
152  NS_LOG_FUNCTION (this);
153  delete m_ccmMacSapUser;
154  delete m_ccmMacSapProvider;
155  delete m_ccmRrcSapProvider;
156 }
157 
158 
159 TypeId
161 {
162  static TypeId tid = TypeId ("ns3::SimpleUeComponentCarrierManager")
164  .SetGroupName("Lte")
165  .AddConstructor<SimpleUeComponentCarrierManager> ()
166  ;
167  return tid;
168 }
169 
172 {
173  NS_LOG_FUNCTION (this);
174  return m_ccmMacSapProvider;
175 }
176 
177 void
179 {
180  NS_LOG_FUNCTION (this << s);
181  m_ccmRrcSapUser = s;
182 }
183 
184 
187 {
188  NS_LOG_FUNCTION (this);
189  return m_ccmRrcSapProvider;
190 }
191 
192 
193 void
195 {
196  NS_LOG_FUNCTION (this);
198 }
199 
200 
201 void
203  LteRrcSap::MeasResults measResults)
204 {
205  NS_LOG_FUNCTION (this << rnti << (uint16_t) measResults.measId);
206 }
207 
208 
209 void
211 {
212  NS_LOG_FUNCTION (this);
213  std::map <uint8_t, LteMacSapProvider*>::iterator it = m_macSapProvidersMap.find (params.componentCarrierId);
214  NS_ASSERT_MSG (it != m_macSapProvidersMap.end (), "could not find Sap for ComponentCarrier " << (uint16_t) params.componentCarrierId);
215  // with this algorithm all traffic is on Primary Carrier
216  it->second->TransmitPdu (params);
217 }
218 
219 void
221 {
222  NS_LOG_FUNCTION (this);
223  std::map <uint8_t, LteMacSapProvider*>::iterator it = m_macSapProvidersMap.find (0);
224  NS_ASSERT_MSG (it != m_macSapProvidersMap.end (), "could not find Sap for ComponentCarrier ");
225  it->second->ReportBufferStatus (params);
226 }
227 
228 void
230 {
231  NS_LOG_FUNCTION (this);
232 }
233 
234 
235 void
236 SimpleUeComponentCarrierManager::DoNotifyTxOpportunity (uint32_t bytes, uint8_t layer, uint8_t harqId, uint8_t componentCarrierId, uint16_t rnti, uint8_t lcid)
237 {
238  NS_LOG_FUNCTION (this);
239  std::map<uint8_t, LteMacSapUser*>::iterator lcidIt = m_lcAttached.find (lcid);
240  NS_ASSERT_MSG (lcidIt != m_lcAttached.end (), "could not find LCID" << lcid);
241  NS_LOG_DEBUG (this << " lcid= " << (uint32_t) lcid << " layer= " << (uint16_t) layer << " componentCarierId " << (uint16_t) componentCarrierId << " rnti " << rnti);
242  (*lcidIt).second->NotifyTxOpportunity (bytes, layer, harqId, componentCarrierId, rnti, lcid);
243 }
244 void
246 {
247  NS_LOG_FUNCTION (this);
248  std::map<uint8_t, LteMacSapUser*>::iterator lcidIt = m_lcAttached.find (lcid);
249  if (lcidIt != m_lcAttached.end ())
250  {
251  (*lcidIt).second->ReceivePdu (p, rnti, lcid);
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_ASSERT_MSG (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  std::map<uint8_t, std::map<uint8_t, LteMacSapProvider*> >::iterator it = m_componentCarrierLcMap.begin ();
267  while (it != m_componentCarrierLcMap.end ())
268  {
269  std::map<uint8_t, LteMacSapProvider*>::iterator 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_ASSERT_MSG (res.size () != 0, "Not found in the ComponentCarrierManager maps the LCID " << lcid);
277 
278  return res;
279 
280 }
281 
282 std::vector<LteUeCcmRrcSapProvider::LcsConfig>
284 {
285  NS_LOG_FUNCTION (this);
286  std::vector<LteUeCcmRrcSapProvider::LcsConfig> res;
287  std::map<uint8_t, LteMacSapUser*>::iterator it = m_lcAttached.find (lcId);
288  NS_ASSERT_MSG (it == m_lcAttached.end (), "Warning, LCID " << lcId << " already exist");
289  m_lcAttached.insert (std::pair<uint8_t, LteMacSapUser*> (lcId, msu));
291  std::map <uint8_t, std::map<uint8_t, LteMacSapProvider*> >::iterator ccLcMapIt;
292  for (uint8_t ncc = 0; ncc < m_noOfComponentCarriersEnabled; ncc++)
293  {
294  elem.componentCarrierId = ncc;
295  elem.lcConfig = &lcConfig;
296  elem.msu = m_ccmMacSapUser;
297  res.insert (res.end (), elem);
298 
299  ccLcMapIt = m_componentCarrierLcMap.find (ncc);
300  if (ccLcMapIt != m_componentCarrierLcMap.end ())
301  {
302  ccLcMapIt->second.insert (std::pair <uint8_t, LteMacSapProvider*> (lcId, m_macSapProvidersMap.at (ncc)));
303  }
304  else
305  {
306  std::map<uint8_t, LteMacSapProvider*> empty;
307  std::pair <std::map <uint8_t, std::map<uint8_t, LteMacSapProvider*> >::iterator, bool>
308  ret = m_componentCarrierLcMap.insert (std::pair <uint8_t, std::map<uint8_t, LteMacSapProvider*> >
309  (ncc, empty));
310  NS_ASSERT_MSG (ret.second, "element already present, ComponentCarrierId already existed");
311  ccLcMapIt = m_componentCarrierLcMap.find (ncc);
312  ccLcMapIt->second.insert (std::pair <uint8_t, LteMacSapProvider*> (lcId, m_macSapProvidersMap.at (ncc)));
313  }
314  }
315 
316  return res;
317 }
318 
319 void
321 {
322  NS_LOG_FUNCTION (this);
323  // this method need to be extended, now support only up to 2 ComponentCarrier Simulations
324 
326  {
327  // new ComponentCarrierConfiguration Requested
329  std::vector<uint8_t> res;
330  res.insert (res.end (), m_noOfComponentCarriersEnabled);
331  //here the code to update all the Lc, since now those should be mapped on all ComponentCarriers
333  }
334 
335 }
338 {
339  NS_LOG_FUNCTION (this);
340  std::map<uint8_t, LteMacSapUser*>::iterator it = m_lcAttached.find (lcid);
341  //NS_ASSERT_MSG (it == m_lcAttached.end (), "Warning, LCID " << (uint8_t) lcid << " already exist");
342  if (it != m_lcAttached.end ())
343  {
344  // This line will remove the former SignalBearer. It is needed in case of handover
345  // since an update of the signal bearer performed.
346  // Now it points on the right LteMacSapUser
347  m_lcAttached.erase (it);
348  }
349  m_lcAttached.insert (std::pair<uint8_t, LteMacSapUser*> (lcid, msu));
350 
351  return m_ccmMacSapUser;
352  }
353 
354 } // 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 "...
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
void DoReceivePdu(Ptr< Packet > p, uint16_t rnti, uint8_t lcid)
Receive PDU function.
uint16_t m_noOfComponentCarriersEnabled
The number of enabled component carriers that are enabled for this UE.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:277
std::vector< uint16_t > DoRemoveLc(uint8_t lcid)
Remove LC function.
LteUeCcmRrcSapProvider * m_ccmRrcSapProvider
Receive API calls from the eNodeB RRC instance.
virtual void DoInitialize()
Initialize() implementation.
LteUeCcmRrcSapUser * m_ccmRrcSapUser
Interface to the eNodeB RRC instance.
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.
Parameters for LteMacSapProvider::ReportBufferStatus.
Definition: lte-mac-sap.h:67
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.
void DoNotifyConnectionReconfigurationMsg()
Notify connection reconfiguration message.
make Callback use a separate empty type
Definition: empty.h:33
MeasResults structure.
Definition: lte-rrc-sap.h:671
LteMacSapUser * DoConfigureSignalBearer(uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser *msu)
Configure signal bearer function.
MemberLteUeCcmRrcSapProvider class.
Service Access Point (SAP) offered by the UE RRC to the UE CCM.
LteMacSapProvider * m_ccmMacSapProvider
Receive API calls from the eNodeB RLC instance.
virtual void NotifyHarqDeliveryFailure()
Called by the MAC to notify the RLC that an HARQ process related to this RLC instance has failed...
tuple mac
Definition: third.py:92
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.
virtual void ReceivePdu(Ptr< Packet > p, uint16_t rnti, uint8_t lcid)
Called by the MAC to notify the RLC of the reception of a new PDU.
virtual void ComponentCarrierEnabling(std::vector< uint8_t > componentCarrierList)=0
this function will be used after the RRC notify to ComponentCarrierManager that a reconfiguration mes...
LteUeCmacSapProvider::LogicalChannelConfig * lcConfig
logical channel config
std::map< uint8_t, LteMacSapProvider * > m_macSapProvidersMap
Map of pointers to SAP to interfaces of the MAC instance if the flows of this UE. ...
void DoNotifyTxOpportunity(uint32_t bytes, uint8_t layer, uint8_t harqId, uint8_t componentCarrierId, uint16_t rnti, uint8_t lcid)
Notify TX opportunity function.
SimpleUeCcmMacSapUser(SimpleUeComponentCarrierManager *mac)
Constructor.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:90
uint8_t measId
measure ID
Definition: lte-rrc-sap.h:673
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.
Service Access Point (SAP) offered by the UE component carrier manager to the UE RRC.
virtual LteUeCcmRrcSapProvider * GetLteCcmRrcSapProvider()
Exports the "provider" part of the ComponentCarrier Management SAP interface.
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:269
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.
void DoNotifyHarqDeliveryFailure()
Notify HARQ deliver failure.
friend class SimpleUeCcmMacSapUser
allow SimpleUeCcmMacSapUser class friend access
virtual void NotifyTxOpportunity(uint32_t bytes, uint8_t layer, uint8_t harqId, uint8_t componentCarrierId, uint16_t rnti, uint8_t lcid)
Called by the MAC to notify the RLC that the scheduler granted a transmission opportunity to this RLC...
LteMacSapUser * m_ccmMacSapUser
Interface to the eNodeB RLC instance.
SimpleUeComponentCarrierManager * m_mac
the component carrier manager
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
virtual void SetLteCcmRrcSapUser(LteUeCcmRrcSapUser *s)
Set the "user" part of the ComponentCarrier Management SAP interface that this UE component carrier m...
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
uint16_t m_noOfComponentCarriers
// The number of component carriers that this UE can support.
Parameters for LteMacSapProvider::TransmitPdu.
Definition: lte-mac-sap.h:45