5G-LENA nr-v3.3-161-gad18933f
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-eesm-ir.cc
1// Copyright (c) 2020 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#include "nr-eesm-ir.h"
6
7#include "ns3/log.h"
8
9namespace ns3
10{
11
12NS_LOG_COMPONENT_DEFINE("NrEesmIr");
13NS_OBJECT_ENSURE_REGISTERED(NrEesmIr);
14
16{
17 NS_LOG_FUNCTION(this);
18}
19
21{
22 NS_LOG_FUNCTION(this);
23}
24
25TypeId
27{
28 static TypeId tid = TypeId("ns3::NrEesmIr").SetParent<NrEesmErrorModel>();
29 return tid;
30}
31
32double
33NrEesmIr::ComputeSINR(const SpectrumValue& sinr,
34 const std::vector<int>& map,
35 uint8_t mcs,
36 uint32_t sizeBit,
37 const NrErrorModel::NrErrorModelHistory& sinrHistory) const
38{
39 NS_LOG_FUNCTION(this);
40 // HARQ INCREMENTAL REDUNDANCY: update SINReff and ECR after retx, assuming
41 // no repetition of coded bits.
42
43 // compute equivalent effective code rate after retransmissions and total map size
44 uint32_t codeBitsSum = 0;
45 uint32_t infoBits = DynamicCast<NrEesmErrorModelOutput>(sinrHistory.front())
46 ->m_infoBits; // information bits of the first TB
47 double mapSumSize = 0.0;
48
49 for (const Ptr<NrErrorModelOutput>& output : sinrHistory)
50 {
51 Ptr<NrEesmErrorModelOutput> sinrHistorytemp = DynamicCast<NrEesmErrorModelOutput>(output);
52 NS_ASSERT(sinrHistorytemp != nullptr);
53
54 NS_LOG_DEBUG(" Exponential SINR sum " << sinrHistorytemp->m_sinrExp << " codeBits "
55 << sinrHistorytemp->m_codeBits
56 << " infoBits: " << sinrHistorytemp->m_infoBits);
57
58 codeBitsSum += sinrHistorytemp->m_codeBits;
59 mapSumSize += sinrHistorytemp->m_map.size();
60 }
61 mapSumSize += map.size();
62 codeBitsSum += sizeBit / GetMcsEcrTable()->at(mcs);
63 ;
64 const_cast<NrEesmIr*>(this)->m_Reff = infoBits / static_cast<double>(codeBitsSum);
65
66 NS_LOG_INFO(" Reff " << m_Reff << " HARQ history (previous) " << sinrHistory.size());
67
68 // compute effective SINR with expSINR_previousTx and mapSumSize
69 double expSINR_previousTx = DynamicCast<NrEesmErrorModelOutput>(sinrHistory.back())->m_sinrExp;
70 return SinrEff(sinr, map, mcs, expSINR_previousTx, mapSumSize);
71}
72
73double
74NrEesmIr::GetMcsEq(uint8_t mcsTx) const
75{
76 NS_LOG_FUNCTION(this);
77 // PHY abstraction for HARQ-IR retx -> get closest ECR to Reff from the
78 // available ones that belong to the same modulation order
79
80 uint8_t mcs_eq = mcsTx;
81
82 uint8_t ModOrder = GetMcsMTable()->at(mcsTx);
83
84 NS_LOG_INFO(" Modulation order: " << +ModOrder);
85 NS_LOG_INFO(" Reff: " << m_Reff);
86
87 for (uint8_t mcsindex = (mcsTx - 1); mcsindex != 255; mcsindex--)
88 // search from MCS=mcs-1 to MCS=0. end at 255 to account for wrap around of uint
89 {
90 if ((GetMcsMTable()->at(mcsindex) == ModOrder) && (GetMcsEcrTable()->at(mcsindex) > m_Reff))
91 {
92 mcs_eq--;
93 }
94 }
95
96 return mcs_eq;
97}
98
99} // namespace ns3
double SinrEff(const SpectrumValue &sinr, const std::vector< int > &map, uint8_t mcs, double a, double b) const
compute the effective SINR for the specified MCS and SINR, according to the EESM method.
virtual const std::vector< uint8_t > * GetMcsMTable() const =0
virtual const std::vector< double > * GetMcsEcrTable() const =0
Eesm error model, based on the IR HARQ.
Definition nr-eesm-ir.h:34
double ComputeSINR(const SpectrumValue &sinr, const std::vector< int > &map, uint8_t mcs, uint32_t sizeBit, const NrErrorModel::NrErrorModelHistory &sinrHistory) const override
Computes the effective SINR after retransmission combining with HARQ-IR. Also, it updates the equival...
Definition nr-eesm-ir.cc:33
~NrEesmIr() override
~NrEesmIr deconstructor
Definition nr-eesm-ir.cc:20
NrEesmIr()
NrEesmIr constructor.
Definition nr-eesm-ir.cc:15
double GetMcsEq(uint8_t mcsTx) const override
Returns the MCS corresponding to the ECR after retransmissions. In case of HARQ-IR the equivalent ECR...
Definition nr-eesm-ir.cc:74
static TypeId GetTypeId()
Get the type id of the object.
Definition nr-eesm-ir.cc:26
std::vector< Ptr< NrErrorModelOutput > > NrErrorModelHistory
Vector of previous output.