22 #include "ns3/boolean.h"
23 #include "ns3/double.h"
25 #include "ns3/lte-helper.h"
26 #include "ns3/lte-ue-net-device.h"
27 #include "ns3/lte-ue-phy.h"
28 #include "ns3/mobility-helper.h"
29 #include "ns3/simulator.h"
30 #include "ns3/string.h"
32 #include <ns3/lte-chunk-processor.h>
55 :
TestSuite(
"lte-link-adaptation", SYSTEM)
59 struct SnrEfficiencyMcs
70 SnrEfficiencyMcs snrEfficiencyMcs[] = {
71 {-5.00000, 0.08024, -1}, {-4.00000, 0.10030, -1}, {-3.00000, 0.12518, -1},
72 {-2.00000, 0.15589, 0}, {-1.00000, 0.19365, 0}, {0.00000, 0.23983, 2},
73 {1.00000, 0.29593, 2}, {2.00000, 0.36360, 2}, {3.00000, 0.44451, 4},
74 {4.00000, 0.54031, 4}, {5.00000, 0.65251, 6}, {6.00000, 0.78240, 6},
75 {7.00000, 0.93086, 8}, {8.00000, 1.09835, 8}, {9.00000, 1.28485, 10},
76 {10.00000, 1.48981, 12}, {11.00000, 1.71229, 12}, {12.00000, 1.95096, 14},
77 {13.00000, 2.20429, 14}, {14.00000, 2.47062, 16}, {15.00000, 2.74826, 18},
78 {16.00000, 3.03560, 18}, {17.00000, 3.33115, 20}, {18.00000, 3.63355, 20},
79 {19.00000, 3.94163, 22}, {20.00000, 4.25439, 22}, {21.00000, 4.57095, 24},
80 {22.00000, 4.89060, 24}, {23.00000, 5.21276, 26}, {24.00000, 5.53693, 26},
81 {25.00000, 5.86271, 28}, {26.00000, 6.18980, 28}, {27.00000, 6.51792, 28},
82 {28.00000, 6.84687, 28}, {29.00000, 7.17649, 28}, {30.00000, 7.50663, 28},
84 int numOfTests =
sizeof(snrEfficiencyMcs) /
sizeof(SnrEfficiencyMcs);
86 double txPowerDbm = 30;
88 double noisePowerDbm =
89 ktDbm + 10 * std::log10(25 * 180000);
90 double receiverNoiseFigureDb = 9.0;
92 for (
int i = 0; i < numOfTests; i++)
95 txPowerDbm - snrEfficiencyMcs[i].snrDb - noisePowerDbm - receiverNoiseFigureDb;
97 std::ostringstream name;
98 name <<
" snr= " << snrEfficiencyMcs[i].snrDb <<
" dB, "
99 <<
" mcs= " << snrEfficiencyMcs[i].mcsIndex;
101 snrEfficiencyMcs[i].snrDb,
103 snrEfficiencyMcs[i].mcsIndex),
127 std::ostringstream sstream1;
128 std::ostringstream sstream2;
129 sstream1 <<
" snr=" << snrDb <<
" mcs=" << mcsIndex;
131 NS_LOG_INFO(
"Creating LteLinkAdaptationTestCase: " + sstream1.str());
165 StringValue(
"ns3::ConstantSpectrumPropagationLossModel"));
178 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
189 lteHelper->
Attach(ueDevs, enbDevs.
Get(0));
201 testSinr->AddCallback(
MakeCallback(&LteSpectrumValueCatcher::ReportValue, &sinrCatcher));
202 uePhy->GetDownlinkSpectrumPhy()->AddCtrlSinrChunkProcessor(testSinr);
204 Config::Connect(
"/NodeList/0/DeviceList/0/ComponentCarrierMap/*/LteEnbMac/DlScheduling",
210 Simulator::Stop(
Seconds(0.040));
213 double calculatedSinrDb = 10.0 * std::log10(sinrCatcher.
GetValue()->operator[](0));
215 Simulator::Destroy();
221 static bool firstTime =
true;
Test that LTE link adaptation works according to the theoretical model.
void DlScheduling(DlSchedulingCallbackInfo dlInfo)
DL scheduling function.
LteLinkAdaptationTestCase()
~LteLinkAdaptationTestCase() override
uint16_t m_mcsIndex
the MCS index
double m_snrDb
the SNR in dB
void DoRun() override
Implementation to actually run this TestCase.
Test 1.3 Link adaptation.
LteLinkAdaptationTestSuite()
TestSuite.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
This class contains the specification of EPS Bearers.
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
void SetPathlossModelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the path loss models to be created.
void EnableRlcTraces()
Enable trace sinks for RLC layer.
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
void EnableMacTraces()
Enable trace sinks for MAC layer.
The LtePhy models the physical layer of LTE.
A sink to be plugged to the callback of LteChunkProcessor allowing to save and later retrieve the lat...
Ptr< SpectrumValue > GetValue()
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
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.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Hold an unsigned integer type.
void Reset()
Reset the initial value of every attribute as well as the value of every global to what they were bef...
void SetDefault(std::string name, const AttributeValue &value)
void Connect(std::string path, const CallbackBase &cb)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
static LteLinkAdaptationTestSuite lteLinkAdaptationTestSuite
Static variable for test initialization.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Time Now()
create an ns3::Time instance which contains the current simulation time.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#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...
Time Seconds(double value)
Construct a Time in the indicated unit.
void LteTestDlSchedulingCallback(LteLinkAdaptationTestCase *testcase, std::string path, DlSchedulingCallbackInfo dlInfo)
Test 1.3 Link Adaptation.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
DlSchedulingCallbackInfo structure.