A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-harq.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Marco Miozzo <marco.miozzo@cttc.es>
7 */
8
9#include "lte-test-harq.h"
10
11#include <ns3/boolean.h>
12#include <ns3/buildings-helper.h>
13#include <ns3/config.h>
14#include <ns3/double.h>
15#include <ns3/enum.h>
16#include <ns3/eps-bearer.h>
17#include <ns3/ff-mac-scheduler.h>
18#include <ns3/hybrid-buildings-propagation-loss-model.h>
19#include <ns3/log.h>
20#include <ns3/lte-enb-net-device.h>
21#include <ns3/lte-enb-phy.h>
22#include <ns3/lte-helper.h>
23#include <ns3/lte-ue-net-device.h>
24#include <ns3/lte-ue-phy.h>
25#include <ns3/lte-ue-rrc.h>
26#include <ns3/mobility-building-info.h>
27#include <ns3/mobility-helper.h>
28#include <ns3/net-device-container.h>
29#include <ns3/node-container.h>
30#include <ns3/object.h>
31#include <ns3/packet.h>
32#include <ns3/ptr.h>
33#include <ns3/radio-bearer-stats-calculator.h>
34#include <ns3/simulator.h>
35#include <ns3/spectrum-error-model.h>
36#include <ns3/spectrum-interference.h>
37#include <ns3/string.h>
38#include <ns3/test.h>
39
40#include <cmath>
41#include <iostream>
42
43using namespace ns3;
44
45NS_LOG_COMPONENT_DEFINE("LenaTestHarq");
46
48 : TestSuite("lte-harq", Type::SYSTEM)
49{
50 NS_LOG_INFO("creating LenaTestHarqTestCase");
51
52 // Tests on DL/UL Data channels (PDSCH, PUSCH)
53 // MCS 0 TB size of 66 bytes SINR -9.91 dB expected throughput 31822 bytes/s
54 // TBLER 1st tx 1.0
55 // TBLER 2nd tx 0.074
56 AddTestCase(new LenaHarqTestCase(2, 2400, 66, 0.12, 31822), TestCase::Duration::QUICK);
57
58 // Tests on DL/UL Data channels (PDSCH, PUSCH)
59 // MCS 10 TB size of 472 bytes SINR 0.3 dB expected throughput 209964 bytes/s
60 // TBLER 1st tx 1.0
61 // TBLER 2nd tx 0.248
62 AddTestCase(new LenaHarqTestCase(1, 770, 472, 0.06, 209964), TestCase::Duration::QUICK);
63}
64
65/**
66 * \ingroup lte-test
67 * Static variable for test initialization
68 */
70
71std::string
72LenaHarqTestCase::BuildNameString(uint16_t nUser, uint16_t dist, uint16_t tbSize)
73{
74 std::ostringstream oss;
75 oss << nUser << " UEs, distance " << dist << " m, TB size " << tbSize;
76 return oss.str();
77}
78
80 uint16_t dist,
81 uint16_t tbSize,
82 double amcBer,
83 double thrRef)
84 : TestCase(BuildNameString(nUser, dist, tbSize)),
85 m_nUser(nUser),
86 m_dist(dist),
87 m_amcBer(amcBer),
88 m_throughputRef(thrRef)
89{
90}
91
95
96void
98{
99 Config::SetDefault("ns3::LteAmc::Ber", DoubleValue(m_amcBer));
100 Config::SetDefault("ns3::LteAmc::AmcModel", EnumValue(LteAmc::PiroEW2010));
101 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
102 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(true));
103 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
104 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
105 StringValue(CreateTempDirFilename("DlMacStats.txt")));
106 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
107 StringValue(CreateTempDirFilename("UlMacStats.txt")));
108 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
109 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
110 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
111 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
112
113 // Disable Uplink Power Control
114 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
115
116 // Config::SetDefault ("ns3::RrFfMacScheduler::HarqEnabled", BooleanValue (false));
117 // LogComponentEnable ("LteEnbRrc", LOG_LEVEL_ALL);
118 // LogComponentEnable ("LteUeRrc", LOG_LEVEL_ALL);
119 // LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL);
120 // LogComponentEnable ("LteUeMac", LOG_LEVEL_ALL);
121 // LogComponentEnable ("LteRlc", LOG_LEVEL_ALL);
122 //
123 // LogComponentEnable ("LtePhy", LOG_LEVEL_ALL);
124 // LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
125 // LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
126
127 // LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
128 // LogComponentEnable ("LteInterference", LOG_LEVEL_ALL);
129 // LogComponentEnable ("LteChunkProcessor", LOG_LEVEL_ALL);
130 //
131 // LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL);
132 // LogComponentEnable ("LossModel", LOG_LEVEL_ALL);
133 // LogComponentEnable ("ShadowingLossModel", LOG_LEVEL_ALL);
134 // LogComponentEnable ("PenetrationLossModel", LOG_LEVEL_ALL);
135 // LogComponentEnable ("MultipathLossModel", LOG_LEVEL_ALL);
136 // LogComponentEnable ("PathLossModel", LOG_LEVEL_ALL);
137 //
138 // LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL);
139 // LogComponentEnable ("LteUeNetDevice", LOG_LEVEL_ALL);
140 // LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL);
141
142 // LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL);
143 // LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL);
144 // LogComponentEnable ("RlcStatsCalculator", LOG_LEVEL_ALL);
145
146 // LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
147 // LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL);
148 // LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
149 // LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
150 // LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL);
151 // LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL);
152 // LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL);
153 // LogComponentEnable ("LteMiErrorModel", LOG_LEVEL_ALL);
154 // LogComponentEnable ("LteAmc", LOG_LEVEL_ALL);
155 //
156 // LogComponentDisableAll (LOG_LEVEL_ALL);
157
158 // LogComponentEnable ("LenaTestHarq", LOG_LEVEL_ALL);
159
160 /**
161 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
162 */
163
165
166 // Create Nodes: eNodeB and UE
167 NodeContainer enbNodes;
168 NodeContainer ueNodes;
169 enbNodes.Create(1);
170 ueNodes.Create(m_nUser);
171
172 // Install Mobility Model
173 MobilityHelper mobility;
174 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
175 mobility.Install(enbNodes);
176 BuildingsHelper::Install(enbNodes);
177
178 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
179 mobility.Install(ueNodes);
181
182 // remove random shadowing component
183 lena->SetAttribute("PathlossModel", StringValue("ns3::HybridBuildingsPropagationLossModel"));
184 lena->SetPathlossModelAttribute("ShadowSigmaOutdoor", DoubleValue(0.0));
185 lena->SetPathlossModelAttribute("ShadowSigmaIndoor", DoubleValue(0.0));
186 lena->SetPathlossModelAttribute("ShadowSigmaExtWalls", DoubleValue(0.0));
187
188 // Create Devices and install them in the Nodes (eNB and UE)
189 NetDeviceContainer enbDevs;
190 NetDeviceContainer ueDevs;
191 lena->SetSchedulerType("ns3::RrFfMacScheduler");
192 lena->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::PUSCH_UL_CQI));
193
194 enbDevs = lena->InstallEnbDevice(enbNodes);
195 ueDevs = lena->InstallUeDevice(ueNodes);
196
197 // Attach a UE to a eNB
198 lena->Attach(ueDevs, enbDevs.Get(0));
199
200 // Activate an EPS bearer
202 EpsBearer bearer(q);
203 lena->ActivateDataRadioBearer(ueDevs, bearer);
204
205 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
206 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
207 enbPhy->SetAttribute("TxPower", DoubleValue(43.0));
208 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
209 // place the HeNB over the default rooftop level (20 mt.)
210 Ptr<MobilityModel> mm = enbNodes.Get(0)->GetObject<MobilityModel>();
211 mm->SetPosition(Vector(0.0, 0.0, 30.0));
212
213 // Set UEs' position and power
214 for (int i = 0; i < m_nUser; i++)
215 {
216 Ptr<MobilityModel> mm = ueNodes.Get(i)->GetObject<MobilityModel>();
217 mm->SetPosition(Vector(m_dist, 0.0, 1.0));
218 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
219 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
220 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
221 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
222 }
223
224 double statsStartTime = 0.050; // need to allow for RRC connection establishment + SRS
225 double statsDuration = 2.0;
226 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.0001));
227
228 lena->EnableRlcTraces();
229 Ptr<RadioBearerStatsCalculator> rlcStats = lena->GetRlcStats();
230 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
231 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
232
233 // for debugging purposes
234 lena->EnableMacTraces();
235
237
238 /**
239 * Check that the assignment is done in a RR fashion
240 */
241 NS_LOG_INFO("\tTest on downlink data shared channels (PDSCH)");
242 NS_LOG_INFO("Test with " << m_nUser << " user(s) at distance " << m_dist << " expected Thr "
243 << m_throughputRef);
244 for (int i = 0; i < m_nUser; i++)
245 {
246 // get the imsi
247 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
248 uint8_t lcId = 3;
249 double txed = rlcStats->GetDlTxData(imsi, lcId);
250 double rxed = rlcStats->GetDlRxData(imsi, lcId);
251 double tolerance = 0.1;
252
253 NS_LOG_INFO(" User " << i << " imsi " << imsi << " bytes rxed/t " << rxed / statsDuration
254 << " txed/t " << txed / statsDuration << " thr Ref " << m_throughputRef
255 << " Err "
256 << (std::abs(txed / statsDuration - m_throughputRef)) /
258
259 NS_TEST_ASSERT_MSG_EQ_TOL(txed / statsDuration,
261 m_throughputRef * tolerance,
262 " Unexpected Throughput!");
263 NS_TEST_ASSERT_MSG_EQ_TOL(rxed / statsDuration,
265 m_throughputRef * tolerance,
266 " Unexpected Throughput!");
267 }
268
270}
This system test program creates different test cases with a single eNB and several UEs,...
double m_throughputRef
throughput reference
void DoRun() override
Implementation to actually run this TestCase.
uint16_t m_dist
distance between nodes
uint16_t m_nUser
number of UE nodes
static std::string BuildNameString(uint16_t nUser, uint16_t dist, uint16_t tbSize)
Build name string function.
LenaHarqTestCase(uint16_t nUser, uint16_t dist, uint16_t tbSize, double amcBer, double thrRef)
Constructor.
~LenaHarqTestCase() override
double m_amcBer
AMC bit error rate.
Test suite for harq test.
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Hold variables of type enum.
Definition enum.h:52
This class contains the specification of EPS Bearers.
Definition eps-bearer.h:80
Qci
QoS Class Indicator.
Definition eps-bearer.h:95
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition eps-bearer.h:96
The eNodeB device implementation.
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition object.h:511
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Hold variables of type string.
Definition string.h:45
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Definition test.cc:432
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
static LenaTestHarqSuite lenaTestHarqSuite
Static variable for test initialization.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition test.h:327
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.