OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2014 Piotr Gawlowicz |
| 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: Piotr Gawlowicz <gawlowicz.p@gmail.com> |
| 19 * |
| 20 */ |
| 21 |
| 22 #include <ns3/simulator.h> |
| 23 #include <ns3/log.h> |
| 24 #include <ns3/callback.h> |
| 25 #include <ns3/config.h> |
| 26 #include <ns3/string.h> |
| 27 #include <ns3/double.h> |
| 28 #include <ns3/enum.h> |
| 29 #include <ns3/boolean.h> |
| 30 #include <ns3/pointer.h> |
| 31 #include <ns3/integer.h> |
| 32 |
| 33 #include "ns3/mobility-helper.h" |
| 34 #include "ns3/lte-helper.h" |
| 35 |
| 36 #include <ns3/ff-mac-scheduler.h> |
| 37 #include <ns3/lte-enb-net-device.h> |
| 38 #include <ns3/lte-enb-phy.h> |
| 39 #include <ns3/lte-enb-rrc.h> |
| 40 #include <ns3/lte-ue-net-device.h> |
| 41 #include <ns3/lte-ue-phy.h> |
| 42 #include <ns3/lte-ue-rrc.h> |
| 43 |
| 44 #include "lte-ffr-simple.h" |
| 45 #include "lte-test-sinr-chunk-processor.h" |
| 46 #include <ns3/lte-common.h> |
| 47 |
| 48 #include "lte-test-uplink-power-control.h" |
| 49 #include <ns3/lte-rrc-sap.h> |
| 50 |
| 51 NS_LOG_COMPONENT_DEFINE ("LteUplinkPowerControlTest"); |
| 52 |
| 53 using namespace ns3; |
| 54 |
| 55 /** |
| 56 * TestSuite |
| 57 */ |
| 58 |
| 59 LteUplinkPowerControlTestSuite::LteUplinkPowerControlTestSuite () |
| 60 : TestSuite ("lte-uplink-power-control", SYSTEM) |
| 61 { |
| 62 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL
_DEBUG); |
| 63 // LogComponentEnable ("LteUplinkPowerControlTest", logLevel); |
| 64 NS_LOG_INFO ("Creating LteUplinkPowerControlTestSuite"); |
| 65 |
| 66 AddTestCase (new LteUplinkOpenLoopPowerControlTestCase ("OpenLoopTest1"), Test
Case::QUICK); |
| 67 AddTestCase (new LteUplinkClosedLoopPowerControlAbsoluteModeTestCase ("ClosedL
oopAbsoluteModeTest1"), TestCase::QUICK); |
| 68 AddTestCase (new LteUplinkClosedLoopPowerControlAccumulatedModeTestCase ("Clos
edLoopAccumulatedModeTest1"), TestCase::QUICK); |
| 69 } |
| 70 |
| 71 static LteUplinkPowerControlTestSuite lteUplinkPowerControlTestSuite; |
| 72 |
| 73 /** |
| 74 * TestCase Data |
| 75 */ |
| 76 void |
| 77 PuschTxPowerNofitication (LteUplinkPowerControlTestCase *testcase, |
| 78 uint16_t cellId, uint16_t rnti, double txPower) |
| 79 { |
| 80 testcase->PuschTxPowerTrace (cellId, rnti, txPower); |
| 81 } |
| 82 |
| 83 void |
| 84 PucchTxPowerNofitication (LteUplinkPowerControlTestCase *testcase, |
| 85 uint16_t cellId, uint16_t rnti, double txPower) |
| 86 { |
| 87 testcase->PucchTxPowerTrace (cellId, rnti, txPower); |
| 88 } |
| 89 |
| 90 void |
| 91 SrsTxPowerNofitication (LteUplinkPowerControlTestCase *testcase, |
| 92 uint16_t cellId, uint16_t rnti, double txPower) |
| 93 { |
| 94 testcase->SrsTxPowerTrace (cellId, rnti, txPower); |
| 95 } |
| 96 |
| 97 LteUplinkPowerControlTestCase::LteUplinkPowerControlTestCase (std::string name) |
| 98 : TestCase (name) |
| 99 { |
| 100 NS_LOG_INFO ("Creating LteUplinkPowerControlTestCase"); |
| 101 } |
| 102 |
| 103 LteUplinkPowerControlTestCase::~LteUplinkPowerControlTestCase () |
| 104 { |
| 105 } |
| 106 |
| 107 void |
| 108 LteUplinkPowerControlTestCase::TeleportUe (uint32_t x, uint32_t y, |
| 109 double expectedPuschTxPower, double e
xpectedPucchTxPower, double expectedSrsTxPower) |
| 110 { |
| 111 NS_LOG_FUNCTION (this); |
| 112 NS_LOG_DEBUG ("Teleport UE to : (" << x << ", " << y << ", 0)"); |
| 113 |
| 114 m_ueMobility->SetPosition (Vector (x, y, 0.0)); |
| 115 m_teleportTime = Simulator::Now (); |
| 116 |
| 117 m_expectedPuschTxPower = expectedPuschTxPower; |
| 118 m_expectedPucchTxPower = expectedPucchTxPower; |
| 119 m_expectedSrsTxPower = expectedSrsTxPower; |
| 120 } |
| 121 |
| 122 void |
| 123 LteUplinkPowerControlTestCase::SetTpcConfiguration (uint32_t tpc, uint32_t tpcNu
m, |
| 124 double expectedPuschTxPower,
double expectedPucchTxPower, double expectedSrsTxPower) |
| 125 { |
| 126 NS_LOG_FUNCTION (this); |
| 127 |
| 128 m_teleportTime = Simulator::Now (); |
| 129 |
| 130 m_expectedPuschTxPower = expectedPuschTxPower; |
| 131 m_expectedPucchTxPower = expectedPucchTxPower; |
| 132 m_expectedSrsTxPower = expectedSrsTxPower; |
| 133 |
| 134 m_ffrSimple->SetTpc (tpc, tpcNum, m_accumulatedMode); |
| 135 } |
| 136 |
| 137 void |
| 138 LteUplinkPowerControlTestCase::PuschTxPowerTrace (uint16_t cellId, uint16_t rnti
, double txPower) |
| 139 { |
| 140 NS_LOG_FUNCTION (this); |
| 141 NS_LOG_DEBUG ("PuschTxPower : CellId: " << cellId << " RNTI: " << rnti << " Pu
schTxPower: " << txPower); |
| 142 //wait because of RSRP filtering |
| 143 if ( (Simulator::Now () - m_teleportTime ) < MilliSeconds (50)) |
| 144 { |
| 145 return; |
| 146 } |
| 147 NS_TEST_ASSERT_MSG_EQ_TOL (txPower, m_expectedPuschTxPower, 0.01, "Wrong Pusch
Tx Power"); |
| 148 } |
| 149 |
| 150 void |
| 151 LteUplinkPowerControlTestCase::PucchTxPowerTrace (uint16_t cellId, uint16_t rnti
, double txPower) |
| 152 { |
| 153 NS_LOG_FUNCTION (this); |
| 154 NS_LOG_DEBUG ("PucchTxPower : CellId: " << cellId << " RNTI: " << rnti << " Pu
schTxPower: " << txPower); |
| 155 //wait because of RSRP filtering |
| 156 if ( (Simulator::Now () - m_teleportTime ) < MilliSeconds (50)) |
| 157 { |
| 158 return; |
| 159 } |
| 160 |
| 161 NS_TEST_ASSERT_MSG_EQ_TOL (txPower, m_expectedPucchTxPower, 0.01, "Wrong Pucch
Tx Power"); |
| 162 } |
| 163 |
| 164 void |
| 165 LteUplinkPowerControlTestCase::SrsTxPowerTrace (uint16_t cellId, uint16_t rnti,
double txPower) |
| 166 { |
| 167 NS_LOG_FUNCTION (this); |
| 168 NS_LOG_DEBUG ("SrsTxPower : CellId: " << cellId << " RNTI: " << rnti << " Pusc
hTxPower: " << txPower); |
| 169 //wait because of RSRP filtering |
| 170 if ( (Simulator::Now () - m_teleportTime ) < MilliSeconds (50)) |
| 171 { |
| 172 return; |
| 173 } |
| 174 NS_TEST_ASSERT_MSG_EQ_TOL (txPower, m_expectedSrsTxPower, 0.01, "Wrong Srs Tx
Power"); |
| 175 } |
| 176 |
| 177 void |
| 178 LteUplinkPowerControlTestCase::DoRun (void) |
| 179 { |
| 180 } |
| 181 |
| 182 |
| 183 LteUplinkOpenLoopPowerControlTestCase::LteUplinkOpenLoopPowerControlTestCase (st
d::string name) |
| 184 : LteUplinkPowerControlTestCase ("Uplink Open Loop Power Control: " + name) |
| 185 { |
| 186 NS_LOG_INFO ("Creating LteUplinkPowerControlTestCase"); |
| 187 } |
| 188 |
| 189 LteUplinkOpenLoopPowerControlTestCase::~LteUplinkOpenLoopPowerControlTestCase () |
| 190 { |
| 191 } |
| 192 |
| 193 void |
| 194 LteUplinkOpenLoopPowerControlTestCase::DoRun (void) |
| 195 { |
| 196 Config::Reset (); |
| 197 Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (false)); |
| 198 |
| 199 double eNbTxPower = 30; |
| 200 Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (eNbTxPower)); |
| 201 Config::SetDefault ("ns3::LteUePhy::TxPower", DoubleValue (10.0)); |
| 202 Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (t
rue)); |
| 203 |
| 204 Config::SetDefault ("ns3::LteUePowerControl::ClosedLoop", BooleanValue (false)
); |
| 205 Config::SetDefault ("ns3::LteUePowerControl::AccumulationEnabled", BooleanValu
e (false)); |
| 206 Config::SetDefault ("ns3::LteUePowerControl::PoNominalPusch", IntegerValue (-9
0)); |
| 207 Config::SetDefault ("ns3::LteUePowerControl::PsrsOffset", IntegerValue (9)); |
| 208 |
| 209 Ptr<LteHelper> lteHelper = CreateObject<LteHelper> (); |
| 210 |
| 211 uint8_t bandwidth = 25; |
| 212 double d1 = 0; |
| 213 |
| 214 // Create Nodes: eNodeB and UE |
| 215 NodeContainer enbNodes; |
| 216 NodeContainer ueNodes; |
| 217 enbNodes.Create (1); |
| 218 ueNodes.Create (1); |
| 219 NodeContainer allNodes = NodeContainer ( enbNodes, ueNodes); |
| 220 |
| 221 /* the topology is the following: |
| 222 * |
| 223 * eNB1-------------------------UE |
| 224 * d1 |
| 225 */ |
| 226 |
| 227 // Install Mobility Model |
| 228 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>
(); |
| 229 positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // eNB1 |
| 230 positionAlloc->Add (Vector (d1, 0.0, 0.0)); // UE1 |
| 231 |
| 232 MobilityHelper mobility; |
| 233 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
| 234 mobility.SetPositionAllocator (positionAlloc); |
| 235 mobility.Install (allNodes); |
| 236 m_ueMobility = ueNodes.Get (0)->GetObject<MobilityModel> (); |
| 237 |
| 238 // Create Devices and install them in the Nodes (eNB and UE) |
| 239 NetDeviceContainer enbDevs; |
| 240 NetDeviceContainer ueDevs; |
| 241 lteHelper->SetSchedulerType ("ns3::PfFfMacScheduler"); |
| 242 |
| 243 lteHelper->SetEnbDeviceAttribute ("DlBandwidth", UintegerValue (bandwidth)); |
| 244 lteHelper->SetEnbDeviceAttribute ("UlBandwidth", UintegerValue (bandwidth)); |
| 245 |
| 246 enbDevs = lteHelper->InstallEnbDevice (enbNodes); |
| 247 ueDevs = lteHelper->InstallUeDevice (ueNodes); |
| 248 |
| 249 Ptr<LteUePhy> uePhy = DynamicCast<LteUePhy>( ueDevs.Get (0)->GetObject<LteUeNe
tDevice> ()->GetPhy () ); |
| 250 m_ueUpc = uePhy->GetUplinkPowerControl (); |
| 251 |
| 252 m_ueUpc->TraceConnectWithoutContext ("ReportPuschTxPower", |
| 253 MakeBoundCallback (&PuschTxPowerNofiticat
ion, this)); |
| 254 m_ueUpc->TraceConnectWithoutContext ("ReportPucchTxPower", |
| 255 MakeBoundCallback (&PucchTxPowerNofiticat
ion, this)); |
| 256 m_ueUpc->TraceConnectWithoutContext ("ReportSrsTxPower", |
| 257 MakeBoundCallback (&SrsTxPowerNofiticatio
n, this)); |
| 258 |
| 259 // Attach a UE to a eNB |
| 260 lteHelper->Attach (ueDevs, enbDevs.Get (0)); |
| 261 |
| 262 // Activate a data radio bearer |
| 263 enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; |
| 264 EpsBearer bearer (q); |
| 265 lteHelper->ActivateDataRadioBearer (ueDevs, bearer); |
| 266 |
| 267 //Changing UE position |
| 268 Simulator::Schedule (MilliSeconds (0), |
| 269 &LteUplinkPowerControlTestCase::TeleportUe, this, 0, 0, -
40, -40, -40); |
| 270 Simulator::Schedule (MilliSeconds (200), |
| 271 &LteUplinkPowerControlTestCase::TeleportUe, this, 200, 0,
8.9745, 8.9745, 11.9745); |
| 272 Simulator::Schedule (MilliSeconds (300), |
| 273 &LteUplinkPowerControlTestCase::TeleportUe, this, 400, 0,
14.9951, 14.9951, 17.9951 ); |
| 274 Simulator::Schedule (MilliSeconds (400), |
| 275 &LteUplinkPowerControlTestCase::TeleportUe, this, 600, 0,
18.5169, 18.5169, 21.5169 ); |
| 276 Simulator::Schedule (MilliSeconds (500), |
| 277 &LteUplinkPowerControlTestCase::TeleportUe, this, 800, 0,
21.0157, 21.0157, 23 ); |
| 278 Simulator::Schedule (MilliSeconds (600), |
| 279 &LteUplinkPowerControlTestCase::TeleportUe, this, 1000, 0
, 22.9539, 22.9539, 23 ); |
| 280 Simulator::Schedule (MilliSeconds (700), |
| 281 &LteUplinkPowerControlTestCase::TeleportUe, this, 1200, 0
, 23, 10, 23 ); |
| 282 Simulator::Schedule (MilliSeconds (800), |
| 283 &LteUplinkPowerControlTestCase::TeleportUe, this, 400, 0,
14.9951, 14.9951, 17.9951 ); |
| 284 Simulator::Schedule (MilliSeconds (900), |
| 285 &LteUplinkPowerControlTestCase::TeleportUe, this, 800, 0,
21.0157, 21.0157, 23 ); |
| 286 Simulator::Schedule (MilliSeconds (1000), |
| 287 &LteUplinkPowerControlTestCase::TeleportUe, this, 0, 0, -
40, -40, -40 ); |
| 288 Simulator::Schedule (MilliSeconds (1100), |
| 289 &LteUplinkPowerControlTestCase::TeleportUe, this, 100, 0,
2.9539, 2.9539, 5.9539 ); |
| 290 Simulator::Stop (Seconds (1.200)); |
| 291 Simulator::Run (); |
| 292 |
| 293 Simulator::Destroy (); |
| 294 } |
| 295 |
| 296 LteUplinkClosedLoopPowerControlAbsoluteModeTestCase::LteUplinkClosedLoopPowerCon
trolAbsoluteModeTestCase (std::string name) |
| 297 : LteUplinkPowerControlTestCase ("Uplink Closed Loop Power Control: " + name) |
| 298 { |
| 299 NS_LOG_INFO ("Creating LteUplinkClosedLoopPowerControlAbsoluteModeTestCase"); |
| 300 } |
| 301 |
| 302 LteUplinkClosedLoopPowerControlAbsoluteModeTestCase::~LteUplinkClosedLoopPowerCo
ntrolAbsoluteModeTestCase () |
| 303 { |
| 304 } |
| 305 |
| 306 void |
| 307 LteUplinkClosedLoopPowerControlAbsoluteModeTestCase::DoRun (void) |
| 308 { |
| 309 Config::Reset (); |
| 310 Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (false)); |
| 311 |
| 312 double eNbTxPower = 30; |
| 313 Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (eNbTxPower)); |
| 314 Config::SetDefault ("ns3::LteUePhy::TxPower", DoubleValue (10.0)); |
| 315 Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (t
rue)); |
| 316 |
| 317 Config::SetDefault ("ns3::LteUePowerControl::ClosedLoop", BooleanValue (true))
; |
| 318 Config::SetDefault ("ns3::LteUePowerControl::AccumulationEnabled", BooleanValu
e (false)); |
| 319 Config::SetDefault ("ns3::LteUePowerControl::PoNominalPusch", IntegerValue (-9
0)); |
| 320 Config::SetDefault ("ns3::LteUePowerControl::PsrsOffset", IntegerValue (9)); |
| 321 |
| 322 Ptr<LteHelper> lteHelper = CreateObject<LteHelper> (); |
| 323 lteHelper->SetFfrAlgorithmType ("ns3::LteFfrSimple"); |
| 324 |
| 325 uint8_t bandwidth = 25; |
| 326 double d1 = 100; |
| 327 |
| 328 // Create Nodes: eNodeB and UE |
| 329 NodeContainer enbNodes; |
| 330 NodeContainer ueNodes; |
| 331 enbNodes.Create (1); |
| 332 ueNodes.Create (1); |
| 333 NodeContainer allNodes = NodeContainer ( enbNodes, ueNodes); |
| 334 |
| 335 /* the topology is the following: |
| 336 * |
| 337 * eNB1-------------------------UE |
| 338 * d1 |
| 339 */ |
| 340 |
| 341 // Install Mobility Model |
| 342 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>
(); |
| 343 positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // eNB1 |
| 344 positionAlloc->Add (Vector (d1, 0.0, 0.0)); // UE1 |
| 345 |
| 346 MobilityHelper mobility; |
| 347 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
| 348 mobility.SetPositionAllocator (positionAlloc); |
| 349 mobility.Install (allNodes); |
| 350 m_ueMobility = ueNodes.Get (0)->GetObject<MobilityModel> (); |
| 351 |
| 352 // Create Devices and install them in the Nodes (eNB and UE) |
| 353 NetDeviceContainer enbDevs; |
| 354 NetDeviceContainer ueDevs; |
| 355 lteHelper->SetSchedulerType ("ns3::PfFfMacScheduler"); |
| 356 |
| 357 lteHelper->SetEnbDeviceAttribute ("DlBandwidth", UintegerValue (bandwidth)); |
| 358 lteHelper->SetEnbDeviceAttribute ("UlBandwidth", UintegerValue (bandwidth)); |
| 359 |
| 360 enbDevs = lteHelper->InstallEnbDevice (enbNodes); |
| 361 ueDevs = lteHelper->InstallUeDevice (ueNodes); |
| 362 |
| 363 Ptr<LteUePhy> uePhy = DynamicCast<LteUePhy>( ueDevs.Get (0)->GetObject<LteUeNe
tDevice> ()->GetPhy () ); |
| 364 m_ueUpc = uePhy->GetUplinkPowerControl (); |
| 365 |
| 366 m_ueUpc->TraceConnectWithoutContext ("ReportPuschTxPower", |
| 367 MakeBoundCallback (&PuschTxPowerNofiticat
ion, this)); |
| 368 m_ueUpc->TraceConnectWithoutContext ("ReportPucchTxPower", |
| 369 MakeBoundCallback (&PucchTxPowerNofiticat
ion, this)); |
| 370 m_ueUpc->TraceConnectWithoutContext ("ReportSrsTxPower", |
| 371 MakeBoundCallback (&SrsTxPowerNofiticatio
n, this)); |
| 372 |
| 373 // Attach a UE to a eNB |
| 374 lteHelper->Attach (ueDevs, enbDevs.Get (0)); |
| 375 |
| 376 // Activate a data radio bearer |
| 377 enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; |
| 378 EpsBearer bearer (q); |
| 379 lteHelper->ActivateDataRadioBearer (ueDevs, bearer); |
| 380 |
| 381 PointerValue tmp; |
| 382 enbDevs.Get (0)->GetAttribute ("LteFfrAlgorithm", tmp); |
| 383 m_ffrSimple = DynamicCast<LteFfrSimple>(tmp.GetObject ()); |
| 384 m_accumulatedMode = false; |
| 385 |
| 386 //Changing TPC value |
| 387 Simulator::Schedule (MilliSeconds (0), |
| 388 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 1, 0, 1.9539, 1.9539, 4.9539); |
| 389 Simulator::Schedule (MilliSeconds (100), |
| 390 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 0, 0, -1.0461, -1.0461, 1.9539); |
| 391 Simulator::Schedule (MilliSeconds (200), |
| 392 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 2, 0, 3.9539, 3.9539, 6.9539); |
| 393 Simulator::Schedule (MilliSeconds (300), |
| 394 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 3, 0, 6.9539, 6.9539, 9.9539); |
| 395 Simulator::Schedule (MilliSeconds (400), |
| 396 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 0, 0, -1.0461, -1.0461, 1.9539); |
| 397 Simulator::Schedule (MilliSeconds (500), |
| 398 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 1, 0, 1.9539, 1.9539, 4.9539); |
| 399 Simulator::Schedule (MilliSeconds (600), |
| 400 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 3, 0, 6.9539, 6.9539, 9.9539); |
| 401 Simulator::Schedule (MilliSeconds (800), |
| 402 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 2, 0, 3.9539, 3.9539, 6.9539); |
| 403 Simulator::Stop (Seconds (1.000)); |
| 404 Simulator::Run (); |
| 405 |
| 406 Simulator::Destroy (); |
| 407 } |
| 408 |
| 409 LteUplinkClosedLoopPowerControlAccumulatedModeTestCase::LteUplinkClosedLoopPower
ControlAccumulatedModeTestCase (std::string name) |
| 410 : LteUplinkPowerControlTestCase ("Uplink Closed Loop Power Control: " + name) |
| 411 { |
| 412 NS_LOG_INFO ("Creating LteUplinkClosedLoopPowerControlAccumulatedModeTestCase"
); |
| 413 } |
| 414 |
| 415 LteUplinkClosedLoopPowerControlAccumulatedModeTestCase::~LteUplinkClosedLoopPowe
rControlAccumulatedModeTestCase () |
| 416 { |
| 417 } |
| 418 |
| 419 void |
| 420 LteUplinkClosedLoopPowerControlAccumulatedModeTestCase::DoRun (void) |
| 421 { |
| 422 Config::Reset (); |
| 423 Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (false)); |
| 424 |
| 425 double eNbTxPower = 30; |
| 426 Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (eNbTxPower)); |
| 427 Config::SetDefault ("ns3::LteUePhy::TxPower", DoubleValue (10.0)); |
| 428 Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (t
rue)); |
| 429 |
| 430 Config::SetDefault ("ns3::LteUePowerControl::ClosedLoop", BooleanValue (true))
; |
| 431 Config::SetDefault ("ns3::LteUePowerControl::AccumulationEnabled", BooleanValu
e (true)); |
| 432 Config::SetDefault ("ns3::LteUePowerControl::PoNominalPusch", IntegerValue (-9
0)); |
| 433 Config::SetDefault ("ns3::LteUePowerControl::PsrsOffset", IntegerValue (9)); |
| 434 |
| 435 Ptr<LteHelper> lteHelper = CreateObject<LteHelper> (); |
| 436 lteHelper->SetFfrAlgorithmType ("ns3::LteFfrSimple"); |
| 437 |
| 438 uint8_t bandwidth = 25; |
| 439 double d1 = 10; |
| 440 |
| 441 // Create Nodes: eNodeB and UE |
| 442 NodeContainer enbNodes; |
| 443 NodeContainer ueNodes; |
| 444 enbNodes.Create (1); |
| 445 ueNodes.Create (1); |
| 446 NodeContainer allNodes = NodeContainer ( enbNodes, ueNodes); |
| 447 |
| 448 /* the topology is the following: |
| 449 * |
| 450 * eNB1-------------------------UE |
| 451 * d1 |
| 452 */ |
| 453 |
| 454 // Install Mobility Model |
| 455 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>
(); |
| 456 positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // eNB1 |
| 457 positionAlloc->Add (Vector (d1, 0.0, 0.0)); // UE1 |
| 458 |
| 459 MobilityHelper mobility; |
| 460 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
| 461 mobility.SetPositionAllocator (positionAlloc); |
| 462 mobility.Install (allNodes); |
| 463 m_ueMobility = ueNodes.Get (0)->GetObject<MobilityModel> (); |
| 464 |
| 465 // Create Devices and install them in the Nodes (eNB and UE) |
| 466 NetDeviceContainer enbDevs; |
| 467 NetDeviceContainer ueDevs; |
| 468 lteHelper->SetSchedulerType ("ns3::PfFfMacScheduler"); |
| 469 |
| 470 lteHelper->SetEnbDeviceAttribute ("DlBandwidth", UintegerValue (bandwidth)); |
| 471 lteHelper->SetEnbDeviceAttribute ("UlBandwidth", UintegerValue (bandwidth)); |
| 472 |
| 473 enbDevs = lteHelper->InstallEnbDevice (enbNodes); |
| 474 ueDevs = lteHelper->InstallUeDevice (ueNodes); |
| 475 |
| 476 Ptr<LteUePhy> uePhy = DynamicCast<LteUePhy>( ueDevs.Get (0)->GetObject<LteUeNe
tDevice> ()->GetPhy () ); |
| 477 m_ueUpc = uePhy->GetUplinkPowerControl (); |
| 478 |
| 479 m_ueUpc->TraceConnectWithoutContext ("ReportPuschTxPower", |
| 480 MakeBoundCallback (&PuschTxPowerNofiticat
ion, this)); |
| 481 m_ueUpc->TraceConnectWithoutContext ("ReportPucchTxPower", |
| 482 MakeBoundCallback (&PucchTxPowerNofiticat
ion, this)); |
| 483 m_ueUpc->TraceConnectWithoutContext ("ReportSrsTxPower", |
| 484 MakeBoundCallback (&SrsTxPowerNofiticatio
n, this)); |
| 485 |
| 486 // Attach a UE to a eNB |
| 487 lteHelper->Attach (ueDevs, enbDevs.Get (0)); |
| 488 |
| 489 // Activate a data radio bearer |
| 490 enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; |
| 491 EpsBearer bearer (q); |
| 492 lteHelper->ActivateDataRadioBearer (ueDevs, bearer); |
| 493 |
| 494 PointerValue tmp; |
| 495 enbDevs.Get (0)->GetAttribute ("LteFfrAlgorithm", tmp); |
| 496 m_ffrSimple = DynamicCast<LteFfrSimple>(tmp.GetObject ()); |
| 497 m_accumulatedMode = true; |
| 498 |
| 499 //Changing TPC value |
| 500 Simulator::Schedule (MilliSeconds (0), |
| 501 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 1, 0, -17.0461, -17.0461, -14.0461); |
| 502 Simulator::Schedule (MilliSeconds (100), |
| 503 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 0, 20, -37.0461, -37.0461, -34.0461); |
| 504 Simulator::Schedule (MilliSeconds (200), |
| 505 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 0, 20, -40, 10, -37.0461); |
| 506 Simulator::Schedule (MilliSeconds (300), |
| 507 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 2, 1, -39.0461, -39.0461, -36.0461); |
| 508 Simulator::Schedule (MilliSeconds (400), |
| 509 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 3, 10, -9.0461, -9.0461, -6.0461); |
| 510 Simulator::Schedule (MilliSeconds (500), |
| 511 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 2, 15, 5.9539, 5.9539, 8.9539); |
| 512 Simulator::Schedule (MilliSeconds (600), |
| 513 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 3, 1, 8.9539, 8.9539, 11.9539); |
| 514 Simulator::Schedule (MilliSeconds (700), |
| 515 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 2, 10, 18.9539, 18.9539, 21.9539); |
| 516 Simulator::Schedule (MilliSeconds (800), |
| 517 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 2, 20, 23, 23, 23); |
| 518 Simulator::Schedule (MilliSeconds (900), |
| 519 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 0, 1, 22.9539, 22.9539, 23); |
| 520 Simulator::Schedule (MilliSeconds (1000), |
| 521 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 0, 20, 2.9539, 2.9539, 5.9539); |
| 522 Simulator::Schedule (MilliSeconds (1100), |
| 523 &LteUplinkPowerControlTestCase::SetTpcConfiguration, this
, 2, 5, 7.9539, 7.9539, 10.9539); |
| 524 Simulator::Stop (Seconds (1.200)); |
| 525 Simulator::Run (); |
| 526 |
| 527 Simulator::Destroy (); |
| 528 } |
OLD | NEW |