A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-harq-phy.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Marco Miozzo <marco.miozzo@cttc.es>
18 */
19
20#include "lte-harq-phy.h"
21
22#include <ns3/assert.h>
23#include <ns3/log.h>
24
25namespace ns3
26{
27
28NS_LOG_COMPONENT_DEFINE("LteHarqPhy");
29
30// NS_OBJECT_ENSURE_REGISTERED (LteHarqPhy)
31// ;
32
34{
35 // Create DL Decodification HARQ buffers
36 std::vector<HarqProcessInfoList_t> dlHarqLayer0;
37 dlHarqLayer0.resize(8);
38 std::vector<HarqProcessInfoList_t> dlHarqLayer1;
39 dlHarqLayer1.resize(8);
40 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer0);
41 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer1);
42}
43
45{
48}
49
50void
52{
53 NS_LOG_FUNCTION(this);
54
55 // left shift UL HARQ buffers
56 for (auto it = m_miUlHarqProcessesInfoMap.begin(); it != m_miUlHarqProcessesInfoMap.end(); it++)
57 {
58 (*it).second.erase((*it).second.begin());
60 (*it).second.push_back(h);
61 }
62}
63
64double
65LteHarqPhy::GetAccumulatedMiDl(uint8_t harqProcId, uint8_t layer)
66{
67 NS_LOG_FUNCTION(this << (uint32_t)harqProcId << (uint16_t)layer);
68 HarqProcessInfoList_t list = m_miDlHarqProcessesInfoMap.at(layer).at(harqProcId);
69 double mi = 0.0;
70 for (std::size_t i = 0; i < list.size(); i++)
71 {
72 mi += list.at(i).m_mi;
73 }
74 return mi;
75}
76
78LteHarqPhy::GetHarqProcessInfoDl(uint8_t harqProcId, uint8_t layer)
79{
80 NS_LOG_FUNCTION(this << (uint32_t)harqProcId << (uint16_t)layer);
81 return m_miDlHarqProcessesInfoMap.at(layer).at(harqProcId);
82}
83
84double
86{
87 NS_LOG_FUNCTION(this << rnti);
88
89 auto it = m_miUlHarqProcessesInfoMap.find(rnti);
90 NS_ASSERT_MSG(it != m_miUlHarqProcessesInfoMap.end(), " Does not find MI for RNTI");
91 HarqProcessInfoList_t list = (*it).second.at(0);
92 double mi = 0.0;
93 for (std::size_t i = 0; i < list.size(); i++)
94 {
95 mi += list.at(i).m_mi;
96 }
97 return mi;
98}
99
101LteHarqPhy::GetHarqProcessInfoUl(uint16_t rnti, uint8_t harqProcId)
102{
103 NS_LOG_FUNCTION(this << rnti << (uint16_t)harqProcId);
104 auto it = m_miUlHarqProcessesInfoMap.find(rnti);
105 if (it == m_miUlHarqProcessesInfoMap.end())
106 {
107 // new entry
108 std::vector<HarqProcessInfoList_t> harqList;
109 harqList.resize(8);
111 std::pair<uint16_t, std::vector<HarqProcessInfoList_t>>(rnti, harqList));
112 return harqList.at(harqProcId);
113 }
114 else
115 {
116 return (*it).second.at(harqProcId);
117 }
118}
119
120void
122 uint8_t layer,
123 double mi,
124 uint16_t infoBytes,
125 uint16_t codeBytes)
126{
127 NS_LOG_FUNCTION(this << (uint16_t)id << mi);
128 if (m_miDlHarqProcessesInfoMap.at(layer).at(id).size() == 3) // MAX HARQ RETX
129 {
130 // HARQ should be disabled -> discard info
131 return;
132 }
134 el.m_mi = mi;
135 el.m_infoBits = infoBytes * 8;
136 el.m_codeBits = codeBytes * 8;
137 m_miDlHarqProcessesInfoMap.at(layer).at(id).push_back(el);
138}
139
140void
142{
143 NS_LOG_FUNCTION(this << (uint16_t)id);
144 for (std::size_t i = 0; i < m_miDlHarqProcessesInfoMap.size(); i++)
145 {
146 m_miDlHarqProcessesInfoMap.at(i).at(id).clear();
147 }
148}
149
150void
152 double mi,
153 uint16_t infoBytes,
154 uint16_t codeBytes)
155{
156 NS_LOG_FUNCTION(this << rnti << mi);
157 auto it = m_miUlHarqProcessesInfoMap.find(rnti);
158 if (it == m_miUlHarqProcessesInfoMap.end())
159 {
160 // new entry
161 std::vector<HarqProcessInfoList_t> harqList;
162 harqList.resize(8);
164 el.m_mi = mi;
165 el.m_infoBits = infoBytes * 8;
166 el.m_codeBits = codeBytes * 8;
167 harqList.at(7).push_back(el);
169 std::pair<uint16_t, std::vector<HarqProcessInfoList_t>>(rnti, harqList));
170 }
171 else
172 {
173 if ((*it).second.at(0).size() == 3) // MAX HARQ RETX
174 {
175 // HARQ should be disabled -> discard info
176 return;
177 }
178
179 // move current status back at the end to maintain full history
180 HarqProcessInfoList_t list = (*it).second.at(0);
181 for (std::size_t i = 0; i < list.size(); i++)
182 {
183 (*it).second.at(7).push_back(list.at(i));
184 }
185
187 el.m_mi = mi;
188 el.m_infoBits = infoBytes * 8;
189 el.m_codeBits = codeBytes * 8;
190 (*it).second.at(7).push_back(el);
191 }
192}
193
194void
195LteHarqPhy::ResetUlHarqProcessStatus(uint16_t rnti, uint8_t id)
196{
197 NS_LOG_FUNCTION(this << rnti << (uint16_t)id);
198 auto it = m_miUlHarqProcessesInfoMap.find(rnti);
199 if (it == m_miUlHarqProcessesInfoMap.end())
200 {
201 // new entry
202 std::vector<HarqProcessInfoList_t> harqList;
203 harqList.resize(8);
205 std::pair<uint16_t, std::vector<HarqProcessInfoList_t>>(rnti, harqList));
206 }
207 else
208 {
209 (*it).second.at(id).clear();
210 }
211}
212
213void
215{
216 NS_LOG_FUNCTION(this << rnti);
217 // flush the DL harq buffers
219 // Recreate DL Decodification HARQ buffers
220 std::vector<HarqProcessInfoList_t> dlHarqLayer0;
221 dlHarqLayer0.resize(8);
222 std::vector<HarqProcessInfoList_t> dlHarqLayer1;
223 dlHarqLayer1.resize(8);
224 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer0);
225 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer1);
226}
227
228} // namespace ns3
void ClearDlHarqBuffer(uint16_t rnti)
Clear the downlink HARQ buffer.
void SubframeIndication(uint32_t frameNo, uint32_t subframeNo)
Subframe Indication function.
Definition: lte-harq-phy.cc:51
void UpdateDlHarqProcessStatus(uint8_t id, uint8_t layer, double mi, uint16_t infoBytes, uint16_t codeBytes)
Update the Info associated to the decodification of an HARQ process for DL (asynchronous)
void UpdateUlHarqProcessStatus(uint16_t rnti, double mi, uint16_t infoBytes, uint16_t codeBytes)
Update the MI value associated to the decodification of an HARQ process for DL (asynchronous)
double GetAccumulatedMiUl(uint16_t rnti)
Return the cumulated MI of the HARQ procId in case of retransmissions for UL (synchronous)
Definition: lte-harq-phy.cc:85
HarqProcessInfoList_t GetHarqProcessInfoDl(uint8_t harqProcId, uint8_t layer)
Return the info of the HARQ procId in case of retransmissions for DL (asynchronous)
Definition: lte-harq-phy.cc:78
HarqProcessInfoList_t GetHarqProcessInfoUl(uint16_t rnti, uint8_t harqProcId)
Return the info of the HARQ procId in case of retransmissions for UL (asynchronous)
std::vector< std::vector< HarqProcessInfoList_t > > m_miDlHarqProcessesInfoMap
MI DL HARQ processes info map.
Definition: lte-harq-phy.h:152
void ResetDlHarqProcessStatus(uint8_t id)
Reset the info associated to the decodification of an HARQ process for DL (asynchronous)
std::map< uint16_t, std::vector< HarqProcessInfoList_t > > m_miUlHarqProcessesInfoMap
MI UL HARQ processes info map.
Definition: lte-harq-phy.h:154
void ResetUlHarqProcessStatus(uint16_t rnti, uint8_t id)
Reset the info associated to the decodification of an HARQ process for DL (asynchronous)
double GetAccumulatedMiDl(uint8_t harqProcId, uint8_t layer)
Return the cumulated MI of the HARQ procId in case of retransmissions for DL (asynchronous)
Definition: lte-harq-phy.cc:65
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< HarqProcessInfoElement_t > HarqProcessInfoList_t
HarqProcessInfoList_t typedef.
Definition: lte-harq-phy.h:44
#define list
HarqProcessInfoElement_t structure.
Definition: lte-harq-phy.h:36
uint16_t m_codeBits
code bits
Definition: lte-harq-phy.h:40
uint16_t m_infoBits
info bits
Definition: lte-harq-phy.h:39
double m_mi
Mutual information.
Definition: lte-harq-phy.h:37