5G-LENA nr-v4.0
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
lena-error-model.cc
1// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#include "lena-error-model.h"
6
7#include "nr-lte-amc.h"
8
9#include "ns3/log.h"
10
11namespace ns3
12{
13
14NS_LOG_COMPONENT_DEFINE("LenaErrorModel");
15NS_OBJECT_ENSURE_REGISTERED(LenaErrorModel);
16
19{
20 NS_LOG_FUNCTION(this);
21}
22
24{
25 NS_LOG_FUNCTION(this);
26}
27
28uint32_t
29LenaErrorModel::GetPayloadSize([[maybe_unused]] uint32_t usefulSC,
30 uint8_t mcs,
31 uint8_t rank,
32 uint32_t rbNum,
33 NrErrorModel::Mode mode) const
34{
35 NS_ASSERT_MSG(rank == 1, "Lena error model does not support MIMO");
36 NS_LOG_FUNCTION(this);
37
38 // Since we call here NrLteAmc which assumes that for data is assigned 11 or 13 symbols
39 // (11 DL and 13 UL).
40 // In DL we will assign o DATA always 13 symbols in OFDMA, but in UL since we have
41 // UL CTRL and at least 1 symbol for SRS, there will be 12 symbols for DATA.
42 // We need to check before converting RBnum in symbols to RBnum in slots
43 // whether the duration is 11, 12 or 13 to be able to convert it properly.
44 // Make sure to configure the number of SRS symbols to be 1
45 // e.g.: nrHelper->SetSchedulerAttribute ("SrsSymbols", UintegerValue (1));
46
47 uint32_t lenaRBNum = 0;
48
49 if (rbNum < 11)
50 {
51 NS_LOG_INFO("Available resources are smaller than the minimum allowed in order to use the "
52 "LENA AMC model.");
53 return 0;
54 }
55
56 if (rbNum % 11 == 0)
57 {
58 lenaRBNum = rbNum / 11;
59 }
60 else if (rbNum % 12 == 0)
61 {
62 lenaRBNum = rbNum / 12;
63 }
64 else
65 {
66 lenaRBNum = rbNum / 13;
67 }
68
69 static NrLteAmc lenaAmc;
70
71 NS_LOG_DEBUG("Asking LENA AMC to retrieve the TBS for MCS " << +mcs << " and RB " << lenaRBNum);
72
73 if (mode == NrErrorModel::DL)
74 {
75 return (lenaAmc.GetDlTbSizeFromMcs(mcs, lenaRBNum) / 8);
76 }
77 else
78 {
79 return (lenaAmc.GetUlTbSizeFromMcs(mcs, lenaRBNum) / 8);
80 }
81}
82
83TypeId
85{
86 static TypeId tid = TypeId("ns3::LenaErrorModel")
87 .SetParent<NrLteMiErrorModel>()
88 .AddConstructor<LenaErrorModel>();
89 return tid;
90}
91
92} // namespace ns3
LenaErrorModel()
NrLteMiErrorModel constructor.
uint32_t GetPayloadSize(uint32_t usefulSC, uint8_t mcs, uint8_t rank, uint32_t rbNum, Mode mode) const override
Get the payload size, following the MCSs in LTE.
~LenaErrorModel() override
~NrLteMiErrorModel
static TypeId GetTypeId()
GetTypeId.
Mode
Indicate the mode (UL or DL)
int GetDlTbSizeFromMcs(int mcs, int nprb)
Get the Transport Block Size for a selected MCS and number of PRB (table 7.1.7.2.1-1 of 36....
int GetUlTbSizeFromMcs(int mcs, int nprb)
Get the Transport Block Size for a selected MCS and number of PRB (table 8.6.1-1 of 36....