ComponentCarrier class implemented
authorDanilo Abrignani <danilo.abrignani@unibo.it>
Fri, 26 Jun 2015 18:40:04 +0200
changeset 11424 7aeb60ea7f77
parent 11423 eeb058e2eb5c
child 11425 fec4e7859e37
ComponentCarrier class implemented
src/lte/examples/lena-simple.cc
src/lte/examples/wscript
src/lte/helper/cc-helper.cc
src/lte/helper/cc-helper.h
src/lte/helper/lte-helper.cc
src/lte/helper/lte-helper.h
src/lte/helper/phy-stats-calculator.cc
src/lte/helper/radio-bearer-stats-calculator.cc
src/lte/model/component-carrier-ue.cc
src/lte/model/component-carrier-ue.h
src/lte/model/component-carrier.cc
src/lte/model/component-carrier.h
src/lte/model/lte-enb-net-device.cc
src/lte/model/lte-enb-net-device.h
src/lte/model/lte-enb-phy.cc
src/lte/model/lte-enb-phy.h
src/lte/model/lte-enb-rrc.cc
src/lte/model/lte-enb-rrc.h
src/lte/model/lte-harq-phy.cc
src/lte/model/lte-rrc-sap.cc
src/lte/model/lte-spectrum-phy.cc
src/lte/model/lte-ue-net-device.cc
src/lte/model/lte-ue-net-device.h
src/lte/model/lte-ue-rrc.cc
src/lte/model/lte-ue-rrc.h
src/lte/test/lte-test-ue-measurements.cc
src/lte/test/test-asn1-encoding.cc
src/lte/wscript
--- a/src/lte/examples/lena-simple.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/examples/lena-simple.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -25,7 +25,7 @@
 #include "ns3/lte-module.h"
 #include "ns3/config-store.h"
 #include <ns3/buildings-helper.h>
-//#include "ns3/gtk-config-store.h"
+#include "ns3/gtk-config-store.h"
 
 using namespace ns3;
 
@@ -88,8 +88,8 @@
 
   Simulator::Run ();
 
-  // GtkConfigStore config;
-  // config.ConfigureAttributes ();
+  GtkConfigStore config;
+  config.ConfigureAttributes ();
 
   Simulator::Destroy ();
   return 0;
--- a/src/lte/examples/wscript	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/examples/wscript	Fri Jun 26 18:40:04 2015 +0200
@@ -55,3 +55,6 @@
     obj = bld.create_ns3_program('lena-uplink-power-control',
                                  ['lte'])
     obj.source = 'lena-uplink-power-control.cc'
+    obj = bld.create_ns3_program('lena-componentcarrierTest',
+                                 ['lte'])
+    obj.source = 'lena-componentcarrierTest.cc'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/helper/cc-helper.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -0,0 +1,166 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2015 Danilo Abrignani
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Danilo Abrignani <danilo.abrignani@unibo.it> (Carrier Aggregation - GSoC 2015)
+ */
+
+
+#include "cc-helper.h"
+#include <ns3/component-carrier.h>
+#include <ns3/string.h>
+#include <ns3/log.h>
+#include <ns3/abort.h>
+#include <ns3/pointer.h>
+#include <iostream>
+#include <ns3/uinteger.h>
+
+#define MIN_CC 1
+#define MAC_CC 2
+namespace ns3 {
+
+NS_LOG_COMPONENT_DEFINE ("CcHelper");
+
+NS_OBJECT_ENSURE_REGISTERED (CcHelper);
+
+CcHelper::CcHelper (void)
+{
+  NS_LOG_FUNCTION (this);
+  m_ccFactory.SetTypeId (ComponentCarrier::GetTypeId ());
+}
+
+void
+CcHelper::DoInitialize (void)
+{
+  NS_LOG_FUNCTION (this);
+}
+
+TypeId CcHelper::GetTypeId (void)
+{
+  static TypeId
+    tid =
+    TypeId ("ns3::CcHelper")
+    .SetParent<Object> ()
+    .AddConstructor<CcHelper> ()
+    .AddAttribute ("NoOfCcs",
+                   "Set the number of Component Carriers to setup per eNodeB"
+                   "Currently the maximum No of Cc allowed is 2",
+                   UintegerValue (1),
+                   MakeUintegerAccessor (&CcHelper::m_noOfCcs),
+                   MakeUintegerChecker<uint16_t> (MIN_CC, MAC_CC))
+    .AddAttribute ("UlFreq",
+                   "Set Ul Channel [EARFCN] for the first carrier component",
+                   UintegerValue (0),
+                   MakeUintegerAccessor (&CcHelper::m_ulEarfcn),
+                   MakeUintegerChecker<uint16_t> ())
+    .AddAttribute ("DlFreq",
+                   "Set Dl Channel [EARFCN] for the first carrier component",
+                   UintegerValue (0),
+                   MakeUintegerAccessor (&CcHelper::m_dlEarfcn),
+                   MakeUintegerChecker<uint16_t> (0))
+    .AddAttribute ("DlBandwidth",
+                   "Set Dl Bandwidth for the first carrier component",
+                   UintegerValue (25),
+                   MakeUintegerAccessor (&CcHelper::m_dlBandwidth),
+                   MakeUintegerChecker<uint16_t> (0,100))
+    .AddAttribute ("UlBandwidth",
+                   "Set Dl Bandwidth for the first carrier component",
+                   UintegerValue (25),
+                   MakeUintegerAccessor (&CcHelper::m_ulBandwidth),
+                   MakeUintegerChecker<uint16_t> (0,100))
+  ;
+
+  return tid;
+}
+
+CcHelper::~CcHelper (void)
+{
+  NS_LOG_FUNCTION (this);
+}
+
+void
+CcHelper::DoDispose ()
+{
+  NS_LOG_FUNCTION (this);
+  Object::DoDispose ();
+}
+
+void 
+CcHelper::SetCcAttribute (std::string n, const AttributeValue &v)
+{
+  NS_LOG_FUNCTION (this << n);
+  m_ccFactory.Set (n, v);
+}
+
+Ptr<ComponentCarrier>
+CcHelper::DoCreateSingleCc (uint16_t ulBw, uint16_t dlBw, uint16_t ulFreq, uint16_t dlFreq, bool pc)
+{
+  return CreateSingleCc (ulBw, dlBw, ulFreq, dlFreq, pc);
+}
+
+std::map< uint8_t, Ptr<ComponentCarrier> > 
+CcHelper::EquallySpacedCcs ()
+{
+  std::map< uint8_t, Ptr<ComponentCarrier> > ccmap;
+
+  for (uint16_t i = 0; i < m_noOfCcs; i++)
+    {
+      bool pc =false;
+      uint16_t ul = m_ulEarfcn + i * m_ulBandwidth;
+      uint16_t dl = m_dlEarfcn + i * m_dlBandwidth;
+      if (i == 0)
+        {
+          pc = true;
+        }
+      Ptr<ComponentCarrier> cc = CreateSingleCc (m_ulBandwidth, m_dlBandwidth, ul, dl, pc);
+      ccmap.insert (std::pair<uint8_t,Ptr<ComponentCarrier> >(i, cc));
+    }
+
+  return ccmap;
+}
+Ptr<ComponentCarrier> 
+CcHelper::CreateSingleCc (uint16_t ulBw, uint16_t dlBw, uint16_t ulFreq, uint16_t dlFreq, bool pc)
+{
+  Ptr <ComponentCarrier> cc =  CreateObject<ComponentCarrier> ();
+  if ( m_ulEarfcn != 0)
+    {
+      cc->SetUlEarfcn (ulFreq);
+    }
+  else 
+    {
+      uint16_t ul = cc->GetUlEarfcn () + ulFreq;
+      cc->SetUlEarfcn (ul);
+    }
+  if ( m_dlEarfcn != 0)
+    {
+      cc->SetDlEarfcn (dlFreq);
+    }
+  else 
+    {
+      uint16_t dl = cc->GetDlEarfcn () + ulFreq;
+      cc->SetDlEarfcn (dl);
+    }
+  cc->SetDlBandwidth (dlBw);
+  cc->SetUlBandwidth (ulBw);
+
+  cc->SetPrimaryCarrier (pc);
+
+  return cc;
+
+
+}
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/helper/cc-helper.h	Fri Jun 26 18:40:04 2015 +0200
@@ -0,0 +1,137 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2015 Danilo Abrignani
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Danilo Abrignani <danilo.abrignani@unibo.it> 
+ */
+
+#ifndef CC_HELPER_H
+#define CC_HELPER_H
+
+#include <ns3/config.h>
+#include <ns3/simulator.h>
+#include <ns3/names.h>
+#include <ns3/net-device.h>
+#include <ns3/net-device-container.h>
+#include <ns3/node.h>
+#include <ns3/node-container.h>
+#include <ns3/component-carrier.h>
+#include <map>
+
+namespace ns3 {
+
+
+/**
+ * \ingroup lte
+ *
+ * Creation and configuration of Component Carrier entities. One CcHelper instance is
+ * typically enough for an LTE simulation. To create it:
+ *
+ *     Ptr<CcHelper> ccHelper = CreateObject<CcHelper> ();
+ *
+ * The general responsibility of the helper is to create various Component Carrier objects
+ * and arrange them together to set the eNodeB. The overall
+ * arrangement would look like the following:
+ * - Ul Bandwidths
+ * - Dl Bandwidths
+ * - Ul Earfcn
+ * - Dl Earfcn
+ * - A LteEnbPhy pointer, the correspondent object it is created and linked within InstallSingleEnb
+ *
+ * It is needed to call this helper before LteHelper, then the map created using the helper
+ * can be sent to the LteHelper LteHelper::SetCcEnb(std::map< uint8_t, Ptr<ComponentCarrier> >)
+ *
+ * This helper it is also used within the LteHelper in order to maintain backwards compatibility
+ * with previous user simulation script. 
+ */
+class CcHelper : public Object
+{
+public:
+  CcHelper (void);
+  virtual ~CcHelper (void);
+
+  /**
+   *  Register this type.
+   *  \return The object TypeId.
+   */
+  static TypeId GetTypeId (void);
+  virtual void DoDispose (void);
+
+  Ptr<ComponentCarrier> DoCreateSingleCc (uint16_t ulBw, uint16_t dlBw, uint16_t ulFreq, uint16_t dlFreq, bool pc);
+
+  /**
+  * Set an attribute for the Component Carrier (LteEnbNetDevice) to be created.
+  *
+  * \param n the name of the attribute.
+  * \param v the value of the attribute
+  */
+  void SetCcAttribute (std::string n, const AttributeValue &v);
+
+  /**
+  * EquallySpacedCcs() create a valid std::map< uint8_t, Ptr<ComponentCarrier> >
+  * The Primary Component Carrier it is at the position 0 in the map
+  * The number of Component Carrier created depend on m_noOfCcs
+  * Currently it is limited to maximum 2 ComponentCarrier
+  * Since, only a LteEnbPhy object is available just symmetric Carrier Aggregation scheme
+  * are allowed, i.e. 2 Uplink Component Carrier and 2 Downlink Component Carrier
+  * Using this method, each CC will have the same characteristics (bandwidth)
+  * while they are spaced by exactly the bandwidth. Hence, using this method,
+  * you will create a intra-channel Carrier Aggregation scheme.
+  */
+
+  std::map< uint8_t, Ptr<ComponentCarrier> > EquallySpacedCcs ();
+
+  uint16_t  m_noOfCcs;
+
+  /**
+  * Probably the attribute listen below will become private and Set/Get method will be written
+  */
+
+  uint16_t m_ulEarfcn; /// Uplink EARFCN
+  uint16_t m_dlEarfcn; /// Downlink EARFCN
+  uint16_t m_dlBandwidth; /// Downlink Bandwidth
+  uint16_t m_ulBandwidth; /// Uplink Bandwidth
+
+
+protected:
+  // inherited from Object
+  virtual void DoInitialize (void);
+
+private:
+  /**
+   * Create an eNodeB device (LteEnbNetDevice) on the given node.
+   * \param ulBw uplink bandwidth for the current CC
+   * \param dlBw downlink bandwidth for the current CC
+   * \param ulFreq uplink EARFCN - not control on the validity at this point
+   * \param dlFreq downlink EARFCN - not control on the validity at this point	
+   * \param pc - this identify if this is the Primary Component Carrier (PCC) - only one PCC is allowed 
+   * \return pointer to the created object
+   */
+  Ptr<ComponentCarrier> CreateSingleCc (uint16_t ulBw, uint16_t dlBw, uint16_t ulFreq, uint16_t dlFreq, bool pc);
+
+  /// Factory for each Carrier Component.
+  ObjectFactory m_ccFactory;
+
+
+
+}; // end of `class LteHelper`
+
+
+} // namespace ns3
+
+
+
+#endif // LTE_HELPER_H
--- a/src/lte/helper/lte-helper.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/helper/lte-helper.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -64,6 +64,11 @@
 #include <ns3/buildings-propagation-loss-model.h>
 #include <ns3/lte-spectrum-value-helper.h>
 #include <ns3/epc-x2.h>
+#include <ns3/cc-helper.h>
+
+#include <ns3/pointer.h>
+#include <ns3/object-map.h>
+#include <ns3/object-factory.h>
 
 namespace ns3 {
 
@@ -84,56 +89,18 @@
   m_channelFactory.SetTypeId (MultiModelSpectrumChannel::GetTypeId ());
 }
 
-void 
+void
 LteHelper::DoInitialize (void)
 {
   NS_LOG_FUNCTION (this);
-  m_downlinkChannel = m_channelFactory.Create<SpectrumChannel> ();
-  m_uplinkChannel = m_channelFactory.Create<SpectrumChannel> ();
-
-  m_downlinkPathlossModel = m_dlPathlossModelFactory.Create ();
-  Ptr<SpectrumPropagationLossModel> dlSplm = m_downlinkPathlossModel->GetObject<SpectrumPropagationLossModel> ();
-  if (dlSplm != 0)
-    {
-      NS_LOG_LOGIC (this << " using a SpectrumPropagationLossModel in DL");
-      m_downlinkChannel->AddSpectrumPropagationLossModel (dlSplm);
-    }
-  else
-    {
-      NS_LOG_LOGIC (this << " using a PropagationLossModel in DL");
-      Ptr<PropagationLossModel> dlPlm = m_downlinkPathlossModel->GetObject<PropagationLossModel> ();
-      NS_ASSERT_MSG (dlPlm != 0, " " << m_downlinkPathlossModel << " is neither PropagationLossModel nor SpectrumPropagationLossModel");
-      m_downlinkChannel->AddPropagationLossModel (dlPlm);
-    }
-
-  m_uplinkPathlossModel = m_ulPathlossModelFactory.Create ();
-  Ptr<SpectrumPropagationLossModel> ulSplm = m_uplinkPathlossModel->GetObject<SpectrumPropagationLossModel> ();
-  if (ulSplm != 0)
-    {
-      NS_LOG_LOGIC (this << " using a SpectrumPropagationLossModel in UL");
-      m_uplinkChannel->AddSpectrumPropagationLossModel (ulSplm);
-    }
-  else
-    {
-      NS_LOG_LOGIC (this << " using a PropagationLossModel in UL");
-      Ptr<PropagationLossModel> ulPlm = m_uplinkPathlossModel->GetObject<PropagationLossModel> ();
-      NS_ASSERT_MSG (ulPlm != 0, " " << m_uplinkPathlossModel << " is neither PropagationLossModel nor SpectrumPropagationLossModel");
-      m_uplinkChannel->AddPropagationLossModel (ulPlm);
-    }
-  if (!m_fadingModelType.empty ())
-    {
-      m_fadingModule = m_fadingModelFactory.Create<SpectrumPropagationLossModel> ();
-      m_fadingModule->Initialize ();
-      m_downlinkChannel->AddSpectrumPropagationLossModel (m_fadingModule);
-      m_uplinkChannel->AddSpectrumPropagationLossModel (m_fadingModule);
-    }
+  // ChanelModelInitializedx ();
   m_phyStats = CreateObject<PhyStatsCalculator> ();
   m_phyTxStats = CreateObject<PhyTxStatsCalculator> ();
   m_phyRxStats = CreateObject<PhyRxStatsCalculator> ();
   m_macStats = CreateObject<MacStatsCalculator> ();
   Object::DoInitialize ();
+}
 
-}
 
 LteHelper::~LteHelper (void)
 {
@@ -189,7 +156,7 @@
     .AddAttribute ("UseIdealRrc",
                    "If true, LteRrcProtocolIdeal will be used for RRC signaling. "
                    "If false, LteRrcProtocolReal will be used.",
-                   BooleanValue (true), 
+                   BooleanValue (true),
                    MakeBooleanAccessor (&LteHelper::m_useIdealRrc),
                    MakeBooleanChecker ())
     .AddAttribute ("AnrEnabled",
@@ -211,6 +178,18 @@
                    MakeStringAccessor (&LteHelper::SetCcsAlgorithmType,
                                        &LteHelper::GetCcsAlgorithmType),
                    MakeStringChecker ())
+    .AddAttribute ("UseCa",
+                   "If true, Carrier Aggregation is enable and a valid Component Carrier Map is expected "
+                   "If false, single carrier simulation  ",
+                   BooleanValue (false),
+                   MakeBooleanAccessor (&LteHelper::m_useCa),
+                   MakeBooleanChecker ())
+    .AddAttribute ("NoOfCcs",
+                   "Set the number of Component carrier to use "
+                   "If it is more than one and m_useCa is false, it will rise an error ",
+                   UintegerValue (1),
+                   MakeUintegerAccessor (&LteHelper::m_noOfCcs),
+                   MakeUintegerChecker<uint16_t> (1, 2))
   ;
   return tid;
 }
@@ -219,21 +198,79 @@
 LteHelper::DoDispose ()
 {
   NS_LOG_FUNCTION (this);
-  m_downlinkChannel = 0;
-  m_uplinkChannel = 0;
+  // for (uint16_t i = 0; i < m_downlinkChannel.size (); i++)
+  //   {
+  //     m_downlinkChannel.at (i) = 0;
+  //   }
+  m_downlinkChannel.clear ();
+  m_uplinkChannel.clear ();   // = 0;
   Object::DoDispose ();
 }
 
+void
+LteHelper::ChanelModelInitializedx (void)
+{
+  // Channel Object (i.e. Ptr<SpecturmChannel>) are within a vector
+  // PathLossModel Objects are vectors --> in InstallSingleEnb we will set the frequency
+  NS_LOG_FUNCTION (this << m_noOfCcs);
 
-void 
+  for (uint16_t i = 0; i < m_noOfCcs; i++)
+    {
+      Ptr<SpectrumChannel> m_downlinkChannelElem = m_channelFactory.Create<SpectrumChannel> ();
+      Ptr<SpectrumChannel> m_uplinkChannelElem = m_channelFactory.Create<SpectrumChannel> ();
+
+      Ptr<Object> m_downlinkPathlossModelElem = m_dlPathlossModelFactory.Create ();
+      Ptr<SpectrumPropagationLossModel> dlSplm = m_downlinkPathlossModelElem->GetObject<SpectrumPropagationLossModel> ();
+      if (dlSplm != 0)
+        {
+          NS_LOG_LOGIC (this << " using a SpectrumPropagationLossModel in DL");
+          m_downlinkChannelElem->AddSpectrumPropagationLossModel (dlSplm);
+        }
+      else
+        {
+          NS_LOG_LOGIC (this << " using a PropagationLossModel in DL");
+          Ptr<PropagationLossModel> dlPlm = m_downlinkPathlossModelElem->GetObject<PropagationLossModel> ();
+          NS_ASSERT_MSG (dlPlm != 0, " " << m_downlinkPathlossModelElem << " is neither PropagationLossModel nor SpectrumPropagationLossModel");
+          m_downlinkChannelElem->AddPropagationLossModel (dlPlm);
+        }
+
+      Ptr<Object> m_uplinkPathlossModelElem = m_ulPathlossModelFactory.Create ();
+      Ptr<SpectrumPropagationLossModel> ulSplm = m_uplinkPathlossModelElem->GetObject<SpectrumPropagationLossModel> ();
+      if (ulSplm != 0)
+        {
+          NS_LOG_LOGIC (this << " using a SpectrumPropagationLossModel in UL");
+          m_uplinkChannelElem->AddSpectrumPropagationLossModel (ulSplm);
+        }
+      else
+        {
+          NS_LOG_LOGIC (this << " using a PropagationLossModel in UL");
+          Ptr<PropagationLossModel> ulPlm = m_uplinkPathlossModelElem->GetObject<PropagationLossModel> ();
+          NS_ASSERT_MSG (ulPlm != 0, " " << m_uplinkPathlossModelElem << " is neither PropagationLossModel nor SpectrumPropagationLossModel");
+          m_uplinkChannelElem->AddPropagationLossModel (ulPlm);
+        }
+      if (!m_fadingModelType.empty ())
+        {
+          m_fadingModule = m_fadingModelFactory.Create<SpectrumPropagationLossModel> ();
+          m_fadingModule->Initialize ();
+          m_downlinkChannelElem->AddSpectrumPropagationLossModel (m_fadingModule);
+          m_uplinkChannelElem->AddSpectrumPropagationLossModel (m_fadingModule);
+        }
+      m_downlinkChannel.push_back (m_downlinkChannelElem);
+      m_uplinkChannel.push_back (m_uplinkChannelElem);
+      m_uplinkPathlossModel.push_back (m_uplinkPathlossModelElem);
+      m_downlinkPathlossModel.push_back (m_downlinkPathlossModelElem);
+    }
+}
+
+void
 LteHelper::SetEpcHelper (Ptr<EpcHelper> h)
 {
   NS_LOG_FUNCTION (this << h);
   m_epcHelper = h;
 }
 
-void 
-LteHelper::SetSchedulerType (std::string type) 
+void
+LteHelper::SetSchedulerType (std::string type)
 {
   NS_LOG_FUNCTION (this << type);
   m_schedulerFactory = ObjectFactory ();
@@ -244,9 +281,9 @@
 LteHelper::GetSchedulerType () const
 {
   return m_schedulerFactory.GetTypeId ().GetName ();
-} 
+}
 
-void 
+void
 LteHelper::SetSchedulerAttribute (std::string n, const AttributeValue &v)
 {
   NS_LOG_FUNCTION (this << n);
@@ -317,8 +354,8 @@
   m_ccsAlgorithmFactory.Set (n, v);
 }
 
-void 
-LteHelper::SetPathlossModelType (std::string type) 
+void
+LteHelper::SetPathlossModelType (std::string type)
 {
   NS_LOG_FUNCTION (this << type);
   m_dlPathlossModelFactory = ObjectFactory ();
@@ -327,7 +364,7 @@
   m_ulPathlossModelFactory.SetTypeId (type);
 }
 
-void 
+void
 LteHelper::SetPathlossModelAttribute (std::string n, const AttributeValue &v)
 {
   NS_LOG_FUNCTION (this << n);
@@ -343,14 +380,14 @@
 }
 
 
-void 
+void
 LteHelper::SetEnbAntennaModelType (std::string type)
 {
   NS_LOG_FUNCTION (this);
   m_enbAntennaModelFactory.SetTypeId (type);
 }
 
-void 
+void
 LteHelper::SetEnbAntennaModelAttribute (std::string n, const AttributeValue &v)
 {
   NS_LOG_FUNCTION (this);
@@ -364,22 +401,22 @@
   m_ueNetDeviceFactory.Set (n, v);
 }
 
-void 
+void
 LteHelper::SetUeAntennaModelType (std::string type)
 {
   NS_LOG_FUNCTION (this);
   m_ueAntennaModelFactory.SetTypeId (type);
 }
 
-void 
+void
 LteHelper::SetUeAntennaModelAttribute (std::string n, const AttributeValue &v)
 {
   NS_LOG_FUNCTION (this);
   m_ueAntennaModelFactory.Set (n, v);
 }
 
-void 
-LteHelper::SetFadingModel (std::string type) 
+void
+LteHelper::SetFadingModel (std::string type)
 {
   NS_LOG_FUNCTION (this << type);
   m_fadingModelType = type;
@@ -390,31 +427,38 @@
     }
 }
 
-void 
+void
 LteHelper::SetFadingModelAttribute (std::string n, const AttributeValue &v)
 {
   m_fadingModelFactory.Set (n, v);
 }
 
-void 
-LteHelper::SetSpectrumChannelType (std::string type) 
+void
+LteHelper::SetSpectrumChannelType (std::string type)
 {
   NS_LOG_FUNCTION (this << type);
   m_channelFactory.SetTypeId (type);
 }
 
-void 
+void
 LteHelper::SetSpectrumChannelAttribute (std::string n, const AttributeValue &v)
 {
   m_channelFactory.Set (n, v);
 }
 
+void
+LteHelper::SetEnbCc ( std::map< uint8_t, Ptr<ComponentCarrier> > ccmap)
+{
+  NS_LOG_FUNCTION (this);
+  m_ccMap = ccmap;
+}
 
 NetDeviceContainer
 LteHelper::InstallEnbDevice (NodeContainer c)
 {
   NS_LOG_FUNCTION (this);
-  Initialize ();  // will run DoInitialize () if necessary
+  Initialize ();    // will run DoInitialize () if necessary
+  ChanelModelInitializedx ();
   NetDeviceContainer devices;
   for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
     {
@@ -446,49 +490,74 @@
 
   NS_ABORT_MSG_IF (m_cellIdCounter == 65535, "max num eNBs exceeded");
   uint16_t cellId = ++m_cellIdCounter;
-
-  Ptr<LteSpectrumPhy> dlPhy = CreateObject<LteSpectrumPhy> ();
-  Ptr<LteSpectrumPhy> ulPhy = CreateObject<LteSpectrumPhy> ();
-
-  Ptr<LteEnbPhy> phy = CreateObject<LteEnbPhy> (dlPhy, ulPhy);
+  // I create the LteEnbNetDevice object here
+  // so if I need default information over CC specification I can take from it
+  Ptr<LteEnbNetDevice> dev = m_enbNetDeviceFactory.Create<LteEnbNetDevice> ();
+  if (m_useCa == false )
+    {
+      // we need to create a valid ComponentCarrier Map now
+      Ptr<CcHelper> cch = CreateObject<CcHelper> ();
+      cch->m_noOfCcs = 1;
+      cch->m_ulEarfcn = dev->GetUlEarfcn ();
+      cch->m_dlEarfcn = dev->GetDlEarfcn ();
+      cch->m_dlBandwidth = dev->GetDlBandwidth ();
+      cch->m_ulBandwidth = dev->GetUlBandwidth ();
 
-  Ptr<LteHarqPhy> harq = Create<LteHarqPhy> ();
-  dlPhy->SetHarqPhyModule (harq);
-  ulPhy->SetHarqPhyModule (harq);
-  phy->SetHarqPhyModule (harq);
-
-  Ptr<LteChunkProcessor> pCtrl = Create<LteChunkProcessor> ();
-  pCtrl->AddCallback (MakeCallback (&LteEnbPhy::GenerateCtrlCqiReport, phy));
-  ulPhy->AddCtrlSinrChunkProcessor (pCtrl); // for evaluating SRS UL-CQI
+      m_ccMap = cch->EquallySpacedCcs ();
+    }
+  else
+    {
+      NS_ABORT_MSG_IF (m_ccMap.empty () == true, "You have to either define a valid Carrier Component MAP or disable Ca");
+    }
+  std::map<uint8_t,Ptr<ComponentCarrier> >::iterator it;
+  uint16_t counter = 0;
+  for (it = m_ccMap.begin (); it != m_ccMap.end (); ++it)
+    {
 
-  Ptr<LteChunkProcessor> pData = Create<LteChunkProcessor> ();
-  pData->AddCallback (MakeCallback (&LteEnbPhy::GenerateDataCqiReport, phy));
-  pData->AddCallback (MakeCallback (&LteSpectrumPhy::UpdateSinrPerceived, ulPhy));
-  ulPhy->AddDataSinrChunkProcessor (pData); // for evaluating PUSCH UL-CQI
+      Ptr<LteSpectrumPhy> dlPhy = CreateObject<LteSpectrumPhy> ();
+      Ptr<LteSpectrumPhy> ulPhy = CreateObject<LteSpectrumPhy> ();
+      Ptr<LteEnbPhy> phy = CreateObject<LteEnbPhy> (dlPhy, ulPhy);
+      it->second->m_phy = phy;
+      Ptr<LteHarqPhy> harq = Create<LteHarqPhy> ();
+      dlPhy->SetHarqPhyModule (harq);
+      ulPhy->SetHarqPhyModule (harq);
+      phy->SetHarqPhyModule (harq);
 
-  Ptr<LteChunkProcessor> pInterf = Create<LteChunkProcessor> ();
-  pInterf->AddCallback (MakeCallback (&LteEnbPhy::ReportInterference, phy));
-  ulPhy->AddInterferenceDataChunkProcessor (pInterf); // for interference power tracing
+      Ptr<LteChunkProcessor> pCtrl = Create<LteChunkProcessor> ();
+      pCtrl->AddCallback (MakeCallback (&LteEnbPhy::GenerateCtrlCqiReport, phy));
+      ulPhy->AddCtrlSinrChunkProcessor (pCtrl);   // for evaluating SRS UL-CQI
+
+      Ptr<LteChunkProcessor> pData = Create<LteChunkProcessor> ();
+      pData->AddCallback (MakeCallback (&LteEnbPhy::GenerateDataCqiReport, phy));
+      pData->AddCallback (MakeCallback (&LteSpectrumPhy::UpdateSinrPerceived, ulPhy));
+      ulPhy->AddDataSinrChunkProcessor (pData);   // for evaluating PUSCH UL-CQI
 
-  dlPhy->SetChannel (m_downlinkChannel);
-  ulPhy->SetChannel (m_uplinkChannel);
+      Ptr<LteChunkProcessor> pInterf = Create<LteChunkProcessor> ();
+      pInterf->AddCallback (MakeCallback (&LteEnbPhy::ReportInterference, phy));
+      ulPhy->AddInterferenceDataChunkProcessor (pInterf);   // for interference power tracing
+
+      dlPhy->SetChannel (m_downlinkChannel.at (counter));
+      ulPhy->SetChannel (m_uplinkChannel.at (counter));
+      counter++;
 
-  Ptr<MobilityModel> mm = n->GetObject<MobilityModel> ();
-  NS_ASSERT_MSG (mm, "MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
-  dlPhy->SetMobility (mm);
-  ulPhy->SetMobility (mm);
+      Ptr<MobilityModel> mm = n->GetObject<MobilityModel> ();
+      NS_ASSERT_MSG (mm, "MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
+      dlPhy->SetMobility (mm);
+      ulPhy->SetMobility (mm);
 
-  Ptr<AntennaModel> antenna = (m_enbAntennaModelFactory.Create ())->GetObject<AntennaModel> ();
-  NS_ASSERT_MSG (antenna, "error in creating the AntennaModel object");
-  dlPhy->SetAntenna (antenna);
-  ulPhy->SetAntenna (antenna);
-
+      Ptr<AntennaModel> antenna = (m_enbAntennaModelFactory.Create ())->GetObject<AntennaModel> ();
+      NS_ASSERT_MSG (antenna, "error in creating the AntennaModel object");
+      dlPhy->SetAntenna (antenna);
+      ulPhy->SetAntenna (antenna);
+    }
   Ptr<LteEnbMac> mac = CreateObject<LteEnbMac> ();
   Ptr<FfMacScheduler> sched = m_schedulerFactory.Create<FfMacScheduler> ();
   Ptr<LteFfrAlgorithm> ffrAlgorithm = m_ffrAlgorithmFactory.Create<LteFfrAlgorithm> ();
   Ptr<LteHandoverAlgorithm> handoverAlgorithm = m_handoverAlgorithmFactory.Create<LteHandoverAlgorithm> ();
   Ptr<LteCcsAlgorithm> ccsAlgorithm = m_ccsAlgorithmFactory.Create<LteCcsAlgorithm> ();
   Ptr<LteEnbRrc> rrc = CreateObject<LteEnbRrc> ();
+  rrc->m_noOfCcs = m_noOfCcs;
+  rrc->InitializeSap ();
 
   if (m_useIdealRrc)
     {
@@ -530,13 +599,15 @@
 
   sched->SetFfMacSchedSapUser (mac->GetFfMacSchedSapUser ());
   sched->SetFfMacCschedSapUser (mac->GetFfMacCschedSapUser ());
-
-  phy->SetLteEnbPhySapUser (mac->GetLteEnbPhySapUser ());
-  mac->SetLteEnbPhySapProvider (phy->GetLteEnbPhySapProvider ());
-
-  phy->SetLteEnbCphySapUser (rrc->GetLteEnbCphySapUser ());
-  rrc->SetLteEnbCphySapProvider (phy->GetLteEnbCphySapProvider ());
-
+  it = m_ccMap.begin ();
+  it->second->GetPhy ()->SetLteEnbPhySapUser (mac->GetLteEnbPhySapUser ());
+  mac->SetLteEnbPhySapProvider (it->second->GetPhy ()->GetLteEnbPhySapProvider ());
+  uint16_t tmpCounter = 0;
+  for (it = m_ccMap.begin (); it != m_ccMap.end (); ++it)
+    {
+      it->second->GetPhy ()->SetLteEnbCphySapUser (rrc->GetLteEnbCphySapUser (tmpCounter));
+      rrc->SetLteEnbCphySapProvider (it->second->GetPhy ()->GetLteEnbCphySapProvider (), tmpCounter);
+    }
   //FFR SAP
   sched->SetLteFfrSapProvider (ffrAlgorithm->GetLteFfrSapProvider ());
   ffrAlgorithm->SetLteFfrSapUser (sched->GetLteFfrSapUser ());
@@ -550,13 +621,15 @@
   ccsAlgorithm->SetLteComponentCarrierManagementSapUser (rrc->GetLteComponentCarrierManagementSapUser ());
   //CCs SAP END
 
-  Ptr<LteEnbNetDevice> dev = m_enbNetDeviceFactory.Create<LteEnbNetDevice> ();
+
   dev->SetNode (n);
-  dev->SetAttribute ("CellId", UintegerValue (cellId)); 
-  dev->SetAttribute ("LteEnbPhy", PointerValue (phy));
+  dev->SetAttribute ("CellId", UintegerValue (cellId));
+  //dev->SetAttribute ("LteEnbPhy", PointerValue (it->second->GetPhy ()));// this will be a pointer to a map of phy
+  //dev->SetAttribute("ComponentCarrierMap", ObjectMapValue (m_ccMap));
+  dev->SetCcMap (m_ccMap);
   dev->SetAttribute ("LteEnbMac", PointerValue (mac));
   dev->SetAttribute ("FfMacScheduler", PointerValue (sched));
-  dev->SetAttribute ("LteEnbRrc", PointerValue (rrc)); 
+  dev->SetAttribute ("LteEnbRrc", PointerValue (rrc));
   dev->SetAttribute ("LteHandoverAlgorithm", PointerValue (handoverAlgorithm));
   dev->SetAttribute ("LteFfrAlgorithm", PointerValue (ffrAlgorithm));
 
@@ -567,36 +640,48 @@
       anr->SetLteAnrSapUser (rrc->GetLteAnrSapUser ());
       dev->SetAttribute ("LteAnr", PointerValue (anr));
     }
-
-  phy->SetDevice (dev);
-  dlPhy->SetDevice (dev);
-  ulPhy->SetDevice (dev);
+  counter = 0;
+  for (it = m_ccMap.begin (); it != m_ccMap.end (); ++it)
+    {
+      Ptr<LteEnbPhy> tmpPhy;
+      tmpPhy = it->second->GetPhy ();
+      tmpPhy->SetDevice (dev);
+      tmpPhy->GetUlSpectrumPhy ()->SetDevice (dev);
+      tmpPhy->GetDlSpectrumPhy ()->SetDevice (dev);
+      tmpPhy->GetDlSpectrumPhy ()->SetDevice (dev);
+      tmpPhy->GetDlSpectrumPhy ()->SetLtePhyRxDataEndOkCallback (MakeCallback (&LteEnbPhy::PhyPduReceived, tmpPhy));
+      tmpPhy->GetDlSpectrumPhy ()->SetLtePhyRxCtrlEndOkCallback (MakeCallback (&LteEnbPhy::ReceiveLteControlMessageList, tmpPhy));
+      tmpPhy->GetDlSpectrumPhy ()->SetLtePhyUlHarqFeedbackCallback (MakeCallback (&LteEnbPhy::ReceiveLteUlHarqFeedback, tmpPhy));
+      NS_LOG_LOGIC ("set the propagation model frequencies");
+      double dlFreq = LteSpectrumValueHelper::GetCarrierFrequency (it->second->m_dlEarfcn);
+      NS_LOG_LOGIC ("DL freq: " << dlFreq);
+      bool dlFreqOk = m_downlinkPathlossModel.at (counter)->SetAttributeFailSafe ("Frequency", DoubleValue (dlFreq));
+      if (!dlFreqOk)
+        {
+          NS_LOG_WARN ("DL propagation model does not have a Frequency attribute");
+        }
 
+      double ulFreq = LteSpectrumValueHelper::GetCarrierFrequency (it->second->m_ulEarfcn);
+
+      NS_LOG_LOGIC ("UL freq: " << ulFreq);
+      bool ulFreqOk = m_uplinkPathlossModel.at (counter)->SetAttributeFailSafe ("Frequency", DoubleValue (ulFreq));
+      if (!ulFreqOk)
+        {
+          NS_LOG_WARN ("UL propagation model does not have a Frequency attribute");
+        }
+
+      counter++;
+    }  //end for
   n->AddDevice (dev);
-  ulPhy->SetLtePhyRxDataEndOkCallback (MakeCallback (&LteEnbPhy::PhyPduReceived, phy));
-  ulPhy->SetLtePhyRxCtrlEndOkCallback (MakeCallback (&LteEnbPhy::ReceiveLteControlMessageList, phy));
-  ulPhy->SetLtePhyUlHarqFeedbackCallback (MakeCallback (&LteEnbPhy::ReceiveLteUlHarqFeedback, phy));
+
+  dev->Initialize ();
+  counter = 0;
+  for (it = m_ccMap.begin (); it != m_ccMap.end (); ++it)
+    {
+      m_uplinkChannel.at (counter)->AddRx (it->second->GetPhy ()->GetUlSpectrumPhy ());
+    }
   rrc->SetForwardUpCallback (MakeCallback (&LteEnbNetDevice::Receive, dev));
 
-  NS_LOG_LOGIC ("set the propagation model frequencies");
-  double dlFreq = LteSpectrumValueHelper::GetCarrierFrequency (dev->GetDlEarfcn ());
-  NS_LOG_LOGIC ("DL freq: " << dlFreq);
-  bool dlFreqOk = m_downlinkPathlossModel->SetAttributeFailSafe ("Frequency", DoubleValue (dlFreq));
-  if (!dlFreqOk)
-    {
-      NS_LOG_WARN ("DL propagation model does not have a Frequency attribute");
-    }
-  double ulFreq = LteSpectrumValueHelper::GetCarrierFrequency (dev->GetUlEarfcn ());
-  NS_LOG_LOGIC ("UL freq: " << ulFreq);
-  bool ulFreqOk = m_uplinkPathlossModel->SetAttributeFailSafe ("Frequency", DoubleValue (ulFreq));
-  if (!ulFreqOk)
-    {
-      NS_LOG_WARN ("UL propagation model does not have a Frequency attribute");
-    }
-
-  dev->Initialize ();
-
-  m_uplinkChannel->AddRx (ulPhy);
 
   if (m_epcHelper != 0)
     {
@@ -622,61 +707,82 @@
 LteHelper::InstallSingleUeDevice (Ptr<Node> n)
 {
   NS_LOG_FUNCTION (this);
-  Ptr<LteSpectrumPhy> dlPhy = CreateObject<LteSpectrumPhy> ();
-  Ptr<LteSpectrumPhy> ulPhy = CreateObject<LteSpectrumPhy> ();
 
-  Ptr<LteUePhy> phy = CreateObject<LteUePhy> (dlPhy, ulPhy);
+  Ptr<LteUeNetDevice> dev = m_ueNetDeviceFactory.Create<LteUeNetDevice> ();
+  std::map<uint8_t, Ptr<ComponentCarrierUe> > m_ccMapUe;
+  std::map<uint8_t, Ptr<ComponentCarrier> >::iterator itCcMap;
+  for (itCcMap = m_ccMap.begin (); itCcMap != m_ccMap.end (); ++itCcMap)
+    {
+      Ptr <ComponentCarrierUe> cc =  CreateObject<ComponentCarrierUe> ();
+      cc->SetUlBandwidth ( itCcMap->second->GetUlBandwidth ());
+      cc->SetDlBandwidth ( itCcMap->second->GetDlBandwidth ());
+      cc->m_dlEarfcn = itCcMap->second->m_dlEarfcn;
+      cc->m_ulEarfcn = itCcMap->second->m_ulEarfcn;
+      cc->SetPrimaryCarrier (itCcMap->second->GetPrimaryCarrier ());
+      // cc->GetPhy ()->Initialize (); // it is initialized within the LteUeNetDevice::DoInitialize ()
+      m_ccMapUe.insert (std::pair<uint8_t, Ptr<ComponentCarrierUe> > (itCcMap->first, cc));
 
-  Ptr<LteHarqPhy> harq = Create<LteHarqPhy> ();
-  dlPhy->SetHarqPhyModule (harq);
-  ulPhy->SetHarqPhyModule (harq);
-  phy->SetHarqPhyModule (harq);
+    }
+  std::map<uint8_t, Ptr<ComponentCarrierUe> >::iterator it;
+  uint16_t counter = 0;
+  for (it = m_ccMapUe.begin (); it != m_ccMapUe.end (); ++it)
+    {
+      Ptr<LteSpectrumPhy> dlPhy = CreateObject<LteSpectrumPhy> ();
+      Ptr<LteSpectrumPhy> ulPhy = CreateObject<LteSpectrumPhy> ();
 
-  Ptr<LteChunkProcessor> pRs = Create<LteChunkProcessor> ();
-  pRs->AddCallback (MakeCallback (&LteUePhy::ReportRsReceivedPower, phy));
-  dlPhy->AddRsPowerChunkProcessor (pRs);
-
-  Ptr<LteChunkProcessor> pInterf = Create<LteChunkProcessor> ();
-  pInterf->AddCallback (MakeCallback (&LteUePhy::ReportInterference, phy));
-  dlPhy->AddInterferenceCtrlChunkProcessor (pInterf); // for RSRQ evaluation of UE Measurements
+      Ptr<LteUePhy> phy = CreateObject<LteUePhy> (dlPhy, ulPhy);
+      it->second->m_phy = phy;
+      Ptr<LteHarqPhy> harq = Create<LteHarqPhy> ();
+      dlPhy->SetHarqPhyModule (harq);
+      ulPhy->SetHarqPhyModule (harq);
+      phy->SetHarqPhyModule (harq);
 
-  Ptr<LteChunkProcessor> pCtrl = Create<LteChunkProcessor> ();
-  pCtrl->AddCallback (MakeCallback (&LteSpectrumPhy::UpdateSinrPerceived, dlPhy));
-  dlPhy->AddCtrlSinrChunkProcessor (pCtrl);
+      Ptr<LteChunkProcessor> pRs = Create<LteChunkProcessor> ();
+      pRs->AddCallback (MakeCallback (&LteUePhy::ReportRsReceivedPower, phy));
+      dlPhy->AddRsPowerChunkProcessor (pRs);
 
-  Ptr<LteChunkProcessor> pData = Create<LteChunkProcessor> ();
-  pData->AddCallback (MakeCallback (&LteSpectrumPhy::UpdateSinrPerceived, dlPhy));
-  dlPhy->AddDataSinrChunkProcessor (pData);
+      Ptr<LteChunkProcessor> pInterf = Create<LteChunkProcessor> ();
+      pInterf->AddCallback (MakeCallback (&LteUePhy::ReportInterference, phy));
+      dlPhy->AddInterferenceCtrlChunkProcessor (pInterf);   // for RSRQ evaluation of UE Measurements
+
+      Ptr<LteChunkProcessor> pCtrl = Create<LteChunkProcessor> ();
+      pCtrl->AddCallback (MakeCallback (&LteSpectrumPhy::UpdateSinrPerceived, dlPhy));
+      dlPhy->AddCtrlSinrChunkProcessor (pCtrl);
 
-  if (m_usePdschForCqiGeneration)
-    {
-      // CQI calculation based on PDCCH for signal and PDSCH for interference
-      pCtrl->AddCallback (MakeCallback (&LteUePhy::GenerateMixedCqiReport, phy));
-      Ptr<LteChunkProcessor> pDataInterf = Create<LteChunkProcessor> ();      
-      pDataInterf->AddCallback (MakeCallback (&LteUePhy::ReportDataInterference, phy));
-      dlPhy->AddInterferenceDataChunkProcessor (pDataInterf);
-    }
-  else
-    {
-      // CQI calculation based on PDCCH for both signal and interference
-      pCtrl->AddCallback (MakeCallback (&LteUePhy::GenerateCtrlCqiReport, phy));
-    }
+      Ptr<LteChunkProcessor> pData = Create<LteChunkProcessor> ();
+      pData->AddCallback (MakeCallback (&LteSpectrumPhy::UpdateSinrPerceived, dlPhy));
+      dlPhy->AddDataSinrChunkProcessor (pData);
+
+      if (m_usePdschForCqiGeneration)
+        {
+          // CQI calculation based on PDCCH for signal and PDSCH for interference
+          pCtrl->AddCallback (MakeCallback (&LteUePhy::GenerateMixedCqiReport, phy));
+          Ptr<LteChunkProcessor> pDataInterf = Create<LteChunkProcessor> ();
+          pDataInterf->AddCallback (MakeCallback (&LteUePhy::ReportDataInterference, phy));
+          dlPhy->AddInterferenceDataChunkProcessor (pDataInterf);
+        }
+      else
+        {
+          // CQI calculation based on PDCCH for both signal and interference
+          pCtrl->AddCallback (MakeCallback (&LteUePhy::GenerateCtrlCqiReport, phy));
+        }
 
 
 
-  dlPhy->SetChannel (m_downlinkChannel);
-  ulPhy->SetChannel (m_uplinkChannel);
+      dlPhy->SetChannel (m_downlinkChannel.at (counter));
+      ulPhy->SetChannel (m_uplinkChannel.at (counter));
+      counter++;
 
-  Ptr<MobilityModel> mm = n->GetObject<MobilityModel> ();
-  NS_ASSERT_MSG (mm, "MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
-  dlPhy->SetMobility (mm);
-  ulPhy->SetMobility (mm);
+      Ptr<MobilityModel> mm = n->GetObject<MobilityModel> ();
+      NS_ASSERT_MSG (mm, "MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
+      dlPhy->SetMobility (mm);
+      ulPhy->SetMobility (mm);
 
-  Ptr<AntennaModel> antenna = (m_ueAntennaModelFactory.Create ())->GetObject<AntennaModel> ();
-  NS_ASSERT_MSG (antenna, "error in creating the AntennaModel object");
-  dlPhy->SetAntenna (antenna);
-  ulPhy->SetAntenna (antenna);
-
+      Ptr<AntennaModel> antenna = (m_ueAntennaModelFactory.Create ())->GetObject<AntennaModel> ();
+      NS_ASSERT_MSG (antenna, "error in creating the AntennaModel object");
+      dlPhy->SetAntenna (antenna);
+      ulPhy->SetAntenna (antenna);
+    }
   Ptr<LteUeMac> mac = CreateObject<LteUeMac> ();
   Ptr<LteUeRrc> rrc = CreateObject<LteUeRrc> ();
 
@@ -709,34 +815,43 @@
   rrc->SetLteUeCmacSapProvider (mac->GetLteUeCmacSapProvider ());
   mac->SetLteUeCmacSapUser (rrc->GetLteUeCmacSapUser ());
   rrc->SetLteMacSapProvider (mac->GetLteMacSapProvider ());
+  it = m_ccMapUe.begin ();
+  it->second->GetPhy ()->SetLteUePhySapUser (mac->GetLteUePhySapUser ());
+  mac->SetLteUePhySapProvider ( it->second->GetPhy ()->GetLteUePhySapProvider ());
 
-  phy->SetLteUePhySapUser (mac->GetLteUePhySapUser ());
-  mac->SetLteUePhySapProvider (phy->GetLteUePhySapProvider ());
-
-  phy->SetLteUeCphySapUser (rrc->GetLteUeCphySapUser ());
-  rrc->SetLteUeCphySapProvider (phy->GetLteUeCphySapProvider ());
+  it->second->GetPhy ()->SetLteUeCphySapUser (rrc->GetLteUeCphySapUser ());
+  rrc->SetLteUeCphySapProvider (it->second->GetPhy ()->GetLteUeCphySapProvider ());
 
   NS_ABORT_MSG_IF (m_imsiCounter >= 0xFFFFFFFF, "max num UEs exceeded");
   uint64_t imsi = ++m_imsiCounter;
 
-  Ptr<LteUeNetDevice> dev = m_ueNetDeviceFactory.Create<LteUeNetDevice> ();
+
   dev->SetNode (n);
   dev->SetAttribute ("Imsi", UintegerValue (imsi));
-  dev->SetAttribute ("LteUePhy", PointerValue (phy));
+  //dev->SetAttribute ("LteUePhy", PointerValue (phy));
+  //dev->SetAttribute ("ComponentCarrierMapUe", ObjectMapValue (m_ccMapUe));
+  dev->SetCcMap (m_ccMapUe);
   dev->SetAttribute ("LteUeMac", PointerValue (mac));
   dev->SetAttribute ("LteUeRrc", PointerValue (rrc));
   dev->SetAttribute ("EpcUeNas", PointerValue (nas));
-
-  phy->SetDevice (dev);
-  dlPhy->SetDevice (dev);
-  ulPhy->SetDevice (dev);
+  counter = 0;
+  for (it = m_ccMapUe.begin (); it != m_ccMapUe.end (); ++it)
+    {
+      Ptr<LteUePhy> tmpPhy;
+      tmpPhy = it->second->GetPhy ();
+      tmpPhy->SetDevice (dev);
+      tmpPhy->GetUlSpectrumPhy ()->SetDevice (dev);
+      tmpPhy->GetDlSpectrumPhy ()->SetDevice (dev);
+      tmpPhy->GetDlSpectrumPhy ()->SetDevice (dev);
+      tmpPhy->GetDlSpectrumPhy ()->SetLtePhyRxDataEndOkCallback (MakeCallback (&LteUePhy::PhyPduReceived, tmpPhy));
+      tmpPhy->GetDlSpectrumPhy ()->SetLtePhyRxCtrlEndOkCallback (MakeCallback (&LteUePhy::ReceiveLteControlMessageList, tmpPhy));
+      tmpPhy->GetDlSpectrumPhy ()->SetLtePhyRxPssCallback (MakeCallback (&LteUePhy::ReceivePss, tmpPhy));
+      tmpPhy->GetDlSpectrumPhy ()->SetLtePhyDlHarqFeedbackCallback (MakeCallback (&LteUePhy::ReceiveLteDlHarqFeedback, tmpPhy));
+    }
   nas->SetDevice (dev);
 
   n->AddDevice (dev);
-  dlPhy->SetLtePhyRxDataEndOkCallback (MakeCallback (&LteUePhy::PhyPduReceived, phy));
-  dlPhy->SetLtePhyRxCtrlEndOkCallback (MakeCallback (&LteUePhy::ReceiveLteControlMessageList, phy));
-  dlPhy->SetLtePhyRxPssCallback (MakeCallback (&LteUePhy::ReceivePss, phy));
-  dlPhy->SetLtePhyDlHarqFeedbackCallback (MakeCallback (&LteUePhy::ReceiveLteDlHarqFeedback, phy));
+
   nas->SetForwardUpCallback (MakeCallback (&LteUeNetDevice::Receive, dev));
 
   if (m_epcHelper != 0)
@@ -819,7 +934,7 @@
       m_epcHelper->ActivateEpsBearer (ueDevice, ueLteDevice->GetImsi (), EpcTft::Default (), EpsBearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT));
     }
 
-  // tricks needed for the simplified LTE-only simulations 
+  // tricks needed for the simplified LTE-only simulations
   if (m_epcHelper == 0)
     {
       ueDevice->GetObject<LteUeNetDevice> ()->SetTargetEnb (enbDevice->GetObject<LteEnbNetDevice> ());
@@ -891,16 +1006,16 @@
  * the Enb RRC Connection Estabilished trace source. When
  * UE change its RRC state to CONNECTED_NORMALLY, activation
  * function is called and bearer is activated.
-*/
+ */
 class DrbActivator : public SimpleRefCount<DrbActivator>
 {
 public:
   /**
-  * DrbActivator Constructor
-  *
-  * \param ueDevice the UeNetDevice for which bearer will be activated
-  * \param bearer the bearer configuration
-  */
+   * DrbActivator Constructor
+   *
+   * \param ueDevice the UeNetDevice for which bearer will be activated
+   * \param bearer the bearer configuration
+   */
   DrbActivator (Ptr<NetDevice> ueDevice, EpsBearer bearer);
 
   /**
@@ -964,7 +1079,7 @@
 
 void
 DrbActivator::ActivateDrb (uint64_t imsi, uint16_t cellId, uint16_t rnti)
-{ 
+{
   NS_LOG_FUNCTION (this << imsi << cellId << rnti << m_active);
   if ((!m_active) && (imsi == m_imsi))
     {
@@ -981,14 +1096,14 @@
       params.rnti = rnti;
       params.bearer = m_bearer;
       params.bearerId = 0;
-      params.gtpTeid = 0; // don't care
+      params.gtpTeid = 0;   // don't care
       enbRrc->GetS1SapUser ()->DataRadioBearerSetupRequest (params);
       m_active = true;
     }
 }
 
 
-void 
+void
 LteHelper::ActivateDataRadioBearer (Ptr<NetDevice> ueDevice, EpsBearer bearer)
 {
   NS_LOG_FUNCTION (this << ueDevice);
@@ -1003,7 +1118,7 @@
   Ptr<LteEnbNetDevice> enbLteDevice = ueDevice->GetObject<LteUeNetDevice> ()->GetTargetEnb ();
 
   std::ostringstream path;
-  path << "/NodeList/" << enbLteDevice->GetNode ()->GetId () 
+  path << "/NodeList/" << enbLteDevice->GetNode ()->GetId ()
        << "/DeviceList/" << enbLteDevice->GetIfIndex ()
        << "/LteEnbRrc/ConnectionEstablished";
   Ptr<DrbActivator> arg = Create<DrbActivator> (ueDevice, bearer);
@@ -1080,7 +1195,7 @@
 }
 
 
-void 
+void
 LteHelper::ActivateDataRadioBearer (NetDeviceContainer ueDevices, EpsBearer bearer)
 {
   NS_LOG_FUNCTION (this);
@@ -1164,16 +1279,22 @@
       Ptr<LteEnbNetDevice> lteEnb = DynamicCast<LteEnbNetDevice> (netDevice);
       if (lteEnb)
         {
-          Ptr<LteSpectrumPhy> dlPhy = lteEnb->GetPhy ()->GetDownlinkSpectrumPhy ();
-          Ptr<LteSpectrumPhy> ulPhy = lteEnb->GetPhy ()->GetUplinkSpectrumPhy ();
+          std::map< uint8_t, Ptr <ComponentCarrier> > tmpMap = lteEnb->GetCcMap ();
+          std::map< uint8_t, Ptr <ComponentCarrier> >::iterator it;
+          it = tmpMap.begin ();
+          Ptr<LteSpectrumPhy> dlPhy = it->second->GetPhy ()->GetDownlinkSpectrumPhy ();
+          Ptr<LteSpectrumPhy> ulPhy = it->second->GetPhy ()->GetUplinkSpectrumPhy ();
           currentStream += dlPhy->AssignStreams (currentStream);
           currentStream += ulPhy->AssignStreams (currentStream);
         }
       Ptr<LteUeNetDevice> lteUe = DynamicCast<LteUeNetDevice> (netDevice);
       if (lteUe)
         {
-          Ptr<LteSpectrumPhy> dlPhy = lteUe->GetPhy ()->GetDownlinkSpectrumPhy ();
-          Ptr<LteSpectrumPhy> ulPhy = lteUe->GetPhy ()->GetUplinkSpectrumPhy ();
+          std::map< uint8_t, Ptr <ComponentCarrierUe> > tmpMap = lteUe->GetCcMap ();
+          std::map< uint8_t, Ptr <ComponentCarrierUe> >::iterator it;
+          it = tmpMap.begin ();
+          Ptr<LteSpectrumPhy> dlPhy = it->second->GetPhy ()->GetDownlinkSpectrumPhy ();
+          Ptr<LteSpectrumPhy> ulPhy = it->second->GetPhy ()->GetUplinkSpectrumPhy ();
           Ptr<LteUeMac> ueMac = lteUe->GetMac ();
           currentStream += dlPhy->AssignStreams (currentStream);
           currentStream += ulPhy->AssignStreams (currentStream);
@@ -1198,28 +1319,28 @@
 void
 LteHelper::EnableDlTxPhyTraces (void)
 {
-  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbPhy/DlPhyTransmission",
+  Config::Connect ("/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbPhy/DlPhyTransmission",
                    MakeBoundCallback (&PhyTxStatsCalculator::DlPhyTransmissionCallback, m_phyTxStats));
 }
 
 void
 LteHelper::EnableUlTxPhyTraces (void)
 {
-  Config::Connect ("/NodeList/*/DeviceList/*/LteUePhy/UlPhyTransmission",
+  Config::Connect ("/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/LteUePhy/UlPhyTransmission",
                    MakeBoundCallback (&PhyTxStatsCalculator::UlPhyTransmissionCallback, m_phyTxStats));
 }
 
 void
 LteHelper::EnableDlRxPhyTraces (void)
 {
-  Config::Connect ("/NodeList/*/DeviceList/*/LteUePhy/DlSpectrumPhy/DlPhyReception",
+  Config::Connect ("/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/LteUePhy/DlSpectrumPhy/DlPhyReception",
                    MakeBoundCallback (&PhyRxStatsCalculator::DlPhyReceptionCallback, m_phyRxStats));
 }
 
 void
 LteHelper::EnableUlRxPhyTraces (void)
 {
-  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbPhy/UlSpectrumPhy/UlPhyReception",
+  Config::Connect ("/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbPhy/UlSpectrumPhy/UlPhyReception",
                    MakeBoundCallback (&PhyRxStatsCalculator::UlPhyReceptionCallback, m_phyRxStats));
 }
 
@@ -1252,7 +1373,7 @@
 LteHelper::EnableDlPhyTraces (void)
 {
   NS_LOG_FUNCTION_NOARGS ();
-  Config::Connect ("/NodeList/*/DeviceList/*/LteUePhy/ReportCurrentCellRsrpSinr",
+  Config::Connect ("/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/LteUePhy/ReportCurrentCellRsrpSinr",
                    MakeBoundCallback (&PhyStatsCalculator::ReportCurrentCellRsrpSinrCallback, m_phyStats));
 }
 
@@ -1260,9 +1381,9 @@
 LteHelper::EnableUlPhyTraces (void)
 {
   NS_LOG_FUNCTION_NOARGS ();
-  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbPhy/ReportUeSinr",
+  Config::Connect ("/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbPhy/ReportUeSinr",
                    MakeBoundCallback (&PhyStatsCalculator::ReportUeSinr, m_phyStats));
-  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbPhy/ReportInterference",
+  Config::Connect ("/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbPhy/ReportInterference",
                    MakeBoundCallback (&PhyStatsCalculator::ReportInterference, m_phyStats));
 
 }
--- a/src/lte/helper/lte-helper.h	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/helper/lte-helper.h	Fri Jun 26 18:40:04 2015 +0200
@@ -39,6 +39,8 @@
 #include <ns3/radio-bearer-stats-connector.h>
 #include <ns3/epc-tft.h>
 #include <ns3/mobility-model.h>
+#include <ns3/component-carrier.h>
+#include <map>
 
 namespace ns3 {
 
@@ -108,8 +110,8 @@
    */
   static TypeId GetTypeId (void);
   virtual void DoDispose (void);
-
-  /** 
+  void ChanelModelInitializedx (void);
+  /**
    * Set the EpcHelper to be used to setup the EPC network in
    * conjunction with the setup of the LTE radio access network.
    *
@@ -119,14 +121,14 @@
    * words, it will be a radio-level simulation involving only LTE PHY
    * and MAC and the FF Scheduler, with a saturation traffic model for
    * the RLC.
-   * 
+   *
    * \param h a pointer to the EpcHelper to be used
    */
   void SetEpcHelper (Ptr<EpcHelper> h);
 
-  /** 
+  /**
    * Set the type of path loss model to be used for both DL and UL channels.
-   * 
+   *
    * \param type type of path loss model, must be a type name of any class
    *             inheriting from ns3::PropagationLossModel, for example:
    *             "ns3::FriisPropagationLossModel"
@@ -135,15 +137,15 @@
 
   /**
    * Set an attribute for the path loss models to be created.
-   * 
+   *
    * \param n the name of the attribute
    * \param v the value of the attribute
    */
   void SetPathlossModelAttribute (std::string n, const AttributeValue &v);
 
-  /** 
+  /**
    * Set the type of scheduler to be used by eNodeB devices.
-   * 
+   *
    * \param type type of scheduler, must be a type name of any class
    *             inheriting from ns3::FfMacScheduler, for example:
    *             "ns3::PfFfMacScheduler"
@@ -156,11 +158,11 @@
    *
    * \return the scheduler type
    */
-  std::string GetSchedulerType () const; 
+  std::string GetSchedulerType () const;
 
   /**
    * Set an attribute for the scheduler to be created.
-   * 
+   *
    * \param n the name of the attribute
    * \param v the value of the attribute
    */
@@ -218,15 +220,15 @@
 
   /**
    * Set an attribute for the eNodeB devices (LteEnbNetDevice) to be created.
-   * 
+   *
    * \param n the name of the attribute.
    * \param v the value of the attribute
    */
   void SetEnbDeviceAttribute (std::string n, const AttributeValue &v);
 
-  /** 
+  /**
    * Set the type of antenna model to be used by eNodeB devices.
-   * 
+   *
    * \param type type of antenna model, must be a type name of any class
    *             inheriting from ns3::AntennaModel, for example:
    *             "ns3::IsotropicAntennaModel"
@@ -235,7 +237,7 @@
 
   /**
    * Set an attribute for the eNodeB antenna model to be created.
-   * 
+   *
    * \param n the name of the attribute.
    * \param v the value of the attribute
    */
@@ -249,9 +251,9 @@
    */
   void SetUeDeviceAttribute (std::string n, const AttributeValue &v);
 
-  /** 
+  /**
    * Set the type of antenna model to be used by UE devices.
-   * 
+   *
    * \param type type of antenna model, must be a type name of any class
    *             inheriting from ns3::AntennaModel, for example:
    *             "ns3::IsotropicAntennaModel"
@@ -260,13 +262,21 @@
 
   /**
    * Set an attribute for the UE antenna model to be created.
-   * 
+   *
    * \param n the name of the attribute
    * \param v the value of the attribute
    */
   void SetUeAntennaModelAttribute (std::string n, const AttributeValue &v);
 
-  /** 
+  /**
+   * This method is used to send the ComponentCarrier map created with CcHelper
+   * to the helper, the structure will be used within InstallSingleEnbDevice
+   *
+   * \param ccmap, the component carrier map
+   */
+  void SetEnbCc (std::map< uint8_t, Ptr<ComponentCarrier> > ccmap);
+
+  /**
    * Set the type of spectrum channel to be used in both DL and UL.
    *
    * \param type type of spectrum channel model, must be a type name of any
@@ -277,7 +287,7 @@
 
   /**
    * Set an attribute for the spectrum channel to be created (both DL and UL).
-   * 
+   *
    * \param n the name of the attribute
    * \param v the value of the attribute
    */
@@ -391,23 +401,23 @@
    */
   void Attach (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
 
-  /** 
+  /**
    * \brief Manual attachment of a set of UE devices to the network via the
    *        closest eNodeB (with respect to distance) among those in the set.
    * \param ueDevices the set of UE devices to be attached
    * \param enbDevices the set of eNodeB devices to be considered
-   * 
+   *
    * This function finds among the eNodeB set the closest eNodeB for each UE,
    * and then invokes manual attachment between the pair.
-   * 
+   *
    * Users are encouraged to use automatic attachment (Idle mode cell selection)
    * instead of this function.
-   * 
+   *
    * \sa LteHelper::Attach(NetDeviceContainer ueDevices);
    */
   void AttachToClosestEnb (NetDeviceContainer ueDevices, NetDeviceContainer enbDevices);
 
-  /** 
+  /**
    * \brief Manual attachment of a UE device to the network via the closest
    *        eNodeB (with respect to distance) among those in the set.
    * \param ueDevice the UE device to be attached
@@ -415,7 +425,7 @@
    *
    * This function finds among the eNodeB set the closest eNodeB for the UE,
    * and then invokes manual attachment between the pair.
-   * 
+   *
    * Users are encouraged to use automatic attachment (Idle mode cell selection)
    * instead of this function.
    *
@@ -483,27 +493,27 @@
                         Ptr<NetDevice> sourceEnbDev, Ptr<NetDevice> targetEnbDev);
 
 
-  /** 
+  /**
    * Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
-   * 
+   *
    * \param ueDevices the set of UE devices
    * \param bearer the characteristics of the bearer to be activated
    */
   void ActivateDataRadioBearer (NetDeviceContainer ueDevices,  EpsBearer bearer);
 
-  /** 
+  /**
    * Activate a Data Radio Bearer on a UE device (for LTE-only simulation).
    * This method will schedule the actual activation
    * the bearer so that it happens after the UE got connected.
-   * 
+   *
    * \param ueDevice the UE device
    * \param bearer the characteristics of the bearer to be activated
    */
   void ActivateDataRadioBearer (Ptr<NetDevice> ueDevice,  EpsBearer bearer);
 
-  /** 
+  /**
    * Set the type of fading model to be used in both DL and UL.
-   * 
+   *
    * \param type type of fading model, must be a type name of any class
    *             inheriting from ns3::SpectrumPropagationLossModel, for
    *             example: "ns3::TraceFadingLossModel"
@@ -585,8 +595,8 @@
    */
   void EnableRlcTraces (void);
 
-  /** 
-   * 
+  /**
+   *
    * \return the RLC stats calculator object
    */
   Ptr<RadioBearerStatsCalculator> GetRlcStats (void);
@@ -596,8 +606,8 @@
    */
   void EnablePdcpTraces (void);
 
-  /** 
-   * 
+  /**
+   *
    * \return the PDCP stats calculator object
    */
   Ptr<RadioBearerStatsCalculator> GetPdcpStats (void);
@@ -615,7 +625,7 @@
    *          LteNetDevice should be modified to use a fixed stream
    * \param stream first stream index to use
    * \return the number of stream indices (possibly zero) that have been assigned
-  */
+   */
   int64_t AssignStreams (NetDeviceContainer c, int64_t stream);
 
   void PrepareRrcCa (Ptr<NetDevice> ue, Ptr<NetDevice> enb);
@@ -624,6 +634,7 @@
   // inherited from Object
   virtual void DoInitialize (void);
 
+
 private:
   /**
    * Create an eNodeB device (LteEnbNetDevice) on the given node.
@@ -668,14 +679,16 @@
   void DoDeActivateDedicatedEpsBearer (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice, uint8_t bearerId);
 
 
+
+
   /// The downlink LTE channel used in the simulation.
-  Ptr<SpectrumChannel> m_downlinkChannel;
+  std::vector <Ptr<SpectrumChannel> > m_downlinkChannel;
   /// The uplink LTE channel used in the simulation.
-  Ptr<SpectrumChannel> m_uplinkChannel;
+  std::vector< Ptr<SpectrumChannel> > m_uplinkChannel;
   /// The path loss model used in the downlink channel.
-  Ptr<Object> m_downlinkPathlossModel;
+  std::vector< Ptr<Object> >  m_downlinkPathlossModel;
   /// The path loss model used in the uplink channel.
-  Ptr<Object> m_uplinkPathlossModel;
+  std::vector< Ptr<Object> > m_uplinkPathlossModel;
 
   /// Factory of MAC scheduler object.
   ObjectFactory m_schedulerFactory;
@@ -764,7 +777,23 @@
    */
   bool m_usePdschForCqiGeneration;
 
-}; // end of `class LteHelper`
+  /**
+   * The `UseCa` attribute. If true, Carrier Aggregation is enable.
+   * Hence, the helper will wait for a valid component carrier map
+   * If it is false, the component carrier will be created within the LteHelper
+   * this is to mantain the backwards compatibility with user script
+   */
+  bool m_useCa;
+
+  /**
+   * This contains all the information about each component carrier
+   * Moreover, there is also a pointer to LteEnbPhy Object.
+   */
+  std::map< uint8_t, Ptr<ComponentCarrier> > m_ccMap;
+
+  uint16_t m_noOfCcs;
+
+};   // end of `class LteHelper`
 
 
 } // namespace ns3
--- a/src/lte/helper/phy-stats-calculator.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/helper/phy-stats-calculator.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -1,6 +1,7 @@
 /* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
 /*
  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
+ * Copyright (c) 2015 Danilo Abrignani
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -16,6 +17,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * Author: Jaume Nin <jnin@cttc.es>
+ *         Danilo Abrignani <danilo.abrignani@unibo.it> (Modification due to new Architecture - Carrier Aggregation - GSoC 2015)
  */
 
 #include "phy-stats-calculator.h"
@@ -48,7 +50,7 @@
 {
   static TypeId tid = TypeId ("ns3::PhyStatsCalculator")
     .SetParent<LteStatsCalculator> ()
-    .SetGroupName("Lte")
+    .SetGroupName ("Lte")
     .AddConstructor<PhyStatsCalculator> ()
     .AddAttribute ("DlRsrpSinrFilename",
                    "Name of the file where the RSRP/SINR statistics will be saved.",
@@ -221,19 +223,21 @@
 
 void
 PhyStatsCalculator::ReportCurrentCellRsrpSinrCallback (Ptr<PhyStatsCalculator> phyStats,
-                      std::string path, uint16_t cellId, uint16_t rnti,
-                      double rsrp, double sinr)
+                                                       std::string path, uint16_t cellId, uint16_t rnti,
+                                                       double rsrp, double sinr)
 {
   NS_LOG_FUNCTION (phyStats << path);
   uint64_t imsi = 0;
-  std::string pathUePhy  = path.substr (0, path.find ("/ReportCurrentCellRsrpSinr"));
+  // std::string pathUePhy  = path.substr (0, path.find ("/ReportCurrentCellRsrpSinr"));
+  std::string pathUePhy  = path.substr (0, path.find ("/ComponentCarrierMapUe"));
   if (phyStats->ExistsImsiPath (pathUePhy) == true)
     {
       imsi = phyStats->GetImsiPath (pathUePhy);
     }
   else
     {
-      imsi = FindImsiFromUePhy (pathUePhy);
+      // imsi = FindImsiFromUePhy (pathUePhy);
+      imsi = FindImsiFromLteNetDevice (pathUePhy);
       phyStats->SetImsiPath (pathUePhy, imsi);
     }
 
@@ -242,7 +246,7 @@
 
 void
 PhyStatsCalculator::ReportUeSinr (Ptr<PhyStatsCalculator> phyStats, std::string path,
-              uint16_t cellId, uint16_t rnti, double sinrLinear)
+                                  uint16_t cellId, uint16_t rnti, double sinrLinear)
 {
   NS_LOG_FUNCTION (phyStats << path);
 
@@ -266,7 +270,7 @@
 
 void
 PhyStatsCalculator::ReportInterference (Ptr<PhyStatsCalculator> phyStats, std::string path,
-                    uint16_t cellId, Ptr<SpectrumValue> interference)
+                                        uint16_t cellId, Ptr<SpectrumValue> interference)
 {
   NS_LOG_FUNCTION (phyStats << path);
   phyStats->ReportInterference (cellId, interference);
--- a/src/lte/helper/radio-bearer-stats-calculator.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/helper/radio-bearer-stats-calculator.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -28,623 +28,623 @@
 
 namespace ns3 {
 
-NS_LOG_COMPONENT_DEFINE ("RadioBearerStatsCalculator");
+  NS_LOG_COMPONENT_DEFINE ("RadioBearerStatsCalculator");
 
-NS_OBJECT_ENSURE_REGISTERED ( RadioBearerStatsCalculator);
+  NS_OBJECT_ENSURE_REGISTERED ( RadioBearerStatsCalculator);
 
-RadioBearerStatsCalculator::RadioBearerStatsCalculator ()
-  : m_firstWrite (true),
-    m_pendingOutput (false), 
-    m_protocolType ("RLC")
-{
-  NS_LOG_FUNCTION (this);
-}
+  RadioBearerStatsCalculator::RadioBearerStatsCalculator ()
+    : m_firstWrite (true),
+      m_pendingOutput (false), 
+      m_protocolType ("RLC")
+  {
+    NS_LOG_FUNCTION (this);
+  }
 
-RadioBearerStatsCalculator::RadioBearerStatsCalculator (std::string protocolType)
-  : m_firstWrite (true),
-    m_pendingOutput (false)
-{
-  NS_LOG_FUNCTION (this);
-  m_protocolType = protocolType;
-}
+  RadioBearerStatsCalculator::RadioBearerStatsCalculator (std::string protocolType)
+    : m_firstWrite (true),
+      m_pendingOutput (false)
+  {
+    NS_LOG_FUNCTION (this);
+    m_protocolType = protocolType;
+  }
 
-RadioBearerStatsCalculator::~RadioBearerStatsCalculator ()
-{
-  NS_LOG_FUNCTION (this);
-}
+  RadioBearerStatsCalculator::~RadioBearerStatsCalculator ()
+  {
+    NS_LOG_FUNCTION (this);
+  }
 
-TypeId
-RadioBearerStatsCalculator::GetTypeId (void)
-{
-  static TypeId tid =
-    TypeId ("ns3::RadioBearerStatsCalculator")
-    .SetParent<LteStatsCalculator> ().AddConstructor<RadioBearerStatsCalculator> ()
-    .SetGroupName("Lte")
-    .AddAttribute ("StartTime", "Start time of the on going epoch.", 
-                   TimeValue (Seconds (0.)),
-                   MakeTimeAccessor (&RadioBearerStatsCalculator::SetStartTime,
-                                     &RadioBearerStatsCalculator::GetStartTime), 
-                   MakeTimeChecker ())
-    .AddAttribute ("EpochDuration", "Epoch duration.", 
-                   TimeValue (Seconds (0.25)), 
-                   MakeTimeAccessor (&RadioBearerStatsCalculator::GetEpoch,
-                                     &RadioBearerStatsCalculator::SetEpoch), 
-                   MakeTimeChecker ())
-    .AddAttribute ("DlRlcOutputFilename",
-                   "Name of the file where the downlink results will be saved.",
-                   StringValue ("DlRlcStats.txt"),
-                   MakeStringAccessor (&LteStatsCalculator::SetDlOutputFilename),
-                   MakeStringChecker ())
-    .AddAttribute ("UlRlcOutputFilename",
-                   "Name of the file where the uplink results will be saved.",
-                   StringValue ("UlRlcStats.txt"),
-                   MakeStringAccessor (&LteStatsCalculator::SetUlOutputFilename),
-                   MakeStringChecker ())
-    .AddAttribute ("DlPdcpOutputFilename",
-                   "Name of the file where the downlink results will be saved.",
-                   StringValue ("DlPdcpStats.txt"),
-                   MakeStringAccessor (&RadioBearerStatsCalculator::SetDlPdcpOutputFilename),
-                   MakeStringChecker ())
-    .AddAttribute ("UlPdcpOutputFilename",
-                   "Name of the file where the uplink results will be saved.",
-                   StringValue ("UlPdcpStats.txt"),
-                   MakeStringAccessor (&RadioBearerStatsCalculator::SetUlPdcpOutputFilename),
-                   MakeStringChecker ())
-  ;
-  return tid;
-}
+  TypeId
+  RadioBearerStatsCalculator::GetTypeId (void)
+  {
+    static TypeId tid =
+      TypeId ("ns3::RadioBearerStatsCalculator")
+      .SetParent<LteStatsCalculator> ().AddConstructor<RadioBearerStatsCalculator> ()
+      .SetGroupName("Lte")
+      .AddAttribute ("StartTime", "Start time of the on going epoch.", 
+                     TimeValue (Seconds (0.)),
+                     MakeTimeAccessor (&RadioBearerStatsCalculator::SetStartTime,
+                                       &RadioBearerStatsCalculator::GetStartTime), 
+                     MakeTimeChecker ())
+      .AddAttribute ("EpochDuration", "Epoch duration.", 
+                     TimeValue (Seconds (0.25)), 
+                     MakeTimeAccessor (&RadioBearerStatsCalculator::GetEpoch,
+                                       &RadioBearerStatsCalculator::SetEpoch), 
+                     MakeTimeChecker ())
+      .AddAttribute ("DlRlcOutputFilename",
+                     "Name of the file where the downlink results will be saved.",
+                     StringValue ("DlRlcStats.txt"),
+                     MakeStringAccessor (&LteStatsCalculator::SetDlOutputFilename),
+                     MakeStringChecker ())
+      .AddAttribute ("UlRlcOutputFilename",
+                     "Name of the file where the uplink results will be saved.",
+                     StringValue ("UlRlcStats.txt"),
+                     MakeStringAccessor (&LteStatsCalculator::SetUlOutputFilename),
+                     MakeStringChecker ())
+      .AddAttribute ("DlPdcpOutputFilename",
+                     "Name of the file where the downlink results will be saved.",
+                     StringValue ("DlPdcpStats.txt"),
+                     MakeStringAccessor (&RadioBearerStatsCalculator::SetDlPdcpOutputFilename),
+                     MakeStringChecker ())
+      .AddAttribute ("UlPdcpOutputFilename",
+                     "Name of the file where the uplink results will be saved.",
+                     StringValue ("UlPdcpStats.txt"),
+                     MakeStringAccessor (&RadioBearerStatsCalculator::SetUlPdcpOutputFilename),
+                     MakeStringChecker ())
+      ;
+    return tid;
+  }
 
-void
-RadioBearerStatsCalculator::DoDispose ()
-{
-  NS_LOG_FUNCTION (this);
-  if (m_pendingOutput)
-    {
-      ShowResults ();
-    }
-}
+  void
+  RadioBearerStatsCalculator::DoDispose ()
+  {
+    NS_LOG_FUNCTION (this);
+    if (m_pendingOutput)
+      {
+        ShowResults ();
+      }
+  }
 
-void 
-RadioBearerStatsCalculator::SetStartTime (Time t)
-{
-  m_startTime = t;
-  RescheduleEndEpoch ();
-}
+  void 
+  RadioBearerStatsCalculator::SetStartTime (Time t)
+  {
+    m_startTime = t;
+    RescheduleEndEpoch ();
+  }
 
-Time 
-RadioBearerStatsCalculator::GetStartTime () const
-{
-  return m_startTime;
-}
+  Time 
+  RadioBearerStatsCalculator::GetStartTime () const
+  {
+    return m_startTime;
+  }
 
-void 
-RadioBearerStatsCalculator::SetEpoch (Time e)
-{
-  m_epochDuration = e;
-  RescheduleEndEpoch ();
-}
+  void 
+  RadioBearerStatsCalculator::SetEpoch (Time e)
+  {
+    m_epochDuration = e;
+    RescheduleEndEpoch ();
+  }
 
-Time 
-RadioBearerStatsCalculator::GetEpoch () const
-{
-  return m_epochDuration;  
-}
+  Time 
+  RadioBearerStatsCalculator::GetEpoch () const
+  {
+    return m_epochDuration;  
+  }
 
-void
-RadioBearerStatsCalculator::UlTxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
-{
-  NS_LOG_FUNCTION (this << "UlTxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize);
-  ImsiLcidPair_t p (imsi, lcid);
-  if (Simulator::Now () >= m_startTime)
-    {
-      m_ulCellId[p] = cellId;
-      m_flowId[p] = LteFlowId_t (rnti, lcid);
-      m_ulTxPackets[p]++;
-      m_ulTxData[p] += packetSize;
-    }
-  m_pendingOutput = true;
-}
+  void
+  RadioBearerStatsCalculator::UlTxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
+  {
+    NS_LOG_FUNCTION (this << "UlTxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize);
+    ImsiLcidPair_t p (imsi, lcid);
+    if (Simulator::Now () >= m_startTime)
+      {
+        m_ulCellId[p] = cellId;
+        m_flowId[p] = LteFlowId_t (rnti, lcid);
+        m_ulTxPackets[p]++;
+        m_ulTxData[p] += packetSize;
+      }
+    m_pendingOutput = true;
+  }
 
-void
-RadioBearerStatsCalculator::DlTxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
-{
-  NS_LOG_FUNCTION (this << "DlTxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize);
-  ImsiLcidPair_t p (imsi, lcid);
-  if (Simulator::Now () >= m_startTime)
-    {
-      m_dlCellId[p] = cellId;
-      m_flowId[p] = LteFlowId_t (rnti, lcid);
-      m_dlTxPackets[p]++;
-      m_dlTxData[p] += packetSize;
-    }
-  m_pendingOutput = true;
-}
+  void
+  RadioBearerStatsCalculator::DlTxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
+  {
+    NS_LOG_FUNCTION (this << "DlTxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize);
+    ImsiLcidPair_t p (imsi, lcid);
+    if (Simulator::Now () >= m_startTime)
+      {
+        m_dlCellId[p] = cellId;
+        m_flowId[p] = LteFlowId_t (rnti, lcid);
+        m_dlTxPackets[p]++;
+        m_dlTxData[p] += packetSize;
+      }
+    m_pendingOutput = true;
+  }
 
-void
-RadioBearerStatsCalculator::UlRxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize,
-                                     uint64_t delay)
-{
-  NS_LOG_FUNCTION (this << "UlRxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize << delay);
-  ImsiLcidPair_t p (imsi, lcid);
-  if (Simulator::Now () >= m_startTime)
-    {
-      m_ulCellId[p] = cellId;
-      m_ulRxPackets[p]++;
-      m_ulRxData[p] += packetSize;
+  void
+  RadioBearerStatsCalculator::UlRxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize,
+                                       uint64_t delay)
+  {
+    NS_LOG_FUNCTION (this << "UlRxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize << delay);
+    ImsiLcidPair_t p (imsi, lcid);
+    if (Simulator::Now () >= m_startTime)
+      {
+        m_ulCellId[p] = cellId;
+        m_ulRxPackets[p]++;
+        m_ulRxData[p] += packetSize;
 
-      Uint64StatsMap::iterator it = m_ulDelay.find (p);
-      if (it == m_ulDelay.end ())
-        {
-          NS_LOG_DEBUG (this << " Creating UL stats calculators for IMSI " << p.m_imsi << " and LCID " << (uint32_t) p.m_lcId);
-          m_ulDelay[p] = CreateObject<MinMaxAvgTotalCalculator<uint64_t> > ();
-          m_ulPduSize[p] = CreateObject<MinMaxAvgTotalCalculator<uint32_t> > ();
-        }
-      m_ulDelay[p]->Update (delay);
-      m_ulPduSize[p]->Update (packetSize);
-    }
-  m_pendingOutput = true;
-}
+        Uint64StatsMap::iterator it = m_ulDelay.find (p);
+        if (it == m_ulDelay.end ())
+          {
+            NS_LOG_DEBUG (this << " Creating UL stats calculators for IMSI " << p.m_imsi << " and LCID " << (uint32_t) p.m_lcId);
+            m_ulDelay[p] = CreateObject<MinMaxAvgTotalCalculator<uint64_t> > ();
+            m_ulPduSize[p] = CreateObject<MinMaxAvgTotalCalculator<uint32_t> > ();
+          }
+        m_ulDelay[p]->Update (delay);
+        m_ulPduSize[p]->Update (packetSize);
+      }
+    m_pendingOutput = true;
+  }
 
-void
-RadioBearerStatsCalculator::DlRxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
-{
-  NS_LOG_FUNCTION (this << "DlRxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize << delay);
-  ImsiLcidPair_t p (imsi, lcid);
-  if (Simulator::Now () >= m_startTime)
-    {
-      m_dlCellId[p] = cellId;
-      m_dlRxPackets[p]++;
-      m_dlRxData[p] += packetSize;
+  void
+  RadioBearerStatsCalculator::DlRxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
+  {
+    NS_LOG_FUNCTION (this << "DlRxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize << delay);
+    ImsiLcidPair_t p (imsi, lcid);
+    if (Simulator::Now () >= m_startTime)
+      {
+        m_dlCellId[p] = cellId;
+        m_dlRxPackets[p]++;
+        m_dlRxData[p] += packetSize;
 
-      Uint64StatsMap::iterator it = m_dlDelay.find (p);
-      if (it == m_dlDelay.end ())
-        {
-          NS_LOG_DEBUG (this << " Creating DL stats calculators for IMSI " << p.m_imsi << " and LCID " << (uint32_t) p.m_lcId);
-          m_dlDelay[p] = CreateObject<MinMaxAvgTotalCalculator<uint64_t> > ();
-          m_dlPduSize[p] = CreateObject<MinMaxAvgTotalCalculator<uint32_t> > ();
-        }
-      m_dlDelay[p]->Update (delay);
-      m_dlPduSize[p]->Update (packetSize);
-    }
-  m_pendingOutput = true;
-}
+        Uint64StatsMap::iterator it = m_dlDelay.find (p);
+        if (it == m_dlDelay.end ())
+          {
+            NS_LOG_DEBUG (this << " Creating DL stats calculators for IMSI " << p.m_imsi << " and LCID " << (uint32_t) p.m_lcId);
+            m_dlDelay[p] = CreateObject<MinMaxAvgTotalCalculator<uint64_t> > ();
+            m_dlPduSize[p] = CreateObject<MinMaxAvgTotalCalculator<uint32_t> > ();
+          }
+        m_dlDelay[p]->Update (delay);
+        m_dlPduSize[p]->Update (packetSize);
+      }
+    m_pendingOutput = true;
+  }
 
-void
-RadioBearerStatsCalculator::ShowResults (void)
-{
+  void
+  RadioBearerStatsCalculator::ShowResults (void)
+  {
 
-  NS_LOG_FUNCTION (this << GetUlOutputFilename ().c_str () << GetDlOutputFilename ().c_str ());
-  NS_LOG_INFO ("Write Rlc Stats in " << GetUlOutputFilename ().c_str () << " and in " << GetDlOutputFilename ().c_str ());
+    NS_LOG_FUNCTION (this << GetUlOutputFilename ().c_str () << GetDlOutputFilename ().c_str ());
+    NS_LOG_INFO ("Write Rlc Stats in " << GetUlOutputFilename ().c_str () << " and in " << GetDlOutputFilename ().c_str ());
 
-  std::ofstream ulOutFile;
-  std::ofstream dlOutFile;
+    std::ofstream ulOutFile;
+    std::ofstream dlOutFile;
 
-  if (m_firstWrite == true)
-    {
-      ulOutFile.open (GetUlOutputFilename ().c_str ());
-      if (!ulOutFile.is_open ())
-        {
-          NS_LOG_ERROR ("Can't open file " << GetUlOutputFilename ().c_str ());
-          return;
-        }
+    if (m_firstWrite == true)
+      {
+        ulOutFile.open (GetUlOutputFilename ().c_str ());
+        if (!ulOutFile.is_open ())
+          {
+            NS_LOG_ERROR ("Can't open file " << GetUlOutputFilename ().c_str ());
+            return;
+          }
 
-      dlOutFile.open (GetDlOutputFilename ().c_str ());
-      if (!dlOutFile.is_open ())
-        {
-          NS_LOG_ERROR ("Can't open file " << GetDlOutputFilename ().c_str ());
-          return;
-        }
-      m_firstWrite = false;
-      ulOutFile << "% start\tend\tCellId\tIMSI\tRNTI\tLCID\tnTxPDUs\tTxBytes\tnRxPDUs\tRxBytes\t";
-      ulOutFile << "delay\tstdDev\tmin\tmax\t";
-      ulOutFile << "PduSize\tstdDev\tmin\tmax";
-      ulOutFile << std::endl;
-      dlOutFile << "% start\tend\tCellId\tIMSI\tRNTI\tLCID\tnTxPDUs\tTxBytes\tnRxPDUs\tRxBytes\t";
-      dlOutFile << "delay\tstdDev\tmin\tmax\t";
-      dlOutFile << "PduSize\tstdDev\tmin\tmax";
-      dlOutFile << std::endl;
-    }
-  else
-    {
-      ulOutFile.open (GetUlOutputFilename ().c_str (), std::ios_base::app);
-      if (!ulOutFile.is_open ())
-        {
-          NS_LOG_ERROR ("Can't open file " << GetUlOutputFilename ().c_str ());
-          return;
-        }
+        dlOutFile.open (GetDlOutputFilename ().c_str ());
+        if (!dlOutFile.is_open ())
+          {
+            NS_LOG_ERROR ("Can't open file " << GetDlOutputFilename ().c_str ());
+            return;
+          }
+        m_firstWrite = false;
+        ulOutFile << "% start\tend\tCellId\tIMSI\tRNTI\tLCID\tnTxPDUs\tTxBytes\tnRxPDUs\tRxBytes\t";
+        ulOutFile << "delay\tstdDev\tmin\tmax\t";
+        ulOutFile << "PduSize\tstdDev\tmin\tmax";
+        ulOutFile << std::endl;
+        dlOutFile << "% start\tend\tCellId\tIMSI\tRNTI\tLCID\tnTxPDUs\tTxBytes\tnRxPDUs\tRxBytes\t";
+        dlOutFile << "delay\tstdDev\tmin\tmax\t";
+        dlOutFile << "PduSize\tstdDev\tmin\tmax";
+        dlOutFile << std::endl;
+      }
+    else
+      {
+        ulOutFile.open (GetUlOutputFilename ().c_str (), std::ios_base::app);
+        if (!ulOutFile.is_open ())
+          {
+            NS_LOG_ERROR ("Can't open file " << GetUlOutputFilename ().c_str ());
+            return;
+          }
 
-      dlOutFile.open (GetDlOutputFilename ().c_str (), std::ios_base::app);
-      if (!dlOutFile.is_open ())
-        {
-          NS_LOG_ERROR ("Can't open file " << GetDlOutputFilename ().c_str ());
-          return;
-        }
-    }
+        dlOutFile.open (GetDlOutputFilename ().c_str (), std::ios_base::app);
+        if (!dlOutFile.is_open ())
+          {
+            NS_LOG_ERROR ("Can't open file " << GetDlOutputFilename ().c_str ());
+            return;
+          }
+      }
 
-  WriteUlResults (ulOutFile);
-  WriteDlResults (dlOutFile);
-  m_pendingOutput = false;
+    WriteUlResults (ulOutFile);
+    WriteDlResults (dlOutFile);
+    m_pendingOutput = false;
 
-}
+  }
 
-void
-RadioBearerStatsCalculator::WriteUlResults (std::ofstream& outFile)
-{
-  NS_LOG_FUNCTION (this);
+  void
+  RadioBearerStatsCalculator::WriteUlResults (std::ofstream& outFile)
+  {
+    NS_LOG_FUNCTION (this);
 
-  // Get the unique IMSI / LCID list
+    // Get the unique IMSI / LCID list
 
-  std::vector < ImsiLcidPair_t > pairVector;
-  for (Uint32Map::iterator it = m_ulTxPackets.begin (); it != m_ulTxPackets.end (); ++it)
-    {
-      if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
-        {
-          pairVector.push_back ((*it).first);
-        }
-    }
+    std::vector < ImsiLcidPair_t > pairVector;
+    for (Uint32Map::iterator it = m_ulTxPackets.begin (); it != m_ulTxPackets.end (); ++it)
+      {
+        if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
+          {
+            pairVector.push_back ((*it).first);
+          }
+      }
 
-  Time endTime = m_startTime + m_epochDuration;
-  for (std::vector<ImsiLcidPair_t>::iterator it = pairVector.begin (); it != pairVector.end (); ++it)
-    {
-      ImsiLcidPair_t p = *it;
-      outFile << m_startTime.GetNanoSeconds () / 1.0e9 << "\t";
-      outFile << endTime.GetNanoSeconds () / 1.0e9 << "\t";
-      outFile << GetUlCellId (p.m_imsi, p.m_lcId) << "\t";
-      outFile << p.m_imsi << "\t";
-      outFile << m_flowId[p].m_rnti << "\t";
-      outFile << (uint32_t) m_flowId[p].m_lcId << "\t";
-      outFile << GetUlTxPackets (p.m_imsi, p.m_lcId) << "\t";
-      outFile << GetUlTxData (p.m_imsi, p.m_lcId) << "\t";
-      outFile << GetUlRxPackets (p.m_imsi, p.m_lcId) << "\t";
-      outFile << GetUlRxData (p.m_imsi, p.m_lcId) << "\t";
-      std::vector<double> stats = GetUlDelayStats (p.m_imsi, p.m_lcId);
-      for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
-        {
-          outFile << (*it) * 1e-9 << "\t";
-        }
-      stats = GetUlPduSizeStats (p.m_imsi, p.m_lcId);
-      for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
-        {
-          outFile << (*it) << "\t";
-        }
-      outFile << std::endl;
-    }
+    Time endTime = m_startTime + m_epochDuration;
+    for (std::vector<ImsiLcidPair_t>::iterator it = pairVector.begin (); it != pairVector.end (); ++it)
+      {
+        ImsiLcidPair_t p = *it;
+        outFile << m_startTime.GetNanoSeconds () / 1.0e9 << "\t";
+        outFile << endTime.GetNanoSeconds () / 1.0e9 << "\t";
+        outFile << GetUlCellId (p.m_imsi, p.m_lcId) << "\t";
+        outFile << p.m_imsi << "\t";
+        outFile << m_flowId[p].m_rnti << "\t";
+        outFile << (uint32_t) m_flowId[p].m_lcId << "\t";
+        outFile << GetUlTxPackets (p.m_imsi, p.m_lcId) << "\t";
+        outFile << GetUlTxData (p.m_imsi, p.m_lcId) << "\t";
+        outFile << GetUlRxPackets (p.m_imsi, p.m_lcId) << "\t";
+        outFile << GetUlRxData (p.m_imsi, p.m_lcId) << "\t";
+        std::vector<double> stats = GetUlDelayStats (p.m_imsi, p.m_lcId);
+        for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
+          {
+            outFile << (*it) * 1e-9 << "\t";
+          }
+        stats = GetUlPduSizeStats (p.m_imsi, p.m_lcId);
+        for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
+          {
+            outFile << (*it) << "\t";
+          }
+        outFile << std::endl;
+      }
 
-  outFile.close ();
-}
+    outFile.close ();
+  }
 
-void
-RadioBearerStatsCalculator::WriteDlResults (std::ofstream& outFile)
-{
-  NS_LOG_FUNCTION (this);
+  void
+  RadioBearerStatsCalculator::WriteDlResults (std::ofstream& outFile)
+  {
+    NS_LOG_FUNCTION (this);
 
-  // Get the unique IMSI list
-  std::vector < ImsiLcidPair_t > pairVector;
-  for (Uint32Map::iterator it = m_dlTxPackets.begin (); it != m_dlTxPackets.end (); ++it)
-    {
-      if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
-        {
-          pairVector.push_back ((*it).first);
-        }
-    }
+    // Get the unique IMSI list
+    std::vector < ImsiLcidPair_t > pairVector;
+    for (Uint32Map::iterator it = m_dlTxPackets.begin (); it != m_dlTxPackets.end (); ++it)
+      {
+        if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
+          {
+            pairVector.push_back ((*it).first);
+          }
+      }
 
-  Time endTime = m_startTime + m_epochDuration;
-  for (std::vector<ImsiLcidPair_t>::iterator pair = pairVector.begin (); pair != pairVector.end (); ++pair)
-    {
-      ImsiLcidPair_t p = *pair;
-      outFile << m_startTime.GetNanoSeconds () / 1.0e9 << "\t";
-      outFile << endTime.GetNanoSeconds () / 1.0e9 << "\t";
-      outFile << GetDlCellId (p.m_imsi, p.m_lcId) << "\t";
-      outFile << p.m_imsi << "\t";
-      outFile << m_flowId[p].m_rnti << "\t";
-      outFile << (uint32_t) m_flowId[p].m_lcId << "\t";
-      outFile << GetDlTxPackets (p.m_imsi, p.m_lcId) << "\t";
-      outFile << GetDlTxData (p.m_imsi, p.m_lcId) << "\t";
-      outFile << GetDlRxPackets (p.m_imsi, p.m_lcId) << "\t";
-      outFile << GetDlRxData (p.m_imsi, p.m_lcId) << "\t";
-      std::vector<double> stats = GetDlDelayStats (p.m_imsi, p.m_lcId);
-      for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
-        {
-          outFile << (*it) * 1e-9 << "\t";
-        }
-      stats = GetDlPduSizeStats (p.m_imsi, p.m_lcId);
-      for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
-        {
-          outFile << (*it) << "\t";
-        }
-      outFile << std::endl;
-    }
+    Time endTime = m_startTime + m_epochDuration;
+    for (std::vector<ImsiLcidPair_t>::iterator pair = pairVector.begin (); pair != pairVector.end (); ++pair)
+      {
+        ImsiLcidPair_t p = *pair;
+        outFile << m_startTime.GetNanoSeconds () / 1.0e9 << "\t";
+        outFile << endTime.GetNanoSeconds () / 1.0e9 << "\t";
+        outFile << GetDlCellId (p.m_imsi, p.m_lcId) << "\t";
+        outFile << p.m_imsi << "\t";
+        outFile << m_flowId[p].m_rnti << "\t";
+        outFile << (uint32_t) m_flowId[p].m_lcId << "\t";
+        outFile << GetDlTxPackets (p.m_imsi, p.m_lcId) << "\t";
+        outFile << GetDlTxData (p.m_imsi, p.m_lcId) << "\t";
+        outFile << GetDlRxPackets (p.m_imsi, p.m_lcId) << "\t";
+        outFile << GetDlRxData (p.m_imsi, p.m_lcId) << "\t";
+        std::vector<double> stats = GetDlDelayStats (p.m_imsi, p.m_lcId);
+        for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
+          {
+            outFile << (*it) * 1e-9 << "\t";
+          }
+        stats = GetDlPduSizeStats (p.m_imsi, p.m_lcId);
+        for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
+          {
+            outFile << (*it) << "\t";
+          }
+        outFile << std::endl;
+      }
 
-  outFile.close ();
-}
+    outFile.close ();
+  }
 
-void
-RadioBearerStatsCalculator::ResetResults (void)
-{
-  NS_LOG_FUNCTION (this);
+  void
+  RadioBearerStatsCalculator::ResetResults (void)
+  {
+    NS_LOG_FUNCTION (this);
 
-  m_ulTxPackets.erase (m_ulTxPackets.begin (), m_ulTxPackets.end ());
-  m_ulRxPackets.erase (m_ulRxPackets.begin (), m_ulRxPackets.end ());
-  m_ulRxData.erase (m_ulRxData.begin (), m_ulRxData.end ());
-  m_ulTxData.erase (m_ulTxData.begin (), m_ulTxData.end ());
-  m_ulDelay.erase (m_ulDelay.begin (), m_ulDelay.end ());
-  m_ulPduSize.erase (m_ulPduSize.begin (), m_ulPduSize.end ());
+    m_ulTxPackets.erase (m_ulTxPackets.begin (), m_ulTxPackets.end ());
+    m_ulRxPackets.erase (m_ulRxPackets.begin (), m_ulRxPackets.end ());
+    m_ulRxData.erase (m_ulRxData.begin (), m_ulRxData.end ());
+    m_ulTxData.erase (m_ulTxData.begin (), m_ulTxData.end ());
+    m_ulDelay.erase (m_ulDelay.begin (), m_ulDelay.end ());
+    m_ulPduSize.erase (m_ulPduSize.begin (), m_ulPduSize.end ());
 
-  m_dlTxPackets.erase (m_dlTxPackets.begin (), m_dlTxPackets.end ());
-  m_dlRxPackets.erase (m_dlRxPackets.begin (), m_dlRxPackets.end ());
-  m_dlRxData.erase (m_dlRxData.begin (), m_dlRxData.end ());
-  m_dlTxData.erase (m_dlTxData.begin (), m_dlTxData.end ());
-  m_dlDelay.erase (m_dlDelay.begin (), m_dlDelay.end ());
-  m_dlPduSize.erase (m_dlPduSize.begin (), m_dlPduSize.end ());
-}
+    m_dlTxPackets.erase (m_dlTxPackets.begin (), m_dlTxPackets.end ());
+    m_dlRxPackets.erase (m_dlRxPackets.begin (), m_dlRxPackets.end ());
+    m_dlRxData.erase (m_dlRxData.begin (), m_dlRxData.end ());
+    m_dlTxData.erase (m_dlTxData.begin (), m_dlTxData.end ());
+    m_dlDelay.erase (m_dlDelay.begin (), m_dlDelay.end ());
+    m_dlPduSize.erase (m_dlPduSize.begin (), m_dlPduSize.end ());
+  }
 
-void
-RadioBearerStatsCalculator::RescheduleEndEpoch (void)
-{
-  NS_LOG_FUNCTION (this);
-  m_endEpochEvent.Cancel ();
-  NS_ASSERT (Simulator::Now ().GetMilliSeconds () == 0); // below event time assumes this
-  m_endEpochEvent = Simulator::Schedule (m_startTime + m_epochDuration, &RadioBearerStatsCalculator::EndEpoch, this);
-}
+  void
+  RadioBearerStatsCalculator::RescheduleEndEpoch (void)
+  {
+    NS_LOG_FUNCTION (this);
+    m_endEpochEvent.Cancel ();
+    NS_ASSERT (Simulator::Now ().GetMilliSeconds () == 0); // below event time assumes this
+    m_endEpochEvent = Simulator::Schedule (m_startTime + m_epochDuration, &RadioBearerStatsCalculator::EndEpoch, this);
+  }
 
-void
-RadioBearerStatsCalculator::EndEpoch (void)
-{
-  NS_LOG_FUNCTION (this);
-  ShowResults ();
-  ResetResults ();
-  m_startTime += m_epochDuration;
-  m_endEpochEvent = Simulator::Schedule (m_epochDuration, &RadioBearerStatsCalculator::EndEpoch, this);
-}
+  void
+  RadioBearerStatsCalculator::EndEpoch (void)
+  {
+    NS_LOG_FUNCTION (this);
+    ShowResults ();
+    ResetResults ();
+    m_startTime += m_epochDuration;
+    m_endEpochEvent = Simulator::Schedule (m_epochDuration, &RadioBearerStatsCalculator::EndEpoch, this);
+  }
 
-uint32_t
-RadioBearerStatsCalculator::GetUlTxPackets (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  return m_ulTxPackets[p];
-}
+  uint32_t
+  RadioBearerStatsCalculator::GetUlTxPackets (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    return m_ulTxPackets[p];
+  }
 
-uint32_t
-RadioBearerStatsCalculator::GetUlRxPackets (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  return m_ulRxPackets[p];
-}
+  uint32_t
+  RadioBearerStatsCalculator::GetUlRxPackets (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    return m_ulRxPackets[p];
+  }
 
-uint64_t
-RadioBearerStatsCalculator::GetUlTxData (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  return m_ulTxData[p];
-}
+  uint64_t
+  RadioBearerStatsCalculator::GetUlTxData (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    return m_ulTxData[p];
+  }
 
-uint64_t
-RadioBearerStatsCalculator::GetUlRxData (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  return m_ulRxData[p];
-}
+  uint64_t
+  RadioBearerStatsCalculator::GetUlRxData (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    return m_ulRxData[p];
+  }
 
-double
-RadioBearerStatsCalculator::GetUlDelay (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  Uint64StatsMap::iterator it = m_ulDelay.find (p);
-  if (it == m_ulDelay.end ())
-    {
-      NS_LOG_ERROR ("UL delay for " << imsi << " - " << (uint16_t) lcid << " not found");
-      return 0;
+  double
+  RadioBearerStatsCalculator::GetUlDelay (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    Uint64StatsMap::iterator it = m_ulDelay.find (p);
+    if (it == m_ulDelay.end ())
+      {
+        NS_LOG_ERROR ("UL delay for " << imsi << " - " << (uint16_t) lcid << " not found");
+        return 0;
 
-    }
-  return m_ulDelay[p]->getMean ();
-}
+      }
+    return m_ulDelay[p]->getMean ();
+  }
 
-std::vector<double>
-RadioBearerStatsCalculator::GetUlDelayStats (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  std::vector<double> stats;
-  Uint64StatsMap::iterator it = m_ulDelay.find (p);
-  if (it == m_ulDelay.end ())
-    {
-      stats.push_back (0.0);
-      stats.push_back (0.0);
-      stats.push_back (0.0);
-      stats.push_back (0.0);
-      return stats;
+  std::vector<double>
+  RadioBearerStatsCalculator::GetUlDelayStats (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    std::vector<double> stats;
+    Uint64StatsMap::iterator it = m_ulDelay.find (p);
+    if (it == m_ulDelay.end ())
+      {
+        stats.push_back (0.0);
+        stats.push_back (0.0);
+        stats.push_back (0.0);
+        stats.push_back (0.0);
+        return stats;
 
-    }
-  stats.push_back (m_ulDelay[p]->getMean ());
-  stats.push_back (m_ulDelay[p]->getStddev ());
-  stats.push_back (m_ulDelay[p]->getMin ());
-  stats.push_back (m_ulDelay[p]->getMax ());
-  return stats;
-}
+      }
+    stats.push_back (m_ulDelay[p]->getMean ());
+    stats.push_back (m_ulDelay[p]->getStddev ());
+    stats.push_back (m_ulDelay[p]->getMin ());
+    stats.push_back (m_ulDelay[p]->getMax ());
+    return stats;
+  }
 
-std::vector<double>
-RadioBearerStatsCalculator::GetUlPduSizeStats (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  std::vector<double> stats;
-  Uint32StatsMap::iterator it = m_ulPduSize.find (p);
-  if (it == m_ulPduSize.end ())
-    {
-      stats.push_back (0.0);
-      stats.push_back (0.0);
-      stats.push_back (0.0);
-      stats.push_back (0.0);
-      return stats;
+  std::vector<double>
+  RadioBearerStatsCalculator::GetUlPduSizeStats (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    std::vector<double> stats;
+    Uint32StatsMap::iterator it = m_ulPduSize.find (p);
+    if (it == m_ulPduSize.end ())
+      {
+        stats.push_back (0.0);
+        stats.push_back (0.0);
+        stats.push_back (0.0);
+        stats.push_back (0.0);
+        return stats;
 
-    }
-  stats.push_back (m_ulPduSize[p]->getMean ());
-  stats.push_back (m_ulPduSize[p]->getStddev ());
-  stats.push_back (m_ulPduSize[p]->getMin ());
-  stats.push_back (m_ulPduSize[p]->getMax ());
-  return stats;
-}
+      }
+    stats.push_back (m_ulPduSize[p]->getMean ());
+    stats.push_back (m_ulPduSize[p]->getStddev ());
+    stats.push_back (m_ulPduSize[p]->getMin ());
+    stats.push_back (m_ulPduSize[p]->getMax ());
+    return stats;
+  }
 
-uint32_t
-RadioBearerStatsCalculator::GetDlTxPackets (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  return m_dlTxPackets[p];
-}
+  uint32_t
+  RadioBearerStatsCalculator::GetDlTxPackets (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    return m_dlTxPackets[p];
+  }
 
-uint32_t
-RadioBearerStatsCalculator::GetDlRxPackets (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  return m_dlRxPackets[p];
-}
+  uint32_t
+  RadioBearerStatsCalculator::GetDlRxPackets (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    return m_dlRxPackets[p];
+  }
 
-uint64_t
-RadioBearerStatsCalculator::GetDlTxData (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  return m_dlTxData[p];
-}
+  uint64_t
+  RadioBearerStatsCalculator::GetDlTxData (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    return m_dlTxData[p];
+  }
 
-uint64_t
-RadioBearerStatsCalculator::GetDlRxData (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  return m_dlRxData[p];
-}
+  uint64_t
+  RadioBearerStatsCalculator::GetDlRxData (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    return m_dlRxData[p];
+  }
 
-uint32_t
-RadioBearerStatsCalculator::GetUlCellId (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  return m_ulCellId[p];
-}
+  uint32_t
+  RadioBearerStatsCalculator::GetUlCellId (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    return m_ulCellId[p];
+  }
 
-uint32_t
-RadioBearerStatsCalculator::GetDlCellId (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  return m_dlCellId[p];
-}
+  uint32_t
+  RadioBearerStatsCalculator::GetDlCellId (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    return m_dlCellId[p];
+  }
 
-double
-RadioBearerStatsCalculator::GetDlDelay (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  Uint64StatsMap::iterator it = m_dlDelay.find (p);
-  if (it == m_dlDelay.end ())
-    {
-      NS_LOG_ERROR ("DL delay for " << imsi << " not found");
-      return 0;
-    }
-  return m_dlDelay[p]->getMean ();
-}
+  double
+  RadioBearerStatsCalculator::GetDlDelay (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    Uint64StatsMap::iterator it = m_dlDelay.find (p);
+    if (it == m_dlDelay.end ())
+      {
+        NS_LOG_ERROR ("DL delay for " << imsi << " not found");
+        return 0;
+      }
+    return m_dlDelay[p]->getMean ();
+  }
 
-std::vector<double>
-RadioBearerStatsCalculator::GetDlDelayStats (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  std::vector<double> stats;
-  Uint64StatsMap::iterator it = m_dlDelay.find (p);
-  if (it == m_dlDelay.end ())
-    {
-      stats.push_back (0.0);
-      stats.push_back (0.0);
-      stats.push_back (0.0);
-      stats.push_back (0.0);
-      return stats;
+  std::vector<double>
+  RadioBearerStatsCalculator::GetDlDelayStats (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    std::vector<double> stats;
+    Uint64StatsMap::iterator it = m_dlDelay.find (p);
+    if (it == m_dlDelay.end ())
+      {
+        stats.push_back (0.0);
+        stats.push_back (0.0);
+        stats.push_back (0.0);
+        stats.push_back (0.0);
+        return stats;
 
-    }
-  stats.push_back (m_dlDelay[p]->getMean ());
-  stats.push_back (m_dlDelay[p]->getStddev ());
-  stats.push_back (m_dlDelay[p]->getMin ());
-  stats.push_back (m_dlDelay[p]->getMax ());
-  return stats;
-}
+      }
+    stats.push_back (m_dlDelay[p]->getMean ());
+    stats.push_back (m_dlDelay[p]->getStddev ());
+    stats.push_back (m_dlDelay[p]->getMin ());
+    stats.push_back (m_dlDelay[p]->getMax ());
+    return stats;
+  }
 
-std::vector<double>
-RadioBearerStatsCalculator::GetDlPduSizeStats (uint64_t imsi, uint8_t lcid)
-{
-  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
-  ImsiLcidPair_t p (imsi, lcid);
-  std::vector<double> stats;
-  Uint32StatsMap::iterator it = m_dlPduSize.find (p);
-  if (it == m_dlPduSize.end ())
-    {
-      stats.push_back (0.0);
-      stats.push_back (0.0);
-      stats.push_back (0.0);
-      stats.push_back (0.0);
-      return stats;
+  std::vector<double>
+  RadioBearerStatsCalculator::GetDlPduSizeStats (uint64_t imsi, uint8_t lcid)
+  {
+    NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
+    ImsiLcidPair_t p (imsi, lcid);
+    std::vector<double> stats;
+    Uint32StatsMap::iterator it = m_dlPduSize.find (p);
+    if (it == m_dlPduSize.end ())
+      {
+        stats.push_back (0.0);
+        stats.push_back (0.0);
+        stats.push_back (0.0);
+        stats.push_back (0.0);
+        return stats;
 
-    }
-  stats.push_back (m_dlPduSize[p]->getMean ());
-  stats.push_back (m_dlPduSize[p]->getStddev ());
-  stats.push_back (m_dlPduSize[p]->getMin ());
-  stats.push_back (m_dlPduSize[p]->getMax ());
-  return stats;
-}
+      }
+    stats.push_back (m_dlPduSize[p]->getMean ());
+    stats.push_back (m_dlPduSize[p]->getStddev ());
+    stats.push_back (m_dlPduSize[p]->getMin ());
+    stats.push_back (m_dlPduSize[p]->getMax ());
+    return stats;
+  }
 
-std::string
-RadioBearerStatsCalculator::GetUlOutputFilename (void)
-{
-  if (m_protocolType == "RLC")
-    {
-      return LteStatsCalculator::GetUlOutputFilename ();
-    }
-  else
-    {
-      return GetUlPdcpOutputFilename ();
-    }
-}
+  std::string
+  RadioBearerStatsCalculator::GetUlOutputFilename (void)
+  {
+    if (m_protocolType == "RLC")
+      {
+        return LteStatsCalculator::GetUlOutputFilename ();
+      }
+    else
+      {
+        return GetUlPdcpOutputFilename ();
+      }
+  }
 
-std::string
-RadioBearerStatsCalculator::GetDlOutputFilename (void)
-{
-  if (m_protocolType == "RLC")
-    {
-      return LteStatsCalculator::GetDlOutputFilename ();
-    }
-  else
-    {
-      return GetDlPdcpOutputFilename ();
-    }
-}
+  std::string
+  RadioBearerStatsCalculator::GetDlOutputFilename (void)
+  {
+    if (m_protocolType == "RLC")
+      {
+        return LteStatsCalculator::GetDlOutputFilename ();
+      }
+    else
+      {
+        return GetDlPdcpOutputFilename ();
+      }
+  }
 
-void
-RadioBearerStatsCalculator::SetUlPdcpOutputFilename (std::string outputFilename)
-{
-  m_ulPdcpOutputFilename = outputFilename;
-}
+  void
+  RadioBearerStatsCalculator::SetUlPdcpOutputFilename (std::string outputFilename)
+  {
+    m_ulPdcpOutputFilename = outputFilename;
+  }
 
-std::string
-RadioBearerStatsCalculator::GetUlPdcpOutputFilename (void)
-{
-  return m_ulPdcpOutputFilename;
-}
-void
-RadioBearerStatsCalculator::SetDlPdcpOutputFilename (std::string outputFilename)
-{
-  m_dlPdcpOutputFilename = outputFilename;
-}
+  std::string
+  RadioBearerStatsCalculator::GetUlPdcpOutputFilename (void)
+  {
+    return m_ulPdcpOutputFilename;
+  }
+  void
+  RadioBearerStatsCalculator::SetDlPdcpOutputFilename (std::string outputFilename)
+  {
+    m_dlPdcpOutputFilename = outputFilename;
+  }
 
-std::string
-RadioBearerStatsCalculator::GetDlPdcpOutputFilename (void)
-{
-  return m_dlPdcpOutputFilename;
-}
+  std::string
+  RadioBearerStatsCalculator::GetDlPdcpOutputFilename (void)
+  {
+    return m_dlPdcpOutputFilename;
+  }
 
 } // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/component-carrier-ue.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -0,0 +1,255 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2015 Danilo Abrignani
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Danilo Abrignani <danilo.abrignani@unibo.it>
+ */
+
+#include "component-carrier-ue.h"
+#include <ns3/uinteger.h>
+#include <ns3/boolean.h>
+#include <ns3/simulator.h>
+#include <ns3/log.h>
+#include <ns3/abort.h>
+#include <ns3/lte-ue-phy.h>
+#include <ns3/pointer.h>
+
+namespace ns3 {
+
+NS_LOG_COMPONENT_DEFINE ("ComponentCarrierUe");
+
+NS_OBJECT_ENSURE_REGISTERED ( ComponentCarrierUe);
+
+TypeId ComponentCarrierUe::GetTypeId (void)
+{
+  static TypeId
+    tid =
+    TypeId ("ns3::ComponentCarrierUe")
+    .SetParent<Object> ()
+    .AddConstructor<ComponentCarrierUe> ()
+    .AddAttribute ("UlBandwidth",
+                   "Uplink Transmission Bandwidth Configuration in number of Resource Blocks",
+                   UintegerValue (25),
+                   MakeUintegerAccessor (&ComponentCarrierUe::SetUlBandwidth,
+                                         &ComponentCarrierUe::GetUlBandwidth),
+                   MakeUintegerChecker<uint8_t> ())
+    .AddAttribute ("DlBandwidth",
+                   "Downlink Transmission Bandwidth Configuration in number of Resource Blocks",
+                   UintegerValue (25),
+                   MakeUintegerAccessor (&ComponentCarrierUe::SetDlBandwidth,
+                                         &ComponentCarrierUe::GetDlBandwidth),
+                   MakeUintegerChecker<uint8_t> ())
+    .AddAttribute ("DlEarfcn",
+                   "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
+                   "as per 3GPP 36.101 Section 5.7.3. ",
+                   UintegerValue (100),
+                   MakeUintegerAccessor (&ComponentCarrierUe::m_dlEarfcn),
+                   MakeUintegerChecker<uint16_t> (0, 6599))
+    .AddAttribute ("UlEarfcn",
+                   "Uplink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
+                   "as per 3GPP 36.101 Section 5.7.3. ",
+                   UintegerValue (18100),
+                   MakeUintegerAccessor (&ComponentCarrierUe::m_ulEarfcn),
+                   MakeUintegerChecker<uint16_t> (18000, 24599))
+    .AddAttribute ("CsgId",
+                   "The Closed Subscriber Group (CSG) identity that this eNodeB belongs to",
+                   UintegerValue (0),
+                   MakeUintegerAccessor (&ComponentCarrierUe::SetCsgId,
+                                         &ComponentCarrierUe::GetCsgId),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("CsgIndication",
+                   "If true, only UEs which are members of the CSG (i.e. same CSG ID) "
+                   "can gain access to the eNodeB, therefore enforcing closed access mode. "
+                   "Otherwise, the eNodeB operates as a non-CSG cell and implements open access mode.",
+                   BooleanValue (false),
+                   MakeBooleanAccessor (&ComponentCarrierUe::SetCsgIndication,
+                                        &ComponentCarrierUe::GetCsgIndication),
+                   MakeBooleanChecker ())
+    .AddAttribute ("PrimaryCarrier",
+                   "If true, this Carrier Component will be the Primary Carrier Component (PCC) "
+                   "Only one PCC per eNodeB is (currently) allowed",
+                   BooleanValue (false),
+                   MakeBooleanAccessor (&ComponentCarrierUe::SetPrimaryCarrier,
+                                        &ComponentCarrierUe::GetPrimaryCarrier),
+                   MakeBooleanChecker ())
+    .AddAttribute ("LteUePhy",
+                   "The PHY associated to this EnbNetDevice",
+                   PointerValue (),
+                   MakePointerAccessor (&ComponentCarrierUe::m_phy),
+                   MakePointerChecker <LteUePhy> ())
+  ;
+  return tid;
+}
+ComponentCarrierUe::ComponentCarrierUe ()
+  : m_isConstructed (false)
+{
+  NS_LOG_FUNCTION (this);
+}
+
+ComponentCarrierUe::~ComponentCarrierUe (void)
+{
+  NS_LOG_FUNCTION (this);
+}
+
+void
+ComponentCarrierUe::DoDispose ()
+{
+  NS_LOG_FUNCTION (this);
+  m_phy->Dispose ();
+  m_phy = 0;
+
+  Object::DoDispose ();
+}
+
+uint8_t
+ComponentCarrierUe::GetUlBandwidth () const
+{
+  return m_ulBandwidth;
+}
+
+void
+ComponentCarrierUe::SetUlBandwidth (uint8_t bw)
+{
+  NS_LOG_FUNCTION (this << uint16_t (bw));
+  switch (bw)
+    {
+    case 6:
+    case 15:
+    case 25:
+    case 50:
+    case 75:
+    case 100:
+      m_ulBandwidth = bw;
+      break;
+
+    default:
+      NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
+      break;
+    }
+}
+
+uint8_t
+ComponentCarrierUe::GetDlBandwidth () const
+{
+  return m_dlBandwidth;
+}
+
+void
+ComponentCarrierUe::SetDlBandwidth (uint8_t bw)
+{
+  NS_LOG_FUNCTION (this << uint16_t (bw));
+  switch (bw)
+    {
+    case 6:
+    case 15:
+    case 25:
+    case 50:
+    case 75:
+    case 100:
+      m_dlBandwidth = bw;
+      break;
+
+    default:
+      NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
+      break;
+    }
+}
+
+uint16_t
+ComponentCarrierUe::GetDlEarfcn () const
+{
+  return m_dlEarfcn;
+}
+
+void
+ComponentCarrierUe::SetDlEarfcn (uint16_t earfcn)
+{
+  NS_LOG_FUNCTION (this << earfcn);
+  m_dlEarfcn = earfcn;
+}
+
+uint16_t
+ComponentCarrierUe::GetUlEarfcn () const
+{
+  return m_ulEarfcn;
+}
+
+void
+ComponentCarrierUe::SetUlEarfcn (uint16_t earfcn)
+{
+  NS_LOG_FUNCTION (this << earfcn);
+  m_ulEarfcn = earfcn;
+}
+
+uint32_t
+ComponentCarrierUe::GetCsgId () const
+{
+  return m_csgId;
+}
+
+void
+ComponentCarrierUe::SetCsgId (uint32_t csgId)
+{
+  NS_LOG_FUNCTION (this << csgId);
+  m_csgId = csgId;
+  // UpdateConfig (); // I guess it is needed to propagate the change to RRC level
+}
+
+bool
+ComponentCarrierUe::GetCsgIndication () const
+{
+  return m_csgIndication;
+}
+
+void
+ComponentCarrierUe::SetCsgIndication (bool csgIndication)
+{
+  NS_LOG_FUNCTION (this << csgIndication);
+  m_csgIndication = csgIndication;
+  // UpdateConfig (); // I guess it is needed to propagate the change to RRC level
+}
+
+bool
+ComponentCarrierUe::GetPrimaryCarrier () const
+{
+  return m_primaryCarrier;
+}
+
+void
+ComponentCarrierUe::SetPrimaryCarrier (bool primaryCarrier)
+{
+  NS_LOG_FUNCTION (this << primaryCarrier);
+  m_primaryCarrier = primaryCarrier;
+  // UpdateConfig (); // I guess it is needed to propagate the change to RRC level
+}
+
+void
+ComponentCarrierUe::DoInitialize (void)
+{
+  NS_LOG_FUNCTION (this);
+  m_isConstructed = true;
+  m_phy->Initialize ();
+}
+
+Ptr<LteUePhy>
+ComponentCarrierUe::GetPhy ()
+{
+  return m_phy;
+}
+
+} // namespace ns3
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/component-carrier-ue.h	Fri Jun 26 18:40:04 2015 +0200
@@ -0,0 +1,173 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2015 Danilo Abrignani
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Danilo Abrignani <danilo.abrignani@unibo.it>
+ */
+
+
+#ifndef COMPONENT_CARRIER_UE_H
+#define COMPONENT_CARRIER_UE_H
+
+#include <ns3/object.h>
+#include <ns3/packet.h>
+#include <ns3/nstime.h>
+#include "ns3/lte-phy.h"
+#include <ns3/lte-ue-phy.h>
+
+namespace ns3 {
+
+/**
+ * \ingroup lte
+ *
+ * ComponentCarrierUe Object, it defines a single Carrier
+ */
+class ComponentCarrierUe : public Object
+{
+public:
+  static TypeId GetTypeId (void);
+
+  ComponentCarrierUe ();
+
+  virtual ~ComponentCarrierUe (void);
+  virtual void DoDispose (void);
+
+  /**
+   * \return the uplink bandwidth in RBs
+   */
+  uint8_t GetUlBandwidth () const;
+
+  /**
+   * \param bw the uplink bandwidth in RBs
+   */
+  void SetUlBandwidth (uint8_t bw);
+
+  /**
+   * \return the downlink bandwidth in RBs
+   */
+  uint8_t GetDlBandwidth () const;
+
+  /**
+   * \param bw the downlink bandwidth in RBs
+   */
+  void SetDlBandwidth (uint8_t bw);
+
+  /**
+   * \return the downlink carrier frequency (EARFCN)
+   */
+  uint16_t GetDlEarfcn () const;
+
+  /**
+   * \param earfcn the downlink carrier frequency (EARFCN)
+   */
+  void SetDlEarfcn (uint16_t earfcn);
+
+  /**
+   * \return the uplink carrier frequency (EARFCN)
+   */
+  uint16_t GetUlEarfcn () const;
+
+  /**
+   * \param earfcn the uplink carrier frequency (EARFCN)
+   */
+  void SetUlEarfcn (uint16_t earfcn);
+
+  /**
+   * \brief Returns the CSG ID of the eNodeB.
+   * \return the Closed Subscriber Group identity
+   * \sa LteEnbNetDevice::SetCsgId
+   */
+  uint32_t GetCsgId () const;
+
+  /**
+   * \brief Associate the eNodeB device with a particular CSG.
+   * \param csgId the intended Closed Subscriber Group identity
+   *
+   * CSG identity is a number identifying a Closed Subscriber Group which the
+   * cell belongs to. eNodeB is associated with a single CSG identity.
+   *
+   * The same CSG identity can also be associated to several UEs, which is
+   * equivalent as enlisting these UEs as the members of this particular CSG.
+   *
+   * \sa LteEnbNetDevice::SetCsgIndication
+   */
+  void SetCsgId (uint32_t csgId);
+
+  /**
+   * \brief Returns the CSG indication flag of the eNodeB.
+   * \return the CSG indication flag
+   * \sa LteEnbNetDevice::SetCsgIndication
+   */
+  bool GetCsgIndication () const;
+
+  /**
+   * \brief Enable or disable the CSG indication flag.
+   * \param csgIndication if TRUE, only CSG members are allowed to access this
+   *                      cell
+   *
+   * When the CSG indication field is set to TRUE, only UEs which are members of
+   * the CSG (i.e. same CSG ID) can gain access to the eNodeB, therefore
+   * enforcing closed access mode. Otherwise, the eNodeB operates as a non-CSG
+   * cell and implements open access mode.
+   *
+   * \note This restriction only applies to initial cell selection and
+   *       EPC-enabled simulation.
+   *
+   * \sa LteEnbNetDevice::SetCsgIndication
+   */
+  void SetCsgIndication (bool csgIndication);
+
+  void SetPrimaryCarrier (bool primaryCarrier);
+
+  bool GetPrimaryCarrier () const;
+
+  /**
+   * \return a pointer to the physical layer.
+   */
+  Ptr<LteUePhy> GetPhy (void);
+
+  uint8_t m_dlBandwidth;   /**< downlink bandwidth in RBs */
+  uint8_t m_ulBandwidth;   /**< uplink bandwidth in RBs */
+
+  uint16_t m_dlEarfcn;    /**< downlink carrier frequency */
+  uint16_t m_ulEarfcn;    /**< uplink carrier frequency */
+  Ptr<LteUePhy> m_phy;
+
+protected:
+  // inherited from Object
+  virtual void DoInitialize (void);
+
+private:
+
+  bool m_isConstructed;
+//    bool m_isConfigured;
+
+  uint16_t m_csgId;
+  bool m_csgIndication;
+
+  bool m_primaryCarrier;
+
+
+
+};
+
+
+
+} // namespace ns3
+
+
+
+#endif /* COMPONENT_CARRIER_UE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/component-carrier.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -0,0 +1,255 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2015 Danilo Abrignani
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Danilo Abrignani <danilo.abrignani@unibo.it>
+ */
+
+#include "component-carrier.h"
+#include <ns3/uinteger.h>
+#include <ns3/boolean.h>
+#include <ns3/simulator.h>
+#include <ns3/log.h>
+#include <ns3/abort.h>
+#include <ns3/lte-enb-phy.h>
+#include <ns3/pointer.h>
+
+namespace ns3 {
+
+NS_LOG_COMPONENT_DEFINE ("ComponentCarrier");
+
+NS_OBJECT_ENSURE_REGISTERED ( ComponentCarrier);
+
+TypeId ComponentCarrier::GetTypeId (void)
+{
+  static TypeId
+    tid =
+    TypeId ("ns3::ComponentCarrier")
+    .SetParent<Object> ()
+    .AddConstructor<ComponentCarrier> ()
+    .AddAttribute ("UlBandwidth",
+                   "Uplink Transmission Bandwidth Configuration in number of Resource Blocks",
+                   UintegerValue (25),
+                   MakeUintegerAccessor (&ComponentCarrier::SetUlBandwidth,
+                                         &ComponentCarrier::GetUlBandwidth),
+                   MakeUintegerChecker<uint8_t> ())
+    .AddAttribute ("DlBandwidth",
+                   "Downlink Transmission Bandwidth Configuration in number of Resource Blocks",
+                   UintegerValue (25),
+                   MakeUintegerAccessor (&ComponentCarrier::SetDlBandwidth,
+                                         &ComponentCarrier::GetDlBandwidth),
+                   MakeUintegerChecker<uint8_t> ())
+    .AddAttribute ("DlEarfcn",
+                   "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
+                   "as per 3GPP 36.101 Section 5.7.3. ",
+                   UintegerValue (100),
+                   MakeUintegerAccessor (&ComponentCarrier::m_dlEarfcn),
+                   MakeUintegerChecker<uint16_t> (0, 6599))
+    .AddAttribute ("UlEarfcn",
+                   "Uplink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
+                   "as per 3GPP 36.101 Section 5.7.3. ",
+                   UintegerValue (18100),
+                   MakeUintegerAccessor (&ComponentCarrier::m_ulEarfcn),
+                   MakeUintegerChecker<uint16_t> (18000, 24599))
+    .AddAttribute ("CsgId",
+                   "The Closed Subscriber Group (CSG) identity that this eNodeB belongs to",
+                   UintegerValue (0),
+                   MakeUintegerAccessor (&ComponentCarrier::SetCsgId,
+                                         &ComponentCarrier::GetCsgId),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("CsgIndication",
+                   "If true, only UEs which are members of the CSG (i.e. same CSG ID) "
+                   "can gain access to the eNodeB, therefore enforcing closed access mode. "
+                   "Otherwise, the eNodeB operates as a non-CSG cell and implements open access mode.",
+                   BooleanValue (false),
+                   MakeBooleanAccessor (&ComponentCarrier::SetCsgIndication,
+                                        &ComponentCarrier::GetCsgIndication),
+                   MakeBooleanChecker ())
+    .AddAttribute ("PrimaryCarrier",
+                   "If true, this Carrier Component will be the Primary Carrier Component (PCC) "
+                   "Only one PCC per eNodeB is (currently) allowed",
+                   BooleanValue (false),
+                   MakeBooleanAccessor (&ComponentCarrier::SetPrimaryCarrier,
+                                        &ComponentCarrier::GetPrimaryCarrier),
+                   MakeBooleanChecker ())
+    .AddAttribute ("LteEnbPhy",
+                   "The PHY associated to this EnbNetDevice",
+                   PointerValue (),
+                   MakePointerAccessor (&ComponentCarrier::m_phy),
+                   MakePointerChecker <LteEnbPhy> ())
+  ;
+  return tid;
+}
+ComponentCarrier::ComponentCarrier ()
+  : m_isConstructed (false)
+{
+  NS_LOG_FUNCTION (this);
+}
+
+ComponentCarrier::~ComponentCarrier (void)
+{
+  NS_LOG_FUNCTION (this);
+}
+
+void
+ComponentCarrier::DoDispose ()
+{
+  NS_LOG_FUNCTION (this);
+  m_phy->Dispose ();
+  m_phy = 0;
+
+  Object::DoDispose ();
+}
+
+uint8_t
+ComponentCarrier::GetUlBandwidth () const
+{
+  return m_ulBandwidth;
+}
+
+void
+ComponentCarrier::SetUlBandwidth (uint8_t bw)
+{
+  NS_LOG_FUNCTION (this << uint16_t (bw));
+  switch (bw)
+    {
+    case 6:
+    case 15:
+    case 25:
+    case 50:
+    case 75:
+    case 100:
+      m_ulBandwidth = bw;
+      break;
+
+    default:
+      NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
+      break;
+    }
+}
+
+uint8_t
+ComponentCarrier::GetDlBandwidth () const
+{
+  return m_dlBandwidth;
+}
+
+void
+ComponentCarrier::SetDlBandwidth (uint8_t bw)
+{
+  NS_LOG_FUNCTION (this << uint16_t (bw));
+  switch (bw)
+    {
+    case 6:
+    case 15:
+    case 25:
+    case 50:
+    case 75:
+    case 100:
+      m_dlBandwidth = bw;
+      break;
+
+    default:
+      NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
+      break;
+    }
+}
+
+uint16_t
+ComponentCarrier::GetDlEarfcn () const
+{
+  return m_dlEarfcn;
+}
+
+void
+ComponentCarrier::SetDlEarfcn (uint16_t earfcn)
+{
+  NS_LOG_FUNCTION (this << earfcn);
+  m_dlEarfcn = earfcn;
+}
+
+uint16_t
+ComponentCarrier::GetUlEarfcn () const
+{
+  return m_ulEarfcn;
+}
+
+void
+ComponentCarrier::SetUlEarfcn (uint16_t earfcn)
+{
+  NS_LOG_FUNCTION (this << earfcn);
+  m_ulEarfcn = earfcn;
+}
+
+uint32_t
+ComponentCarrier::GetCsgId () const
+{
+  return m_csgId;
+}
+
+void
+ComponentCarrier::SetCsgId (uint32_t csgId)
+{
+  NS_LOG_FUNCTION (this << csgId);
+  m_csgId = csgId;
+  // UpdateConfig (); // I guess it is needed to propagate the change to RRC level
+}
+
+bool
+ComponentCarrier::GetCsgIndication () const
+{
+  return m_csgIndication;
+}
+
+void
+ComponentCarrier::SetCsgIndication (bool csgIndication)
+{
+  NS_LOG_FUNCTION (this << csgIndication);
+  m_csgIndication = csgIndication;
+  // UpdateConfig (); // I guess it is needed to propagate the change to RRC level
+}
+
+bool
+ComponentCarrier::GetPrimaryCarrier () const
+{
+  return m_primaryCarrier;
+}
+
+void
+ComponentCarrier::SetPrimaryCarrier (bool primaryCarrier)
+{
+  NS_LOG_FUNCTION (this << primaryCarrier);
+  m_primaryCarrier = primaryCarrier;
+  // UpdateConfig (); // I guess it is needed to propagate the change to RRC level
+}
+
+void
+ComponentCarrier::DoInitialize (void)
+{
+  NS_LOG_FUNCTION (this);
+  m_isConstructed = true;
+  //m_phy->Initialize ();
+}
+
+Ptr<LteEnbPhy>
+ComponentCarrier::GetPhy ()
+{
+  return m_phy;
+}
+
+} // namespace ns3
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/component-carrier.h	Fri Jun 26 18:40:04 2015 +0200
@@ -0,0 +1,174 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2015 Danilo Abrignani
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Danilo Abrignani <danilo.abrignani@unibo.it>
+ */
+
+
+#ifndef COMPONENT_CARRIER_H
+#define COMPONENT_CARRIER_H
+
+#include <ns3/object.h>
+#include <ns3/packet.h>
+#include <ns3/nstime.h>
+#include "ns3/lte-phy.h"
+#include <ns3/lte-enb-phy.h>
+#include <ns3/pointer.h>
+
+namespace ns3 {
+
+/**
+ * \ingroup lte
+ *
+ * ComponentCarrier Object, it defines a single Carrier
+ */
+class ComponentCarrier : public Object
+{
+public:
+  static TypeId GetTypeId (void);
+
+  ComponentCarrier ();
+
+  virtual ~ComponentCarrier (void);
+  virtual void DoDispose (void);
+
+  /**
+   * \return the uplink bandwidth in RBs
+   */
+  uint8_t GetUlBandwidth () const;
+
+  /**
+   * \param bw the uplink bandwidth in RBs
+   */
+  void SetUlBandwidth (uint8_t bw);
+
+  /**
+   * \return the downlink bandwidth in RBs
+   */
+  uint8_t GetDlBandwidth () const;
+
+  /**
+   * \param bw the downlink bandwidth in RBs
+   */
+  void SetDlBandwidth (uint8_t bw);
+
+  /**
+   * \return the downlink carrier frequency (EARFCN)
+   */
+  uint16_t GetDlEarfcn () const;
+
+  /**
+   * \param earfcn the downlink carrier frequency (EARFCN)
+   */
+  void SetDlEarfcn (uint16_t earfcn);
+
+  /**
+   * \return the uplink carrier frequency (EARFCN)
+   */
+  uint16_t GetUlEarfcn () const;
+
+  /**
+   * \param earfcn the uplink carrier frequency (EARFCN)
+   */
+  void SetUlEarfcn (uint16_t earfcn);
+
+  /**
+   * \brief Returns the CSG ID of the eNodeB.
+   * \return the Closed Subscriber Group identity
+   * \sa LteEnbNetDevice::SetCsgId
+   */
+  uint32_t GetCsgId () const;
+
+  /**
+   * \brief Associate the eNodeB device with a particular CSG.
+   * \param csgId the intended Closed Subscriber Group identity
+   *
+   * CSG identity is a number identifying a Closed Subscriber Group which the
+   * cell belongs to. eNodeB is associated with a single CSG identity.
+   *
+   * The same CSG identity can also be associated to several UEs, which is
+   * equivalent as enlisting these UEs as the members of this particular CSG.
+   *
+   * \sa LteEnbNetDevice::SetCsgIndication
+   */
+  void SetCsgId (uint32_t csgId);
+
+  /**
+   * \brief Returns the CSG indication flag of the eNodeB.
+   * \return the CSG indication flag
+   * \sa LteEnbNetDevice::SetCsgIndication
+   */
+  bool GetCsgIndication () const;
+
+  /**
+   * \brief Enable or disable the CSG indication flag.
+   * \param csgIndication if TRUE, only CSG members are allowed to access this
+   *                      cell
+   *
+   * When the CSG indication field is set to TRUE, only UEs which are members of
+   * the CSG (i.e. same CSG ID) can gain access to the eNodeB, therefore
+   * enforcing closed access mode. Otherwise, the eNodeB operates as a non-CSG
+   * cell and implements open access mode.
+   *
+   * \note This restriction only applies to initial cell selection and
+   *       EPC-enabled simulation.
+   *
+   * \sa LteEnbNetDevice::SetCsgIndication
+   */
+  void SetCsgIndication (bool csgIndication);
+
+  void SetPrimaryCarrier (bool primaryCarrier);
+
+  bool GetPrimaryCarrier () const;
+
+  /**
+   * \return a pointer to the physical layer.
+   */
+  Ptr<LteEnbPhy> GetPhy (void);
+
+  uint8_t m_dlBandwidth;   /**< downlink bandwidth in RBs */
+  uint8_t m_ulBandwidth;   /**< uplink bandwidth in RBs */
+
+  uint16_t m_dlEarfcn;    /**< downlink carrier frequency */
+  uint16_t m_ulEarfcn;    /**< uplink carrier frequency */
+  Ptr<LteEnbPhy> m_phy;
+
+protected:
+  // inherited from Object
+  virtual void DoInitialize (void);
+
+private:
+
+  bool m_isConstructed;
+//    bool m_isConfigured;
+
+  uint16_t m_csgId;
+  bool m_csgIndication;
+
+  bool m_primaryCarrier;
+
+
+
+};
+
+
+
+} // namespace ns3
+
+
+
+#endif /* COMPONENT_CARRIER_H */
--- a/src/lte/model/lte-enb-net-device.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/model/lte-enb-net-device.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -45,6 +45,13 @@
 #include <ns3/abort.h>
 #include <ns3/log.h>
 
+#include <ns3/fatal-error.h>
+
+#include <ns3/simulator.h>
+
+#include <ns3/object-map.h>
+#include <ns3/object-factory.h>
+
 namespace ns3 {
 
 NS_LOG_COMPONENT_DEFINE ("LteEnbNetDevice");
@@ -93,6 +100,10 @@
                    PointerValue (),
                    MakePointerAccessor (&LteEnbNetDevice::m_phy),
                    MakePointerChecker <LteEnbPhy> ())
+    .AddAttribute ("ComponentCarrierMap", "List of all component Carrier.",
+                   ObjectMapValue (),
+                   MakeObjectMapAccessor (&LteEnbNetDevice::m_ccMap),
+                   MakeObjectMapChecker<ComponentCarrier> ())
     .AddAttribute ("UlBandwidth",
                    "Uplink Transmission Bandwidth Configuration in number of Resource Blocks",
                    UintegerValue (25),
@@ -179,10 +190,16 @@
   m_ffrAlgorithm->Dispose ();
   m_ffrAlgorithm = 0;
 
-  m_phy->Dispose ();
-  m_phy = 0;
+  //  m_phy->Dispose ();
+  // m_phy = 0;
+  for (uint32_t i = 0; i < m_ccMap.size (); i++)
+    {
+      m_ccMap.at (i)->Dispose ();
+    }
+  LteNetDevice::DoDispose ();
+//  m_ccMap.clear ();
 
-  LteNetDevice::DoDispose ();
+
 }
 
 
@@ -319,6 +336,17 @@
   UpdateConfig (); // propagate the change to RRC level
 }
 
+std::map < uint8_t, Ptr<ComponentCarrier> >
+LteEnbNetDevice::GetCcMap ()
+{
+  return m_ccMap;
+}
+
+void
+LteEnbNetDevice::SetCcMap (std::map< uint8_t, Ptr<ComponentCarrier> > ccm)
+{
+  m_ccMap = ccm;
+}
 
 void 
 LteEnbNetDevice::DoInitialize (void)
@@ -326,7 +354,12 @@
   NS_LOG_FUNCTION (this);
   m_isConstructed = true;
   UpdateConfig ();
-  m_phy->Initialize ();
+  //m_phy->Initialize ();
+  std::map< uint8_t, Ptr<ComponentCarrier> >::iterator it;
+  for (it = m_ccMap.begin (); it != m_ccMap.end (); ++it)
+    {
+      it->second->GetPhy ()->Initialize ();
+    }
   m_mac->Initialize ();
   m_rrc->Initialize ();
   m_handoverAlgorithm->Initialize ();
@@ -360,7 +393,7 @@
         {
           NS_LOG_LOGIC (this << " Configure cell " << m_cellId);
           // we have to make sure that this function is called only once
-          m_rrc->ConfigureCell (m_ulBandwidth, m_dlBandwidth, m_ulEarfcn, m_dlEarfcn, m_cellId);
+          m_rrc->ConfigureCell (m_ccMap, m_cellId);
           m_isConfigured = true;
         }
 
--- a/src/lte/model/lte-enb-net-device.h	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/model/lte-enb-net-device.h	Fri Jun 26 18:40:04 2015 +0200
@@ -28,8 +28,11 @@
 #include "ns3/traced-callback.h"
 #include "ns3/nstime.h"
 #include "ns3/lte-phy.h"
+#include "ns3/component-carrier.h"
 #include <vector>
 
+#include <map>
+
 namespace ns3 {
 
 class Packet;
@@ -167,6 +170,12 @@
    */
   void SetCsgIndication (bool csgIndication);
 
+  void SetCcMap (std::map< uint8_t, Ptr<ComponentCarrier> > ccm);
+
+  std::map< uint8_t, Ptr<ComponentCarrier> >  GetCcMap (void);
+
+
+
 protected:
   // inherited from Object
   virtual void DoInitialize (void);
@@ -213,6 +222,8 @@
   uint16_t m_csgId;
   bool m_csgIndication;
 
+  std::map < uint8_t, Ptr<ComponentCarrier> > m_ccMap;
+
 }; // end of class LteEnbNetDevice
 
 } // namespace ns3
--- a/src/lte/model/lte-enb-phy.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/model/lte-enb-phy.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -159,7 +159,7 @@
 {
   static TypeId tid = TypeId ("ns3::LteEnbPhy")
     .SetParent<LtePhy> ()
-    .SetGroupName("Lte")
+    .SetGroupName ("Lte")
     .AddConstructor<LteEnbPhy> ()
     .AddAttribute ("TxPower",
                    "Transmission power in dBm",
--- a/src/lte/model/lte-enb-phy.h	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/model/lte-enb-phy.h	Fri Jun 26 18:40:04 2015 +0200
@@ -134,6 +134,7 @@
    */
   Ptr<LteSpectrumPhy> GetDlSpectrumPhy () const;
 
+
   /**
    * \return a pointer to the LteSpectrumPhy instance relative to the uplink
    */
@@ -290,7 +291,7 @@
    * \param [in] rnti
    * \param [in] sinrLinear
    */
-  typedef void (* ReportUeSinrTracedCallback)
+  typedef void (*ReportUeSinrTracedCallback)
     (const uint16_t cellId, const uint16_t rnti, const double sinrLinear);
 
   /**
@@ -299,7 +300,7 @@
    * \param [in] cellId
    * \param [in] spectrumValue
    */
-  typedef void (* ReportInterferenceTracedCallback)
+  typedef void (*ReportInterferenceTracedCallback)
     (const uint16_t cellId, const Ptr<const SpectrumValue> spectrumValue);
 
 
--- a/src/lte/model/lte-enb-rrc.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/model/lte-enb-rrc.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -163,7 +163,10 @@
   m_physicalConfigDedicated.pdschConfigDedicated.pa = LteRrcSap::PdschConfigDedicated::dB0;
 
   m_rrc->m_cmacSapProvider->AddUe (m_rnti);
-  m_rrc->m_cphySapProvider->AddUe (m_rnti);
+  for (uint16_t i = 0; i < m_rrc->m_noOfCcs; i++)
+    {
+      m_rrc->m_cphySapProvider.at (i)->AddUe (m_rnti);
+    }
 
   // setup the eNB side of SRB0
   {
@@ -237,9 +240,11 @@
   m_rrc->m_cmacSapProvider->UeUpdateConfigurationReq (req);
 
   // configure PHY
-  m_rrc->m_cphySapProvider->SetTransmissionMode (m_rnti, m_physicalConfigDedicated.antennaInfo.transmissionMode);
-  m_rrc->m_cphySapProvider->SetSrsConfigurationIndex (m_rnti, m_physicalConfigDedicated.soundingRsUlConfigDedicated.srsConfigIndex);
-
+  for (uint16_t i = 0; i < m_rrc->m_noOfCcs; i++)
+    {
+      m_rrc->m_cphySapProvider.at (i)->SetTransmissionMode (m_rnti, m_physicalConfigDedicated.antennaInfo.transmissionMode);
+      m_rrc->m_cphySapProvider.at (i)->SetSrsConfigurationIndex (m_rnti, m_physicalConfigDedicated.soundingRsUlConfigDedicated.srsConfigIndex);
+    }
   // schedule this UeManager instance to be deleted if the UE does not give any sign of life within a reasonable time
   Time maxConnectionDelay;
   switch (m_state)
@@ -676,8 +681,8 @@
             if (bearerInfo != NULL)
               {
                 LtePdcpSapProvider* pdcpSapProvider = bearerInfo->m_pdcp->GetLtePdcpSapProvider ();
-        pdcpSapProvider->TransmitPdcpSdu (params);
-      }
+                pdcpSapProvider->TransmitPdcpSdu (params);
+              }
           }
       }
       break;
@@ -890,10 +895,16 @@
           m_rrc->m_cmacSapProvider->UeUpdateConfigurationReq (req);
 
           // configure PHY
-          m_rrc->m_cphySapProvider->SetTransmissionMode (req.m_rnti, req.m_transmissionMode);
+          for (uint16_t i = 0; i < m_rrc->m_noOfCcs; i++)
+            {
+              m_rrc->m_cphySapProvider.at (i)->SetTransmissionMode (req.m_rnti, req.m_transmissionMode);
+            }
 
           double paDouble = LteRrcSap::ConvertPdschConfigDedicated2Double (m_physicalConfigDedicated.pdschConfigDedicated);
-          m_rrc->m_cphySapProvider->SetPa (m_rnti, paDouble);
+          for (uint16_t i = 0; i < m_rrc->m_noOfCcs; i++)
+            {
+              m_rrc->m_cphySapProvider.at (i)->SetPa (m_rnti, paDouble);
+            }
 
           m_needPhyMacConfiguration = false;
         }
@@ -1077,7 +1088,10 @@
 {
   NS_LOG_FUNCTION (this);
   m_physicalConfigDedicated.soundingRsUlConfigDedicated.srsConfigIndex = srsConfIndex;
-  m_rrc->m_cphySapProvider->SetSrsConfigurationIndex (m_rnti, srsConfIndex);
+  for (uint16_t i = 0; i < m_rrc->m_noOfCcs; i++)
+    {
+      m_rrc->m_cphySapProvider.at (i)->SetSrsConfigurationIndex (m_rnti, srsConfIndex);
+    }
   switch (m_state)
     {
     case INITIAL_RANDOM_ACCESS:
@@ -1305,8 +1319,8 @@
   NS_LOG_FUNCTION ( this );
   LteRrcSap::NonCriticalExtensionConfiguration ncec;
   LteRrcSap::SCellToAddMod scell;
-  ncec.sCellsToAddModList.push_back(scell);  
-  
+  ncec.sCellsToAddModList.push_back (scell);
+
   return ncec;
 }
 
@@ -1341,7 +1355,7 @@
   m_rrcSapProvider = new MemberLteEnbRrcSapProvider<LteEnbRrc> (this);
   m_x2SapUser = new EpcX2SpecificEpcX2SapUser<LteEnbRrc> (this);
   m_s1SapUser = new MemberEpcEnbS1SapUser<LteEnbRrc> (this);
-  m_cphySapUser = new MemberLteEnbCphySapUser<LteEnbRrc> (this);
+  //m_cphySapUser = new MemberLteEnbCphySapUser<LteEnbRrc> (this);
 }
 
 
@@ -1355,6 +1369,7 @@
 LteEnbRrc::DoDispose ()
 {
   NS_LOG_FUNCTION (this);
+
   m_ueMap.clear ();
   delete m_cmacSapUser;
   delete m_handoverManagementSapUser;
@@ -1363,7 +1378,9 @@
   delete m_rrcSapProvider;
   delete m_x2SapUser;
   delete m_s1SapUser;
-  delete m_cphySapUser;
+  m_cphySapUser.erase (m_cphySapUser.begin (),m_cphySapUser.end ());
+  m_cphySapUser.clear ();
+  //delete m_cphySapUser;
 }
 
 TypeId
@@ -1459,6 +1476,17 @@
                    IntegerValue (-70),
                    MakeIntegerAccessor (&LteEnbRrc::m_qRxLevMin),
                    MakeIntegerChecker<int8_t> (-70, -22))
+    .AddAttribute ("NoOfCcs",
+                   "One of information transmitted within the SIB1 message, "
+                   "indicating the required minimum RSRP level that any UE must "
+                   "receive from this cell before it is allowed to camp to this "
+                   "cell. The default value -70 corresponds to -140 dBm and is "
+                   "the lowest possible value as defined by Section 6.3.4 of "
+                   "3GPP TS 36.133. This restriction, however, only applies to "
+                   "initial cell selection and EPC-enabled simulation.",
+                   UintegerValue (1),
+                   MakeIntegerAccessor (&LteEnbRrc::m_noOfCcs),
+                   MakeIntegerChecker<int16_t> (1, 2))
 
     // Handover related attributes
     .AddAttribute ("AdmitHandoverRequest",
@@ -1520,6 +1548,12 @@
 }
 
 void
+LteEnbRrc::InitializeSap (void)
+{
+  m_cphySapUser.resize (m_noOfCcs);
+  m_cphySapProvider.resize (m_noOfCcs);
+}
+void
 LteEnbRrc::SetEpcX2SapProvider (EpcX2SapProvider * s)
 {
   NS_LOG_FUNCTION (this << s);
@@ -1641,14 +1675,28 @@
 LteEnbRrc::SetLteEnbCphySapProvider (LteEnbCphySapProvider * s)
 {
   NS_LOG_FUNCTION (this << s);
-  m_cphySapProvider = s;
+  m_cphySapProvider[0] = s;
 }
 
 LteEnbCphySapUser*
 LteEnbRrc::GetLteEnbCphySapUser ()
 {
   NS_LOG_FUNCTION (this);
-  return m_cphySapUser;
+  return m_cphySapUser[0];
+}
+
+void
+LteEnbRrc::SetLteEnbCphySapProvider (LteEnbCphySapProvider * s, uint16_t pos)
+{
+  NS_LOG_FUNCTION (this << s);
+  m_cphySapProvider[pos] = s;
+}
+
+LteEnbCphySapUser*
+LteEnbRrc::GetLteEnbCphySapUser (uint16_t pos)
+{
+  NS_LOG_FUNCTION (this);
+  return m_cphySapUser[pos];
 }
 
 bool
@@ -1758,23 +1806,33 @@
 }
 
 void
-LteEnbRrc::ConfigureCell (uint8_t ulBandwidth, uint8_t dlBandwidth,
-                          uint16_t ulEarfcn, uint16_t dlEarfcn, uint16_t cellId)
+LteEnbRrc::ConfigureCell (std::map<uint8_t, Ptr<ComponentCarrier> > ccm, uint16_t cellId)
 {
+  std::map<uint8_t, Ptr<ComponentCarrier> >::iterator it;
+  it = ccm.begin ();
+  uint8_t ulBandwidth = it->second->m_ulBandwidth;
+  uint8_t dlBandwidth = it->second->m_dlBandwidth;
+  uint16_t ulEarfcn = it->second->m_ulEarfcn;
+  uint16_t dlEarfcn = it->second->m_dlEarfcn;
   NS_LOG_FUNCTION (this << (uint16_t) ulBandwidth << (uint16_t) dlBandwidth
                         << ulEarfcn << dlEarfcn << cellId);
   NS_ASSERT (!m_configured);
+  for (it = ccm.begin (); it != ccm.end (); ++it)
+    {
+      m_cphySapProvider[it->first]->SetBandwidth (it->second->m_ulBandwidth, it->second->m_dlBandwidth);
+      m_cphySapProvider[it->first]->SetEarfcn (it->second->m_ulEarfcn, it->second->m_dlEarfcn);
+      m_cphySapProvider[it->first]->SetCellId (cellId);
+    }
+
+
   m_cmacSapProvider->ConfigureMac (ulBandwidth, dlBandwidth);
-  m_cphySapProvider->SetBandwidth (ulBandwidth, dlBandwidth);
-  m_cphySapProvider->SetEarfcn (ulEarfcn, dlEarfcn);
   m_dlEarfcn = dlEarfcn;
   m_ulEarfcn = ulEarfcn;
   m_dlBandwidth = dlBandwidth;
   m_ulBandwidth = ulBandwidth;
   m_cellId = cellId;
-  m_cphySapProvider->SetCellId (cellId);
   m_ffrRrcSapProvider->SetCellId (cellId);
-  m_ffrRrcSapProvider->SetBandwidth(ulBandwidth, dlBandwidth);
+  m_ffrRrcSapProvider->SetBandwidth (ulBandwidth, dlBandwidth);
 
   /*
    * Initializing the list of UE measurement configuration (m_ueMeasConfig).
@@ -1802,8 +1860,11 @@
   // Enabling MIB transmission
   LteRrcSap::MasterInformationBlock mib;
   mib.dlBandwidth = m_dlBandwidth;
-  m_cphySapProvider->SetMasterInformationBlock (mib);
-
+  // for (uint16_t i = 0; i < m_noOfCcs; i++)
+  //   {
+  //     m_cphySapProvider.at (i)->SetMasterInformationBlock (mib);
+  //   }
+  m_cphySapProvider.at (0)->SetMasterInformationBlock (mib);
   // Enabling SIB1 transmission with default values
   m_sib1.cellAccessRelatedInfo.cellIdentity = cellId;
   m_sib1.cellAccessRelatedInfo.csgIndication = false;
@@ -1811,7 +1872,7 @@
   m_sib1.cellAccessRelatedInfo.plmnIdentityInfo.plmnIdentity = 0; // not used
   m_sib1.cellSelectionInfo.qQualMin = -34; // not used, set as minimum value
   m_sib1.cellSelectionInfo.qRxLevMin = m_qRxLevMin; // set as minimum value
-  m_cphySapProvider->SetSystemInformationBlockType1 (m_sib1);
+  m_cphySapProvider[0]->SetSystemInformationBlockType1 (m_sib1);
 
   /*
    * Enabling transmission of other SIB. The first time System Information is
@@ -1833,7 +1894,17 @@
 
   // update SIB1 too
   m_sib1.cellAccessRelatedInfo.cellIdentity = cellId;
-  m_cphySapProvider->SetSystemInformationBlockType1 (m_sib1);
+  m_cphySapProvider.at (0)->SetSystemInformationBlockType1 (m_sib1);
+}
+
+void
+LteEnbRrc::SetCellId (uint16_t cellId, uint16_t ccIndex)
+{
+  m_cellId = cellId;
+
+  // update SIB1 too
+  m_sib1.cellAccessRelatedInfo.cellIdentity = cellId;
+  m_cphySapProvider[ccIndex]->SetSystemInformationBlockType1 (m_sib1);
 }
 
 bool
@@ -2142,7 +2213,7 @@
 
   NS_LOG_LOGIC ("Number of cellInformationItems = " << params.cellInformationList.size ());
 
-  m_ffrRrcSapProvider->RecvLoadInformation(params);
+  m_ffrRrcSapProvider->RecvLoadInformation (params);
 }
 
 void
@@ -2286,7 +2357,7 @@
 {
   NS_LOG_FUNCTION (this);
 
-  m_x2SapProvider->SendLoadInformation(params);
+  m_x2SapProvider->SendLoadInformation (params);
 }
 
 uint16_t
@@ -2325,7 +2396,10 @@
   uint16_t srsCi = (*it).second->GetSrsConfigurationIndex ();
   m_ueMap.erase (it);
   m_cmacSapProvider->RemoveUe (rnti);
-  m_cphySapProvider->RemoveUe (rnti);
+  for (uint16_t i = 0; i < m_noOfCcs; i++)
+    {
+      m_cphySapProvider.at (i)->RemoveUe (rnti);
+    }
   if (m_s1SapProvider != 0)
     {
       m_s1SapProvider->UeContextRelease (rnti);
@@ -2386,7 +2460,7 @@
   NS_LOG_FUNCTION (this << csgId << csgIndication);
   m_sib1.cellAccessRelatedInfo.csgIdentity = csgId;
   m_sib1.cellAccessRelatedInfo.csgIndication = csgIndication;
-  m_cphySapProvider->SetSystemInformationBlockType1 (m_sib1);
+  m_cphySapProvider.at (0)->SetSystemInformationBlockType1 (m_sib1);
 }
 
 
@@ -2536,7 +2610,7 @@
   si.haveSib2 = true;
   si.sib2.freqInfo.ulCarrierFreq = m_ulEarfcn;
   si.sib2.freqInfo.ulBandwidth = m_ulBandwidth;
-  si.sib2.radioResourceConfigCommon.pdschConfigCommon.referenceSignalPower = m_cphySapProvider->GetReferenceSignalPower();
+  si.sib2.radioResourceConfigCommon.pdschConfigCommon.referenceSignalPower = m_cphySapProvider.at (0)->GetReferenceSignalPower ();
   si.sib2.radioResourceConfigCommon.pdschConfigCommon.pb = 0;
 
   LteEnbCmacSapProvider::RachConfig rc = m_cmacSapProvider->GetRachConfig ();
--- a/src/lte/model/lte-enb-rrc.h	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/model/lte-enb-rrc.h	Fri Jun 26 18:40:04 2015 +0200
@@ -46,6 +46,8 @@
 
 #include <map>
 #include <set>
+#include <ns3/component-carrier.h>
+#include <vector>
 
 namespace ns3 {
 
@@ -316,9 +318,9 @@
    * \param [in] oldState
    * \param [in] newState
    */
-  typedef void (* StateTracedCallback)
+  typedef void (*StateTracedCallback)
     (const uint64_t imsi, const uint16_t cellId, const uint16_t rnti,
-     const State oldState, const State newState);
+    const State oldState, const State newState);
 
 private:
 
@@ -351,12 +353,12 @@
    * current configuration
    */
   LteRrcSap::RrcConnectionReconfiguration BuildRrcConnectionReconfiguration ();
-  
+
   /** 
    * 
    * \return an NonCriticalExtensionConfiguration struct built based on the
    * current configuration
-   */  
+   */
   LteRrcSap::NonCriticalExtensionConfiguration BuildNonCriticalExtentionConfigurationCa ();
 
   /** 
@@ -551,7 +553,9 @@
 public:
   static TypeId GetTypeId (void);
 
+  uint16_t m_noOfCcs;
 
+  void InitializeSap (void);
   /**
    * Set the X2 SAP this RRC should interact with
    * \param s the X2 SAP Provider to be used by this RRC entity
@@ -684,6 +688,8 @@
    */
   void SetLteEnbCphySapProvider (LteEnbCphySapProvider * s);
 
+  void SetLteEnbCphySapProvider (LteEnbCphySapProvider * s, uint16_t pos);
+
   /**
    *
    *
@@ -691,6 +697,8 @@
    */
   LteEnbCphySapUser* GetLteEnbCphySapUser ();
 
+  LteEnbCphySapUser* GetLteEnbCphySapUser (uint16_t pos);
+
   /** 
    * 
    * 
@@ -748,10 +756,7 @@
    *
    * \warning Raises an error when executed more than once.
    */
-  void ConfigureCell (uint8_t ulBandwidth,
-                      uint8_t dlBandwidth,
-                      uint16_t ulEarfcn, 
-                      uint16_t dlEarfcn,
+  void ConfigureCell (std::map<uint8_t, Ptr<ComponentCarrier> > ccm,
                       uint16_t cellId);
 
   /** 
@@ -761,6 +766,8 @@
    */
   void SetCellId (uint16_t m_cellId);
 
+  void SetCellId (uint16_t m_cellId, uint16_t ccIndex);
+
   /** 
    * Enqueue an IP data packet on the proper bearer for downlink
    * transmission. Normally expected to be called by the NetDevice
@@ -855,7 +862,7 @@
    * \param [in] cellId
    * \param [in] rnti
    */
-  typedef void (* NewUeContextTracedCallback)
+  typedef void (*NewUeContextTracedCallback)
     (const uint16_t cellId, const uint16_t rnti);
 
   /**
@@ -865,9 +872,9 @@
    * \param [in] cellId
    * \param [in] rnti
    */
-  typedef void (* ConnectionHandoverTracedCallback)
+  typedef void (*ConnectionHandoverTracedCallback)
     (const uint64_t imsi, const uint16_t cellId, const uint16_t rnti);
-  
+
   /**
    * TracedCallback signature for handover start events.
    *
@@ -876,9 +883,9 @@
    * \param [in] rnti
    * \param [in] targetCid
    */
-  typedef void (* HandoverStartTracedCallback)
+  typedef void (*HandoverStartTracedCallback)
     (const uint64_t imsi, const uint16_t cellId, const uint16_t rnti,
-     const uint16_t targetCid);
+    const uint16_t targetCid);
 
   /**
    * TracedCallback signature for receive measurement report events.
@@ -888,10 +895,10 @@
    * \param [in] rnti
    * \param [in] report
    */
-  typedef void (* ReceiveReportTracedCallback)
+  typedef void (*ReceiveReportTracedCallback)
     (const uint64_t imsi, const uint16_t cellId, const uint16_t rnti,
-     const LteRrcSap::MeasurementReport report);
-  
+    const LteRrcSap::MeasurementReport report);
+
 private:
 
 
@@ -1116,10 +1123,10 @@
   /// Interface to receive messages from core network over the S1 protocol.
   EpcEnbS1SapUser* m_s1SapUser;
 
-  /// Receive API calls from the eNodeB PHY instance.
-  LteEnbCphySapUser* m_cphySapUser;
-  /// Interface to the eNodeB PHY instance.
-  LteEnbCphySapProvider* m_cphySapProvider;
+  /// Receive API calls from the eNodeB PHY instances.
+  std::vector<LteEnbCphySapUser*> m_cphySapUser;
+  /// Interface to the eNodeB PHY instances.
+  std::vector<LteEnbCphySapProvider*> m_cphySapProvider;
 
   /// True if ConfigureCell() has been completed.
   bool m_configured;
--- a/src/lte/model/lte-harq-phy.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/model/lte-harq-phy.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -56,7 +56,7 @@
   NS_LOG_FUNCTION (this);
 
   // left shift UL HARQ buffers
-  std::map <uint16_t, std::vector <HarqProcessInfoList_t> >::iterator it;
+  std::map <uint16_t, std::vector <HarqProcessInfoList_t> >:: iterator it;
   for (it = m_miUlHarqProcessesInfoMap.begin (); it != m_miUlHarqProcessesInfoMap.end (); it++)
     {
       (*it).second.erase ((*it).second.begin ());
--- a/src/lte/model/lte-rrc-sap.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/model/lte-rrc-sap.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -22,29 +22,29 @@
 
 namespace ns3 {
 
-LteRrcSap::~LteRrcSap ()
-{
-}
+  LteRrcSap::~LteRrcSap ()
+  {
+  }
 
-LteRrcSap::ReportConfigEutra::ReportConfigEutra ()
-{
-  triggerType = EVENT;
-  eventId = EVENT_A1;
-  threshold1.choice = ThresholdEutra::THRESHOLD_RSRP;
-  threshold1.range = 0;
-  threshold2.choice = ThresholdEutra::THRESHOLD_RSRP;
-  threshold2.range = 0;
-  reportOnLeave = false;
-  a3Offset = 0;
-  hysteresis = 0;
-  timeToTrigger = 0;
-  purpose = REPORT_STRONGEST_CELLS;
-  triggerQuantity = RSRP;
-  reportQuantity = BOTH;
-  maxReportCells = MaxReportCells;
-  reportInterval = MS480;
-  reportAmount = 255;
-}
+  LteRrcSap::ReportConfigEutra::ReportConfigEutra ()
+  {
+    triggerType = EVENT;
+    eventId = EVENT_A1;
+    threshold1.choice = ThresholdEutra::THRESHOLD_RSRP;
+    threshold1.range = 0;
+    threshold2.choice = ThresholdEutra::THRESHOLD_RSRP;
+    threshold2.range = 0;
+    reportOnLeave = false;
+    a3Offset = 0;
+    hysteresis = 0;
+    timeToTrigger = 0;
+    purpose = REPORT_STRONGEST_CELLS;
+    triggerQuantity = RSRP;
+    reportQuantity = BOTH;
+    maxReportCells = MaxReportCells;
+    reportInterval = MS480;
+    reportAmount = 255;
+  }
 
 
 } // namespace ns3
--- a/src/lte/model/lte-spectrum-phy.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/model/lte-spectrum-phy.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -1150,6 +1150,7 @@
   if (m_ctrlErrorModelEnabled)
     {
       double  errorRate = LteMiErrorModel::GetPcfichPdcchError (m_sinrPerceived);
+      errorRate = LteMiErrorModel::GetPcfichPdcchError (m_sinrPerceived);
       error = m_random->GetValue () > errorRate ? false : true;
       NS_LOG_DEBUG (this << " PCFICH-PDCCH Decodification, errorRate " << errorRate << " error " << error);
     }
--- a/src/lte/model/lte-ue-net-device.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/model/lte-ue-net-device.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -1,6 +1,7 @@
 /* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
 /*
  * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
+ * Copyright (c) 2015 Danilo Abrignani
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -18,6 +19,7 @@
  * Author: Giuseppe Piro  <g.piro@poliba.it>
  *         Nicola Baldo <nbaldo@cttc.es>
  *         Marco Miozzo <mmiozzo@cttc.es>
+ *         Danilo Abrignani <danilo.abrignani@unibo.it> - Carrier Aggregation - GSoC 2015
  */
 
 #include "ns3/llc-snap-header.h"
@@ -44,6 +46,9 @@
 #include <ns3/log.h>
 #include "epc-tft.h"
 
+#include <ns3/object-map.h>
+#include <ns3/object-factory.h>
+
 namespace ns3 {
 
 NS_LOG_COMPONENT_DEFINE ("LteUeNetDevice");
@@ -78,6 +83,10 @@
                    PointerValue (),
                    MakePointerAccessor (&LteUeNetDevice::m_phy),
                    MakePointerChecker <LteUePhy> ())
+    .AddAttribute ("ComponentCarrierMapUe", "List of all component Carrier.",
+                   ObjectMapValue (),
+                   MakeObjectMapAccessor (&LteUeNetDevice::m_ccMap),
+                   MakeObjectMapChecker<ComponentCarrierUe> ())
     .AddAttribute ("Imsi",
                    "International Mobile Subscriber Identity assigned to this UE",
                    UintegerValue (0),
@@ -125,10 +134,14 @@
   m_mac = 0;
   m_rrc->Dispose ();
   m_rrc = 0;
-  m_phy->Dispose ();
-  m_phy = 0;
+  //  m_phy->Dispose ();
+  // m_phy = 0;
   m_nas->Dispose ();
   m_nas = 0;
+  for (uint32_t i = 0; i < m_ccMap.size (); i++)
+    {
+      m_ccMap.at (i)->Dispose ();
+    }
   LteNetDevice::DoDispose ();
 }
 
@@ -237,13 +250,31 @@
   return m_targetEnb;
 }
 
+std::map < uint8_t, Ptr<ComponentCarrierUe> >
+LteUeNetDevice::GetCcMap ()
+{
+  return m_ccMap;
+}
+
+void
+LteUeNetDevice::SetCcMap (std::map< uint8_t, Ptr<ComponentCarrierUe> > ccm)
+{
+  m_ccMap = ccm;
+}
+
 void 
 LteUeNetDevice::DoInitialize (void)
 {
   NS_LOG_FUNCTION (this);
   m_isConstructed = true;
   UpdateConfig ();
-  m_phy->Initialize ();
+
+  // m_phy->Initialize ();
+  std::map< uint8_t, Ptr<ComponentCarrierUe> >::iterator it;
+  for (it = m_ccMap.begin (); it != m_ccMap.end (); ++it)
+    {
+      it->second->GetPhy ()->Initialize ();
+    }
   m_mac->Initialize ();
   m_rrc->Initialize ();
 }
@@ -254,9 +285,9 @@
   NS_LOG_FUNCTION (this << dest << protocolNumber);
   if (protocolNumber != Ipv4L3Protocol::PROT_NUMBER)
     {
-      NS_LOG_INFO("unsupported protocol " << protocolNumber << ", only IPv4 is supported");
+      NS_LOG_INFO ("unsupported protocol " << protocolNumber << ", only IPv4 is supported");
       return true;
-    }  
+    }
   return m_nas->Send (packet);
 }
 
--- a/src/lte/model/lte-ue-net-device.h	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/model/lte-ue-net-device.h	Fri Jun 26 18:40:04 2015 +0200
@@ -1,6 +1,7 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
  * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
+ * Copyright (c) 2015 Danilo Abrignani 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -17,6 +18,7 @@
  *
  * Author: Giuseppe Piro  <g.piro@poliba.it>
  *         Nicola Baldo <nbaldo@cttc.es>
+ *         Danilo Abrignani <danilo.abrignani@unibo.it> - Carrier Aggregation GSoC 2015
  */
 
 #ifndef LTE_UE_NET_DEVICE_H
@@ -29,7 +31,10 @@
 #include "ns3/nstime.h"
 #include "ns3/lte-phy.h"
 #include "ns3/eps-bearer.h"
+#include "ns3/component-carrier-ue.h"
+#include <vector>
 
+#include <map>
 
 namespace ns3 {
 
@@ -120,6 +125,11 @@
    */
   Ptr<LteEnbNetDevice> GetTargetEnb (void);
 
+  void SetCcMap (std::map< uint8_t, Ptr<ComponentCarrierUe> > ccm);
+
+  std::map< uint8_t, Ptr<ComponentCarrierUe> >  GetCcMap (void);
+
+
 
 protected:
   // inherited from Object
@@ -153,6 +163,8 @@
 
   uint32_t m_csgId;
 
+  std::map < uint8_t, Ptr<ComponentCarrierUe> > m_ccMap;
+
 }; // end of class LteUeNetDevice
 
 } // namespace ns3
--- a/src/lte/model/lte-ue-rrc.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/model/lte-ue-rrc.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -122,8 +122,7 @@
 
 
 LteUeRrc::LteUeRrc ()
-  : m_cphySapProvider (0),
-    m_cmacSapProvider (0),
+  : m_cmacSapProvider (0),
     m_rrcSapUser (0),
     m_macSapProvider (0),
     m_asSapUser (0),
@@ -139,11 +138,18 @@
     m_csgWhiteList (0)
 {
   NS_LOG_FUNCTION (this);
-  m_cphySapUser = new MemberLteUeCphySapUser<LteUeRrc> (this);
+  //m_cphySapUser = new MemberLteUeCphySapUser<LteUeRrc> (this);
   m_cmacSapUser = new UeMemberLteUeCmacSapUser (this);
   m_rrcSapProvider = new MemberLteUeRrcSapProvider<LteUeRrc> (this);
   m_drbPdcpSapUser = new LtePdcpSpecificLtePdcpSapUser<LteUeRrc> (this);
   m_asSapProvider = new MemberLteAsSapProvider<LteUeRrc> (this);
+  m_supportCa = false;
+  m_cphySapUser.resize (1);
+  m_cphySapProvider.resize (1);
+  for ( uint16_t i = 0; i < m_cphySapUser.size (); i++)
+    {
+      m_cphySapUser[i] = new MemberLteUeCphySapUser<LteUeRrc> (this);
+    }
 }
 
 
@@ -156,12 +162,14 @@
 LteUeRrc::DoDispose ()
 {
   NS_LOG_FUNCTION (this);
-  delete m_cphySapUser;
+  //delete m_cphySapUser;
   delete m_cmacSapUser;
   delete m_rrcSapProvider;
   delete m_drbPdcpSapUser;
   delete m_asSapProvider;
   m_drbMap.clear ();
+  m_cphySapUser.erase (m_cphySapUser.begin (),m_cphySapUser.end ());
+  m_cphySapUser.clear ();
 }
 
 TypeId
@@ -169,7 +177,7 @@
 {
   static TypeId tid = TypeId ("ns3::LteUeRrc")
     .SetParent<Object> ()
-    .SetGroupName("Lte")
+    .SetGroupName ("Lte")
     .AddConstructor<LteUeRrc> ()
     .AddAttribute ("DataRadioBearerMap", "List of UE RadioBearerInfo for Data Radio Bearers by LCID.",
                    ObjectMapValue (),
@@ -185,12 +193,12 @@
                    MakePointerChecker<LteSignalingRadioBearerInfo> ())
     .AddAttribute ("CellId",
                    "Serving cell identifier",
-                   UintegerValue (0), // unused, read-only attribute
+                   UintegerValue (0),   // unused, read-only attribute
                    MakeUintegerAccessor (&LteUeRrc::GetCellId),
                    MakeUintegerChecker<uint16_t> ())
     .AddAttribute ("C-RNTI",
                    "Cell Radio Network Temporary Identifier",
-                   UintegerValue (0), // unused, read-only attribute
+                   UintegerValue (0),   // unused, read-only attribute
                    MakeUintegerAccessor (&LteUeRrc::GetRnti),
                    MakeUintegerChecker<uint16_t> ())
     .AddAttribute ("T300",
@@ -199,6 +207,11 @@
                    TimeValue (MilliSeconds (100)),
                    MakeTimeAccessor (&LteUeRrc::m_t300),
                    MakeTimeChecker ())
+    .AddAttribute ("CarrierAggegationSupport", "If this flag is enabled the UE support Carrier Aggregation",
+                   BooleanValue (),
+                   MakeBooleanAccessor (&LteUeRrc::SetCaSupport,
+                                        &LteUeRrc::GetCaSupport),
+                   MakeBooleanChecker ())
     .AddTraceSource ("MibReceived",
                      "trace fired upon reception of Master Information Block",
                      MakeTraceSourceAccessor (&LteUeRrc::m_mibReceivedTrace),
@@ -264,14 +277,14 @@
 LteUeRrc::SetLteUeCphySapProvider (LteUeCphySapProvider * s)
 {
   NS_LOG_FUNCTION (this << s);
-  m_cphySapProvider = s;
+  m_cphySapProvider[0] = s;
 }
 
 LteUeCphySapUser*
 LteUeRrc::GetLteUeCphySapUser ()
 {
   NS_LOG_FUNCTION (this);
-  return m_cphySapUser;
+  return m_cphySapUser[0];
 }
 
 void
@@ -315,13 +328,13 @@
   m_asSapUser = s;
 }
 
-LteAsSapProvider* 
+LteAsSapProvider*
 LteUeRrc::GetAsSapProvider ()
 {
   return m_asSapProvider;
 }
 
-void 
+void
 LteUeRrc::SetImsi (uint64_t imsi)
 {
   NS_LOG_FUNCTION (this << imsi);
@@ -349,14 +362,14 @@
 }
 
 
-uint8_t 
+uint8_t
 LteUeRrc::GetUlBandwidth () const
 {
   NS_LOG_FUNCTION (this);
   return m_ulBandwidth;
 }
 
-uint8_t 
+uint8_t
 LteUeRrc::GetDlBandwidth () const
 {
   NS_LOG_FUNCTION (this);
@@ -369,7 +382,7 @@
   return m_dlEarfcn;
 }
 
-uint16_t 
+uint16_t
 LteUeRrc::GetUlEarfcn () const
 {
   NS_LOG_FUNCTION (this);
@@ -384,7 +397,7 @@
 }
 
 void
-LteUeRrc::SetUseRlcSm (bool val) 
+LteUeRrc::SetUseRlcSm (bool val)
 {
   NS_LOG_FUNCTION (this);
   m_useRlcSm = val;
@@ -392,6 +405,21 @@
 
 
 void
+LteUeRrc::SetCaSupport (bool supportCa)
+{
+  NS_LOG_FUNCTION (this << supportCa);
+  m_supportCa = supportCa;
+}
+
+uint64_t
+LteUeRrc::GetCaSupport (void) const
+{
+  NS_LOG_FUNCTION (this);
+  return m_supportCa;
+}
+
+
+void
 LteUeRrc::DoInitialize (void)
 {
   NS_LOG_FUNCTION (this);
@@ -414,10 +442,10 @@
 
   // CCCH (LCID 0) is pre-configured, here is the hardcoded configuration:
   LteUeCmacSapProvider::LogicalChannelConfig lcConfig;
-  lcConfig.priority = 0; // highest priority
-  lcConfig.prioritizedBitRateKbps = 65535; // maximum
-  lcConfig.bucketSizeDurationMs = 65535; // maximum
-  lcConfig.logicalChannelGroup = 0; // all SRBs mapped to LCG 0
+  lcConfig.priority = 0;   // highest priority
+  lcConfig.prioritizedBitRateKbps = 65535;   // maximum
+  lcConfig.bucketSizeDurationMs = 65535;   // maximum
+  lcConfig.logicalChannelGroup = 0;   // all SRBs mapped to LCG 0
 
   m_cmacSapProvider->AddLc (lcid, lcConfig, rlc->GetLteMacSapUser ());
 
@@ -433,19 +461,19 @@
 
   if (drbid != 0)
     {
-  std::map<uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it =   m_drbMap.find (drbid);
-  NS_ASSERT_MSG (it != m_drbMap.end (), "could not find bearer with drbid == " << drbid);
-
-  LtePdcpSapProvider::TransmitPdcpSduParameters params;
-  params.pdcpSdu = packet;
-  params.rnti = m_rnti;
-  params.lcid = it->second->m_logicalChannelIdentity;
-
-  NS_LOG_LOGIC (this << " RNTI=" << m_rnti << " sending packet " << packet
-                     << " on DRBID " << (uint32_t) drbid
-                     << " (LCID " << (uint32_t) params.lcid << ")"
-                     << " (" << packet->GetSize () << " bytes)");
-  it->second->m_pdcp->GetLtePdcpSapProvider ()->TransmitPdcpSdu (params);
+      std::map<uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it =   m_drbMap.find (drbid);
+      NS_ASSERT_MSG (it != m_drbMap.end (), "could not find bearer with drbid == " << drbid);
+
+      LtePdcpSapProvider::TransmitPdcpSduParameters params;
+      params.pdcpSdu = packet;
+      params.rnti = m_rnti;
+      params.lcid = it->second->m_logicalChannelIdentity;
+
+      NS_LOG_LOGIC (this << " RNTI=" << m_rnti << " sending packet " << packet
+                         << " on DRBID " << (uint32_t) drbid
+                         << " (LCID " << (uint32_t) params.lcid << ")"
+                         << " (" << packet->GetSize () << " bytes)");
+      it->second->m_pdcp->GetLtePdcpSapProvider ()->TransmitPdcpSdu (params);
     }
 }
 
@@ -478,7 +506,7 @@
       LeaveConnectedMode ();
       break;
 
-    default: // i.e. IDLE_RANDOM_ACCESS
+    default:   // i.e. IDLE_RANDOM_ACCESS
       NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
       break;
     }
@@ -498,7 +526,7 @@
   NS_LOG_FUNCTION (this << rnti);
   m_rnti = rnti;
   m_srb0->m_rlc->SetRnti (m_rnti);
-  m_cphySapProvider->SetRnti (m_rnti);
+  m_cphySapProvider[0]->SetRnti (m_rnti);
 }
 
 void
@@ -512,11 +540,11 @@
     case IDLE_RANDOM_ACCESS:
       {
         // we just received a RAR with a T-C-RNTI and an UL grant
-        // send RRC connection request as message 3 of the random access procedure 
+        // send RRC connection request as message 3 of the random access procedure
         SwitchToState (IDLE_CONNECTING);
         LteRrcSap::RrcConnectionRequest msg;
         msg.ueIdentity = m_imsi;
-        m_rrcSapUser->SendRrcConnectionRequest (msg); 
+        m_rrcSapUser->SendRrcConnectionRequest (msg);
         m_connectionTimeout = Simulator::Schedule (m_t300,
                                                    &LteUeRrc::ConnectionTimeout,
                                                    this);
@@ -545,7 +573,7 @@
 
     default:
       NS_FATAL_ERROR ("unexpected event in state " << ToString (m_state));
-      break; 
+      break;
     }
 }
 
@@ -589,18 +617,18 @@
   m_csgWhiteList = csgId;
 }
 
-void 
+void
 LteUeRrc::DoStartCellSelection (uint16_t dlEarfcn)
 {
   NS_LOG_FUNCTION (this << m_imsi << dlEarfcn);
   NS_ASSERT_MSG (m_state == IDLE_START,
                  "cannot start cell selection from state " << ToString (m_state));
   m_dlEarfcn = dlEarfcn;
-  m_cphySapProvider->StartCellSearch (dlEarfcn);
+  m_cphySapProvider[0]->StartCellSearch (dlEarfcn);
   SwitchToState (IDLE_CELL_SEARCH);
 }
 
-void 
+void
 LteUeRrc::DoForceCampedOnEnb (uint16_t cellId, uint16_t dlEarfcn)
 {
   NS_LOG_FUNCTION (this << m_imsi << cellId << dlEarfcn);
@@ -610,7 +638,7 @@
     case IDLE_START:
       m_cellId = cellId;
       m_dlEarfcn = dlEarfcn;
-      m_cphySapProvider->SynchronizeWithEnb (m_cellId, m_dlEarfcn);
+      m_cphySapProvider[0]->SynchronizeWithEnb (m_cellId, m_dlEarfcn);
       SwitchToState (IDLE_WAIT_MIB);
       break;
 
@@ -690,9 +718,9 @@
 void
 LteUeRrc::DoRecvMasterInformationBlock (uint16_t cellId,
                                         LteRrcSap::MasterInformationBlock msg)
-{ 
+{
   m_dlBandwidth = msg.dlBandwidth;
-  m_cphySapProvider->SetDlBandwidth (msg.dlBandwidth);
+  m_cphySapProvider[0]->SetDlBandwidth (msg.dlBandwidth);
   m_hasReceivedMib = true;
   m_mibReceivedTrace (m_imsi, m_cellId, m_rnti, cellId);
 
@@ -747,7 +775,7 @@
       // MIB has not been received, so ignore this SIB1
       break;
 
-    default: // e.g. IDLE_START, IDLE_CELL_SEARCH, IDLE_WAIT_MIB, IDLE_WAIT_SIB2
+    default:   // e.g. IDLE_START, IDLE_CELL_SEARCH, IDLE_WAIT_MIB, IDLE_WAIT_SIB2
       // do nothing
       break;
     }
@@ -784,13 +812,13 @@
         }
     }
 
-} // end of LteUeRrc::DoReportUeMeasurements
+}   // end of LteUeRrc::DoReportUeMeasurements
 
 
 
 // RRC SAP methods
 
-void 
+void
 LteUeRrc::DoCompleteSetup (LteUeRrcSapProvider::CompleteSetupParameters params)
 {
   NS_LOG_FUNCTION (this << " RNTI " << m_rnti);
@@ -802,7 +830,7 @@
 }
 
 
-void 
+void
 LteUeRrc::DoRecvSystemInformation (LteRrcSap::SystemInformation msg)
 {
   NS_LOG_FUNCTION (this << " RNTI " << m_rnti);
@@ -828,8 +856,8 @@
           rc.preambleTransMax = msg.sib2.radioResourceConfigCommon.rachConfigCommon.raSupervisionInfo.preambleTransMax;
           rc.raResponseWindowSize = msg.sib2.radioResourceConfigCommon.rachConfigCommon.raSupervisionInfo.raResponseWindowSize;
           m_cmacSapProvider->ConfigureRach (rc);
-          m_cphySapProvider->ConfigureUplink (m_ulEarfcn, m_ulBandwidth);
-          m_cphySapProvider->ConfigureReferenceSignalPower(msg.sib2.radioResourceConfigCommon.pdschConfigCommon.referenceSignalPower);
+          m_cphySapProvider[0]->ConfigureUplink (m_ulEarfcn, m_ulBandwidth);
+          m_cphySapProvider[0]->ConfigureReferenceSignalPower (msg.sib2.radioResourceConfigCommon.pdschConfigCommon.referenceSignalPower);
           if (m_state == IDLE_WAIT_SIB2)
             {
               NS_ASSERT (m_connectionPending);
@@ -837,7 +865,7 @@
             }
           break;
 
-        default: // IDLE_START, IDLE_CELL_SEARCH, IDLE_WAIT_MIB, IDLE_WAIT_MIB_SIB1, IDLE_WAIT_SIB1
+        default:   // IDLE_START, IDLE_CELL_SEARCH, IDLE_WAIT_MIB, IDLE_WAIT_MIB_SIB1, IDLE_WAIT_SIB1
           // do nothing
           break;
         }
@@ -846,7 +874,7 @@
 }
 
 
-void 
+void
 LteUeRrc::DoRecvRrcConnectionSetup (LteRrcSap::RrcConnectionSetup msg)
 {
   NS_LOG_FUNCTION (this << " RNTI " << m_rnti);
@@ -875,9 +903,19 @@
 LteUeRrc::DoRecvRrcConnectionReconfiguration (LteRrcSap::RrcConnectionReconfiguration msg)
 {
   NS_LOG_FUNCTION (this << " RNTI " << m_rnti);
+  NS_LOG_FUNCTION ( this << " haveNonCriticalExtension " << msg.haveNonCriticalExtension );
   switch (m_state)
     {
     case CONNECTED_NORMALLY:
+      if (msg.haveNonCriticalExtension)
+        {
+          NS_LOG_FUNCTION ( this << "RNTI " << m_rnti << " Configured for CA" );
+          std::cout << "LTE-AAA" << std::endl;
+        }
+      else
+        {
+          NS_LOG_FUNCTION ( this << "RNTI " << m_rnti << " NOT for CA" );
+        }
       if (msg.haveMobilityControlInfo)
         {
           NS_LOG_INFO ("haveMobilityControlInfo == true");
@@ -885,18 +923,18 @@
           const LteRrcSap::MobilityControlInfo& mci = msg.mobilityControlInfo;
           m_handoverStartTrace (m_imsi, m_cellId, m_rnti, mci.targetPhysCellId);
           m_cmacSapProvider->Reset ();
-          m_cphySapProvider->Reset ();
+          m_cphySapProvider[0]->Reset ();
           m_cellId = mci.targetPhysCellId;
           NS_ASSERT (mci.haveCarrierFreq);
           NS_ASSERT (mci.haveCarrierBandwidth);
-          m_cphySapProvider->SynchronizeWithEnb (m_cellId, mci.carrierFreq.dlCarrierFreq);
-          m_cphySapProvider->SetDlBandwidth ( mci.carrierBandwidth.dlBandwidth);
-          m_cphySapProvider->ConfigureUplink (mci.carrierFreq.ulCarrierFreq, mci.carrierBandwidth.ulBandwidth); 
+          m_cphySapProvider[0]->SynchronizeWithEnb (m_cellId, mci.carrierFreq.dlCarrierFreq);
+          m_cphySapProvider[0]->SetDlBandwidth ( mci.carrierBandwidth.dlBandwidth);
+          m_cphySapProvider[0]->ConfigureUplink (mci.carrierFreq.ulCarrierFreq, mci.carrierBandwidth.ulBandwidth);
           m_rnti = msg.mobilityControlInfo.newUeIdentity;
           m_srb0->m_rlc->SetRnti (m_rnti);
           NS_ASSERT_MSG (mci.haveRachConfigDedicated, "handover is only supported with non-contention-based random access procedure");
           m_cmacSapProvider->StartNonContentionBasedRandomAccessProcedure (m_rnti, mci.rachConfigDedicated.raPreambleIndex, mci.rachConfigDedicated.raPrachMaskIndex);
-          m_cphySapProvider->SetRnti (m_rnti);
+          m_cphySapProvider[0]->SetRnti (m_rnti);
           m_lastRrcTransactionIdentifier = msg.rrcTransactionIdentifier;
           NS_ASSERT (msg.haveRadioResourceConfigDedicated);
 
@@ -906,9 +944,9 @@
           // if we did so. Hence we schedule it for later disposal
           m_srb1Old = m_srb1;
           Simulator::ScheduleNow (&LteUeRrc::DisposeOldSrb1, this);
-          m_srb1 = 0; // new instance will be be created within ApplyRadioResourceConfigDedicated
-
-          m_drbMap.clear (); // dispose all DRBs
+          m_srb1 = 0;   // new instance will be be created within ApplyRadioResourceConfigDedicated
+
+          m_drbMap.clear ();   // dispose all DRBs
           ApplyRadioResourceConfigDedicated (msg.radioResourceConfigDedicated);
 
           if (msg.haveMeasConfig)
@@ -924,7 +962,7 @@
           if (msg.haveRadioResourceConfigDedicated)
             {
               ApplyRadioResourceConfigDedicated (msg.radioResourceConfigDedicated);
-            } 
+            }
           if (msg.haveMeasConfig)
             {
               ApplyMeasConfig (msg.measConfig);
@@ -942,7 +980,7 @@
     }
 }
 
-void 
+void
 LteUeRrc::DoRecvRrcConnectionReestablishment (LteRrcSap::RrcConnectionReestablishment msg)
 {
   NS_LOG_FUNCTION (this << " RNTI " << m_rnti);
@@ -966,7 +1004,7 @@
     }
 }
 
-void 
+void
 LteUeRrc::DoRecvRrcConnectionReestablishmentReject (LteRrcSap::RrcConnectionReestablishmentReject msg)
 {
   NS_LOG_FUNCTION (this << " RNTI " << m_rnti);
@@ -988,23 +1026,23 @@
     }
 }
 
-void 
+void
 LteUeRrc::DoRecvRrcConnectionRelease (LteRrcSap::RrcConnectionRelease msg)
 {
   NS_LOG_FUNCTION (this << " RNTI " << m_rnti);
   /// \todo Currently not implemented, see Section 5.3.8 of 3GPP TS 36.331.
 }
 
-void 
+void
 LteUeRrc::DoRecvRrcConnectionReject (LteRrcSap::RrcConnectionReject msg)
 {
   NS_LOG_FUNCTION (this);
   m_connectionTimeout.Cancel ();
 
-  m_cmacSapProvider->Reset ();       // reset the MAC
-  m_hasReceivedSib2 = false;         // invalidate the previously received SIB2
+  m_cmacSapProvider->Reset ();         // reset the MAC
+  m_hasReceivedSib2 = false;           // invalidate the previously received SIB2
   SwitchToState (IDLE_CAMPED_NORMALLY);
-  m_asSapUser->NotifyConnectionFailed ();  // inform upper layer
+  m_asSapUser->NotifyConnectionFailed ();    // inform upper layer
 }
 
 
@@ -1045,11 +1083,11 @@
     {
       NS_LOG_LOGIC (this << " cell " << maxRsrpCellId
                          << " is the strongest untried surrounding cell");
-      m_cphySapProvider->SynchronizeWithEnb (maxRsrpCellId, m_dlEarfcn);
+      m_cphySapProvider[0]->SynchronizeWithEnb (maxRsrpCellId, m_dlEarfcn);
       SwitchToState (IDLE_WAIT_MIB_SIB1);
     }
 
-} // end of void LteUeRrc::SynchronizeToStrongestCell ()
+}   // end of void LteUeRrc::SynchronizeToStrongestCell ()
 
 
 void
@@ -1090,8 +1128,8 @@
   if (isSuitableCell)
     {
       m_cellId = cellId;
-      m_cphySapProvider->SynchronizeWithEnb (cellId, m_dlEarfcn);
-      m_cphySapProvider->SetDlBandwidth (m_dlBandwidth);
+      m_cphySapProvider[0]->SynchronizeWithEnb (cellId, m_dlEarfcn);
+      m_cphySapProvider[0]->SetDlBandwidth (m_dlBandwidth);
       m_initialCellSelectionEndOkTrace (m_imsi, cellId);
       SwitchToState (IDLE_CAMPED_NORMALLY);
     }
@@ -1113,13 +1151,13 @@
         }
 
       SwitchToState (IDLE_CELL_SEARCH);
-      SynchronizeToStrongestCell (); // retry to a different cell
+      SynchronizeToStrongestCell ();   // retry to a different cell
     }
 
-} // end of void LteUeRrc::EvaluateCellForSelection ()
-
-
-void 
+}   // end of void LteUeRrc::EvaluateCellForSelection ()
+
+
+void
 LteUeRrc::ApplyRadioResourceConfigDedicated (LteRrcSap::RadioResourceConfigDedicated rrcd)
 {
   NS_LOG_FUNCTION (this);
@@ -1127,11 +1165,11 @@
 
   if (pcd.haveAntennaInfoDedicated)
     {
-      m_cphySapProvider->SetTransmissionMode (pcd.antennaInfo.transmissionMode);
+      m_cphySapProvider[0]->SetTransmissionMode (pcd.antennaInfo.transmissionMode);
     }
   if (pcd.haveSoundingRsUlConfigDedicated)
     {
-      m_cphySapProvider->SetSrsConfigurationIndex (pcd.soundingRsUlConfigDedicated.srsConfigIndex);
+      m_cphySapProvider[0]->SetSrsConfigurationIndex (pcd.soundingRsUlConfigDedicated.srsConfigIndex);
     }
 
   if (pcd.havePdschConfigDedicated)
@@ -1139,7 +1177,7 @@
       // update PdschConfigDedicated (i.e. P_A value)
       m_pdschConfigDedicated = pcd.pdschConfigDedicated;
       double paDouble = LteRrcSap::ConvertPdschConfigDedicated2Double (m_pdschConfigDedicated);
-      m_cphySapProvider->SetPa (paDouble);
+      m_cphySapProvider[0]->SetPa (paDouble);
     }
 
   std::list<LteRrcSap::SrbToAddMod>::const_iterator stamIt = rrcd.srbToAddModList.begin ();
@@ -1147,17 +1185,17 @@
     {
       if (m_srb1 == 0)
         {
-          // SRB1 not setup yet        
-          NS_ASSERT_MSG ((m_state == IDLE_CONNECTING) || (m_state == CONNECTED_HANDOVER), 
+          // SRB1 not setup yet
+          NS_ASSERT_MSG ((m_state == IDLE_CONNECTING) || (m_state == CONNECTED_HANDOVER),
                          "unexpected state " << ToString (m_state));
           NS_ASSERT_MSG (stamIt->srbIdentity == 1, "only SRB1 supported");
 
-          const uint8_t lcid = 1; // fixed LCID for SRB1
+          const uint8_t lcid = 1;   // fixed LCID for SRB1
 
           Ptr<LteRlc> rlc = CreateObject<LteRlcAm> ();
           rlc->SetLteMacSapProvider (m_macSapProvider);
           rlc->SetRnti (m_rnti);
-          rlc->SetLcId (lcid);      
+          rlc->SetLcId (lcid);
 
           Ptr<LtePdcp> pdcp = CreateObject<LtePdcp> ();
           pdcp->SetRnti (m_rnti);
@@ -1170,7 +1208,7 @@
           m_srb1->m_rlc = rlc;
           m_srb1->m_pdcp = pdcp;
           m_srb1->m_srbIdentity = 1;
-          
+
           m_srb1->m_logicalChannelConfig.priority = stamIt->logicalChannelConfig.priority;
           m_srb1->m_logicalChannelConfig.prioritizedBitRateKbps = stamIt->logicalChannelConfig.prioritizedBitRateKbps;
           m_srb1->m_logicalChannelConfig.bucketSizeDurationMs = stamIt->logicalChannelConfig.bucketSizeDurationMs;
@@ -1181,12 +1219,12 @@
           lcConfig.prioritizedBitRateKbps = stamIt->logicalChannelConfig.prioritizedBitRateKbps;
           lcConfig.bucketSizeDurationMs = stamIt->logicalChannelConfig.bucketSizeDurationMs;
           lcConfig.logicalChannelGroup = stamIt->logicalChannelConfig.logicalChannelGroup;
-      
+
           m_cmacSapProvider->AddLc (lcid, lcConfig, rlc->GetLteMacSapUser ());
-      
+
           ++stamIt;
-          NS_ASSERT_MSG (stamIt == rrcd.srbToAddModList.end (), "at most one SrbToAdd supported");     
-          
+          NS_ASSERT_MSG (stamIt == rrcd.srbToAddModList.end (), "at most one SrbToAdd supported");
+
           LteUeRrcSapUser::SetupParameters ueParams;
           ueParams.srb0SapProvider = m_srb0->m_rlc->GetLteRlcSapProvider ();
           ueParams.srb1SapProvider = m_srb1->m_pdcp->GetLtePdcpSapProvider ();
@@ -1212,7 +1250,7 @@
       if (drbMapIt == m_drbMap.end ())
         {
           NS_LOG_INFO ("New Data Radio Bearer");
-        
+
           TypeId rlcTypeId;
           if (m_useRlcSm)
             {
@@ -1222,20 +1260,20 @@
             {
               switch (dtamIt->rlcConfig.choice)
                 {
-                case LteRrcSap::RlcConfig::AM: 
+                case LteRrcSap::RlcConfig::AM:
                   rlcTypeId = LteRlcAm::GetTypeId ();
                   break;
-          
-                case LteRrcSap::RlcConfig::UM_BI_DIRECTIONAL: 
+
+                case LteRrcSap::RlcConfig::UM_BI_DIRECTIONAL:
                   rlcTypeId = LteRlcUm::GetTypeId ();
                   break;
-          
+
                 default:
                   NS_FATAL_ERROR ("unsupported RLC configuration");
-                  break;                
+                  break;
                 }
             }
-  
+
           ObjectFactory rlcObjectFactory;
           rlcObjectFactory.SetTypeId (rlcTypeId);
           Ptr<LteRlc> rlc = rlcObjectFactory.Create ()->GetObject<LteRlc> ();
@@ -1263,15 +1301,15 @@
             }
 
           m_bid2DrbidMap[dtamIt->epsBearerIdentity] = dtamIt->drbIdentity;
-  
+
           m_drbMap.insert (std::pair<uint8_t, Ptr<LteDataRadioBearerInfo> > (dtamIt->drbIdentity, drbInfo));
-  
+
 
           struct LteUeCmacSapProvider::LogicalChannelConfig lcConfig;
           lcConfig.priority = dtamIt->logicalChannelConfig.priority;
           lcConfig.prioritizedBitRateKbps = dtamIt->logicalChannelConfig.prioritizedBitRateKbps;
           lcConfig.bucketSizeDurationMs = dtamIt->logicalChannelConfig.bucketSizeDurationMs;
-          lcConfig.logicalChannelGroup = dtamIt->logicalChannelConfig.logicalChannelGroup;      
+          lcConfig.logicalChannelGroup = dtamIt->logicalChannelConfig.logicalChannelGroup;
 
           m_cmacSapProvider->AddLc (dtamIt->logicalChannelIdentity,
                                     lcConfig,
@@ -1285,7 +1323,7 @@
           /// \todo currently not implemented. Would need to modify drbInfo, and then propagate changes to the MAC
         }
     }
-  
+
   std::list<uint8_t>::iterator dtdmIt;
   for (dtdmIt = rrcd.drbToReleaseList.begin ();
        dtdmIt != rrcd.drbToReleaseList.end ();
@@ -1295,7 +1333,7 @@
       NS_LOG_INFO (this << " IMSI " << m_imsi << " releasing DRB " << (uint32_t) drbid << drbid);
       std::map<uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it =   m_drbMap.find (drbid);
       NS_ASSERT_MSG (it != m_drbMap.end (), "could not find bearer with given lcid");
-      m_drbMap.erase (it);      
+      m_drbMap.erase (it);
       m_bid2DrbidMap.erase (drbid);
       //Remove LCID
       m_cmacSapProvider->RemoveLc (drbid + 2);
@@ -1303,12 +1341,12 @@
 }
 
 
-void 
+void
 LteUeRrc::ApplyMeasConfig (LteRrcSap::MeasConfig mc)
 {
   NS_LOG_FUNCTION (this);
 
-  // perform the actions specified in 3GPP TS 36.331 section 5.5.2.1 
+  // perform the actions specified in 3GPP TS 36.331 section 5.5.2.1
 
   // 3GPP TS 36.331 section 5.5.2.4 Measurement object removal
   for (std::list<uint8_t>::iterator it = mc.measObjectToRemoveList.begin ();
@@ -1356,7 +1394,7 @@
         {
           NS_LOG_LOGIC ("measObjectId " << (uint32_t) measObjectId << " exists, updating entry");
           measObjectIt->second = *it;
-          for (std::map<uint8_t, LteRrcSap::MeasIdToAddMod>::iterator measIdIt 
+          for (std::map<uint8_t, LteRrcSap::MeasIdToAddMod>::iterator measIdIt
                  = m_varMeasConfig.measIdList.begin ();
                measIdIt != m_varMeasConfig.measIdList.end ();
                ++measIdIt)
@@ -1420,7 +1458,7 @@
         {
           NS_LOG_LOGIC ("reportConfigId " << (uint32_t) reportConfigId << " exists, updating entry");
           m_varMeasConfig.reportConfigList[reportConfigId] = *it;
-          for (std::map<uint8_t, LteRrcSap::MeasIdToAddMod>::iterator measIdIt 
+          for (std::map<uint8_t, LteRrcSap::MeasIdToAddMod>::iterator measIdIt
                  = m_varMeasConfig.measIdList.begin ();
                measIdIt != m_varMeasConfig.measIdList.end ();
                ++measIdIt)
@@ -1488,7 +1526,7 @@
                  != m_varMeasConfig.measObjectList.end ());
       NS_ASSERT (m_varMeasConfig.reportConfigList.find (it->reportConfigId)
                  != m_varMeasConfig.reportConfigList.end ());
-      m_varMeasConfig.measIdList[it->measId] = *it; // side effect: create new entry if not exists
+      m_varMeasConfig.measIdList[it->measId] = *it;   // side effect: create new entry if not exists
       std::map<uint8_t, VarMeasReport>::iterator measReportIt = m_varMeasReportList.find (it->measId);
       if (measReportIt != m_varMeasReportList.end ())
         {
@@ -1539,7 +1577,7 @@
           if (std::isnan (storedMeasIt->second.rsrq))
             {
               // the previous RSRQ measurements provided UE PHY are invalid
-              storedMeasIt->second.rsrq = rsrq; // replace it with unfiltered value
+              storedMeasIt->second.rsrq = rsrq;   // replace it with unfiltered value
             }
           else
             {
@@ -1561,7 +1599,7 @@
       v.rsrq = rsrq;
       std::pair<uint16_t, MeasValues> val (cellId, v);
       std::pair<std::map<uint16_t, MeasValues>::iterator, bool>
-        ret = m_storedMeasValues.insert (val);
+      ret = m_storedMeasValues.insert (val);
       NS_ASSERT_MSG (ret.second == true, "element already existed");
       storedMeasIt = ret.first;
     }
@@ -1572,7 +1610,7 @@
                      << ", new RSRQ " << rsrq << " stored " << storedMeasIt->second.rsrq);
   storedMeasIt->second.timestamp = Simulator::Now ();
 
-} // end of void SaveUeMeasurements
+}   // end of void SaveUeMeasurements
 
 void
 LteUeRrc::MeasurementReportTriggering (uint8_t measId)
@@ -1620,8 +1658,8 @@
          * Please refer to 3GPP TS 36.331 Section 5.5.4.2
          */
 
-        double ms; // Ms, the measurement result of the serving cell
-        double thresh; // Thresh, the threshold parameter for this event
+        double ms;   // Ms, the measurement result of the serving cell
+        double thresh;   // Thresh, the threshold parameter for this event
         // Hys, the hysteresis parameter for this event.
         double hys = EutranMeasurementMapping::IeValue2ActualHysteresis (reportConfigEutra.hysteresis);
 
@@ -1696,7 +1734,7 @@
                            << " entryCond=" << entryCond
                            << " leavingCond=" << leavingCond);
 
-      } // end of case LteRrcSap::ReportConfigEutra::EVENT_A1
+      }   // end of case LteRrcSap::ReportConfigEutra::EVENT_A1
 
       break;
 
@@ -1707,8 +1745,8 @@
          * Please refer to 3GPP TS 36.331 Section 5.5.4.3
          */
 
-        double ms; // Ms, the measurement result of the serving cell
-        double thresh; // Thresh, the threshold parameter for this event
+        double ms;   // Ms, the measurement result of the serving cell
+        double thresh;   // Thresh, the threshold parameter for this event
         // Hys, the hysteresis parameter for this event.
         double hys = EutranMeasurementMapping::IeValue2ActualHysteresis (reportConfigEutra.hysteresis);
 
@@ -1783,7 +1821,7 @@
                            << " entryCond=" << entryCond
                            << " leavingCond=" << leavingCond);
 
-      } // end of case LteRrcSap::ReportConfigEutra::EVENT_A2
+      }   // end of case LteRrcSap::ReportConfigEutra::EVENT_A2
 
       break;
 
@@ -1794,12 +1832,12 @@
          * Please refer to 3GPP TS 36.331 Section 5.5.4.4
          */
 
-        double mn; // Mn, the measurement result of the neighbouring cell
-        double ofn = measObjectEutra.offsetFreq; // Ofn, the frequency specific offset of the frequency of the
-        double ocn = 0.0; // Ocn, the cell specific offset of the neighbour cell
-        double mp; // Mp, the measurement result of the PCell
-        double ofp = measObjectEutra.offsetFreq; // Ofp, the frequency specific offset of the primary frequency
-        double ocp = 0.0; // Ocp, the cell specific offset of the PCell
+        double mn;   // Mn, the measurement result of the neighbouring cell
+        double ofn = measObjectEutra.offsetFreq;   // Ofn, the frequency specific offset of the frequency of the
+        double ocn = 0.0;   // Ocn, the cell specific offset of the neighbour cell
+        double mp;   // Mp, the measurement result of the PCell
+        double ofp = measObjectEutra.offsetFreq;   // Ofp, the frequency specific offset of the primary frequency
+        double ocp = 0.0;   // Ocp, the cell specific offset of the PCell
         // Off, the offset parameter for this event.
         double off = EutranMeasurementMapping::IeValue2ActualA3Offset (reportConfigEutra.a3Offset);
         // Hys, the hysteresis parameter for this event.
@@ -1886,9 +1924,9 @@
                                << " entryCond=" << entryCond
                                << " leavingCond=" << leavingCond);
 
-          } // end of for (storedMeasIt)
-
-      } // end of case LteRrcSap::ReportConfigEutra::EVENT_A3
+          }   // end of for (storedMeasIt)
+
+      }   // end of case LteRrcSap::ReportConfigEutra::EVENT_A3
 
       break;
 
@@ -1899,10 +1937,10 @@
          * Please refer to 3GPP TS 36.331 Section 5.5.4.5
          */
 
-        double mn; // Mn, the measurement result of the neighbouring cell
-        double ofn = measObjectEutra.offsetFreq; // Ofn, the frequency specific offset of the frequency of the
-        double ocn = 0.0; // Ocn, the cell specific offset of the neighbour cell
-        double thresh; // Thresh, the threshold parameter for this event
+        double mn;   // Mn, the measurement result of the neighbouring cell
+        double ofn = measObjectEutra.offsetFreq;   // Ofn, the frequency specific offset of the frequency of the
+        double ocn = 0.0;   // Ocn, the cell specific offset of the neighbour cell
+        double thresh;   // Thresh, the threshold parameter for this event
         // Hys, the hysteresis parameter for this event.
         double hys = EutranMeasurementMapping::IeValue2ActualHysteresis (reportConfigEutra.hysteresis);
 
@@ -1987,9 +2025,9 @@
                                << " entryCond=" << entryCond
                                << " leavingCond=" << leavingCond);
 
-          } // end of for (storedMeasIt)
-
-      } // end of case LteRrcSap::ReportConfigEutra::EVENT_A4
+          }   // end of for (storedMeasIt)
+
+      }   // end of case LteRrcSap::ReportConfigEutra::EVENT_A4
 
       break;
 
@@ -2001,12 +2039,12 @@
          * Please refer to 3GPP TS 36.331 Section 5.5.4.6
          */
 
-        double mp; // Mp, the measurement result of the PCell
-        double mn; // Mn, the measurement result of the neighbouring cell
-        double ofn = measObjectEutra.offsetFreq; // Ofn, the frequency specific offset of the frequency of the
-        double ocn = 0.0; // Ocn, the cell specific offset of the neighbour cell
-        double thresh1; // Thresh1, the threshold parameter for this event
-        double thresh2; // Thresh2, the threshold parameter for this event
+        double mp;   // Mp, the measurement result of the PCell
+        double mn;   // Mn, the measurement result of the neighbouring cell
+        double ofn = measObjectEutra.offsetFreq;   // Ofn, the frequency specific offset of the frequency of the
+        double ocn = 0.0;   // Ocn, the cell specific offset of the neighbour cell
+        double thresh1;   // Thresh1, the threshold parameter for this event
+        double thresh2;   // Thresh2, the threshold parameter for this event
         // Hys, the hysteresis parameter for this event.
         double hys = EutranMeasurementMapping::IeValue2ActualHysteresis (reportConfigEutra.hysteresis);
 
@@ -2090,9 +2128,9 @@
                                    << " thresh1=" << thresh1
                                    << " entryCond=" << entryCond);
 
-              } // end of for (storedMeasIt)
-
-          } // end of if (entryCond)
+              }   // end of for (storedMeasIt)
+
+          }   // end of if (entryCond)
         else
           {
             NS_LOG_LOGIC (this << " event A5: serving cell " << m_cellId
@@ -2133,7 +2171,7 @@
                             eventLeavingCondApplicable = true;
                           }
                       }
-                  } // end of if (reportConfigEutra.timeToTrigger == 0)
+                  }   // end of if (reportConfigEutra.timeToTrigger == 0)
                 else
                   {
                     // leaving condition #2 has to be checked to cancel time-to-trigger
@@ -2187,18 +2225,18 @@
                                                << " thresh1=" << thresh1
                                                << " leavingCond=" << leavingCond);
 
-                          } // end of if (measReportIt->second.cellsTriggeredList.find (cellId)
-                            //            != measReportIt->second.cellsTriggeredList.end ())
-
-                      } // end of for (storedMeasIt)
-
-                  } // end of else of if (reportConfigEutra.timeToTrigger == 0)
+                          }   // end of if (measReportIt->second.cellsTriggeredList.find (cellId)
+                        //            != measReportIt->second.cellsTriggeredList.end ())
+
+                      }   // end of for (storedMeasIt)
+
+                  }   // end of else of if (reportConfigEutra.timeToTrigger == 0)
 
                 NS_LOG_LOGIC (this << " event A5: serving cell " << m_cellId
                                    << " mp=" << mp << " thresh1=" << thresh1
                                    << " leavingCond=" << leavingCond);
 
-              } // end of if (leavingCond)
+              }   // end of if (leavingCond)
             else
               {
                 if (reportConfigEutra.timeToTrigger > 0)
@@ -2249,16 +2287,16 @@
                                            << " thresh1=" << thresh1
                                            << " leavingCond=" << leavingCond);
 
-                      } // end of if (measReportIt->second.cellsTriggeredList.find (cellId)
-                        //            != measReportIt->second.cellsTriggeredList.end ())
-
-                  } // end of for (storedMeasIt)
-
-              } // end of else of if (leavingCond)
-
-          } // end of if (isMeasIdInReportList)
-
-      } // end of case LteRrcSap::ReportConfigEutra::EVENT_A5
+                      }   // end of if (measReportIt->second.cellsTriggeredList.find (cellId)
+                    //            != measReportIt->second.cellsTriggeredList.end ())
+
+                  }   // end of for (storedMeasIt)
+
+              }   // end of else of if (leavingCond)
+
+          }   // end of if (isMeasIdInReportList)
+
+      }   // end of case LteRrcSap::ReportConfigEutra::EVENT_A5
 
       break;
 
@@ -2266,7 +2304,7 @@
       NS_FATAL_ERROR ("unsupported eventId " << reportConfigEutra.eventId);
       break;
 
-    } // switch (event type)
+    }   // switch (event type)
 
   NS_LOG_LOGIC (this << " eventEntryCondApplicable=" << eventEntryCondApplicable
                      << " eventLeavingCondApplicable=" << eventLeavingCondApplicable);
@@ -2317,7 +2355,7 @@
         }
     }
 
-} // end of void LteUeRrc::MeasurementReportTriggering (uint8_t measId)
+}   // end of void LteUeRrc::MeasurementReportTriggering (uint8_t measId)
 
 void
 LteUeRrc::CancelEnteringTrigger (uint8_t measId)
@@ -2458,7 +2496,7 @@
       r.measId = measId;
       std::pair<uint8_t, VarMeasReport> val (measId, r);
       std::pair<std::map<uint8_t, VarMeasReport>::iterator, bool>
-        ret = m_varMeasReportList.insert (val);
+      ret = m_varMeasReportList.insert (val);
       NS_ASSERT_MSG (ret.second == true, "element already existed");
       measReportIt = ret.first;
     }
@@ -2506,9 +2544,9 @@
             }
         }
 
-    } // end of if (!enteringTriggerIt->second.empty ())
-
-} // end of LteUeRrc::VarMeasReportListAdd
+    }   // end of if (!enteringTriggerIt->second.empty ())
+
+}   // end of LteUeRrc::VarMeasReportListAdd
 
 void
 LteUeRrc::VarMeasReportListErase (uint8_t measId, ConcernedCells_t leavingCells,
@@ -2567,9 +2605,9 @@
             }
         }
 
-    } // end of if (!leavingTriggerIt->second.empty ())
-
-} // end of LteUeRrc::VarMeasReportListErase
+    }   // end of if (!leavingTriggerIt->second.empty ())
+
+}   // end of LteUeRrc::VarMeasReportListErase
 
 void
 LteUeRrc::VarMeasReportListClear (uint8_t measId)
@@ -2590,17 +2628,17 @@
   CancelLeavingTrigger (measId);
 }
 
-void 
+void
 LteUeRrc::SendMeasurementReport (uint8_t measId)
 {
   NS_LOG_FUNCTION (this << (uint16_t) measId);
   //  3GPP TS 36.331 section 5.5.5 Measurement reporting
 
-  std::map<uint8_t, LteRrcSap::MeasIdToAddMod>::iterator 
+  std::map<uint8_t, LteRrcSap::MeasIdToAddMod>::iterator
     measIdIt = m_varMeasConfig.measIdList.find (measId);
   NS_ASSERT (measIdIt != m_varMeasConfig.measIdList.end ());
 
-  std::map<uint8_t, LteRrcSap::ReportConfigToAddMod>::iterator 
+  std::map<uint8_t, LteRrcSap::ReportConfigToAddMod>::iterator
     reportConfigIt = m_varMeasConfig.reportConfigList.find (measIdIt->second.reportConfigId);
   NS_ASSERT (reportConfigIt != m_varMeasConfig.reportConfigList.end ());
   LteRrcSap::ReportConfigEutra& reportConfigEutra = reportConfigIt->second.reportConfigEutra;
@@ -2668,7 +2706,7 @@
               measResultEutra.rsrpResult = EutranMeasurementMapping::Dbm2RsrpRange (neighborMeasIt->second.rsrp);
               measResultEutra.haveRsrqResult = true;
               measResultEutra.rsrqResult = EutranMeasurementMapping::Db2RsrqRange (neighborMeasIt->second.rsrq);
-              NS_LOG_INFO (this << " reporting neighbor cell " << (uint32_t) measResultEutra.physCellId 
+              NS_LOG_INFO (this << " reporting neighbor cell " << (uint32_t) measResultEutra.physCellId
                                 << " RSRP " << (uint32_t) measResultEutra.rsrpResult
                                 << " (" << neighborMeasIt->second.rsrp << " dBm)"
                                 << " RSRQ " << (uint32_t) measResultEutra.rsrqResult
@@ -2738,28 +2776,28 @@
         }
 
       // schedule the next measurement reporting
-      measReportIt->second.periodicReportTimer 
+      measReportIt->second.periodicReportTimer
         = Simulator::Schedule (reportInterval,
                                &LteUeRrc::SendMeasurementReport,
                                this, measId);
 
       // send the measurement report to eNodeB
       m_rrcSapUser->SendMeasurementReport (measurementReport);
-    } 
+    }
 }
 
-void 
+void
 LteUeRrc::StartConnection ()
 {
   NS_LOG_FUNCTION (this << m_imsi);
   NS_ASSERT (m_hasReceivedMib);
   NS_ASSERT (m_hasReceivedSib2);
-  m_connectionPending = false; // reset the flag
+  m_connectionPending = false;   // reset the flag
   SwitchToState (IDLE_RANDOM_ACCESS);
   m_cmacSapProvider->StartContentionBasedRandomAccessProcedure ();
 }
 
-void 
+void
 LteUeRrc::LeaveConnectedMode ()
 {
   NS_LOG_FUNCTION (this << m_imsi);
@@ -2780,11 +2818,11 @@
 LteUeRrc::ConnectionTimeout ()
 {
   NS_LOG_FUNCTION (this << m_imsi);
-  m_cmacSapProvider->Reset ();       // reset the MAC
-  m_hasReceivedSib2 = false;         // invalidate the previously received SIB2
+  m_cmacSapProvider->Reset ();         // reset the MAC
+  m_hasReceivedSib2 = false;           // invalidate the previously received SIB2
   SwitchToState (IDLE_CAMPED_NORMALLY);
   m_connectionTimeoutTrace (m_imsi, m_cellId, m_rnti);
-  m_asSapUser->NotifyConnectionFailed ();  // inform upper layer
+  m_asSapUser->NotifyConnectionFailed ();    // inform upper layer
 }
 
 void
@@ -2794,7 +2832,7 @@
   m_srb1Old = 0;
 }
 
-uint8_t 
+uint8_t
 LteUeRrc::Bid2Drbid (uint8_t bid)
 {
   std::map<uint8_t, uint8_t>::iterator it = m_bid2DrbidMap.find (bid);
@@ -2805,11 +2843,11 @@
     }
   else
     {
-  return it->second;
+      return it->second;
     }
 }
 
-void 
+void
 LteUeRrc::SwitchToState (State newState)
 {
   NS_LOG_FUNCTION (this << ToString (newState));
--- a/src/lte/model/lte-ue-rrc.h	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/model/lte-ue-rrc.h	Fri Jun 26 18:40:04 2015 +0200
@@ -30,6 +30,8 @@
 #include <ns3/lte-ue-cphy-sap.h>
 #include <ns3/lte-rrc-sap.h>
 #include <ns3/traced-callback.h>
+#include "ns3/component-carrier-ue.h"
+#include <vector>
 
 #include <map>
 #include <set>
@@ -246,6 +248,18 @@
    */
   void SetUseRlcSm (bool val);
 
+    /** 
+   * 
+   * \param support CA
+   */
+  void SetCaSupport (bool supportCa);
+
+  /**
+   *
+   * \return support CA
+   */
+  uint64_t GetCaSupport (void) const;
+
 
   /**
    * TracedCallback signature for imsi, cellId and rnti events.
@@ -292,7 +306,6 @@
     (const uint64_t imsi, const uint16_t cellId, const uint16_t rnti,
      const State oldState, const State newState);
 
-
 private:
 
 
@@ -521,8 +534,9 @@
 
   std::map<uint8_t, uint8_t> m_bid2DrbidMap;
 
-  LteUeCphySapUser* m_cphySapUser;
-  LteUeCphySapProvider* m_cphySapProvider;
+  std::vector<LteUeCphySapUser*> m_cphySapUser;
+  std::vector<LteUeCphySapProvider*> m_cphySapProvider;
+
 
   LteUeCmacSapUser* m_cmacSapUser;
   LteUeCmacSapProvider* m_cmacSapProvider;
@@ -551,6 +565,11 @@
   uint16_t m_cellId;
 
   /**
+   * This parameter is set if the UE support Carrier Aggregation
+   */
+  bool m_supportCa;
+
+  /**
    * The `Srb0` attribute. SignalingRadioBearerInfo for SRB0.
    */
   Ptr<LteSignalingRadioBearerInfo> m_srb0;
--- a/src/lte/test/lte-test-ue-measurements.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/test/lte-test-ue-measurements.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -198,12 +198,12 @@
   lteHelper->ActivateDataRadioBearer (ueDevs2, bearer);
 
 
-  Config::Connect ("/NodeList/2/DeviceList/0/LteUePhy/ReportUeMeasurements",
+  Config::Connect ("/NodeList/2/DeviceList/0/ComponentCarrierMapUe/0/LteUePhy/ReportUeMeasurements",
                    MakeBoundCallback (&ReportUeMeasurementsCallback, this));
   Config::Connect ("/NodeList/0/DeviceList/0/LteEnbRrc/RecvMeasurementReport",
                    MakeBoundCallback (&RecvMeasurementReportCallback, this));
 
-  Config::Connect ("/NodeList/3/DeviceList/0/LteUePhy/ReportUeMeasurements",
+  Config::Connect ("/NodeList/3/DeviceList/0/ComponentCarrierMapUe/0/LteUePhy/ReportUeMeasurements",
                    MakeBoundCallback (&ReportUeMeasurementsCallback, this));
   Config::Connect ("/NodeList/1/DeviceList/0/LteEnbRrc/RecvMeasurementReport",
                    MakeBoundCallback (&RecvMeasurementReportCallback, this));
--- a/src/lte/test/test-asn1-encoding.cc	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/test/test-asn1-encoding.cc	Fri Jun 26 18:40:04 2015 +0200
@@ -100,12 +100,12 @@
   Ptr<Packet> packet;
 };
 
-RrcHeaderTestCase::RrcHeaderTestCase (std::string s) : TestCase (s)
+RrcHeaderTestCase :: RrcHeaderTestCase (std::string s) : TestCase (s)
 {
 }
 
 LteRrcSap::RadioResourceConfigDedicated
-RrcHeaderTestCase::CreateRadioResourceConfigDedicated ()
+RrcHeaderTestCase :: CreateRadioResourceConfigDedicated ()
 {
   LteRrcSap::RadioResourceConfigDedicated rrd;
 
@@ -159,7 +159,7 @@
 }
 
 void
-RrcHeaderTestCase::AssertEqualRadioResourceConfigDedicated (LteRrcSap::RadioResourceConfigDedicated rrcd1, LteRrcSap::RadioResourceConfigDedicated rrcd2)
+RrcHeaderTestCase :: AssertEqualRadioResourceConfigDedicated (LteRrcSap::RadioResourceConfigDedicated rrcd1, LteRrcSap::RadioResourceConfigDedicated rrcd2)
 {
   NS_TEST_ASSERT_MSG_EQ (rrcd1.srbToAddModList.size (), rrcd2.srbToAddModList.size (),"SrbToAddModList different sizes");
 
@@ -574,6 +574,8 @@
 
   msg.radioResourceConfigDedicated = CreateRadioResourceConfigDedicated ();
 
+  msg.haveNonCriticalExtension = false; //Danilo
+
   RrcConnectionReconfigurationHeader source;
   source.SetMessage (msg);
 
--- a/src/lte/wscript	Mon Jun 08 11:23:11 2015 +0200
+++ b/src/lte/wscript	Fri Jun 26 18:40:04 2015 +0200
@@ -124,6 +124,9 @@
         'model/lte-componentcarrier-management-sap.cc',
         'model/lte-ccs-algorithm.cc',
         'model/no-op-ccs-algorithm.cc',
+        'model/component-carrier.cc',
+        'helper/cc-helper.cc',
+        'model/component-carrier-ue.cc',
         ]
 
     module_test = bld.create_ns3_module_test_library('lte')
@@ -302,6 +305,10 @@
         'model/lte-componentcarrier-management-sap.h',  
         'model/lte-ccs-algorithm.h',
         'model/no-op-ccs-algorithm.h',
+        'model/component-carrier.h',
+        'helper/cc-helper.h',
+        'model/component-carrier.h',
+        'model/component-carrier-ue.h',
         ]
 
     if (bld.env['ENABLE_EMU']):