A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
lte-common.cc
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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: Manuel Requena <manuel.requena@cttc.es>
19  * Author: Marco Miozzo <marco.miozzo@cttc.es>
20  */
21 
22 #include "lte-common.h"
23 #include <ns3/log.h>
24 #include <ns3/abort.h>
25 
26 NS_LOG_COMPONENT_DEFINE ("LteCommon");
27 
28 namespace ns3 {
29 
30 
31 LteFlowId_t::LteFlowId_t ()
32 {
33 }
34 
35 LteFlowId_t::LteFlowId_t (const uint16_t a, const uint8_t b)
36  : m_rnti (a),
37  m_lcId (b)
38 {
39 }
40 
41 bool
42 operator == (const LteFlowId_t &a, const LteFlowId_t &b)
43 {
44  return ( (a.m_rnti == b.m_rnti) && (a.m_lcId == b.m_lcId) );
45 }
46 
47 bool
48 operator < (const LteFlowId_t& a, const LteFlowId_t& b)
49 {
50  return ( (a.m_rnti < b.m_rnti) || ( (a.m_rnti == b.m_rnti) && (a.m_lcId < b.m_lcId) ) );
51 }
52 
53 ImsiLcidPair_t::ImsiLcidPair_t ()
54 {
55 }
56 
57 ImsiLcidPair_t::ImsiLcidPair_t (const uint64_t a, const uint8_t b)
58  : m_imsi (a),
59  m_lcId (b)
60 {
61 }
62 
63 bool
64 operator == (const ImsiLcidPair_t &a, const ImsiLcidPair_t &b)
65 {
66  return ((a.m_imsi == b.m_imsi) && (a.m_lcId == b.m_lcId));
67 }
68 
69 bool
70 operator < (const ImsiLcidPair_t& a, const ImsiLcidPair_t& b)
71 {
72  return ((a.m_imsi < b.m_imsi) || ((a.m_imsi == b.m_imsi) && (a.m_lcId
73  < b.m_lcId)));
74 }
75 
76 
77 LteUeConfig_t::LteUeConfig_t ()
78 {
79 }
80 
81 
82 
83 bool
84 operator == (const LteUeConfig_t &a, const LteUeConfig_t &b)
85 {
86  return (a.m_rnti == b.m_rnti);
87 }
88 
89 bool
90 operator < (const LteUeConfig_t& a, const LteUeConfig_t& b)
91 {
92  return (a.m_rnti < b.m_rnti);
93 }
94 
95 
96 uint16_t
97 LteFfConverter::double2fpS11dot3 (double val)
98 {
99  // convert from double to fixed point notation Sxxxxxxxxxxx.xxx
100  // truncate val to notation limits
101  if (val > 4095.88)
102  {
103  val = 4095.88;
104  }
105  if (val < -4096)
106  {
107  val = -4096;
108  }
109  int16_t valFp = (int16_t)(val * 8);
110  return (valFp);
111 }
112 
113 double
114 LteFfConverter::fpS11dot3toDouble (uint16_t val)
115 {
116  // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
117  double valD = ((int16_t)val) / 8.0;
118  return (valD);
119 }
120 
121 double
122 LteFfConverter::getMinFpS11dot3Value ()
123 {
124  return (-4096); // -4096 = 0x8000 = 1000 0000 0000 0000 b
125 }
126 
127 //static double g_lowestFpS11dot3Value = -4096; // 0x8001 (1000 0000 0000 0000)
128 
129 
130 uint32_t BufferSizeLevelBsrTable[64] = {
131 
132  0, 10, 12, 14, 17, 19, 22, 26, 31, 36, 42, 49, 57, 67, 78, 91,
133  107, 125, 146, 171, 200, 234, 274, 321, 376, 440, 515, 603,
134  706, 826, 967, 1132, 1326, 1552, 1817, 2127, 2490, 2915, 3413,
135  3995, 4677, 5476, 6411, 7505, 8787, 10287, 12043, 14099, 16507,
136  19325, 22624, 26487, 31009, 36304, 42502, 49759, 58255,
137  68201, 79846, 93749, 109439, 128125, 150000, 150000
138 
139 };
140 
141 uint32_t
142 BufferSizeLevelBsr::BsrId2BufferSize (uint8_t val)
143 {
144  NS_ABORT_MSG_UNLESS (val < 64, "val = " << val << " is out of range");
145  return BufferSizeLevelBsrTable[val];
146 }
147 
148 uint8_t
149 BufferSizeLevelBsr::BufferSize2BsrId (uint32_t val)
150 {
151  int index = 0;
152  if (BufferSizeLevelBsrTable[63] < val)
153  {
154  index = 63;
155  }
156  else
157  {
158  while (BufferSizeLevelBsrTable[index] < val)
159  {
160  NS_ASSERT (index < 64);
161  index++;
162  }
163  }
164 
165  return (index);
166 }
167 
168 
169 uint8_t
170 TransmissionModesLayers::TxMode2LayerNum (uint8_t txMode)
171 {
172  uint8_t nLayer = 0;
173  switch (txMode)
174  {
175  case 0: // Tx MODE 1: SISO
176  nLayer = 1;
177  break;
178  case 1: // Tx MODE 2: MIMO Tx Diversity
179  nLayer = 1;
180  break;
181  case 2: // Tx MODE 3: MIMO Spatial Multiplexity Open Loop
182  nLayer = 2;
183  break;
184  case 3: // Tx MODE 4: MIMO Spatial Multiplexity Closed Loop
185  nLayer = 2;
186  break;
187  case 4: // Tx MODE 5: MIMO Multi-User
188  nLayer = 2;
189  break;
190  case 5: // Tx MODE 6: Closer loop single layer percoding
191  nLayer = 1;
192  break;
193  case 6: // Tx MODE 7: Single antenna port 5
194  nLayer = 1;
195  break;
196  }
197  return (nLayer);
198 }
199 
200 
201 }; // namespace ns3
202 
#define NS_ASSERT(condition)
Definition: assert.h:64
#define NS_LOG_COMPONENT_DEFINE(name)
Definition: log.h:122
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if cond is false.
Definition: abort.h:131