5G-LENA nr-v3.3-159-ga6832aa7
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-eesm-cc.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-cc.h"
6
7#include "ns3/log.h"
8
9namespace ns3
10{
11
12NS_LOG_COMPONENT_DEFINE("NrEesmCc");
13NS_OBJECT_ENSURE_REGISTERED(NrEesmCc);
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::NrEesmCc").SetParent<NrEesmErrorModel>();
29 return tid;
30}
31
32double
33NrEesmCc::ComputeSINR(const SpectrumValue& sinr,
34 const std::vector<int>& map,
35 uint8_t mcs,
36 [[maybe_unused]] uint32_t sizeBit,
37 const NrErrorModel::NrErrorModelHistory& sinrHistory) const
38{
39 NS_LOG_FUNCTION(this);
40
41 // HARQ CHASE COMBINING: update SINReff, but not ECR after retx
42 // repetition of coded bits
43
44 // make a vector of history that contains the last tx (but without modifying
45 // sinrHistory, as it will be modified by the caller when it will be the time)
46 Ptr<NrEesmErrorModelOutput> last = Create<NrEesmErrorModelOutput>(0.0);
47 last->m_map = map;
48 last->m_sinr = sinr;
49
50 NrErrorModel::NrErrorModelHistory total = sinrHistory;
51 total.emplace_back(last);
52
53 // evaluate SINR_eff over "total", as per Chase Combining
54
55 NS_ASSERT(sinr.GetSpectrumModel()->GetNumBands() == sinr.GetValuesN());
56
57 SpectrumValue sinr_sum(sinr.GetSpectrumModel());
58 uint32_t historySize = static_cast<uint32_t>(total.size());
59 uint32_t maxRBUsed = 0;
60 for (uint32_t i = 0; i < historySize; ++i)
61 {
62 Ptr<NrEesmErrorModelOutput> output = DynamicCast<NrEesmErrorModelOutput>(total.at(i));
63 maxRBUsed = std::max(maxRBUsed, static_cast<uint32_t>(output->m_map.size()));
64 }
65
66 std::vector<int> map_sum;
67 map_sum.reserve(maxRBUsed);
68
69 for (uint32_t i = 0; i < maxRBUsed; ++i)
70 {
71 sinr_sum[i] = 0;
72 map_sum.push_back(static_cast<int>(i));
73 }
74
75 /* combine at the bit level. Example:
76 * SINR{1}=[0 0 10 20 10 0 0];
77 * SINR{2}=[1 2 1 2 1 0 3];
78 * SINR{3}=[5 0 0 0 0 0 0];
79 *
80 * map{1}=[2 3 4];
81 * map{2}=[0 1 2 3 4 6];
82 * map{3}=[0];
83 *
84 * MAP_SUM = [0 1 2 3 4 5]
85 * SINR_SUM = [16 27 16 17 26 18]
86 *
87 * (the value at SINR_SUM[0] is SINR{1}[2] + SINR{2}[0] + SINR{3}[0])
88 */
89 for (uint32_t i = 0; i < historySize; ++i)
90 {
91 Ptr<NrEesmErrorModelOutput> output = DynamicCast<NrEesmErrorModelOutput>(total.at(i));
92 uint32_t size = output->m_map.size();
93 for (uint32_t j = 0; j < maxRBUsed; ++j)
94 {
95 sinr_sum[j] += output->m_sinr[output->m_map[j % size]];
96 }
97 }
98
99 NS_LOG_INFO("\tHISTORY:");
100 for (const auto& element : total)
101 {
102 Ptr<NrEesmErrorModelOutput> output = DynamicCast<NrEesmErrorModelOutput>(element);
103 NS_LOG_INFO("\tMAP:" << PrintMap(output->m_map));
104 NS_LOG_INFO("\tSINR: " << output->m_sinr);
105 }
106
107 NS_LOG_INFO("MAP_SUM: " << PrintMap(map_sum));
108 NS_LOG_INFO("SINR_SUM: " << sinr_sum);
109
110 // compute effective SINR with the sinr_sum vector and map_sum RB map
111 return SinrEff(sinr_sum, map_sum, mcs, 0.0, map_sum.size());
112}
113
114double
115NrEesmCc::GetMcsEq(uint8_t mcsTx) const
116{
117 NS_LOG_FUNCTION(this);
118 return mcsTx;
119}
120
121} // namespace ns3
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-CC.
Definition nr-eesm-cc.cc:33
static TypeId GetTypeId()
Get the type id of the object.
Definition nr-eesm-cc.cc:26
NrEesmCc()
NrEesmCc constructor.
Definition nr-eesm-cc.cc:15
~NrEesmCc() override
~NrEesmCc
Definition nr-eesm-cc.cc:20
double GetMcsEq(uint8_t mcsTx) const override
Returns the MCS corresponding to the ECR after retransmissions. As the ECR does not change with retra...
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.
std::string PrintMap(const std::vector< int > &map) const
function to print the RB map
std::vector< Ptr< NrErrorModelOutput > > NrErrorModelHistory
Vector of previous output.