Hello,
I have some indications that are probably not the best way to do it, but it is better than nothing.
I assume you are not a beginner.
To retrieve the RSRP:
Config::Connect
("/NodeList/*/DeviceList/0/LteUePhy/ReportUeMeasurements",
MakeBoundCallback (&ReportUeMeasurementsCallback, this));
void ReportUeMeasurementsCallback (LteUeMeasurementsTestCase *testcase, std::string path,
uint16_t rnti, uint16_t cellId, double rsrp, double rsrq, bool servingCell)
{
// called each time an UE receives a measurement
}
You can use this function to store the RSRP regarding each UE over time.
Then you can write a function
GetStrongestCell(...) that returns the ID of the cell that has the strongest signalThen you add a periodic function
HandoverToStrongest(...) that forces the handover:
void DoHandoverRequest (Ptr<NetDevice> ueDev, Ptr<NetDevice> sourceEnbDev, Ptr<NetDevice> targetEnbDev)
{
uint16_t targetCellId = targetEnbDev->GetObject<LteEnbNetDevice> ()->GetCellId ();
Ptr<LteEnbRrc> sourceRrc = sourceEnbDev->GetObject<LteEnbNetDevice> ()->GetRrc ();
uint16_t rnti = ueDev->GetObject<LteUeNetDevice> ()->GetRrc ()->GetRnti ();
sourceRrc->SendHandoverRequest (rnti, targetCellId);
}
void HandoverToStrongest(NetDeviceContainer enbLteDevs, NetDeviceContainer ueLteDevs) {
for(uint32_t u = 0 ; u < ueLteDevs.GetN() ; u++) { //for each UE
uint16_t attachedCellId = ueLteDevs.Get(u)->GetObject<LteUeNetDevice>()->GetRrc()->GetCellId();
uint16_t strongestCellId = GetStrongestCell(...);
if (attachedCellId != strongestCellId) {
DoHandoverRequest( ueLteDevs.Get(u), enbLteDevs.Get (attachedCellId-1), enbLteDevs.Get (strongestCellId-1) );
}
}
Simulator::Schedule(Seconds(HANDOVER_FORCING_PERIOD), &HandoverToStrongest, enbLteDevs, ueLteDevs);
}
This is really a dirty solution but it should work.