1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  * Author: Giuseppe Piro  <g.piro@poliba.it>
19  *         Nicola Baldo <nbaldo@cttc.es>
20  * Modified by:
21  *          Danilo Abrignani <danilo.abrignani@unibo.it> (Carrier Aggregation - GSoC 2015)
22  *          Biljana Bojovic <biljana.bojovic@cttc.es> (Carrier Aggregation)
23  */
24 
25 #ifndef LTE_UE_NET_DEVICE_H
26 #define LTE_UE_NET_DEVICE_H
27 
28 #include "ns3/lte-net-device.h"
29 #include "ns3/event-id.h"
30 #include "ns3/traced-callback.h"
31 #include "ns3/nstime.h"
32 #include "ns3/lte-phy.h"
33 #include "ns3/eps-bearer.h"
34 #include "ns3/component-carrier-ue.h"
35 #include <vector>
36 #include <map>
37 
38 namespace ns3 {
39 
40 class Packet;
41 class PacketBurst;
42 class Node;
43 class LtePhy;
44 class LteUePhy;
45 class LteEnbNetDevice;
46 class LteUeMac;
47 class LteUeRrc;
48 class EpcUeNas;
49 class EpcTft;
50 class LteUeComponentCarrierManager;
51 
52 /**
53  * \ingroup lte
54  * The LteUeNetDevice class implements the UE net device
55  */
56 class LteUeNetDevice : public LteNetDevice
57 {
58 
59 public:
60   /**
61    * \brief Get the type ID.
62    * \return the object TypeId
63    */
64   static TypeId GetTypeId (void);
65 
66   LteUeNetDevice (void);
67   virtual ~LteUeNetDevice (void);
68   virtual void DoDispose ();
69 
70 
71   // inherited from NetDevice
72   virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
73 
74   /**
75    * \brief Get the MAC.
76    * \return the LTE UE MAC
77    */
78   Ptr<LteUeMac> GetMac (void) const;
79 
80   /**
81    * \brief Get the RRC.
82    * \return the LTE UE RRC
83    */
84   Ptr<LteUeRrc> GetRrc () const;
85 
86   /**
87    * \brief Get the Phy.
88    * \return the LTE UE Phy
89    */
90   Ptr<LteUePhy> GetPhy (void) const;
91 
92   /**
93    * \brief Get the NAS.
94    * \return the LTE UE NAS
95    */
96   Ptr<EpcUeNas> GetNas (void) const;
97 
98   /**
99    * \brief Get the componentn carrier manager.
100    * \return the LTE UE component carrier manager
101    */
102   Ptr<LteUeComponentCarrierManager> GetComponentCarrierManager (void) const;
103 
104   /**
105    * \brief Get the IMSI.
106    * \return the IMSI
107    */
108   uint64_t GetImsi () const;
109 
110   /**
111    * \return the downlink carrier frequency (EARFCN)
112    *
113    * Note that real-life handset typically supports more than one EARFCN, but
114    * the sake of simplicity we assume only one EARFCN is supported.
115    */
116   uint32_t GetDlEarfcn () const;
117 
118   /**
119    * \param earfcn the downlink carrier frequency (EARFCN)
120    *
121    * Note that real-life handset typically supports more than one EARFCN, but
122    * the sake of simplicity we assume only one EARFCN is supported.
123    */
124   void SetDlEarfcn (uint32_t earfcn);
125 
126   /**
127    * \brief Returns the CSG ID the UE is currently a member of.
128    * \return the Closed Subscriber Group identity
129    */
130   uint32_t GetCsgId () const;
131 
132   /**
133    * \brief Enlist the UE device as a member of a particular CSG.
134    * \param csgId the intended Closed Subscriber Group identity
135    *
136    * UE is associated with a single CSG identity, and thus becoming a member of
137    * this particular CSG. As a result, the UE may gain access to cells which
138    * belong to this CSG. This does not revoke the UE's access to non-CSG cells.
139    *
140    * \note This restriction only applies to initial cell selection and
141    *       EPC-enabled simulation.
142    */
143   void SetCsgId (uint32_t csgId);
144 
145   /**
146    * \brief Set the target eNB where the UE is registered
147    * \param enb
148    */
149   void SetTargetEnb (Ptr<LteEnbNetDevice> enb);
150 
151   /**
152    * \brief Get the target eNB where the UE is registered
153    * \return the pointer to the enb
154    */
155   Ptr<LteEnbNetDevice> GetTargetEnb (void);
156 
157   /**
158    * \brief Set the ComponentCarrier Map for the UE
159    * \param ccm the map of ComponentCarrierUe
160    */
161   void SetCcMap (std::map< uint8_t, Ptr<ComponentCarrierUe> > ccm);
162 
163   /**
164    * \brief Get the ComponentCarrier Map for the UE
165    * \returns the map of ComponentCarrierUe
166    */
167   std::map< uint8_t, Ptr<ComponentCarrierUe> >  GetCcMap (void);
168 
169 
170 
171 protected:
172   // inherited from Object
173   virtual void DoInitialize (void);
174 
175 
176 private:
177   bool m_isConstructed; ///< is constructed?
178 
179   /**
180    * \brief Propagate attributes and configuration to sub-modules.
181    *
182    * Several attributes (e.g., the IMSI) are exported as the attributes of the
183    * LteUeNetDevice from a user perspective, but are actually used also in other
184    * sub-modules (the RRC, the PHY, etc.). This method takes care of updating
185    * the configuration of all these sub-modules so that their copy of attribute
186    * values are in sync with the one in the LteUeNetDevice.
187    */
188   void UpdateConfig ();
189 
190   Ptr<LteEnbNetDevice> m_targetEnb; ///< target ENB
191 
192   Ptr<LteUeRrc> m_rrc; ///< the RRC
193   Ptr<EpcUeNas> m_nas; ///< the NAS
194   Ptr<LteUeComponentCarrierManager> m_componentCarrierManager; ///< the component carrier manager
195 
196   uint64_t m_imsi; ///< the IMSI
197 
198   uint32_t m_dlEarfcn; /**< downlink carrier frequency */
199 
200   uint32_t m_csgId; ///< the CSG ID
201 
202   std::map < uint8_t, Ptr<ComponentCarrierUe> > m_ccMap; ///< CC map
203 
204 }; // end of class LteUeNetDevice
205 
206 } // namespace ns3
207 
208 #endif /* LTE_UE_NET_DEVICE_H */
209