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 "nist-lte-ffr-distributed-algorithm.h" |
| 23 #include <ns3/log.h> |
| 24 |
| 25 namespace ns3 { |
| 26 |
| 27 NS_LOG_COMPONENT_DEFINE ("NistLteFfrDistributedAlgorithm"); |
| 28 |
| 29 NS_OBJECT_ENSURE_REGISTERED (NistLteFfrDistributedAlgorithm); |
| 30 |
| 31 |
| 32 NistLteFfrDistributedAlgorithm::NistLteFfrDistributedAlgorithm () |
| 33 : m_ffrSapUser (0), |
| 34 m_ffrRrcSapUser (0) |
| 35 { |
| 36 NS_LOG_FUNCTION (this); |
| 37 m_ffrSapProvider = new MemberNistLteFfrSapProvider<NistLteFfrDistributedAlgori
thm> (this); |
| 38 m_ffrRrcSapProvider = new MemberNistLteFfrRrcSapProvider<NistLteFfrDistributed
Algorithm> (this); |
| 39 } |
| 40 |
| 41 |
| 42 NistLteFfrDistributedAlgorithm::~NistLteFfrDistributedAlgorithm () |
| 43 { |
| 44 NS_LOG_FUNCTION (this); |
| 45 } |
| 46 |
| 47 |
| 48 void |
| 49 NistLteFfrDistributedAlgorithm::DoDispose () |
| 50 { |
| 51 NS_LOG_FUNCTION (this); |
| 52 delete m_ffrSapProvider; |
| 53 delete m_ffrRrcSapProvider; |
| 54 } |
| 55 |
| 56 |
| 57 TypeId |
| 58 NistLteFfrDistributedAlgorithm::GetTypeId () |
| 59 { |
| 60 static TypeId tid = TypeId ("ns3::NistLteFfrDistributedAlgorithm") |
| 61 .SetParent<NistLteFfrAlgorithm> () |
| 62 .AddConstructor<NistLteFfrDistributedAlgorithm> () |
| 63 .AddAttribute ("CalculationInterval", |
| 64 "Time interval between calculation of Edge sub-band, Default
value 1 second", |
| 65 TimeValue (Seconds (1)), |
| 66 MakeTimeAccessor (&NistLteFfrDistributedAlgorithm::m_calculat
ionInterval), |
| 67 MakeTimeChecker ()) |
| 68 .AddAttribute ("RsrqThreshold", |
| 69 "If the RSRQ of is worse than this threshold, UE should be se
rved in Edge sub-band", |
| 70 UintegerValue (20), |
| 71 MakeUintegerAccessor (&NistLteFfrDistributedAlgorithm::m_egde
SubBandRsrqThreshold), |
| 72 MakeUintegerChecker<uint8_t> ()) |
| 73 .AddAttribute ("RsrpDifferenceThreshold", |
| 74 "If the difference between the power of the signal received b
y UE from " |
| 75 "the serving cell and the power of the signal received from t
he adjacent cell is less " |
| 76 "than a RsrpDifferenceThreshold value, the cell weight is inc
remented", |
| 77 UintegerValue (20), |
| 78 MakeUintegerAccessor (&NistLteFfrDistributedAlgorithm::m_rsrp
DifferenceThreshold), |
| 79 MakeUintegerChecker<uint8_t> ()) |
| 80 .AddAttribute ("CenterPowerOffset", |
| 81 "NistPdschConfigDedicated::Pa value for Edge Sub-band, defaul
t value dB0", |
| 82 UintegerValue (5), |
| 83 MakeUintegerAccessor (&NistLteFfrDistributedAlgorithm::m_cent
erPowerOffset), |
| 84 MakeUintegerChecker<uint8_t> ()) |
| 85 .AddAttribute ("EdgePowerOffset", |
| 86 "NistPdschConfigDedicated::Pa value for Edge Sub-band, defaul
t value dB0", |
| 87 UintegerValue (5), |
| 88 MakeUintegerAccessor (&NistLteFfrDistributedAlgorithm::m_edge
PowerOffset), |
| 89 MakeUintegerChecker<uint8_t> ()) |
| 90 .AddAttribute ("EdgeRbNum", |
| 91 "Number of RB that can be used in edge Sub-band", |
| 92 UintegerValue (8), |
| 93 MakeUintegerAccessor (&NistLteFfrDistributedAlgorithm::m_edge
RbNum), |
| 94 MakeUintegerChecker<uint8_t> ()) |
| 95 .AddAttribute ("CenterAreaTpc", |
| 96 "TPC value which will be set in DL-DCI for UEs in center area
" |
| 97 "Absolute mode is used, default value 1 is mapped to -1 accor
ding to" |
| 98 "TS36.213 Table 5.1.1.1-2", |
| 99 UintegerValue (1), |
| 100 MakeUintegerAccessor (&NistLteFfrDistributedAlgorithm::m_cent
erAreaTpc), |
| 101 MakeUintegerChecker<uint8_t> ()) |
| 102 .AddAttribute ("EdgeAreaTpc", |
| 103 "TPC value which will be set in DL-DCI for UEs in edge area" |
| 104 "Absolute mode is used, default value 1 is mapped to -1 accor
ding to" |
| 105 "TS36.213 Table 5.1.1.1-2", |
| 106 UintegerValue (1), |
| 107 MakeUintegerAccessor (&NistLteFfrDistributedAlgorithm::m_edge
AreaTpc), |
| 108 MakeUintegerChecker<uint8_t> ()) |
| 109 |
| 110 ; |
| 111 return tid; |
| 112 } |
| 113 |
| 114 |
| 115 void |
| 116 NistLteFfrDistributedAlgorithm::SetNistLteFfrSapUser (NistLteFfrSapUser* s) |
| 117 { |
| 118 NS_LOG_FUNCTION (this << s); |
| 119 m_ffrSapUser = s; |
| 120 } |
| 121 |
| 122 |
| 123 NistLteFfrSapProvider* |
| 124 NistLteFfrDistributedAlgorithm::GetNistLteFfrSapProvider () |
| 125 { |
| 126 NS_LOG_FUNCTION (this); |
| 127 return m_ffrSapProvider; |
| 128 } |
| 129 |
| 130 void |
| 131 NistLteFfrDistributedAlgorithm::SetNistLteFfrRrcSapUser (NistLteFfrRrcSapUser* s
) |
| 132 { |
| 133 NS_LOG_FUNCTION (this << s); |
| 134 m_ffrRrcSapUser = s; |
| 135 } |
| 136 |
| 137 |
| 138 NistLteFfrRrcSapProvider* |
| 139 NistLteFfrDistributedAlgorithm::GetNistLteFfrRrcSapProvider () |
| 140 { |
| 141 NS_LOG_FUNCTION (this); |
| 142 return m_ffrRrcSapProvider; |
| 143 } |
| 144 |
| 145 |
| 146 void |
| 147 NistLteFfrDistributedAlgorithm::DoInitialize () |
| 148 { |
| 149 NS_LOG_FUNCTION (this); |
| 150 NistLteFfrAlgorithm::DoInitialize (); |
| 151 |
| 152 if (m_frCellTypeId != 0) |
| 153 { |
| 154 SetDownlinkConfiguration (m_frCellTypeId, m_dlBandwidth); |
| 155 SetUplinkConfiguration (m_frCellTypeId, m_ulBandwidth); |
| 156 } |
| 157 |
| 158 NS_LOG_LOGIC (this << " requesting Event A1 and A4 measurements" |
| 159 << " (threshold = 0" << ")"); |
| 160 NistLteRrcSap::NistReportConfigEutra reportConfig; |
| 161 reportConfig.eventId = NistLteRrcSap::NistReportConfigEutra::EVENT_A1; |
| 162 reportConfig.threshold1.choice = NistLteRrcSap::NistThresholdEutra::THRESHOLD_
RSRQ; |
| 163 reportConfig.threshold1.range = 0; |
| 164 reportConfig.triggerQuantity = NistLteRrcSap::NistReportConfigEutra::RSRQ; |
| 165 reportConfig.reportInterval = NistLteRrcSap::NistReportConfigEutra::MS120; |
| 166 m_rsrqMeasId = m_ffrRrcSapUser->AddUeMeasReportConfigForFfr (reportConfig); |
| 167 |
| 168 NistLteRrcSap::NistReportConfigEutra reportConfigA4; |
| 169 reportConfigA4.eventId = NistLteRrcSap::NistReportConfigEutra::EVENT_A4; |
| 170 reportConfigA4.threshold1.choice = NistLteRrcSap::NistThresholdEutra::THRESHOL
D_RSRP; |
| 171 reportConfigA4.threshold1.range = 0; // intentionally very low threshold |
| 172 reportConfigA4.triggerQuantity = NistLteRrcSap::NistReportConfigEutra::RSRP; |
| 173 reportConfigA4.reportInterval = NistLteRrcSap::NistReportConfigEutra::MS120; |
| 174 m_rsrpMeasId = m_ffrRrcSapUser->AddUeMeasReportConfigForFfr (reportConfigA4); |
| 175 |
| 176 int rbgSize = GetRbgSize (m_dlBandwidth); |
| 177 m_dlEdgeRbgMap.resize (m_dlBandwidth / rbgSize, false); |
| 178 m_ulEdgeRbgMap.resize (m_ulBandwidth, false); |
| 179 m_calculationEvent = Simulator::ScheduleNow (&NistLteFfrDistributedAlgorithm::
Calculate, this); |
| 180 |
| 181 } |
| 182 |
| 183 void |
| 184 NistLteFfrDistributedAlgorithm::Reconfigure () |
| 185 { |
| 186 NS_LOG_FUNCTION (this); |
| 187 if (m_frCellTypeId != 0) |
| 188 { |
| 189 SetDownlinkConfiguration (m_frCellTypeId, m_dlBandwidth); |
| 190 SetUplinkConfiguration (m_frCellTypeId, m_ulBandwidth); |
| 191 } |
| 192 InitializeDownlinkRbgMaps (); |
| 193 InitializeUplinkRbgMaps (); |
| 194 m_needReconfiguration = false; |
| 195 } |
| 196 |
| 197 void |
| 198 NistLteFfrDistributedAlgorithm::SetDownlinkConfiguration (uint16_t cellId, uint8
_t bandwidth) |
| 199 { |
| 200 NS_LOG_FUNCTION (this); |
| 201 } |
| 202 |
| 203 void |
| 204 NistLteFfrDistributedAlgorithm::SetUplinkConfiguration (uint16_t cellId, uint8_t
bandwidth) |
| 205 { |
| 206 NS_LOG_FUNCTION (this); |
| 207 } |
| 208 |
| 209 void |
| 210 NistLteFfrDistributedAlgorithm::InitializeDownlinkRbgMaps () |
| 211 { |
| 212 NS_LOG_FUNCTION (this); |
| 213 m_dlRbgMap.clear (); |
| 214 int rbgSize = GetRbgSize (m_dlBandwidth); |
| 215 m_dlRbgMap.resize (m_dlBandwidth / rbgSize, false); |
| 216 } |
| 217 |
| 218 void |
| 219 NistLteFfrDistributedAlgorithm::InitializeUplinkRbgMaps () |
| 220 { |
| 221 NS_LOG_FUNCTION (this); |
| 222 m_ulRbgMap.clear (); |
| 223 m_ulRbgMap.resize (m_ulBandwidth, false); |
| 224 } |
| 225 |
| 226 std::vector <bool> |
| 227 NistLteFfrDistributedAlgorithm::DoGetAvailableDlRbg () |
| 228 { |
| 229 NS_LOG_FUNCTION (this); |
| 230 |
| 231 if (m_needReconfiguration) |
| 232 { |
| 233 Reconfigure (); |
| 234 } |
| 235 |
| 236 if (m_dlRbgMap.empty ()) |
| 237 { |
| 238 InitializeDownlinkRbgMaps (); |
| 239 } |
| 240 |
| 241 return m_dlRbgMap; |
| 242 } |
| 243 |
| 244 bool |
| 245 NistLteFfrDistributedAlgorithm::DoIsDlRbgAvailableForUe (int rbgId, uint16_t rnt
i) |
| 246 { |
| 247 NS_LOG_FUNCTION (this); |
| 248 |
| 249 bool edgeRbg = m_dlEdgeRbgMap[rbgId]; |
| 250 |
| 251 std::map< uint16_t, uint8_t >::iterator it = m_ues.find (rnti); |
| 252 if (it == m_ues.end ()) |
| 253 { |
| 254 m_ues.insert (std::pair< uint16_t, uint8_t > (rnti, AreaUnset)); |
| 255 return !edgeRbg; |
| 256 } |
| 257 |
| 258 bool edgeUe = false; |
| 259 if (it->second == EdgeArea ) |
| 260 { |
| 261 edgeUe = true; |
| 262 } |
| 263 |
| 264 return (edgeRbg && edgeUe) || (!edgeRbg && !edgeUe); |
| 265 } |
| 266 |
| 267 std::vector <bool> |
| 268 NistLteFfrDistributedAlgorithm::DoGetAvailableUlRbg () |
| 269 { |
| 270 NS_LOG_FUNCTION (this); |
| 271 |
| 272 if (m_ulRbgMap.empty ()) |
| 273 { |
| 274 InitializeUplinkRbgMaps (); |
| 275 } |
| 276 |
| 277 return m_ulRbgMap; |
| 278 } |
| 279 |
| 280 bool |
| 281 NistLteFfrDistributedAlgorithm::DoIsUlRbgAvailableForUe (int rbId, uint16_t rnti
) |
| 282 { |
| 283 NS_LOG_FUNCTION (this); |
| 284 |
| 285 if (!m_enabledInUplink) |
| 286 { |
| 287 return true; |
| 288 } |
| 289 |
| 290 bool edgeRbg = m_ulEdgeRbgMap[rbId]; |
| 291 |
| 292 std::map< uint16_t, uint8_t >::iterator it = m_ues.find (rnti); |
| 293 if (it == m_ues.end ()) |
| 294 { |
| 295 m_ues.insert (std::pair< uint16_t, uint8_t > (rnti, AreaUnset)); |
| 296 return !edgeRbg; |
| 297 } |
| 298 |
| 299 bool edgeUe = false; |
| 300 if (it->second == EdgeArea ) |
| 301 { |
| 302 edgeUe = true; |
| 303 } |
| 304 |
| 305 return (edgeRbg && edgeUe) || (!edgeRbg && !edgeUe); |
| 306 } |
| 307 |
| 308 void |
| 309 NistLteFfrDistributedAlgorithm::DoReportDlCqiInfo (const struct NistFfMacSchedSa
pProvider::NistSchedDlCqiInfoReqParameters& params) |
| 310 { |
| 311 NS_LOG_FUNCTION (this); |
| 312 NS_LOG_WARN ("Method should not be called, because it is empty"); |
| 313 } |
| 314 |
| 315 void |
| 316 NistLteFfrDistributedAlgorithm::DoReportUlCqiInfo (const struct NistFfMacSchedSa
pProvider::NistSchedUlCqiInfoReqParameters& params) |
| 317 { |
| 318 NS_LOG_FUNCTION (this); |
| 319 NS_LOG_WARN ("Method should not be called, because it is empty"); |
| 320 } |
| 321 |
| 322 void |
| 323 NistLteFfrDistributedAlgorithm::DoReportUlCqiInfo (std::map <uint16_t, std::vect
or <double> > ulCqiMap) |
| 324 { |
| 325 NS_LOG_FUNCTION (this); |
| 326 NS_LOG_WARN ("Method should not be called, because it is empty"); |
| 327 } |
| 328 |
| 329 uint8_t |
| 330 NistLteFfrDistributedAlgorithm::DoGetTpc (uint16_t rnti) |
| 331 { |
| 332 NS_LOG_FUNCTION (this); |
| 333 |
| 334 if (!m_enabledInUplink) |
| 335 { |
| 336 return 1; // 1 is mapped to 0 for Accumulated mode, and to -1 in Absol
ute mode TS36.213 Table 5.1.1.1-2 |
| 337 } |
| 338 |
| 339 //TS36.213 Table 5.1.1.1-2 |
| 340 // TPC | Accumulated Mode | Absolute Mode |
| 341 //------------------------------------------------ |
| 342 // 0 | -1 | -4 |
| 343 // 1 | 0 | -1 |
| 344 // 2 | 1 | 1 |
| 345 // 3 | 3 | 4 |
| 346 //------------------------------------------------ |
| 347 // here Absolute mode is used |
| 348 |
| 349 std::map< uint16_t, uint8_t >::iterator it = m_ues.find (rnti); |
| 350 if (it == m_ues.end ()) |
| 351 { |
| 352 return 1; |
| 353 } |
| 354 |
| 355 if (it->second == EdgeArea ) |
| 356 { |
| 357 return m_edgeAreaTpc; |
| 358 } |
| 359 else |
| 360 { |
| 361 return m_centerAreaTpc; |
| 362 } |
| 363 |
| 364 return 1; |
| 365 } |
| 366 |
| 367 uint8_t |
| 368 NistLteFfrDistributedAlgorithm::DoGetMinContinuousUlBandwidth () |
| 369 { |
| 370 NS_LOG_FUNCTION (this); |
| 371 |
| 372 uint8_t minContinuousUlBandwidth = m_ulBandwidth; |
| 373 |
| 374 if (!m_enabledInUplink) |
| 375 { |
| 376 return minContinuousUlBandwidth; |
| 377 } |
| 378 |
| 379 minContinuousUlBandwidth = |
| 380 ((m_edgeRbNum > 0 ) && (m_edgeRbNum < minContinuousUlBandwidth)) ? m_edgeRbN
um : minContinuousUlBandwidth; |
| 381 |
| 382 return minContinuousUlBandwidth; |
| 383 } |
| 384 |
| 385 void |
| 386 NistLteFfrDistributedAlgorithm::DoReportUeMeas (uint16_t rnti, |
| 387 NistLteRrcSap::NistMeasResults measR
esults) |
| 388 { |
| 389 NS_LOG_FUNCTION (this << rnti << (uint16_t) measResults.measId); |
| 390 NS_LOG_INFO ("CellId: " << m_cellId << " RNTI :" << rnti << " MeasId: " << (ui
nt16_t) measResults.measId |
| 391 << " RSRP: " << (uint16_t)measResults.rsrpResult |
| 392 << " RSRQ: " << (uint16_t)measResults.rsrqResult); |
| 393 |
| 394 if (measResults.measId == m_rsrqMeasId) |
| 395 { |
| 396 //check if it is center or edge UE |
| 397 std::map< uint16_t, uint8_t >::iterator it = m_ues.find (rnti); |
| 398 if (it == m_ues.end ()) |
| 399 { |
| 400 m_ues.insert (std::pair< uint16_t, uint8_t > (rnti, AreaUnset)); |
| 401 } |
| 402 |
| 403 it = m_ues.find (rnti); |
| 404 if (measResults.rsrqResult >= m_egdeSubBandRsrqThreshold) |
| 405 { |
| 406 if (it->second != CenterArea) |
| 407 { |
| 408 NS_LOG_INFO ("UE RNTI: " << rnti << " will be served in Center sub
-band"); |
| 409 it->second = CenterArea; |
| 410 |
| 411 NistLteRrcSap::NistPdschConfigDedicated pdschConfigDedicated; |
| 412 pdschConfigDedicated.pa = m_centerPowerOffset; |
| 413 m_ffrRrcSapUser->SetNistPdschConfigDedicated (rnti, pdschConfigDed
icated); |
| 414 } |
| 415 } |
| 416 else |
| 417 { |
| 418 if (it->second != EdgeArea ) |
| 419 { |
| 420 NS_LOG_INFO ("UE RNTI: " << rnti << " will be served in Edge sub-b
and"); |
| 421 it->second = EdgeArea; |
| 422 |
| 423 NistLteRrcSap::NistPdschConfigDedicated pdschConfigDedicated; |
| 424 pdschConfigDedicated.pa = m_edgePowerOffset; |
| 425 m_ffrRrcSapUser->SetNistPdschConfigDedicated (rnti, pdschConfigDed
icated); |
| 426 } |
| 427 } |
| 428 } |
| 429 else if (measResults.measId == m_rsrpMeasId) |
| 430 { |
| 431 std::map< uint16_t, uint8_t >::iterator it = m_ues.find (rnti); |
| 432 if (it == m_ues.end ()) |
| 433 { |
| 434 m_ues.insert (std::pair< uint16_t, uint8_t > (rnti, AreaUnset)); |
| 435 } |
| 436 |
| 437 UpdateNeighbourMeasurements (rnti, m_cellId, measResults.rsrpResult, measR
esults.rsrqResult); |
| 438 |
| 439 if (measResults.haveMeasResultNeighCells |
| 440 && !measResults.measResultListEutra.empty ()) |
| 441 { |
| 442 for (std::list <NistLteRrcSap::NistMeasResultEutra>::iterator it = mea
sResults.measResultListEutra.begin (); |
| 443 it != measResults.measResultListEutra.end (); |
| 444 ++it) |
| 445 { |
| 446 NS_ASSERT_MSG (it->haveRsrpResult == true, |
| 447 "RSRP measurement is missing from cellId " << it->p
hysCellId); |
| 448 NS_ASSERT_MSG (it->haveRsrqResult == true, |
| 449 "RSRQ measurement is missing from cellId " << it->p
hysCellId); |
| 450 UpdateNeighbourMeasurements (rnti, it->physCellId, it->rsrpResult,
it->rsrqResult); |
| 451 |
| 452 bool found = false; |
| 453 for (std::vector<uint16_t>::iterator ncIt = m_neigborCell.begin ()
; ncIt != m_neigborCell.end (); ncIt++) |
| 454 { |
| 455 if ((*ncIt) == it->physCellId) |
| 456 { |
| 457 found = true; |
| 458 } |
| 459 } |
| 460 if (found == false) |
| 461 { |
| 462 m_neigborCell.push_back (it->physCellId); |
| 463 } |
| 464 } |
| 465 } |
| 466 else |
| 467 { |
| 468 NS_LOG_WARN (this << " Event A4 received without measurement results f
rom neighbouring cells"); |
| 469 } |
| 470 } |
| 471 else |
| 472 { |
| 473 NS_LOG_WARN ("Ignoring measId " << (uint16_t) measResults.measId); |
| 474 } |
| 475 } |
| 476 |
| 477 void |
| 478 NistLteFfrDistributedAlgorithm::Calculate () |
| 479 { |
| 480 NS_LOG_FUNCTION (this); |
| 481 m_calculationEvent = Simulator::Schedule (m_calculationInterval, &NistLteFfrDi
stributedAlgorithm::Calculate, this); |
| 482 |
| 483 int rbgSize = GetRbgSize (m_dlBandwidth); |
| 484 uint16_t rbgNum = m_dlBandwidth / rbgSize; |
| 485 |
| 486 m_cellWeightMap.clear (); |
| 487 m_dlEdgeRbgMap.clear (); |
| 488 m_dlEdgeRbgMap.resize (m_dlBandwidth / rbgSize, false); |
| 489 m_ulEdgeRbgMap.clear (); |
| 490 m_ulEdgeRbgMap.resize (m_ulBandwidth, false); |
| 491 |
| 492 MeasurementTable_t::iterator it1; |
| 493 MeasurementRow_t::iterator it2; |
| 494 Ptr<NistUeMeasure> servingCellMeasures; |
| 495 Ptr<NistUeMeasure> neighbourCellMeasures; |
| 496 |
| 497 uint32_t edgeUeNum = 0; |
| 498 std::map< uint16_t, uint8_t >::iterator areaIt; |
| 499 for (areaIt = m_ues.begin (); areaIt != m_ues.end (); areaIt++) |
| 500 { |
| 501 if (areaIt->second == EdgeArea) |
| 502 { |
| 503 edgeUeNum++; |
| 504 } |
| 505 } |
| 506 |
| 507 if (edgeUeNum != 0) |
| 508 { |
| 509 for (it1 = m_ueMeasures.begin (); it1 != m_ueMeasures.end (); it1++) |
| 510 { |
| 511 std::map< uint16_t, uint8_t >::iterator areaIt = m_ues.find (it1->firs
t); |
| 512 if (areaIt->second != EdgeArea) |
| 513 { |
| 514 continue; |
| 515 } |
| 516 |
| 517 servingCellMeasures = 0; |
| 518 neighbourCellMeasures = 0; |
| 519 |
| 520 it2 = it1->second.find (m_cellId); |
| 521 if (it2 != it1->second.end ()) |
| 522 { |
| 523 servingCellMeasures = it2->second; |
| 524 } |
| 525 else |
| 526 { |
| 527 continue; |
| 528 } |
| 529 |
| 530 for (it2 = it1->second.begin (); it2 != it1->second.end (); it2++) |
| 531 { |
| 532 if (it2->first != m_cellId) |
| 533 { |
| 534 neighbourCellMeasures = it2->second; |
| 535 } |
| 536 else |
| 537 { |
| 538 continue; |
| 539 } |
| 540 |
| 541 if (servingCellMeasures && neighbourCellMeasures) |
| 542 { |
| 543 int16_t rsrpDifference = servingCellMeasures->m_rsrp - neighbo
urCellMeasures->m_rsrp; |
| 544 NS_LOG_INFO ("CellId: " << m_cellId << " UE RNTI: " << it1->fi
rst |
| 545 << " NeighborCellId: " << neighbourCel
lMeasures->m_cellId |
| 546 << " RSRP Serving: " << (int)servingCe
llMeasures->m_rsrp |
| 547 << " RSRP Neighbor: " << (int)neighbou
rCellMeasures->m_rsrp |
| 548 << " RSRP Difference: " << (int)rsrpDi
fference); |
| 549 |
| 550 if (rsrpDifference < m_rsrpDifferenceThreshold) |
| 551 { |
| 552 m_cellWeightMap[neighbourCellMeasures->m_cellId]++; |
| 553 } |
| 554 } |
| 555 } |
| 556 } |
| 557 |
| 558 std::map< uint16_t, uint64_t > metricA; |
| 559 for (uint16_t i = 0; i < rbgNum; i++) |
| 560 { |
| 561 metricA[i] = 0; |
| 562 } |
| 563 |
| 564 std::map<uint16_t, uint32_t>::iterator cellIt; |
| 565 for (cellIt = m_cellWeightMap.begin (); cellIt != m_cellWeightMap.end ();
cellIt++) |
| 566 { |
| 567 NS_LOG_INFO ("CellId: " << m_cellId << " NeighborCellId: " << cellIt->
first << " Weight: " << cellIt->second); |
| 568 |
| 569 std::map<uint16_t, std::vector <bool> >::iterator rntpIt = m_rntp.find
(cellIt->first); |
| 570 if (rntpIt == m_rntp.end ()) |
| 571 { |
| 572 continue; |
| 573 } |
| 574 |
| 575 for (uint8_t i = 0; i < rbgNum; i++) |
| 576 { |
| 577 metricA[i] += cellIt->second * rntpIt->second[i]; |
| 578 } |
| 579 } |
| 580 |
| 581 std::vector<uint16_t> sortedRbgByMetric; |
| 582 std::multimap< uint64_t, uint16_t > sortedMetricA; |
| 583 for (std::map<uint16_t, uint64_t>::const_iterator it = metricA.begin (); i
t != metricA.end (); ++it) |
| 584 { |
| 585 sortedMetricA.insert (std::pair<uint64_t, uint16_t> (it->second, it->f
irst)); |
| 586 } |
| 587 |
| 588 for (std::multimap< uint64_t, uint16_t >::const_iterator it = sortedMetric
A.begin (); |
| 589 it != sortedMetricA.end (); ++it) |
| 590 { |
| 591 sortedRbgByMetric.push_back (it->second); |
| 592 } |
| 593 |
| 594 for (int i = 0; i < m_edgeRbNum / rbgSize; i++) |
| 595 { |
| 596 m_dlEdgeRbgMap[ sortedRbgByMetric[i] ] = true; |
| 597 } |
| 598 |
| 599 for (int i = 0; i < m_edgeRbNum / rbgSize; i++) |
| 600 { |
| 601 uint32_t rbgIndex = sortedRbgByMetric[i]; |
| 602 for (int k = 0; k < rbgSize; k++) |
| 603 { |
| 604 uint32_t rbIndex = rbgSize * rbgIndex + k; |
| 605 m_ulEdgeRbgMap[ rbIndex ] = true; |
| 606 } |
| 607 } |
| 608 } |
| 609 |
| 610 for (std::vector<uint16_t>::iterator ncIt = m_neigborCell.begin (); ncIt != m_
neigborCell.end (); ncIt++) |
| 611 { |
| 612 SendLoadInformation ((*ncIt)); |
| 613 } |
| 614 } |
| 615 |
| 616 void |
| 617 NistLteFfrDistributedAlgorithm::SendLoadInformation (uint16_t targetCellId) |
| 618 { |
| 619 NS_LOG_FUNCTION (this); |
| 620 |
| 621 NS_LOG_INFO ("SendLoadInformation to CellId : " << targetCellId ); |
| 622 |
| 623 std::vector<NistEpcX2Sap::UlInterferenceOverloadIndicationItem> m_currentUlInt
erferenceOverloadIndicationList; |
| 624 std::vector <NistEpcX2Sap::NistUlHighInterferenceInformationItem> m_currentUl
HighInterferenceInformationList; |
| 625 NistEpcX2Sap::NistRelativeNarrowbandTxBand m_currentNistRelativeNarrowbandTxBa
nd; |
| 626 |
| 627 m_currentNistRelativeNarrowbandTxBand.rntpPerPrbList = m_dlEdgeRbgMap; |
| 628 |
| 629 NistEpcX2Sap::NistCellInformationItem cii; |
| 630 cii.sourceCellId = m_cellId; |
| 631 cii.ulInterferenceOverloadIndicationList = m_currentUlInterferenceOverloadIndi
cationList; |
| 632 cii.ulHighInterferenceInformationList = m_currentUlHighInterferenceInformation
List; |
| 633 cii.relativeNarrowbandTxBand = m_currentNistRelativeNarrowbandTxBand; |
| 634 |
| 635 NistEpcX2Sap::NistLoadInformationParams params; |
| 636 params.targetCellId = targetCellId; |
| 637 params.cellInformationList.push_back (cii); |
| 638 |
| 639 m_ffrRrcSapUser->SendLoadInformation (params); |
| 640 } |
| 641 |
| 642 void |
| 643 NistLteFfrDistributedAlgorithm::DoRecvLoadInformation (NistEpcX2Sap::NistLoadInf
ormationParams params) |
| 644 { |
| 645 NS_LOG_FUNCTION (this); |
| 646 NS_LOG_INFO ("CellId: " << m_cellId |
| 647 << " Recv X2 message: LOAD INFORMATION from CellId:" <
< params.cellInformationList[0].sourceCellId); |
| 648 |
| 649 if (params.cellInformationList[0].sourceCellId > m_cellId) |
| 650 { |
| 651 return; |
| 652 } |
| 653 |
| 654 uint16_t neighborCellId = params.cellInformationList[0].sourceCellId; |
| 655 std::map<uint16_t, std::vector <bool> >::iterator it = m_rntp.find (neighborCe
llId); |
| 656 if (it != m_rntp.end ()) |
| 657 { |
| 658 it->second = params.cellInformationList[0].relativeNarrowbandTxBand.rntpPe
rPrbList; |
| 659 } |
| 660 else |
| 661 { |
| 662 m_rntp.insert (std::pair<uint16_t, std::vector <bool> > (neighborCellId, p
arams.cellInformationList[0].relativeNarrowbandTxBand.rntpPerPrbList)); |
| 663 } |
| 664 } |
| 665 |
| 666 void |
| 667 NistLteFfrDistributedAlgorithm::UpdateNeighbourMeasurements (uint16_t rnti, |
| 668 uint16_t cellId, |
| 669 uint8_t rsrp, |
| 670 uint8_t rsrq) |
| 671 { |
| 672 NS_LOG_FUNCTION (this << rnti << cellId << (uint16_t) rsrq); |
| 673 |
| 674 MeasurementTable_t::iterator it1; |
| 675 it1 = m_ueMeasures.find (rnti); |
| 676 |
| 677 if (it1 == m_ueMeasures.end ()) |
| 678 { |
| 679 // insert a new UE entry |
| 680 MeasurementRow_t row; |
| 681 std::pair<MeasurementTable_t::iterator, bool> ret; |
| 682 ret = m_ueMeasures.insert (std::pair<uint16_t, MeasurementRow_t> (rnti, ro
w)); |
| 683 NS_ASSERT (ret.second); |
| 684 it1 = ret.first; |
| 685 } |
| 686 |
| 687 NS_ASSERT (it1 != m_ueMeasures.end ()); |
| 688 Ptr<NistUeMeasure> cellMeasures; |
| 689 std::map<uint16_t, Ptr<NistUeMeasure> >::iterator it2; |
| 690 it2 = it1->second.find (cellId); |
| 691 |
| 692 if (it2 != it1->second.end ()) |
| 693 { |
| 694 cellMeasures = it2->second; |
| 695 cellMeasures->m_cellId = cellId; |
| 696 cellMeasures->m_rsrp = rsrp; |
| 697 cellMeasures->m_rsrq = rsrq; |
| 698 } |
| 699 else |
| 700 { |
| 701 // insert a new cell entry |
| 702 cellMeasures = Create<NistUeMeasure> (); |
| 703 cellMeasures->m_cellId = cellId; |
| 704 cellMeasures->m_rsrp = rsrp; |
| 705 cellMeasures->m_rsrq = rsrq; |
| 706 it1->second[cellId] = cellMeasures; |
| 707 } |
| 708 |
| 709 } // end of UpdateNeighbourMeasurements |
| 710 |
| 711 } // end of namespace ns3 |
OLD | NEW |