Resource Blocks allocated to each User Equipment can be logged into a  text or csv file as per the requirement. Following is one such example where we log the resource blocks allocated to each UE in a separate file along with the event time.


i.Open NetSim source code in Visual Studio 2015 by double clicking on the NetSim.sln file present in “<NetSim_Install_Directory>/src/Simulation” folder.

ii.Go to LTE project through the solution explorer and open the file LTE_Phy.c. Add the lines of code highlighted in red as shown below:


int fn_NetSim_LTE_CalculateReceivedPower()
{
NETSIM_ID i;
FILE* fp1;
char rblock[100];

for (i = 0; i < NETWORK->nDeviceCount; i++)
{
if (NETWORK->ppstruDeviceList[i]->nDeviceType == eNB ||
DEVICE_TYPE(i + 1) == RELAY)
{
NETSIM_ID ifid = get_eNB_Interface(i + 1);
LTE_ENB_MAC* enbMac = (LTE_ENB_MAC*)DEVICE_MACVAR(i + 1, ifid);
LTE_ASSOCIATEUE_INFO* info = enbMac->associatedUEInfo;
while (info)
{
unsigned int j;
for (j = 0; j < enbMac->ca_count; j++)
{

fn_NetSim_LTE_CalculateRxPower(i + 1, ifid, info, j);
fn_NetSim_LTE_CalculateSNR(i + 1, ifid, info, j);
fn_NetSim_LTE_GetCQIIndex(i + 1, ifid, info, j);
fn_NetSim_LTE_GetMCS_TBS_Index(info, j);
while (info->DLInfo[j].nCQIIndex > 1 && info->ULInfo[j].nCQIIndex > 1)
{
double ber;
fn_NetSim_LTE_GetMCS_TBS_Index(info, j);
ber = fn_NetSim_LTE_CalculateBER(0, info->DLInfo[j].MCSIndex, info->DLInfo[j].dSNR);
if (ber < TARGET_BER)
break;
else
{
info->DLInfo[j].nCQIIndex--;
info->ULInfo[j].nCQIIndex--;
}
}
//RB Log
sprintf(rblock, "LTE_UE_RB_%d.csv", fn_NetSim_GetDeviceIdByConfigId(info->nUEId));
fp1 = fopen(rblock, "w+");
if (fp1)
{
fprintf(fp1, "UE_ID,Time(micro seconds),UL_RB,DL_RB");
fclose(fp1);
}

//RB Log
}

info = (LTE_ASSOCIATEUE_INFO*)LIST_NEXT(info);
}
}
}
return 1;
}


iii.In the file CA.c add the lines of code highlighted in red as shown below:


void fn_NetSim_LTE_A_FormNextFrameForEachCarrier(NETSIM_ID enbId, NETSIM_ID enbInterface, unsigned int nSSId)
{
unsigned int i;
LTE_ENB_MAC* enbMac = get_enb_mac(enbId, enbInterface);
LTE_ASSOCIATEUE_INFO* info = enbMac->associatedUEInfo;
FILE *fp1;
char rblock[100];

while (info)
{
LTE_UE_MAC* m = get_ue_mac(info->nUEId, info->nUEInterface);
m->carrier_id = -1;
info->carrier_id = -1;
info = (LTE_ASSOCIATEUE_INFO*)LIST_NEXT(info);
}

info = enbMac->associatedUEInfo;
while (info)
{
int devicen = fn_NetSim_GetDeviceIdByConfigId(info->nUEId);
sprintf(rblock, "LTE_UE_RB_%d.csv", fn_NetSim_GetDeviceIdByConfigId(info->nUEId));
unsigned int rb_ul = 0, rb_dl = 0;

for (i = 0; i < enbMac->ca_count; i++)
{
enbMac->ca_mac[i].nAllocatedRBG = 0;
fn_NetSim_LTE_FormUPlinkFrame(enbId, enbInterface, i, nSSId);

// For each of the carriers in the eNB Resource block ground RBG is multipled by Resource Block count in group to get total

// Resource block count. This is done for uplink and downlink
unsigned int block_ul = enbMac->ca_mac[i].nAllocatedRBG*enbMac->ca_mac[i].nRBCountInGroup;
rb_ul = rb_ul + block_ul;
fn_NetSim_LTE_FormDownlinkFrame(enbId, enbInterface, i, nSSId);
unsigned int block_dl = enbMac->ca_mac[i].nAllocatedRBG*enbMac->ca_mac[i].nRBCountInGroup;
rb_dl = rb_dl + block_dl;

fp1 = fopen(rblock, "a+");
if (fp1)
{
fprintf(fp1, "\n%d,%lf,%d,%d", fn_NetSim_GetDeviceIdByConfigId(info->nUEId), pstruEventDetails->dEventTime, rb_ul, rb_dl);
fclose(fp1);
}

}
info = (LTE_ASSOCIATEUE_INFO*)LIST_NEXT(info);

}
}

iv.Now right click on LTE module in the solution explorer and select rebuild.

v.Upon successful build, you will get a new libLTE.dll file in the “<NetSim_Install_Directory>/src/Simulation/DLL” folder.

vi.Copy this newly built DLL file and replace it in the bin folder of NetSim after you rename the original libLTE.dll file which is already existing there(as a backup).

vii.Now on running any simulation in LTE, you will get individual logs for each UE which contains the resource blocks allocated along with event time,  in the bin folder of NetSim (“<NetSim_Install_Directory>/bin”) as shown below:

 

Note: The above explained steps are applicable to NetSim v10.2.