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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Marco Miozzo <marco.miozzo@cttc.es>
7 */
8
9#include "lte-harq-phy.h"
10
11#include <ns3/assert.h>
12#include <ns3/log.h>
13
14namespace ns3
15{
16
17NS_LOG_COMPONENT_DEFINE("LteHarqPhy");
18
19// NS_OBJECT_ENSURE_REGISTERED (LteHarqPhy)
20// ;
21
23{
24 // Create DL Decodification HARQ buffers
25 std::vector<HarqProcessInfoList_t> dlHarqLayer0;
26 dlHarqLayer0.resize(8);
27 std::vector<HarqProcessInfoList_t> dlHarqLayer1;
28 dlHarqLayer1.resize(8);
29 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer0);
30 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer1);
31}
32
38
39void
41{
42 NS_LOG_FUNCTION(this);
43
44 // left shift UL HARQ buffers
45 for (auto it = m_miUlHarqProcessesInfoMap.begin(); it != m_miUlHarqProcessesInfoMap.end(); it++)
46 {
47 (*it).second.erase((*it).second.begin());
49 (*it).second.push_back(h);
50 }
51}
52
53double
54LteHarqPhy::GetAccumulatedMiDl(uint8_t harqProcId, uint8_t layer)
55{
56 NS_LOG_FUNCTION(this << (uint32_t)harqProcId << (uint16_t)layer);
57 HarqProcessInfoList_t list = m_miDlHarqProcessesInfoMap.at(layer).at(harqProcId);
58 double mi = 0.0;
59 for (std::size_t i = 0; i < list.size(); i++)
60 {
61 mi += list.at(i).m_mi;
62 }
63 return mi;
64}
65
67LteHarqPhy::GetHarqProcessInfoDl(uint8_t harqProcId, uint8_t layer)
68{
69 NS_LOG_FUNCTION(this << (uint32_t)harqProcId << (uint16_t)layer);
70 return m_miDlHarqProcessesInfoMap.at(layer).at(harqProcId);
71}
72
73double
75{
76 NS_LOG_FUNCTION(this << rnti);
77
78 auto it = m_miUlHarqProcessesInfoMap.find(rnti);
79 NS_ASSERT_MSG(it != m_miUlHarqProcessesInfoMap.end(), " Does not find MI for RNTI");
80 HarqProcessInfoList_t list = (*it).second.at(0);
81 double mi = 0.0;
82 for (std::size_t i = 0; i < list.size(); i++)
83 {
84 mi += list.at(i).m_mi;
85 }
86 return mi;
87}
88
90LteHarqPhy::GetHarqProcessInfoUl(uint16_t rnti, uint8_t harqProcId)
91{
92 NS_LOG_FUNCTION(this << rnti << (uint16_t)harqProcId);
93 auto it = m_miUlHarqProcessesInfoMap.find(rnti);
94 if (it == m_miUlHarqProcessesInfoMap.end())
95 {
96 // new entry
97 std::vector<HarqProcessInfoList_t> harqList;
98 harqList.resize(8);
100 std::pair<uint16_t, std::vector<HarqProcessInfoList_t>>(rnti, harqList));
101 return harqList.at(harqProcId);
102 }
103 else
104 {
105 return (*it).second.at(harqProcId);
106 }
107}
108
109void
111 uint8_t layer,
112 double mi,
113 uint16_t infoBytes,
114 uint16_t codeBytes)
115{
116 NS_LOG_FUNCTION(this << (uint16_t)id << mi);
117 if (m_miDlHarqProcessesInfoMap.at(layer).at(id).size() == 3) // MAX HARQ RETX
118 {
119 // HARQ should be disabled -> discard info
120 return;
121 }
123 el.m_mi = mi;
124 el.m_infoBits = infoBytes * 8;
125 el.m_codeBits = codeBytes * 8;
126 m_miDlHarqProcessesInfoMap.at(layer).at(id).push_back(el);
127}
128
129void
131{
132 NS_LOG_FUNCTION(this << (uint16_t)id);
133 for (std::size_t i = 0; i < m_miDlHarqProcessesInfoMap.size(); i++)
134 {
135 m_miDlHarqProcessesInfoMap.at(i).at(id).clear();
136 }
137}
138
139void
141 double mi,
142 uint16_t infoBytes,
143 uint16_t codeBytes)
144{
145 NS_LOG_FUNCTION(this << rnti << mi);
146 auto it = m_miUlHarqProcessesInfoMap.find(rnti);
147 if (it == m_miUlHarqProcessesInfoMap.end())
148 {
149 // new entry
150 std::vector<HarqProcessInfoList_t> harqList;
151 harqList.resize(8);
153 el.m_mi = mi;
154 el.m_infoBits = infoBytes * 8;
155 el.m_codeBits = codeBytes * 8;
156 harqList.at(7).push_back(el);
158 std::pair<uint16_t, std::vector<HarqProcessInfoList_t>>(rnti, harqList));
159 }
160 else
161 {
162 if ((*it).second.at(0).size() == 3) // MAX HARQ RETX
163 {
164 // HARQ should be disabled -> discard info
165 return;
166 }
167
168 // move current status back at the end to maintain full history
169 HarqProcessInfoList_t list = (*it).second.at(0);
170 for (std::size_t i = 0; i < list.size(); i++)
171 {
172 (*it).second.at(7).push_back(list.at(i));
173 }
174
176 el.m_mi = mi;
177 el.m_infoBits = infoBytes * 8;
178 el.m_codeBits = codeBytes * 8;
179 (*it).second.at(7).push_back(el);
180 }
181}
182
183void
184LteHarqPhy::ResetUlHarqProcessStatus(uint16_t rnti, uint8_t id)
185{
186 NS_LOG_FUNCTION(this << rnti << (uint16_t)id);
187 auto it = m_miUlHarqProcessesInfoMap.find(rnti);
188 if (it == m_miUlHarqProcessesInfoMap.end())
189 {
190 // new entry
191 std::vector<HarqProcessInfoList_t> harqList;
192 harqList.resize(8);
194 std::pair<uint16_t, std::vector<HarqProcessInfoList_t>>(rnti, harqList));
195 }
196 else
197 {
198 (*it).second.at(id).clear();
199 }
200}
201
202void
204{
205 NS_LOG_FUNCTION(this << rnti);
206 // flush the DL harq buffers
208 // Recreate DL Decodification HARQ buffers
209 std::vector<HarqProcessInfoList_t> dlHarqLayer0;
210 dlHarqLayer0.resize(8);
211 std::vector<HarqProcessInfoList_t> dlHarqLayer1;
212 dlHarqLayer1.resize(8);
213 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer0);
214 m_miDlHarqProcessesInfoMap.push_back(dlHarqLayer1);
215}
216
217} // namespace ns3
void ClearDlHarqBuffer(uint16_t rnti)
Clear the downlink HARQ buffer.
void SubframeIndication(uint32_t frameNo, uint32_t subframeNo)
Subframe Indication function.
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)
HarqProcessInfoList_t GetHarqProcessInfoDl(uint8_t harqProcId, uint8_t layer)
Return the info of the HARQ procId in case of retransmissions for DL (asynchronous)
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.
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.
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)
#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:75
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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.
HarqProcessInfoElement_t structure.
uint16_t m_codeBits
code bits
uint16_t m_infoBits
info bits
double m_mi
Mutual information.