author | Nicola Baldo <nbaldo@cttc.es> |
Mon, 05 Dec 2011 21:27:44 +0100 | |
changeset 8463 | cc818aa536a5 |
parent 8460 | fbb53bda0ec7 |
child 8506 | f9616c9094a5 |
permissions | -rw-r--r-- |
8029 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License version 2 as |
|
7 |
* published by the Free Software Foundation; |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
18 |
* Author: Manuel Requena <manuel.requena@cttc.es> |
|
19 |
*/ |
|
20 |
||
21 |
#include "ns3/simulator.h" |
|
22 |
#include "ns3/log.h" |
|
23 |
#include "ns3/string.h" |
|
24 |
#include "ns3/double.h" |
|
25 |
||
26 |
#include "ns3/mobility-helper.h" |
|
8460
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
27 |
#include "ns3/lte-helper.h" |
8029 | 28 |
|
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
29 |
#include "ns3/lte-ue-phy.h" |
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
30 |
#include "ns3/lte-ue-net-device.h" |
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
31 |
|
8029 | 32 |
#include "ns3/lte-test-link-adaptation.h" |
33 |
||
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
34 |
#include "lte-test-sinr-chunk-processor.h" |
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
35 |
|
8029 | 36 |
NS_LOG_COMPONENT_DEFINE ("LteLinkAdaptationTest"); |
37 |
||
38 |
using namespace ns3; |
|
39 |
||
40 |
||
41 |
/** |
|
42 |
* Test 1.3 Link Adaptation |
|
43 |
*/ |
|
44 |
||
45 |
void |
|
8039 | 46 |
LteTestDlSchedulingCallback (LteLinkAdaptationTestCase *testcase, std::string path, |
8149 | 47 |
uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, |
48 |
uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2) |
|
8029 | 49 |
{ |
8149 | 50 |
testcase->DlScheduling (frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2); |
8029 | 51 |
} |
52 |
||
53 |
/** |
|
54 |
* TestSuite |
|
55 |
*/ |
|
56 |
||
57 |
LteLinkAdaptationTestSuite::LteLinkAdaptationTestSuite () |
|
58 |
: TestSuite ("lte-link-adaptation", SYSTEM) |
|
59 |
{ |
|
60 |
NS_LOG_INFO ("Creating LteLinkAdaptionTestSuite"); |
|
61 |
||
8046 | 62 |
struct SnrEfficiencyMcs |
8149 | 63 |
{ |
64 |
double snrDb; |
|
65 |
double efficiency; |
|
66 |
int mcsIndex; |
|
67 |
}; |
|
8039 | 68 |
|
8046 | 69 |
/** |
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
70 |
* Test vectors: SNRDB, Spectral Efficiency, MCS index |
8046 | 71 |
* From XXX |
72 |
*/ |
|
8053
3404ba78e449
new test vector for AMC test; some test cases passing, but not all
Nicola Baldo <nbaldo@cttc.es>
parents:
8046
diff
changeset
|
73 |
SnrEfficiencyMcs snrEfficiencyMcs[] = { |
8149 | 74 |
{ -5.00000, 0.08024, -1}, |
75 |
{ -4.00000, 0.10030, -1}, |
|
76 |
{ -3.00000, 0.12518, -1}, |
|
77 |
{ -2.00000, 0.15589, 0}, |
|
78 |
{ -1.00000, 0.19365, 0}, |
|
79 |
{ 0.00000, 0.23983, 2}, |
|
80 |
{ 1.00000, 0.29593, 2}, |
|
81 |
{ 2.00000, 0.36360, 2}, |
|
82 |
{ 3.00000, 0.44451, 4}, |
|
83 |
{ 4.00000, 0.54031, 4}, |
|
84 |
{ 5.00000, 0.65251, 6}, |
|
85 |
{ 6.00000, 0.78240, 6}, |
|
86 |
{ 7.00000, 0.93086, 8}, |
|
87 |
{ 8.00000, 1.09835, 8}, |
|
88 |
{ 9.00000, 1.28485, 10}, |
|
89 |
{ 10.00000, 1.48981, 12}, |
|
90 |
{ 11.00000, 1.71229, 12}, |
|
91 |
{ 12.00000, 1.95096, 14}, |
|
92 |
{ 13.00000, 2.20429, 14}, |
|
93 |
{ 14.00000, 2.47062, 16}, |
|
94 |
{ 15.00000, 2.74826, 18}, |
|
95 |
{ 16.00000, 3.03560, 18}, |
|
96 |
{ 17.00000, 3.33115, 20}, |
|
97 |
{ 18.00000, 3.63355, 20}, |
|
98 |
{ 19.00000, 3.94163, 22}, |
|
99 |
{ 20.00000, 4.25439, 22}, |
|
100 |
{ 21.00000, 4.57095, 24}, |
|
101 |
{ 22.00000, 4.89060, 24}, |
|
102 |
{ 23.00000, 5.21276, 26}, |
|
103 |
{ 24.00000, 5.53693, 26}, |
|
104 |
{ 25.00000, 5.86271, 28}, |
|
105 |
{ 26.00000, 6.18980, 28}, |
|
106 |
{ 27.00000, 6.51792, 28}, |
|
107 |
{ 28.00000, 6.84687, 28}, |
|
108 |
{ 29.00000, 7.17649, 28}, |
|
109 |
{ 30.00000, 7.50663, 28}, |
|
8132
d897e9d45e1f
clean link adaptation test
Manuel Requena <manuel.requena@cttc.es>
parents:
8065
diff
changeset
|
110 |
}; |
8046 | 111 |
int numOfTests = sizeof (snrEfficiencyMcs) / sizeof (SnrEfficiencyMcs); |
8039 | 112 |
|
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
113 |
double txPowerDbm = 30; // default eNB TX power over whole bandwdith |
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
114 |
double ktDbm = -174; // reference LTE noise PSD |
8149 | 115 |
double noisePowerDbm = ktDbm + 10 * log10 (25 * 180000); // corresponds to kT*bandwidth in linear units |
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
116 |
double receiverNoiseFigureDb = 9.0; // default UE noise figure |
8132
d897e9d45e1f
clean link adaptation test
Manuel Requena <manuel.requena@cttc.es>
parents:
8065
diff
changeset
|
117 |
|
8053
3404ba78e449
new test vector for AMC test; some test cases passing, but not all
Nicola Baldo <nbaldo@cttc.es>
parents:
8046
diff
changeset
|
118 |
for ( int i = 0 ; i < numOfTests; i++ ) |
8132
d897e9d45e1f
clean link adaptation test
Manuel Requena <manuel.requena@cttc.es>
parents:
8065
diff
changeset
|
119 |
{ |
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
120 |
double lossDb = txPowerDbm - snrEfficiencyMcs[i].snrDb - noisePowerDbm - receiverNoiseFigureDb; |
8046 | 121 |
|
8053
3404ba78e449
new test vector for AMC test; some test cases passing, but not all
Nicola Baldo <nbaldo@cttc.es>
parents:
8046
diff
changeset
|
122 |
std::ostringstream name; |
8065
47f0ce9e40cd
added out-of-range test cases to link adaptation test
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
123 |
name << " snr= " << snrEfficiencyMcs[i].snrDb << " dB, " |
8053
3404ba78e449
new test vector for AMC test; some test cases passing, but not all
Nicola Baldo <nbaldo@cttc.es>
parents:
8046
diff
changeset
|
124 |
<< " mcs= " << snrEfficiencyMcs[i].mcsIndex; |
8132
d897e9d45e1f
clean link adaptation test
Manuel Requena <manuel.requena@cttc.es>
parents:
8065
diff
changeset
|
125 |
AddTestCase (new LteLinkAdaptationTestCase (name.str (), snrEfficiencyMcs[i].snrDb, lossDb, snrEfficiencyMcs[i].mcsIndex)); |
8046 | 126 |
} |
8029 | 127 |
|
128 |
} |
|
129 |
||
130 |
static LteLinkAdaptationTestSuite lteLinkAdaptationTestSuite; |
|
131 |
||
132 |
||
133 |
/** |
|
134 |
* TestCase |
|
135 |
*/ |
|
136 |
||
8132
d897e9d45e1f
clean link adaptation test
Manuel Requena <manuel.requena@cttc.es>
parents:
8065
diff
changeset
|
137 |
LteLinkAdaptationTestCase::LteLinkAdaptationTestCase (std::string name, double snrDb, double loss, uint16_t mcsIndex) |
8053
3404ba78e449
new test vector for AMC test; some test cases passing, but not all
Nicola Baldo <nbaldo@cttc.es>
parents:
8046
diff
changeset
|
138 |
: TestCase (name), |
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
139 |
m_snrDb (snrDb), |
8039 | 140 |
m_loss (loss), |
8046 | 141 |
m_mcsIndex (mcsIndex) |
8029 | 142 |
{ |
143 |
std::ostringstream sstream1, sstream2; |
|
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
144 |
sstream1 << " snr=" << snrDb |
8053
3404ba78e449
new test vector for AMC test; some test cases passing, but not all
Nicola Baldo <nbaldo@cttc.es>
parents:
8046
diff
changeset
|
145 |
<< " mcs=" << mcsIndex; |
8029 | 146 |
|
8135 | 147 |
NS_LOG_INFO ("Creating LteLinkAdaptationTestCase: " + sstream1.str ()); |
8029 | 148 |
} |
149 |
||
150 |
LteLinkAdaptationTestCase::~LteLinkAdaptationTestCase () |
|
151 |
{ |
|
152 |
} |
|
153 |
||
154 |
void |
|
155 |
LteLinkAdaptationTestCase::DoRun (void) |
|
156 |
{ |
|
157 |
/** |
|
158 |
* Simulation Topology |
|
159 |
*/ |
|
160 |
||
8460
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
161 |
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> (); |
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
162 |
// lteHelper->EnableLogComponents (); |
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
163 |
lteHelper->EnableMacTraces (); |
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
164 |
lteHelper->EnableRlcTraces (); |
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
165 |
lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::ConstantSpectrumPropagationLossModel")); |
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
166 |
NS_LOG_INFO ("SNR = " << m_snrDb << " LOSS = " << m_loss); |
8460
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
167 |
lteHelper->SetPathlossModelAttribute ("Loss", DoubleValue (m_loss)); |
8029 | 168 |
|
169 |
// Create Nodes: eNodeB and UE |
|
170 |
NodeContainer enbNodes; |
|
171 |
NodeContainer ueNodes; |
|
172 |
enbNodes.Create (1); |
|
173 |
ueNodes.Create (1); |
|
174 |
NodeContainer allNodes = NodeContainer ( enbNodes, ueNodes ); |
|
175 |
||
176 |
// Install Mobility Model |
|
177 |
MobilityHelper mobility; |
|
178 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
|
179 |
mobility.Install (allNodes); |
|
180 |
||
181 |
// Create Devices and install them in the Nodes (eNB and UE) |
|
182 |
NetDeviceContainer enbDevs; |
|
183 |
NetDeviceContainer ueDevs; |
|
8460
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
184 |
lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler"); |
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
185 |
enbDevs = lteHelper->InstallEnbDevice (enbNodes); |
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
186 |
ueDevs = lteHelper->InstallUeDevice (ueNodes); |
8029 | 187 |
|
188 |
// Attach a UE to a eNB |
|
8460
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
189 |
lteHelper->Attach (ueDevs, enbDevs.Get (0)); |
8029 | 190 |
|
8380 | 191 |
// Activate the default EPS bearer |
192 |
enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; |
|
8029 | 193 |
EpsBearer bearer (q); |
8463 | 194 |
lteHelper->ActivateEpsBearer (ueDevs, bearer, EpcTft::Default ()); |
8029 | 195 |
|
8132
d897e9d45e1f
clean link adaptation test
Manuel Requena <manuel.requena@cttc.es>
parents:
8065
diff
changeset
|
196 |
// Use testing chunk processor in the PHY layer |
d897e9d45e1f
clean link adaptation test
Manuel Requena <manuel.requena@cttc.es>
parents:
8065
diff
changeset
|
197 |
// It will be used to test that the SNR is as intended |
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
198 |
Ptr<LtePhy> uePhy = ueDevs.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> (); |
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
199 |
Ptr<LteTestSinrChunkProcessor> testSinr = Create<LteTestSinrChunkProcessor> (uePhy); |
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
200 |
uePhy->GetDownlinkSpectrumPhy ()->AddSinrChunkProcessor (testSinr); |
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
201 |
|
8029 | 202 |
Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/DlScheduling", |
8149 | 203 |
MakeBoundCallback (&LteTestDlSchedulingCallback, this)); |
8029 | 204 |
|
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
205 |
Simulator::Stop (Seconds (0.005)); |
8029 | 206 |
Simulator::Run (); |
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
207 |
|
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
208 |
double calculatedSinrDb = 10.0 * log10 (testSinr->GetSinr ()[0]); |
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8053
diff
changeset
|
209 |
NS_TEST_ASSERT_MSG_EQ_TOL (calculatedSinrDb, m_snrDb, 0.0000001, "Wrong SINR !"); |
8029 | 210 |
Simulator::Destroy (); |
211 |
} |
|
8039 | 212 |
|
213 |
||
214 |
void |
|
215 |
LteLinkAdaptationTestCase::DlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, |
|
8135 | 216 |
uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2) |
8039 | 217 |
{ |
218 |
static bool firstTime = true; |
|
219 |
||
220 |
if ( firstTime ) |
|
221 |
{ |
|
222 |
firstTime = false; |
|
8135 | 223 |
NS_LOG_INFO ("SNR\tRef_MCS\tCalc_MCS"); |
8039 | 224 |
} |
225 |
||
8046 | 226 |
/** |
227 |
* Note: |
|
8053
3404ba78e449
new test vector for AMC test; some test cases passing, but not all
Nicola Baldo <nbaldo@cttc.es>
parents:
8046
diff
changeset
|
228 |
* For first 4 subframeNo in the first frameNo, the MCS cannot be properly evaluated, |
3404ba78e449
new test vector for AMC test; some test cases passing, but not all
Nicola Baldo <nbaldo@cttc.es>
parents:
8046
diff
changeset
|
229 |
* because CQI feedback is still not available at the eNB. |
8046 | 230 |
*/ |
231 |
if ( (frameNo > 1) || (subframeNo > 4) ) |
|
8039 | 232 |
{ |
8135 | 233 |
NS_LOG_INFO (m_snrDb << "\t" << m_mcsIndex << "\t" << (uint16_t)mcsTb1); |
8039 | 234 |
|
8046 | 235 |
NS_TEST_ASSERT_MSG_EQ ((uint16_t)mcsTb1, m_mcsIndex, "Wrong MCS index"); |
236 |
} |
|
237 |
} |