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 std::map<uint16_t, std::vector<HarqProcessInfoList_t>>::iterator it;
57 for (it = m_miUlHarqProcessesInfoMap.begin(); it != m_miUlHarqProcessesInfoMap.end(); it++)
58 {
59 (*it).second.erase((*it).second.begin());
61 (*it).second.push_back(h);
62 }
63}
64
65double
66LteHarqPhy::GetAccumulatedMiDl(uint8_t harqProcId, uint8_t layer)
67{
68 NS_LOG_FUNCTION(this << (uint32_t)harqProcId << (uint16_t)layer);
69 HarqProcessInfoList_t list = m_miDlHarqProcessesInfoMap.at(layer).at(harqProcId);
70 double mi = 0.0;
71 for (std::size_t i = 0; i < list.size(); i++)
72 {
73 mi += list.at(i).m_mi;
74 }
75 return (mi);
76}
77
79LteHarqPhy::GetHarqProcessInfoDl(uint8_t harqProcId, uint8_t layer)
80{
81 NS_LOG_FUNCTION(this << (uint32_t)harqProcId << (uint16_t)layer);
82 return (m_miDlHarqProcessesInfoMap.at(layer).at(harqProcId));
83}
84
85double
87{
88 NS_LOG_FUNCTION(this << rnti);
89
90 std::map<uint16_t, std::vector<HarqProcessInfoList_t>>::iterator it;
91 it = m_miUlHarqProcessesInfoMap.find(rnti);
92 NS_ASSERT_MSG(it != m_miUlHarqProcessesInfoMap.end(), " Does not find MI for RNTI");
93 HarqProcessInfoList_t list = (*it).second.at(0);
94 double mi = 0.0;
95 for (std::size_t i = 0; i < list.size(); i++)
96 {
97 mi += list.at(i).m_mi;
98 }
99 return (mi);
100}
101
103LteHarqPhy::GetHarqProcessInfoUl(uint16_t rnti, uint8_t harqProcId)
104{
105 NS_LOG_FUNCTION(this << rnti << (uint16_t)harqProcId);
106 std::map<uint16_t, std::vector<HarqProcessInfoList_t>>::iterator it;
107 it = m_miUlHarqProcessesInfoMap.find(rnti);
108 if (it == m_miUlHarqProcessesInfoMap.end())
109 {
110 // new entry
111 std::vector<HarqProcessInfoList_t> harqList;
112 harqList.resize(8);
114 std::pair<uint16_t, std::vector<HarqProcessInfoList_t>>(rnti, harqList));
115 return (harqList.at(harqProcId));
116 }
117 else
118 {
119 return ((*it).second.at(harqProcId));
120 }
121}
122
123void
125 uint8_t layer,
126 double mi,
127 uint16_t infoBytes,
128 uint16_t codeBytes)
129{
130 NS_LOG_FUNCTION(this << (uint16_t)id << mi);
131 if (m_miDlHarqProcessesInfoMap.at(layer).at(id).size() == 3) // MAX HARQ RETX
132 {
133 // HARQ should be disabled -> discard info
134 return;
135 }
137 el.m_mi = mi;
138 el.m_infoBits = infoBytes * 8;
139 el.m_codeBits = codeBytes * 8;
140 m_miDlHarqProcessesInfoMap.at(layer).at(id).push_back(el);
141}
142
143void
145{
146 NS_LOG_FUNCTION(this << (uint16_t)id);
147 for (std::size_t i = 0; i < m_miDlHarqProcessesInfoMap.size(); i++)
148 {
149 m_miDlHarqProcessesInfoMap.at(i).at(id).clear();
150 }
151}
152
153void
155 double mi,
156 uint16_t infoBytes,
157 uint16_t codeBytes)
158{
159 NS_LOG_FUNCTION(this << rnti << mi);
160 std::map<uint16_t, std::vector<HarqProcessInfoList_t>>::iterator it;
161 it = m_miUlHarqProcessesInfoMap.find(rnti);
162 if (it == m_miUlHarqProcessesInfoMap.end())
163 {
164 // new entry
165 std::vector<HarqProcessInfoList_t> harqList;
166 harqList.resize(8);
168 el.m_mi = mi;
169 el.m_infoBits = infoBytes * 8;
170 el.m_codeBits = codeBytes * 8;
171 harqList.at(7).push_back(el);
173 std::pair<uint16_t, std::vector<HarqProcessInfoList_t>>(rnti, harqList));
174 }
175 else
176 {
177 if ((*it).second.at(0).size() == 3) // MAX HARQ RETX
178 {
179 // HARQ should be disabled -> discard info
180 return;
181 }
182
183 // move current status back at the end to maintain full history
184 HarqProcessInfoList_t list = (*it).second.at(0);
185 for (std::size_t i = 0; i < list.size(); i++)
186 {
187 (*it).second.at(7).push_back(list.at(i));
188 }
189
191 el.m_mi = mi;
192 el.m_infoBits = infoBytes * 8;
193 el.m_codeBits = codeBytes * 8;
194 (*it).second.at(7).push_back(el);
195 }
196}
197
198void
199LteHarqPhy::ResetUlHarqProcessStatus(uint16_t rnti, uint8_t id)
200{
201 NS_LOG_FUNCTION(this << rnti << (uint16_t)id);
202 std::map<uint16_t, std::vector<HarqProcessInfoList_t>>::iterator it;
203 it = m_miUlHarqProcessesInfoMap.find(rnti);
204 if (it == m_miUlHarqProcessesInfoMap.end())
205 {
206 // new entry
207 std::vector<HarqProcessInfoList_t> harqList;
208 harqList.resize(8);
210 std::pair<uint16_t, std::vector<HarqProcessInfoList_t>>(rnti, harqList));
211 }
212 else
213 {
214 (*it).second.at(id).clear();
215 }
216}
217
218void
220{
221 NS_LOG_FUNCTION(this << rnti);
222 // flush the DL harq buffers
224 // Recreate DL Decodification HARQ buffers
225 std::vector<HarqProcessInfoList_t> dlHarqLayer0;
226 dlHarqLayer0.resize(8);
227 std::vector<HarqProcessInfoList_t> dlHarqLayer1;
228 dlHarqLayer1.resize(8);
229 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer0);
230 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer1);
231}
232
233} // 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:86
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:79
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:66
#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