21 #include "ns3/simulator.h" 23 #include "ns3/spectrum-test.h" 24 #include "ns3/lte-phy-tag.h" 25 #include "ns3/lte-chunk-processor.h" 26 #include <ns3/hybrid-buildings-propagation-loss-model.h> 27 #include <ns3/node-container.h> 28 #include <ns3/mobility-helper.h> 29 #include <ns3/buildings-helper.h> 30 #include <ns3/lte-helper.h> 31 #include <ns3/single-model-spectrum-channel.h> 32 #include "ns3/string.h" 33 #include "ns3/double.h" 34 #include <ns3/boolean.h> 35 #include <ns3/building.h> 37 #include <ns3/net-device-container.h> 38 #include <ns3/lte-ue-net-device.h> 39 #include <ns3/lte-enb-net-device.h> 40 #include <ns3/lte-ue-rrc.h> 41 #include <ns3/lte-enb-phy.h> 42 #include <ns3/lte-ue-phy.h> 70 :
TestSuite (
"lte-pathloss-model", SYSTEM)
80 struct SnrEfficiencyMcs
91 SnrEfficiencyMcs snrEfficiencyMcs[] = {
92 { -5.00000, 0.08024, -1},
93 { -4.00000, 0.10030, -1},
94 { -3.00000, 0.12518, -1},
95 { -2.00000, 0.15589, 0},
96 { -1.00000, 0.19365, 0},
97 { 0.00000, 0.23983, 2},
98 { 1.00000, 0.29593, 2},
99 { 2.00000, 0.36360, 2},
100 { 3.00000, 0.44451, 4},
101 { 4.00000, 0.54031, 4},
102 { 5.00000, 0.65251, 6},
103 { 6.00000, 0.78240, 6},
104 { 7.00000, 0.93086, 8},
105 { 8.00000, 1.09835, 8},
106 { 9.00000, 1.28485, 10},
107 { 10.00000, 1.48981, 12},
108 { 11.00000, 1.71229, 12},
109 { 12.00000, 1.95096, 14},
110 { 13.00000, 2.20429, 14},
111 { 14.00000, 2.47062, 16},
112 { 15.00000, 2.74826, 18},
113 { 16.00000, 3.03560, 18},
114 { 17.00000, 3.33115, 20},
115 { 18.00000, 3.63355, 20},
116 { 19.00000, 3.94163, 22},
117 { 20.00000, 4.25439, 22},
118 { 21.00000, 4.57095, 24},
119 { 22.00000, 4.89060, 24},
120 { 23.00000, 5.21276, 26},
121 { 24.00000, 5.53693, 26},
122 { 25.00000, 5.86271, 28},
123 { 26.00000, 6.18980, 28},
124 { 27.00000, 6.51792, 28},
125 { 28.00000, 6.84687, 28},
126 { 29.00000, 7.17649, 28},
127 { 30.00000, 7.50663, 28},
131 double txPowerDbm = 30;
132 double txPowerLin = std::pow (10, (txPowerDbm - 30)/10);
134 double noisePowerDbm = ktDbm + 10 * std::log10 (25 * 180000);
135 double receiverNoiseFigureDb = 9.0;
136 double noiseLin = std::pow (10, (noisePowerDbm-30+receiverNoiseFigureDb)/10);
140 double loss[] = {81.062444, 134.078605, 144.259958};
141 double dist[] = {100.0, 500.0, 1500};
143 int numOfTests =
sizeof (loss) /
sizeof (
double);
144 for (
int i = 0 ; i < numOfTests; i++ )
147 double sinrLin = (txPowerLin/(pow(10, loss[i]/10))) / noiseLin;
149 double sinrDb = 10 * std::log10 (sinrLin);
150 NS_LOG_INFO (
" Ptx " << txPowerDbm <<
" Pn " << noisePowerDbm <<
" Fn " << receiverNoiseFigureDb <<
" Pl " << loss[i] <<
" dist " << dist[i]);
153 int numSnrEfficiencyMcsEntries =
sizeof (snrEfficiencyMcs) /
sizeof (SnrEfficiencyMcs);
154 for (
int j = 0; j < numSnrEfficiencyMcsEntries && snrEfficiencyMcs[j].snrDb < sinrDb; ++j)
156 mcs = snrEfficiencyMcs[j].mcsIndex;
159 std::ostringstream name;
160 name <<
" snr= " << sinrDb <<
" dB, " 161 <<
" mcs= " << snrEfficiencyMcs[i].mcsIndex;
180 m_mcsIndex (mcsIndex)
182 std::ostringstream sstream1, sstream2;
183 sstream1 <<
" snr=" << snrDb
184 <<
" mcs=" << mcsIndex <<
" distance=" << dist;
186 NS_LOG_INFO (
"Creating LtePathlossModelSystemTestCase: " + sstream1.str ());
227 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
229 BuildingsHelper::Install (allNodes);
246 enbPhy->SetAttribute (
"TxPower",
DoubleValue (30.0));
247 enbPhy->SetAttribute (
"NoiseFigure",
DoubleValue (5.0));
251 uePhy->SetAttribute (
"TxPower",
DoubleValue (23.0));
252 uePhy->SetAttribute (
"NoiseFigure",
DoubleValue (9.0));
256 lteHelper->
Attach (ueDevs, enbDevs.
Get (0));
269 uePhy->GetDownlinkSpectrumPhy ()->AddCtrlSinrChunkProcessor (testSinr);
274 Simulator::Stop (
Seconds (0.035));
277 double calculatedSinrDb = 10.0 * std::log10 (sinrCatcher.GetValue ()->operator[] (0));
279 Simulator::Destroy ();
287 static bool firstTime =
true;
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
void SetPathlossModelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the path loss models to be created.
AttributeValue implementation for Boolean.
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Hold variables of type string.
LtePathlossModelTestSuite()
void DlScheduling(DlSchedulingCallbackInfo dlInfo)
DL scheduling function.
LtePathlossModelSystemTestCase()
void LteTestPathlossDlSchedCallback(LtePathlossModelSystemTestCase *testcase, std::string path, DlSchedulingCallbackInfo dlInfo)
Test 1.1 Pathloss compound test.
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
void EnableRlcTraces(void)
Enable trace sinks for RLC layer.
void SetUeDeviceAttribute(std::string n, const AttributeValue &v)
Set an attribute for the UE devices (LteUeNetDevice) to be created.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
double m_distance
the distance
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
static LtePathlossModelTestSuite ltePathlossModelTestSuite
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Keep track of the current position and velocity of an object.
Test 1.1 pathloss calculation.
This class contains the specification of EPS Bearers.
virtual void AddCallback(LteChunkProcessorCallback c)
Add callback to list.
double m_snrDb
the SNR in dB
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
virtual ~LtePathlossModelSystemTestCase()
uint16_t m_mcsIndex
the MCS index
Hold an unsigned integer type.
#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.
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
A sink to be plugged to the callback of LteChunkProcessor allowing to save and later retrieve the lat...
Ptr< LteEnbPhy > GetPhy(void) const
#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...
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Ptr< LteUePhy > GetPhy(void) const
Get the Phy.
void SetPosition(const Vector &position)
Tests that the BuildingPathlossModel works according to the expected theoretical values.
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Helper class used to assign positions and mobility models to nodes.
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetDefault(std::string name, const AttributeValue &value)
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void EnableMacTraces(void)
Enable trace sinks for MAC layer.
DlSchedulingCallbackInfo structure.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
The eNodeB device implementation.
void SetEnbDeviceAttribute(std::string n, const AttributeValue &v)
Set an attribute for the eNodeB devices (LteEnbNetDevice) to be created.
The LteUeNetDevice class implements the UE net device.