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 SetDataDir(NS_TEST_SOURCEDIR);
100 Config::SetDefault("ns3::LteAmc::Ber", DoubleValue(m_amcBer));
101 Config::SetDefault("ns3::LteAmc::AmcModel", EnumValue(LteAmc::PiroEW2010));
102 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
103 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(true));
104 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
105 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
106 StringValue(CreateTempDirFilename("DlMacStats.txt")));
107 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
108 StringValue(CreateTempDirFilename("UlMacStats.txt")));
109 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
110 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
111 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
112 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
113
114 // Disable Uplink Power Control
115 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
116
117 // Config::SetDefault ("ns3::RrFfMacScheduler::HarqEnabled", BooleanValue (false));
118 // LogComponentEnable ("LteEnbRrc", LOG_LEVEL_ALL);
119 // LogComponentEnable ("LteUeRrc", LOG_LEVEL_ALL);
120 // LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL);
121 // LogComponentEnable ("LteUeMac", LOG_LEVEL_ALL);
122 // LogComponentEnable ("LteRlc", LOG_LEVEL_ALL);
123 //
124 // LogComponentEnable ("LtePhy", LOG_LEVEL_ALL);
125 // LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
126 // LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
127
128 // LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
129 // LogComponentEnable ("LteInterference", LOG_LEVEL_ALL);
130 // LogComponentEnable ("LteChunkProcessor", LOG_LEVEL_ALL);
131 //
132 // LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL);
133 // LogComponentEnable ("LossModel", LOG_LEVEL_ALL);
134 // LogComponentEnable ("ShadowingLossModel", LOG_LEVEL_ALL);
135 // LogComponentEnable ("PenetrationLossModel", LOG_LEVEL_ALL);
136 // LogComponentEnable ("MultipathLossModel", LOG_LEVEL_ALL);
137 // LogComponentEnable ("PathLossModel", LOG_LEVEL_ALL);
138 //
139 // LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL);
140 // LogComponentEnable ("LteUeNetDevice", LOG_LEVEL_ALL);
141 // LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL);
142
143 // LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL);
144 // LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL);
145 // LogComponentEnable ("RlcStatsCalculator", LOG_LEVEL_ALL);
146
147 // LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
148 // LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL);
149 // LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
150 // LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
151 // LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL);
152 // LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL);
153 // LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL);
154 // LogComponentEnable ("LteMiErrorModel", LOG_LEVEL_ALL);
155 // LogComponentEnable ("LteAmc", LOG_LEVEL_ALL);
156 //
157 // LogComponentDisableAll (LOG_LEVEL_ALL);
158
159 // LogComponentEnable ("LenaTestHarq", LOG_LEVEL_ALL);
160
161 /**
162 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
163 */
164
166
167 // Create Nodes: eNodeB and UE
168 NodeContainer enbNodes;
169 NodeContainer ueNodes;
170 enbNodes.Create(1);
171 ueNodes.Create(m_nUser);
172
173 // Install Mobility Model
174 MobilityHelper mobility;
175 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
176 mobility.Install(enbNodes);
177 BuildingsHelper::Install(enbNodes);
178
179 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
180 mobility.Install(ueNodes);
182
183 // remove random shadowing component
184 lena->SetAttribute("PathlossModel", StringValue("ns3::HybridBuildingsPropagationLossModel"));
185 lena->SetPathlossModelAttribute("ShadowSigmaOutdoor", DoubleValue(0.0));
186 lena->SetPathlossModelAttribute("ShadowSigmaIndoor", DoubleValue(0.0));
187 lena->SetPathlossModelAttribute("ShadowSigmaExtWalls", DoubleValue(0.0));
188
189 // Create Devices and install them in the Nodes (eNB and UE)
190 NetDeviceContainer enbDevs;
191 NetDeviceContainer ueDevs;
192 lena->SetSchedulerType("ns3::RrFfMacScheduler");
193 lena->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::PUSCH_UL_CQI));
194
195 enbDevs = lena->InstallEnbDevice(enbNodes);
196 ueDevs = lena->InstallUeDevice(ueNodes);
197
198 // Attach a UE to a eNB
199 lena->Attach(ueDevs, enbDevs.Get(0));
200
201 // Activate an EPS bearer
203 EpsBearer bearer(q);
204 lena->ActivateDataRadioBearer(ueDevs, bearer);
205
206 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
207 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
208 enbPhy->SetAttribute("TxPower", DoubleValue(43.0));
209 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
210 // place the HeNB over the default rooftop level (20 mt.)
211 Ptr<MobilityModel> mm = enbNodes.Get(0)->GetObject<MobilityModel>();
212 mm->SetPosition(Vector(0.0, 0.0, 30.0));
213
214 // Set UEs' position and power
215 for (int i = 0; i < m_nUser; i++)
216 {
217 Ptr<MobilityModel> mm = ueNodes.Get(i)->GetObject<MobilityModel>();
218 mm->SetPosition(Vector(m_dist, 0.0, 1.0));
219 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
220 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
221 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
222 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
223 }
224
225 double statsStartTime = 0.050; // need to allow for RRC connection establishment + SRS
226 double statsDuration = 2.0;
227 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.0001));
228
229 lena->EnableRlcTraces();
230 Ptr<RadioBearerStatsCalculator> rlcStats = lena->GetRlcStats();
231 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
232 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
233
234 // for debugging purposes
235 lena->EnableMacTraces();
236
238
239 /**
240 * Check that the assignment is done in a RR fashion
241 */
242 NS_LOG_INFO("\tTest on downlink data shared channels (PDSCH)");
243 NS_LOG_INFO("Test with " << m_nUser << " user(s) at distance " << m_dist << " expected Thr "
244 << m_throughputRef);
245 for (int i = 0; i < m_nUser; i++)
246 {
247 // get the imsi
248 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
249 uint8_t lcId = 3;
250 double txed = rlcStats->GetDlTxData(imsi, lcId);
251 double rxed = rlcStats->GetDlRxData(imsi, lcId);
252 double tolerance = 0.1;
253
254 NS_LOG_INFO(" User " << i << " imsi " << imsi << " bytes rxed/t " << rxed / statsDuration
255 << " txed/t " << txed / statsDuration << " thr Ref " << m_throughputRef
256 << " Err "
257 << (std::abs(txed / statsDuration - m_throughputRef)) /
259
260 NS_TEST_ASSERT_MSG_EQ_TOL(txed / statsDuration,
262 m_throughputRef * tolerance,
263 " Unexpected Throughput!");
264 NS_TEST_ASSERT_MSG_EQ_TOL(rxed / statsDuration,
266 m_throughputRef * tolerance,
267 " Unexpected Throughput!");
268 }
269
271}
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.
AttributeValue implementation for Boolean.
Definition boolean.h:26
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
void SetDataDir(std::string directory)
Set the data directory where reference trace files can be found.
Definition test.cc:472
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
AttributeValue implementation for Time.
Definition nstime.h:1432
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:886
#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:1345
Every class exported by the ns3 library is enclosed in the ns3 namespace.