A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("LteHarqPhy");
27 
28 namespace ns3 {
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 (7).size () == 3) // MAX HARQ RETX
180  {
181  // HARQ should be disabled -> discard info
182  return;
183  }
185  el.m_mi = mi;
186  el.m_infoBits = infoBytes * 8;
187  el.m_codeBits = codeBytes * 8;
188  (*it).second.at (7).push_back (el);
189  }
190 }
191 
192 void
193 LteHarqPhy::ResetUlHarqProcessStatus (uint16_t rnti, uint8_t id)
194 {
195  NS_LOG_FUNCTION (this << rnti << (uint16_t)id);
196  std::map <uint16_t, std::vector <HarqProcessInfoList_t> >::iterator it;
197  it = m_miUlHarqProcessesInfoMap.find (rnti);
198  if (it==m_miUlHarqProcessesInfoMap.end ())
199  {
200  // new entry
201  std::vector <HarqProcessInfoList_t> harqList;
202  harqList.resize (8);
203  m_miUlHarqProcessesInfoMap.insert (std::pair <uint16_t, std::vector <HarqProcessInfoList_t> > (rnti, harqList));
204  }
205  else
206  {
207  (*it).second.at (id).clear ();
208  }
209 }
210 
211 
212 
213 
214 } // end namespace
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
void SubframeIndication(uint32_t frameNo, uint32_t subframeNo)
Definition: lte-harq-phy.cc:54
HarqProcessInfoList_t GetHarqProcessInfoDl(uint8_t harqProcId, uint8_t layer)
Return the info of the HARQ procId in case of retranmissions for DL (asynchronous) ...
Definition: lte-harq-phy.cc:84
NS_LOG_COMPONENT_DEFINE("LteHarqPhy")
double GetAccumulatedMiDl(uint8_t harqProcId, uint8_t layer)
Return the cumulated MI of the HARQ procId in case of retranmissions for DL (asynchronous) ...
Definition: lte-harq-phy.cc:71
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) ...
#define list
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) ...
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
std::vector< std::vector< HarqProcessInfoList_t > > m_miDlHarqProcessesInfoMap
Definition: lte-harq-phy.h:138
std::map< uint16_t, std::vector< HarqProcessInfoList_t > > m_miUlHarqProcessesInfoMap
Definition: lte-harq-phy.h:139
void ResetUlHarqProcessStatus(uint16_t rnti, uint8_t id)
Reset the info 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 retranmissions for UL (synchronous) ...
Definition: lte-harq-phy.cc:92
void ResetDlHarqProcessStatus(uint8_t id)
Reset the info associated to the decodification of an HARQ process for DL (asynchronous) ...
HarqProcessInfoList_t GetHarqProcessInfoUl(uint16_t rnti, uint8_t harqProcId)
Return the info of the HARQ procId in case of retranmissions for UL (asynchronous) ...
std::vector< HarqProcessInfoElement_t > HarqProcessInfoList_t
Definition: lte-harq-phy.h:47