A Discrete-Event Network Simulator
API
lte-harq-phy.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2012 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: Marco Miozzo <marco.miozzo@cttc.es>
19  */
20 
21 
22 #include <ns3/lte-harq-phy.h>
23 #include <ns3/log.h>
24 #include <ns3/assert.h>
25 
26 namespace ns3 {
27 
28 NS_LOG_COMPONENT_DEFINE ("LteHarqPhy");
29 
30 //NS_OBJECT_ENSURE_REGISTERED (LteHarqPhy)
31 // ;
32 
33 
35 {
36  // Create DL Decodification HARQ buffers
37  std::vector <HarqProcessInfoList_t> dlHarqLayer0;
38  dlHarqLayer0.resize (8);
39  std::vector <HarqProcessInfoList_t> dlHarqLayer1;
40  dlHarqLayer1.resize (8);
41  m_miDlHarqProcessesInfoMap.push_back (dlHarqLayer0);
42  m_miDlHarqProcessesInfoMap.push_back (dlHarqLayer1);
43 }
44 
45 
47 {
50 }
51 
52 
53 void
54 LteHarqPhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo)
55 {
56  NS_LOG_FUNCTION (this);
57 
58  // left shift UL HARQ buffers
59  std::map <uint16_t, std::vector <HarqProcessInfoList_t> >::iterator it;
60  for (it = m_miUlHarqProcessesInfoMap.begin (); it != m_miUlHarqProcessesInfoMap.end (); it++)
61  {
62  (*it).second.erase ((*it).second.begin ());
64  (*it).second.push_back (h);
65  }
66 
67 }
68 
69 
70 double
71 LteHarqPhy::GetAccumulatedMiDl (uint8_t harqProcId, uint8_t layer)
72 {
73  NS_LOG_FUNCTION (this << (uint32_t)harqProcId << (uint16_t)layer);
74  HarqProcessInfoList_t list = m_miDlHarqProcessesInfoMap.at (layer).at (harqProcId);
75  double mi = 0.0;
76  for (uint8_t i = 0; i < list.size (); i++)
77  {
78  mi += list.at (i).m_mi;
79  }
80  return (mi);
81 }
82 
84 LteHarqPhy::GetHarqProcessInfoDl (uint8_t harqProcId, uint8_t layer)
85 {
86  NS_LOG_FUNCTION (this << (uint32_t)harqProcId << (uint16_t)layer);
87  return (m_miDlHarqProcessesInfoMap.at (layer).at (harqProcId));
88 }
89 
90 
91 double
93 {
94  NS_LOG_FUNCTION (this << rnti);
95 
96  std::map <uint16_t, std::vector <HarqProcessInfoList_t> >::iterator it;
97  it = m_miUlHarqProcessesInfoMap.find (rnti);
98  NS_ASSERT_MSG (it!=m_miUlHarqProcessesInfoMap.end (), " Does not find MI for RNTI");
99  HarqProcessInfoList_t list = (*it).second.at (0);
100  double mi = 0.0;
101  for (uint8_t i = 0; i < list.size (); i++)
102  {
103  mi += list.at (i).m_mi;
104  }
105  return (mi);
106 }
107 
109 LteHarqPhy::GetHarqProcessInfoUl (uint16_t rnti, uint8_t harqProcId)
110 {
111  NS_LOG_FUNCTION (this << rnti << (uint16_t)harqProcId);
112  std::map <uint16_t, std::vector <HarqProcessInfoList_t> >::iterator it;
113  it = m_miUlHarqProcessesInfoMap.find (rnti);
114  if (it==m_miUlHarqProcessesInfoMap.end ())
115  {
116  // new entry
117  std::vector <HarqProcessInfoList_t> harqList;
118  harqList.resize (8);
119  m_miUlHarqProcessesInfoMap.insert (std::pair <uint16_t, std::vector <HarqProcessInfoList_t> > (rnti, harqList));
120  return (harqList.at (harqProcId));
121  }
122  else
123  {
124  return ((*it).second.at (harqProcId));
125  }
126 }
127 
128 
129 
130 void
131 LteHarqPhy::UpdateDlHarqProcessStatus (uint8_t id, uint8_t layer, double mi, uint16_t infoBytes, uint16_t codeBytes)
132 {
133  NS_LOG_FUNCTION (this << (uint16_t) id << mi);
134  if (m_miDlHarqProcessesInfoMap.at (layer).at (id).size () == 3) // MAX HARQ RETX
135  {
136  // HARQ should be disabled -> discard info
137  return;
138  }
140  el.m_mi = mi;
141  el.m_infoBits = infoBytes * 8;
142  el.m_codeBits = codeBytes * 8;
143  m_miDlHarqProcessesInfoMap.at (layer).at (id).push_back (el);
144 }
145 
146 
147 void
149 {
150  NS_LOG_FUNCTION (this << (uint16_t) id);
151  for (uint8_t i = 0; i < m_miDlHarqProcessesInfoMap.size (); i++)
152  {
153  m_miDlHarqProcessesInfoMap.at (i).at (id).clear ();
154  }
155 
156 }
157 
158 
159 void
160 LteHarqPhy::UpdateUlHarqProcessStatus (uint16_t rnti, double mi, uint16_t infoBytes, uint16_t codeBytes)
161 {
162  NS_LOG_FUNCTION (this << rnti << mi);
163  std::map <uint16_t, std::vector <HarqProcessInfoList_t> >::iterator it;
164  it = m_miUlHarqProcessesInfoMap.find (rnti);
165  if (it==m_miUlHarqProcessesInfoMap.end ())
166  {
167  // new entry
168  std::vector <HarqProcessInfoList_t> harqList;
169  harqList.resize (8);
171  el.m_mi = mi;
172  el.m_infoBits = infoBytes * 8;
173  el.m_codeBits = codeBytes * 8;
174  harqList.at (7).push_back (el);
175  m_miUlHarqProcessesInfoMap.insert (std::pair <uint16_t, std::vector <HarqProcessInfoList_t> > (rnti, harqList));
176  }
177  else
178  {
179  if ((*it).second.at (0).size () == 3) // MAX HARQ RETX
180  {
181  // HARQ should be disabled -> discard info
182  return;
183  }
184 
185 // move current status back at the end to maintain full history
186  HarqProcessInfoList_t list = (*it).second.at (0);
187  for (uint8_t i = 0; i < list.size (); i++)
188  {
189  (*it).second.at (7).push_back (list.at (i));
190  }
191 
193  el.m_mi = mi;
194  el.m_infoBits = infoBytes * 8;
195  el.m_codeBits = codeBytes * 8;
196  (*it).second.at (7).push_back (el);
197  }
198 }
199 
200 void
201 LteHarqPhy::ResetUlHarqProcessStatus (uint16_t rnti, uint8_t id)
202 {
203  NS_LOG_FUNCTION (this << rnti << (uint16_t)id);
204  std::map <uint16_t, std::vector <HarqProcessInfoList_t> >::iterator it;
205  it = m_miUlHarqProcessesInfoMap.find (rnti);
206  if (it==m_miUlHarqProcessesInfoMap.end ())
207  {
208  // new entry
209  std::vector <HarqProcessInfoList_t> harqList;
210  harqList.resize (8);
211  m_miUlHarqProcessesInfoMap.insert (std::pair <uint16_t, std::vector <HarqProcessInfoList_t> > (rnti, harqList));
212  }
213  else
214  {
215  (*it).second.at (id).clear ();
216  }
217 }
218 
219 void
221 {
222  NS_LOG_FUNCTION (this << rnti);
223  // flush the DL harq buffers
225  // Recreate DL Decodification HARQ buffers
226  std::vector<HarqProcessInfoList_t> dlHarqLayer0;
227  dlHarqLayer0.resize (8);
228  std::vector<HarqProcessInfoList_t> dlHarqLayer1;
229  dlHarqLayer1.resize (8);
230  m_miDlHarqProcessesInfoMap.push_back (dlHarqLayer0);
231  m_miDlHarqProcessesInfoMap.push_back (dlHarqLayer1);
232 }
233 
234 
235 
236 
237 
238 } // end namespace
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:54
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)
std::map< uint16_t, std::vector< HarqProcessInfoList_t > > m_miUlHarqProcessesInfoMap
MI UL HARQ processes info map.
Definition: lte-harq-phy.h:154
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:92
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:84
HarqProcessInfoList_t GetHarqProcessInfoUl(uint16_t rnti, uint8_t harqProcId)
Return the info of the HARQ procId in case of retransmissions for UL (asynchronous)
void ResetDlHarqProcessStatus(uint8_t id)
Reset the info associated to the decodification of an HARQ process for DL (asynchronous)
std::vector< std::vector< HarqProcessInfoList_t > > m_miDlHarqProcessesInfoMap
MI DL HARQ processes info map.
Definition: lte-harq-phy.h:153
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:71
#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:88
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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:48
#define list
HarqProcessInfoElement_t structure.
Definition: lte-harq-phy.h:41
uint16_t m_codeBits
code bits
Definition: lte-harq-phy.h:45
uint16_t m_infoBits
info bits
Definition: lte-harq-phy.h:44
double m_mi
Mutual information.
Definition: lte-harq-phy.h:42