Applicable VersionsNetSim StandardNetSim Pro


Applicable Releasesv13.3


NetSim allows users to set handover-related parameters such as 

(i) Handover interruption time, 

(ii) Handover margin, and 

(iii) Time to Trigger 

directly in the GUI as part of the gNB properties as shown below:



TTT log can also be enabled to understand how handover occurs when TTT is set. 


Applicable Releases
v13.2


Time-to-Trigger implementation is available as a project for NetSim v13.2. The project documentation can be found in TETCOS File Exchange at https://www.tetcos.com/pdf/v13.2/v13.2.35-Time-to-Trigger.pdf


Applicable Releases
v12.2 / v13 / v13.1 


The following procedure can be followed to involve the Time-to-Trigger parameter in NetSim LTE Simulations:

1. Open NetSim source code in Visual Studio 2019 by going to Open Simulation ->Workspace Options and clicking on the Open Code button.

2. Go to the LTE_NR project through the solution explorer and open the file LTE_NR.h. Add the lines of code highlighted in red as shown below:


#ifndef _NETSIM_LTE_NR_H_

#define _NETSIM_LTE_NR_H_


#include "List.h"


#ifdef  __cplusplus

extern "C" {

#endif

    typedef struct stru_LTE_Handover_Status

        LTE_Handover;

    struct stru_LTE_Handover_Status

    {

        bool status;

        double time;

        NETSIM_ID targetENB;

    };

    LTE_Handover** devices;

    typedef enum enum_LTE_NR_DEVICE_TYPE

    {

        LTENR_DEVICETYPE_UE = 0,

        LTENR_DEVICETYPE_GNB = 1,

        LTENR_DEVICETYPE_ENB = 1,

        LTENR_DEVICETYPE_EPC = 2,

        LTENR_DEVICETYPE_LAST, //Keep me at last

    }LTENR_DEVICETYPE;


 

3. Now open the file LTE_NR.c. Add the lines of code highlighted in red in fn_NetSim_LTE_NR_Init() as shown below:

_declspec(dllexport) int fn_NetSim_LTE_NR_Init()

{

    int i;

    devices = calloc(NETWORK->nDeviceCount + 1, sizeof * devices);

    for (i = 0; i < NETWORK->nDeviceCount + 1; i++)

    {

        devices[i] = (LTE_Handover*)malloc(1 * sizeof(struct stru_LTE_Handover_Status));

        devices[i]->status = false;

        devices[i]->targetENB = 0;

        devices[i]->time = 0.0;

    }

    return fn_NetSim_LTE_NR_Init_F();

}

4. Next open the file LTENR_GNBRRC.h. Add the line of code highlighted in red as shown below:

#ifndef _NETSIM_LTENR_GNBRRC_H_

#define _NETSIM_LTENR_GNBRRC_H_

#include "LTENR_Msg.h"

#include "LTENR_PDCP.h"

#include "LTENR_RLC.h"


#ifdef  __cplusplus

extern "C" {

#endif


    //Default Timer

#define LTENR_MSG_MIB_REGENERATION_TIME        80*MILLISECOND

#define    LTENR_MSG_SIB1_REGENERATION_TIME    160*MILLISECOND

#define LTENR_MSG_UE_MEASUREMENT_REPORT_PERIOD_TIME 120*MILLISECOND

#define HANDOVER_DIFF 3//db

#define TIME_TO_TRIGGER 5000000

    //Default packet size

#define LTENR_MSG_MIB_SIZE                    3    // Bytes


5. Now open the file LTENR_GNBRRC .c. In the function fn_NetSim_LTENR_RRC_UE_MEASUREMENT_RECV() replace the entire function definition with the following since it involves code modifications in multiple places.

void fn_NetSim_LTENR_RRC_UE_MEASUREMENT_RECV(NETSIM_ID gnbID, NETSIM_ID gnbIF, NETSIM_ID ueID, NETSIM_ID ueIF, ptrLTENR_RRC_UE_MEASUREMENT_REPORT report)

{

    //modification start

    int i, count = 0;

    double tempfavourablesnr = 0;

    NETSIM_ID tempfavourabledevice = 0;

    NETSIM_ID enbid;

    NETSIM_ID ueid;

    //modification end

    double serveingSINR = 0;

    double serveringRSRP = 0;

    double serveringRSRQ = 0;

    double targetSINR = INT_MIN;

    NETSIM_ID target = 0;

    ptrLTENR_RRC_UE_MEASUREMENT_REPORT report1 = report;

    while (report1)

    {

        if (report1->cellID == gnbID)

        {

            //modification start

            enbid = report1->cellID;

            ueid = report1->ueID;

            //modification end

            serveingSINR = report1->sinr;

            serveringRSRP = report1->rsrp;

            serveringRSRQ = report1->rsrq;

        }

        if (targetSINR < report1->sinr)

        {

            targetSINR = report1->sinr;

            target = report1->cellID;

            tempfavourabledevice = report1->cellID;

        }

        report1 = LIST_NEXT(report1);

    }

    ptrLTENR_HANDOVER_Hdr msg = calloc(1, sizeof * msg);

    //modification start

    report1 = report;

    while (report1)

    {

        if (report1->cellID != pstruEventDetails->nDeviceId)

        {

            double d = report1->sinr;

            if (d >= serveingSINR + HANDOVER_DIFF)

            {

                if (d > targetSINR)

                {

                    tempfavourabledevice = report->cellID;

                    targetSINR = d;

                }

            }

        }

        report1 = LIST_NEXT(report1);

    }


    if (devices[ueid]->targetENB == 0)

    {

        devices[ueid]->targetENB = enbid;

    }

    if (targetSINR <= serveingSINR + HANDOVER_DIFF)

    {

        devices[ueid]->time = pstruEventDetails->dEventTime;

    }

    else if (targetSINR > serveingSINR)

    {

        if (devices[ueid]->targetENB == tempfavourabledevice)

        {

            if (targetSINR >= serveingSINR + HANDOVER_DIFF && devices[ueid]->time)

            {

                if (pstruEventDetails->dEventTime - devices[ueid]->time >= TIME_TO_TRIGGER)

                {

                    devices[ueid]->status = true;

                    devices[ueid]->time = pstruEventDetails->dEventTime;

                }

            }

        }

        else

        {

            report1 = report;

            while (report1)

            {

                if (report1->cellID == devices[ueid]->targetENB)

                {

                    double d = report1->sinr;

                    if (d >= serveingSINR + HANDOVER_DIFF)

                    {

                        if (pstruEventDetails->dEventTime - devices[ueid]->time >= TIME_TO_TRIGGER && devices[ueid]->time)

                        {

                            devices[ueid]->status = true;

                            devices[ueid]->targetENB = tempfavourabledevice;

                            devices[ueid]->time = pstruEventDetails->dEventTime;

                            break;

                        }

                    }

                    else if (d >= serveingSINR && d < serveingSINR + HANDOVER_DIFF && (pstruEventDetails->nDeviceId, report1->cellID))

                    {

                        devices[ueid]->targetENB = tempfavourabledevice;

                    }

                }

                report1 = LIST_NEXT(report1);

            }

        }


    }


    if (devices[ueid]->status == true && devices[ueid]->targetENB)

    {

        if (serveingSINR + HANDOVER_DIFF < targetSINR && gnbID != devices[ueid]->targetENB) {

            //call nas for handover request

            msg->serveringCellID = gnbID;

            msg->serveringCellIF = gnbIF;

            ptrLTENR_GNBMAC mac = LTENR_GNBMAC_GET(gnbID, gnbIF);

            msg->AMFID = mac->epcId;

            msg->AMFIF = mac->epcIf;

            msg->targetCellID = devices[ueid]->targetENB;

            msg->targetCellIF = fn_NetSim_Get_LTENR_INTERFACE_ID_FROM_DEVICE_ID(devices[ueid]->targetENB, LTENR_DEVICETYPE_GNB);

            msg->UEID = ueID;

            msg->UEIF = ueIF;

            fn_NetSim_LTENR_NAS_HANDOVER_REQUEST(msg);

        }

    }

}


6. The new constant TIME_TO_TRIGGER that we have added to the code can be customized as per the requirement and is currently set to 5 Seconds. Based on the value set, Handover will happen if the difference in signal strength between the target and serving cell is greater than the Handover Margin(HANDOVER_DIFF) for a time period greater than TIME_TO_TRIGGER.

7. After setting HANDOVER_DIFF and TIME_TO_TRIGGER parameters as per the requirement, right-click on the LTE module in the solution explorer and select rebuild.

10. Now upon running LTE simulations involving UE handovers, handover will be initiated only if the difference in signal strength is more than the HANDOVER_DIFF for a time period greater than TIME_TO_TRIGGER  specified by you.

11. You can then run multiple simulations of the same network scenario varying certain parameters such as seed values, the velocity of devices, etc and take the average Number of Handovers and Throughput. 

12. Record the results of every test case in an excel file and once all the test cases are complete plot graphs of Number of Handovers versus Speed and Throughput versus speed.