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  * Author: Marco Miozzo <marco.miozzo@cttc.es>
20  */
21 
22 #ifndef LTE_CONTROL_MESSAGES_H
23 #define LTE_CONTROL_MESSAGES_H
24 
25 #include <ns3/ptr.h>
26 #include <ns3/simple-ref-count.h>
27 #include <ns3/ff-mac-common.h>
28 #include <ns3/lte-rrc-sap.h>
29 #include <list>
30 
31 namespace ns3 {
32 
33 class LteNetDevice;
34 
35 
36 /**
37  * \ingroup lte
38  *
39  * The LteControlMessage provides a basic implementations for
40  * control messages (such as PDCCH allocation map, CQI feedbacks)
41  * that are exchanged among eNodeB and UEs.
42  */
43 class LteControlMessage : public SimpleRefCount<LteControlMessage>
44 {
45 public:
46   /**
47    * The type of the message
48    * NOTE: The messages sent by UE are filtered by the
49    *  LteEnbPhy::ReceiveLteControlMessageList in order to remove the ones
50    *  that has been already handoff by the eNB for avoiding propagation of
51    *  spurious messages. When new messaged have to been added, consider to
52    *  update the switch statement implementing the filtering.
53    */
54   enum MessageType
55   {
56     DL_DCI, UL_DCI, // Downlink/Uplink Data Control Indicator
57     DL_CQI, UL_CQI, // Downlink/Uplink Channel Quality Indicator
58     BSR, // Buffer Status Report
59     DL_HARQ, // UL HARQ feedback
60     RACH_PREAMBLE, // Random Access Preamble
61     RAR, // Random Access Response
62     MIB, // Master Information Block
63     SIB1, // System Information Block Type 1
64   };
65 
66   LteControlMessage (void);
67   virtual ~LteControlMessage (void);
68 
69   /**
70    * \brief Set the type of the message
71    * \param type the type of the message
72    */
73   void SetMessageType (MessageType type);
74   /**
75    * \brief Get the type of the message
76    * \return the type of the message
77    */
78   MessageType GetMessageType (void);
79 
80 private:
81   MessageType m_type; ///< message type
82 };
83 
84 
85 // -----------------------------------------------------------------------
86 
87 /**
88  * \ingroup lte
89  * The Downlink Data Control Indicator messages defines the RB allocation for the
90  * users in the downlink
91  */
92 class DlDciLteControlMessage : public LteControlMessage
93 {
94 public:
95   DlDciLteControlMessage (void);
96   virtual ~DlDciLteControlMessage (void);
97 
98   /**
99   * \brief add a DCI into the message
100   * \param dci the dci
101   */
102   void SetDci (DlDciListElement_s dci);
103 
104   /**
105   * \brief Get dic information
106   * \return dci messages
107   */
108   DlDciListElement_s GetDci (void);
109 
110 private:
111   DlDciListElement_s m_dci; ///< DCI
112 };
113 
114 
115 // ---------------------------------------------------------------------------
116 
117 /**
118  * \ingroup lte
119  * The Uplink Data Control Indicator messages defines the RB allocation for the
120  * users in the uplink
121  */
122 class UlDciLteControlMessage : public LteControlMessage
123 {
124 public:
125   UlDciLteControlMessage (void);
126   virtual ~UlDciLteControlMessage (void);
127 
128   /**
129   * \brief add a DCI into the message
130   * \param dci the dci
131   */
132   void SetDci (UlDciListElement_s dci);
133 
134   /**
135   * \brief Get dic information
136   * \return dci messages
137   */
138   UlDciListElement_s GetDci (void);
139 
140 private:
141   UlDciListElement_s m_dci; ///< DCI
142 };
143 
144 
145 // ---------------------------------------------------------------------------
146 
147 /**
148  * \ingroup lte
149  * The downlink CqiLteControlMessage defines an ideal list of
150  * feedback about the channel quality sent by the UE to the eNodeB.
151  */
152 class DlCqiLteControlMessage : public LteControlMessage
153 {
154 public:
155   DlCqiLteControlMessage (void);
156   virtual ~DlCqiLteControlMessage (void);
157 
158   /**
159   * \brief add a DL-CQI feedback record into the message.
160   * \param dlcqi the DL cqi feedback
161   */
162   void SetDlCqi (CqiListElement_s dlcqi);
163 
164   /**
165   * \brief Get DL cqi information
166   * \return dlcqi messages
167   */
168   CqiListElement_s GetDlCqi (void);
169 
170 private:
171   CqiListElement_s m_dlCqi; ///< DL CQI
172 };
173 
174 
175 // ---------------------------------------------------------------------------
176 
177 /**
178  * \ingroup lte
179  * The uplink BsrLteControlMessage defines the specific
180  * extension of the CE element for reporting the buffer status report
181  */
182 class BsrLteControlMessage : public LteControlMessage
183 {
184 public:
185   BsrLteControlMessage (void);
186   virtual ~BsrLteControlMessage (void);
187 
188   /**
189   * \brief add a BSR feedback record into the message.
190   * \param bsr the BSR feedback
191   */
192   void SetBsr (MacCeListElement_s bsr);
193 
194   /**
195   * \brief Get BSR information
196   * \return BSR message
197   */
198   MacCeListElement_s GetBsr (void);
199 
200 private:
201   MacCeListElement_s m_bsr; ///< BSR
202 
203 };
204 
205 
206 // ---------------------------------------------------------------------------
207 
208 /**
209  * \ingroup lte
210  * The downlink DlHarqFeedbackLteControlMessage defines the specific
211  * messages for transmitting the DL HARQ feedback through PUCCH
212  */
213 class DlHarqFeedbackLteControlMessage : public LteControlMessage
214 {
215 public:
216   DlHarqFeedbackLteControlMessage (void);
217   virtual ~DlHarqFeedbackLteControlMessage (void);
218 
219   /**
220   * \brief add a DL HARQ feedback record into the message.
221   * \param m the DL HARQ feedback
222   */
223   void SetDlHarqFeedback (DlInfoListElement_s m);
224 
225   /**
226   * \brief Get DL HARQ information
227   * \return DL HARQ message
228   */
229   DlInfoListElement_s GetDlHarqFeedback (void);
230 
231 private:
232   DlInfoListElement_s m_dlInfoListElement; ///< DL info list element
233 
234 };
235 
236 
237 // ---------------------------------------------------------------------------
238 
239 /**
240  * \ingroup lte
241  *
242  * abstract model for the Random Access Preamble
243  */
244 class RachPreambleLteControlMessage : public LteControlMessage
245 {
246 public:
247   RachPreambleLteControlMessage (void);
248 
249   /**
250    * Set the Random Access Preamble Identifier (RAPID), see 3GPP TS 36.321 6.2.2
251    *
252    * \param rapid the RAPID
253    */
254   void SetRapId (uint32_t rapid);
255 
256   /**
257    *
258    * \return the RAPID
259    */
260   uint32_t GetRapId () const;
261 
262 private:
263   uint32_t m_rapId; ///< the RAPID
264 
265 };
266 
267 
268 // ---------------------------------------------------------------------------
269 
270 /**
271  * \ingroup lte
272  *
273  * abstract model for the MAC Random Access Response message
274  */
275 class RarLteControlMessage : public LteControlMessage
276 {
277 public:
278   RarLteControlMessage (void);
279 
280   /**
281    *
282    * \param raRnti the RA-RNTI, see 3GPP TS 36.321 5.1.4
283    */
284   void SetRaRnti (uint16_t raRnti);
285 
286   /**
287    *
288    * \return  the RA-RNTI, see 3GPP TS 36.321 5.1.4
289    */
290   uint16_t GetRaRnti () const;
291 
292   /**
293    * a MAC RAR and the corresponding RAPID subheader
294    *
295    */
296   struct Rar
297   {
298     uint8_t rapId; ///< RAPID
299     BuildRarListElement_s rarPayload; ///< RAR payload
300   };
301 
302   /**
303    * add a RAR to the MAC PDU, see 3GPP TS 36.321 6.2.3
304    *
305    * \param rar the rar
306    */
307   void AddRar (Rar rar);
308 
309   /**
310    *
311    * \return a const iterator to the beginning of the RAR list
312    */
313   std::list<Rar>::const_iterator RarListBegin () const;
314 
315   /**
316    *
317    * \return a const iterator to the end of the RAR list
318    */
319   std::list<Rar>::const_iterator RarListEnd () const;
320 
321 private:
322   std::list<Rar> m_rarList; ///< RAR list
323   uint16_t m_raRnti; ///< RA RNTI
324 
325 };
326 
327 
328 // ---------------------------------------------------------------------------
329 
330 /**
331  * \ingroup lte
332  * \brief Abstract model for broadcasting the Master Information Block (MIB)
333  *        within the control channel (BCCH).
334  *
335  * MIB is transmitted by eNodeB RRC and received by UE RRC at every radio frame,
336  * i.e., every 10 milliseconds.
337  *
338  * \sa LteEnbRrc::ConfigureCell, LteEnbPhy::StartFrame,
339  *     LteUeRrc::DoRecvMasterInformationBlock
340  */
341 class MibLteControlMessage : public LteControlMessage
342 {
343 public:
344   /**
345    * \brief Create a new instance of MIB control message.
346    */
347   MibLteControlMessage (void);
348 
349   /**
350    * \brief Replace the MIB content of this control message.
351    * \param mib the desired MIB content
352    */
353   void SetMib (LteRrcSap::MasterInformationBlock mib);
354 
355   /**
356    * \brief Retrieve the MIB content from this control message.
357    * \return the current MIB content that this control message holds
358    */
359   LteRrcSap::MasterInformationBlock GetMib () const;
360 
361 private:
362   LteRrcSap::MasterInformationBlock m_mib; ///< MIB
363 
364 }; // end of class MibLteControlMessage
365 
366 
367 // ---------------------------------------------------------------------------
368 
369 /**
370  * \ingroup lte
371  * \brief Abstract model for broadcasting the System Information Block Type 1
372  *        (SIB1) within the control channel (BCCH).
373  *
374  * SIB1 is transmitted by eNodeB RRC and received by UE RRC at the 6th subframe
375  * of every odd-numbered radio frame, i.e., every 20 milliseconds.
376  *
377  * \sa LteEnbRrc::SetSystemInformationBlockType1, LteEnbPhy::StartSubFrame,
378  *     LteUeRrc::DoRecvSystemInformationBlockType1
379  */
380 class Sib1LteControlMessage : public LteControlMessage
381 {
382 public:
383   /**
384    * \brief Create a new instance of SIB1 control message.
385    */
386   Sib1LteControlMessage (void);
387 
388   /**
389    * \brief Replace the SIB1 content of this control message.
390    * \param sib1 the desired SIB1 content
391    */
392   void SetSib1 (LteRrcSap::SystemInformationBlockType1 sib1);
393 
394   /**
395    * \brief Retrieve the SIB1 content from this control message.
396    * \return the current SIB1 content that this control message holds
397    */
398   LteRrcSap::SystemInformationBlockType1 GetSib1 () const;
399 
400 private:
401   LteRrcSap::SystemInformationBlockType1 m_sib1; ///< SIB1
402 
403 }; // end of class Sib1LteControlMessage
404 
405 
406 } // namespace ns3
407 
408 #endif  // LTE_CONTROL_MESSAGES_H
409