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 <ns3/assert.h>
21#include <ns3/log.h>
22#include <ns3/lte-harq-phy.h>
23
24namespace ns3
25{
26
27NS_LOG_COMPONENT_DEFINE("LteHarqPhy");
28
29// NS_OBJECT_ENSURE_REGISTERED (LteHarqPhy)
30// ;
31
33{
34 // Create DL Decodification HARQ buffers
35 std::vector<HarqProcessInfoList_t> dlHarqLayer0;
36 dlHarqLayer0.resize(8);
37 std::vector<HarqProcessInfoList_t> dlHarqLayer1;
38 dlHarqLayer1.resize(8);
39 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer0);
40 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer1);
41}
42
44{
47}
48
49void
51{
52 NS_LOG_FUNCTION(this);
53
54 // left shift UL HARQ buffers
55 std::map<uint16_t, std::vector<HarqProcessInfoList_t>>::iterator it;
56 for (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 std::map<uint16_t, std::vector<HarqProcessInfoList_t>>::iterator it;
90 it = m_miUlHarqProcessesInfoMap.find(rnti);
91 NS_ASSERT_MSG(it != m_miUlHarqProcessesInfoMap.end(), " Does not find MI for RNTI");
92 HarqProcessInfoList_t list = (*it).second.at(0);
93 double mi = 0.0;
94 for (std::size_t i = 0; i < list.size(); i++)
95 {
96 mi += list.at(i).m_mi;
97 }
98 return (mi);
99}
100
102LteHarqPhy::GetHarqProcessInfoUl(uint16_t rnti, uint8_t harqProcId)
103{
104 NS_LOG_FUNCTION(this << rnti << (uint16_t)harqProcId);
105 std::map<uint16_t, std::vector<HarqProcessInfoList_t>>::iterator it;
106 it = m_miUlHarqProcessesInfoMap.find(rnti);
107 if (it == m_miUlHarqProcessesInfoMap.end())
108 {
109 // new entry
110 std::vector<HarqProcessInfoList_t> harqList;
111 harqList.resize(8);
113 std::pair<uint16_t, std::vector<HarqProcessInfoList_t>>(rnti, harqList));
114 return (harqList.at(harqProcId));
115 }
116 else
117 {
118 return ((*it).second.at(harqProcId));
119 }
120}
121
122void
124 uint8_t layer,
125 double mi,
126 uint16_t infoBytes,
127 uint16_t codeBytes)
128{
129 NS_LOG_FUNCTION(this << (uint16_t)id << mi);
130 if (m_miDlHarqProcessesInfoMap.at(layer).at(id).size() == 3) // MAX HARQ RETX
131 {
132 // HARQ should be disabled -> discard info
133 return;
134 }
136 el.m_mi = mi;
137 el.m_infoBits = infoBytes * 8;
138 el.m_codeBits = codeBytes * 8;
139 m_miDlHarqProcessesInfoMap.at(layer).at(id).push_back(el);
140}
141
142void
144{
145 NS_LOG_FUNCTION(this << (uint16_t)id);
146 for (std::size_t i = 0; i < m_miDlHarqProcessesInfoMap.size(); i++)
147 {
148 m_miDlHarqProcessesInfoMap.at(i).at(id).clear();
149 }
150}
151
152void
154 double mi,
155 uint16_t infoBytes,
156 uint16_t codeBytes)
157{
158 NS_LOG_FUNCTION(this << rnti << mi);
159 std::map<uint16_t, std::vector<HarqProcessInfoList_t>>::iterator it;
160 it = m_miUlHarqProcessesInfoMap.find(rnti);
161 if (it == m_miUlHarqProcessesInfoMap.end())
162 {
163 // new entry
164 std::vector<HarqProcessInfoList_t> harqList;
165 harqList.resize(8);
167 el.m_mi = mi;
168 el.m_infoBits = infoBytes * 8;
169 el.m_codeBits = codeBytes * 8;
170 harqList.at(7).push_back(el);
172 std::pair<uint16_t, std::vector<HarqProcessInfoList_t>>(rnti, harqList));
173 }
174 else
175 {
176 if ((*it).second.at(0).size() == 3) // MAX HARQ RETX
177 {
178 // HARQ should be disabled -> discard info
179 return;
180 }
181
182 // move current status back at the end to maintain full history
183 HarqProcessInfoList_t list = (*it).second.at(0);
184 for (std::size_t i = 0; i < list.size(); i++)
185 {
186 (*it).second.at(7).push_back(list.at(i));
187 }
188
190 el.m_mi = mi;
191 el.m_infoBits = infoBytes * 8;
192 el.m_codeBits = codeBytes * 8;
193 (*it).second.at(7).push_back(el);
194 }
195}
196
197void
198LteHarqPhy::ResetUlHarqProcessStatus(uint16_t rnti, uint8_t id)
199{
200 NS_LOG_FUNCTION(this << rnti << (uint16_t)id);
201 std::map<uint16_t, std::vector<HarqProcessInfoList_t>>::iterator it;
202 it = m_miUlHarqProcessesInfoMap.find(rnti);
203 if (it == m_miUlHarqProcessesInfoMap.end())
204 {
205 // new entry
206 std::vector<HarqProcessInfoList_t> harqList;
207 harqList.resize(8);
209 std::pair<uint16_t, std::vector<HarqProcessInfoList_t>>(rnti, harqList));
210 }
211 else
212 {
213 (*it).second.at(id).clear();
214 }
215}
216
217void
219{
220 NS_LOG_FUNCTION(this << rnti);
221 // flush the DL harq buffers
223 // Recreate DL Decodification HARQ buffers
224 std::vector<HarqProcessInfoList_t> dlHarqLayer0;
225 dlHarqLayer0.resize(8);
226 std::vector<HarqProcessInfoList_t> dlHarqLayer1;
227 dlHarqLayer1.resize(8);
228 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer0);
229 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer1);
230}
231
232} // 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:50
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