author | Marco Miozzo <marco.miozzo@cttc.es> |
Thu, 08 Mar 2012 12:03:44 +0100 | |
changeset 8674 | 2bd42ffd4fe8 |
parent 8580 | 69e6897f7bc9 |
child 8680 | 6f04863cf772 |
permissions | -rw-r--r-- |
7938 | 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> |
|
7947 | 19 |
* Author: Marco Miozzo <marco.miozzo@cttc.es> |
7938 | 20 |
*/ |
21 |
||
22 |
#include "lte-common.h" |
|
7947 | 23 |
#include <ns3/log.h> |
8580
69e6897f7bc9
array boundary checking in lte-common.cc
Nicola Baldo <nbaldo@cttc.es>
parents:
8435
diff
changeset
|
24 |
#include <ns3/abort.h> |
7938 | 25 |
|
8580
69e6897f7bc9
array boundary checking in lte-common.cc
Nicola Baldo <nbaldo@cttc.es>
parents:
8435
diff
changeset
|
26 |
NS_LOG_COMPONENT_DEFINE ("LteCommon"); |
7938 | 27 |
|
28 |
namespace ns3 { |
|
29 |
||
30 |
||
7971 | 31 |
LteFlowId_t::LteFlowId_t () |
7938 | 32 |
{ |
33 |
} |
|
34 |
||
7971 | 35 |
LteFlowId_t::LteFlowId_t (const uint16_t a, const uint8_t b) |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
7971
diff
changeset
|
36 |
: m_rnti (a), |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
7971
diff
changeset
|
37 |
m_lcId (b) |
7938 | 38 |
{ |
39 |
} |
|
40 |
||
41 |
bool |
|
7971 | 42 |
operator == (const LteFlowId_t &a, const LteFlowId_t &b) |
7938 | 43 |
{ |
44 |
return ( (a.m_rnti == b.m_rnti) && (a.m_lcId == b.m_lcId) ); |
|
45 |
} |
|
46 |
||
47 |
bool |
|
7971 | 48 |
operator < (const LteFlowId_t& a, const LteFlowId_t& b) |
7938 | 49 |
{ |
50 |
return ( (a.m_rnti < b.m_rnti) || ( (a.m_rnti == b.m_rnti) && (a.m_lcId < b.m_lcId) ) ); |
|
51 |
} |
|
52 |
||
8266
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
53 |
ImsiLcidPair_t::ImsiLcidPair_t () |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
54 |
{ |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
55 |
} |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
56 |
|
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
57 |
ImsiLcidPair_t::ImsiLcidPair_t (const uint64_t a, const uint8_t b) |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
58 |
: m_imsi (a), |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
59 |
m_lcId (b) |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
60 |
{ |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
61 |
} |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
62 |
|
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
63 |
bool |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
64 |
operator == (const ImsiLcidPair_t &a, const ImsiLcidPair_t &b) |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
65 |
{ |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
66 |
return ((a.m_imsi == b.m_imsi) && (a.m_lcId == b.m_lcId)); |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
67 |
} |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
68 |
|
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
69 |
bool |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
70 |
operator < (const ImsiLcidPair_t& a, const ImsiLcidPair_t& b) |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
71 |
{ |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
72 |
return ((a.m_imsi < b.m_imsi) || ((a.m_imsi == b.m_imsi) && (a.m_lcId |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
73 |
< b.m_lcId))); |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
74 |
} |
3a30a2b5c94c
Refactoring of the statistics classes to avoid continious calls to the attribute system.
jaumenin
parents:
8148
diff
changeset
|
75 |
|
7938 | 76 |
|
7947 | 77 |
uint16_t |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
7971
diff
changeset
|
78 |
LteFfConverter::double2fpS11dot3 (double val) |
7947 | 79 |
{ |
80 |
// convert from double to fixed point notation Sxxxxxxxxxxx.xxx |
|
8674
2bd42ffd4fe8
Introduce sanity checks on LteFfConverter::double2fpS11dot3
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8580
diff
changeset
|
81 |
// truncate val to notation limits |
2bd42ffd4fe8
Introduce sanity checks on LteFfConverter::double2fpS11dot3
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8580
diff
changeset
|
82 |
if (val > 4095.88) val = 4095.88; |
2bd42ffd4fe8
Introduce sanity checks on LteFfConverter::double2fpS11dot3
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8580
diff
changeset
|
83 |
if (val < -4096) val = -4096; |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
7971
diff
changeset
|
84 |
int16_t valFp = (int16_t)(val * pow (2, 3)); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
7971
diff
changeset
|
85 |
return (valFp); |
7947 | 86 |
} |
87 |
||
88 |
double |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
7971
diff
changeset
|
89 |
LteFfConverter::fpS11dot3toDouble (uint16_t val) |
7947 | 90 |
{ |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
7971
diff
changeset
|
91 |
// convert from fixed point notation Sxxxxxxxxxxx.xxx to double |
7947 | 92 |
double valD = ((int16_t)val) / pow (2, 3); |
93 |
return (valD); |
|
94 |
} |
|
95 |
||
96 |
double |
|
97 |
LteFfConverter::getMinFpS11dot3Value () |
|
98 |
{ |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
7971
diff
changeset
|
99 |
return (-4096); // -4096 = 0x8000 = 1000 0000 0000 0000 b |
7947 | 100 |
} |
101 |
||
102 |
//static double g_lowestFpS11dot3Value = -4096; // 0x8001 (1000 0000 0000 0000) |
|
103 |
||
104 |
||
8435
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
105 |
uint32_t BufferSizeLevelBsrTable[64] = { |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
106 |
|
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
107 |
0, 10, 12, 14, 17, 19, 22, 26, 31, 36, 42, 49, 57, 67, 78, 91, |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
108 |
107, 125, 146, 171, 200, 234, 274, 321, 376, 440, 515, 603, |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
109 |
706, 826, 967, 1132, 1326, 1552, 1817, 2127, 2490, 2915, 3413, |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
110 |
3995, 4677, 5476, 6411, 7505, 8787, 10287, 12043, 14099, 16507, |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
111 |
19325, 22624, 26487, 31009, 36304, 42502, 49759, 58255, |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
112 |
68201, 79846, 93749, 109439, 128125, 150000, 150000 |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
113 |
|
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
114 |
}; |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
115 |
|
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
116 |
uint32_t |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
117 |
BufferSizeLevelBsr::BsrId2BufferSize (uint8_t val) |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
118 |
{ |
8580
69e6897f7bc9
array boundary checking in lte-common.cc
Nicola Baldo <nbaldo@cttc.es>
parents:
8435
diff
changeset
|
119 |
NS_ABORT_MSG_UNLESS (val >= 0 && val < 64, "val = " << val << " is out of range"); |
8435
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
120 |
return BufferSizeLevelBsrTable[val]; |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
121 |
} |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
122 |
|
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
123 |
uint8_t |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
124 |
BufferSizeLevelBsr::BufferSize2BsrId (uint32_t val) |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
125 |
{ |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
126 |
int index = 0; |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
127 |
if (BufferSizeLevelBsrTable[63] < val) |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
128 |
{ |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
129 |
index = 63; |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
130 |
} |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
131 |
else |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
132 |
{ |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
133 |
while (BufferSizeLevelBsrTable[index] < val) |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
134 |
{ |
8580
69e6897f7bc9
array boundary checking in lte-common.cc
Nicola Baldo <nbaldo@cttc.es>
parents:
8435
diff
changeset
|
135 |
NS_ASSERT (index < 64); |
8435
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
136 |
index++; |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
137 |
} |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
138 |
} |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
139 |
|
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
140 |
return (index); |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
141 |
} |
6b0542a91970
Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents:
8266
diff
changeset
|
142 |
|
7947 | 143 |
|
7938 | 144 |
}; // namespace ns3 |
145 |