Applicable Versions | NetSim Standard | NetSim Pro |
Applicable Releases | v13.1 |
The parameters such as MCS and SNR are unique to each carrier and each MIMO layer, in NetSim. The maximum number of carriers that can be aggregated is 14 and the maximum number of MIMO layers is 16, in NetSim.
The total bits per PRB for a particular carrier taking into account all the layers is calculated in the function LTENR_MACSchedular_UpdateInfoForUE() which is part of the LTENR_MAC.c file. The SNR and MCS values for each layer for a particular carrier can also be accessed in the same location.
For instance, to print these parameters to the console, the following lines of code can be written in LTENR_MACSchedular_UpdateInfoForUE() function which is part of the LTENR_MAC.c file:
static void LTENR_MACSchedular_UpdateInfoForUE(ptrLTENR_GNBMAC mac, ptrLTENR_GNBPHY phy,
ptrLTENR_ASSOCIATEDUEPHYINFO assocInfo,
ptrLTENR_UESCHEDULARINFO info, bool isUplink, int CA_ID)
{
ptrLTENR_UEPHY uePhy = LTENR_UEPHY_GET(assocInfo->ueId, assocInfo->ueIf);
UINT layerCount = LTENR_PHY_GET_LAYER_COUNT(uePhy, isUplink);
UINT64 bitsPerPRB = 0;
for (UINT i = 0; i < layerCount; i++)
{
ptrLTENR_AMCINFO amc = isUplink ? assocInfo->uplinkAMCInfo[CA_ID][i] : assocInfo->downlinkAMCInfo[CA_ID][i];
if (amc->cqiTable.CQIIndex != 0)
bitsPerPRB += LTENR_calculateTBSSize(phy, 1, amc->mcsTable, CA_ID);
}
ptrLTENR_SCHEDULARINFO si = mac->schedularInfo[CA_ID];
if (fn_NetSim_LTENR_RRC_isActive(mac->gnbId, mac->gnbIf, assocInfo->ueId, assocInfo->ueIf)) {
info->bitsPerPRB = bitsPerPRB;
si->isUERRCSetUpCompleted = true;
}
else info->bitsPerPRB = 0;
ptrLTENR_PROPAGATIONINFO pinfo = assocInfo->propagationInfo[CA_ID];
if (!isUplink)
{
fprintf(stderr, "\nEvent Time: %lf gNB %d UE %d CA %d\n", pstruEventDetails->dEventTime,
phy->gnbId, info->ueId, CA_ID);
fprintf(stderr, "downlink BitsPerPRB: %d\n", info->bitsPerPRB);
fprintf(stderr, "downlink SNR: %lf\n", pinfo->downlink.SNR_db[0]);
fprintf(stderr, "downlink MCS: %d\n", assocInfo->downlinkAMCInfo[CA_ID][0]->mcsTable.mcsIndex);
}
if (isUplink)
info->bufferSize = fn_NetSim_LTENR_RLC_BufferStatusNotificaton(assocInfo->ueId, assocInfo->ueIf,
mac->gnbId, mac->gnbIf,
LTENR_LOGICALCHANNEL_DTCH);
else
info->bufferSize = fn_NetSim_LTENR_RLC_BufferStatusNotificaton(mac->gnbId, mac->gnbIf,
assocInfo->ueId, assocInfo->ueIf,
LTENR_LOGICALCHANNEL_DTCH);
}
ptrLTENR_ASSOCIATEDUEPHYINFO assocInfo,
ptrLTENR_UESCHEDULARINFO info, bool isUplink, int CA_ID)
{
ptrLTENR_UEPHY uePhy = LTENR_UEPHY_GET(assocInfo->ueId, assocInfo->ueIf);
UINT layerCount = LTENR_PHY_GET_LAYER_COUNT(uePhy, isUplink);
UINT64 bitsPerPRB = 0;
for (UINT i = 0; i < layerCount; i++)
{
ptrLTENR_AMCINFO amc = isUplink ? assocInfo->uplinkAMCInfo[CA_ID][i] : assocInfo->downlinkAMCInfo[CA_ID][i];
if (amc->cqiTable.CQIIndex != 0)
bitsPerPRB += LTENR_calculateTBSSize(phy, 1, amc->mcsTable, CA_ID);
}
ptrLTENR_SCHEDULARINFO si = mac->schedularInfo[CA_ID];
if (fn_NetSim_LTENR_RRC_isActive(mac->gnbId, mac->gnbIf, assocInfo->ueId, assocInfo->ueIf)) {
info->bitsPerPRB = bitsPerPRB;
si->isUERRCSetUpCompleted = true;
}
else info->bitsPerPRB = 0;
ptrLTENR_PROPAGATIONINFO pinfo = assocInfo->propagationInfo[CA_ID];
if (!isUplink)
{
fprintf(stderr, "\nEvent Time: %lf gNB %d UE %d CA %d\n", pstruEventDetails->dEventTime,
phy->gnbId, info->ueId, CA_ID);
fprintf(stderr, "downlink BitsPerPRB: %d\n", info->bitsPerPRB);
fprintf(stderr, "downlink SNR: %lf\n", pinfo->downlink.SNR_db[0]);
fprintf(stderr, "downlink MCS: %d\n", assocInfo->downlinkAMCInfo[CA_ID][0]->mcsTable.mcsIndex);
}
if (isUplink)
info->bufferSize = fn_NetSim_LTENR_RLC_BufferStatusNotificaton(assocInfo->ueId, assocInfo->ueIf,
mac->gnbId, mac->gnbIf,
LTENR_LOGICALCHANNEL_DTCH);
else
info->bufferSize = fn_NetSim_LTENR_RLC_BufferStatusNotificaton(mac->gnbId, mac->gnbIf,
assocInfo->ueId, assocInfo->ueIf,
LTENR_LOGICALCHANNEL_DTCH);
}
In the above code, the SNR and MCS values are printed only for the first layer.
Upon building the LTE_NR source codes with the above changes, and running any 5G network simulation, the parameters will get printed to the simulation console during runtime as shown below:
To pass parameters to MATLAB during runtime, the NetSim-MATLAB socket interface can be used. Associated APIs and examples are discussed in section 10.3.1 of the NetSim User Manual.
Following is an example of passing these parameters to MATLAB instead of printing them to the console:
1. Add a call to netsim_matlab_interface_configure () function in the fn_NetSim_LTE_NR_Init() function of LTE_NR.c file as shown below:
_declspec(dllexport) int fn_NetSim_LTE_NR_Init()
{
netsim_matlab_interface_configure(pszAppPath);
return fn_NetSim_LTE_NR_Init_F();
}
{
netsim_matlab_interface_configure(pszAppPath);
return fn_NetSim_LTE_NR_Init_F();
}
2.
static void LTENR_MACSchedular_UpdateInfoForUE(ptrLTENR_GNBMAC mac, ptrLTENR_GNBPHY phy,
ptrLTENR_ASSOCIATEDUEPHYINFO assocInfo,
ptrLTENR_UESCHEDULARINFO info, bool isUplink, int CA_ID)
{
ptrLTENR_UEPHY uePhy = LTENR_UEPHY_GET(assocInfo->ueId, assocInfo->ueIf);
UINT layerCount = LTENR_PHY_GET_LAYER_COUNT(uePhy, isUplink);
UINT64 bitsPerPRB = 0;
for (UINT i = 0; i < layerCount; i++)
{
ptrLTENR_AMCINFO amc = isUplink ? assocInfo->uplinkAMCInfo[CA_ID][i] : assocInfo->downlinkAMCInfo[CA_ID][i];
if (amc->cqiTable.CQIIndex != 0)
bitsPerPRB += LTENR_calculateTBSSize(phy, 1, amc->mcsTable, CA_ID);
}
ptrLTENR_SCHEDULARINFO si = mac->schedularInfo[CA_ID];
if (fn_NetSim_LTENR_RRC_isActive(mac->gnbId, mac->gnbIf, assocInfo->ueId, assocInfo->ueIf)) {
info->bitsPerPRB = bitsPerPRB;
si->isUERRCSetUpCompleted = true;
}
else info->bitsPerPRB = 0;
ptrLTENR_PROPAGATIONINFO pinfo = assocInfo->propagationInfo[CA_ID];
if (!isUplink)
{
netsim_matlab_send_ascii_command("snr=%lf", pinfo->downlink.SNR_db[0]);
netsim_matlab_send_ascii_command("BitsPerPRB=%d", info->bitsPerPRB);
netsim_matlab_send_ascii_command("mcs=%d", assocInfo->downlinkAMCInfo[CA_ID][0]->mcsTable.mcsIndex);
}
if (isUplink)
info->bufferSize = fn_NetSim_LTENR_RLC_BufferStatusNotificaton(assocInfo->ueId, assocInfo->ueIf,
mac->gnbId, mac->gnbIf,
LTENR_LOGICALCHANNEL_DTCH);
else
info->bufferSize = fn_NetSim_LTENR_RLC_BufferStatusNotificaton(mac->gnbId, mac->gnbIf,
assocInfo->ueId, assocInfo->ueIf,
LTENR_LOGICALCHANNEL_DTCH);
}
ptrLTENR_ASSOCIATEDUEPHYINFO assocInfo,
ptrLTENR_UESCHEDULARINFO info, bool isUplink, int CA_ID)
{
ptrLTENR_UEPHY uePhy = LTENR_UEPHY_GET(assocInfo->ueId, assocInfo->ueIf);
UINT layerCount = LTENR_PHY_GET_LAYER_COUNT(uePhy, isUplink);
UINT64 bitsPerPRB = 0;
for (UINT i = 0; i < layerCount; i++)
{
ptrLTENR_AMCINFO amc = isUplink ? assocInfo->uplinkAMCInfo[CA_ID][i] : assocInfo->downlinkAMCInfo[CA_ID][i];
if (amc->cqiTable.CQIIndex != 0)
bitsPerPRB += LTENR_calculateTBSSize(phy, 1, amc->mcsTable, CA_ID);
}
ptrLTENR_SCHEDULARINFO si = mac->schedularInfo[CA_ID];
if (fn_NetSim_LTENR_RRC_isActive(mac->gnbId, mac->gnbIf, assocInfo->ueId, assocInfo->ueIf)) {
info->bitsPerPRB = bitsPerPRB;
si->isUERRCSetUpCompleted = true;
}
else info->bitsPerPRB = 0;
ptrLTENR_PROPAGATIONINFO pinfo = assocInfo->propagationInfo[CA_ID];
if (!isUplink)
{
netsim_matlab_send_ascii_command("snr=%lf", pinfo->downlink.SNR_db[0]);
netsim_matlab_send_ascii_command("BitsPerPRB=%d", info->bitsPerPRB);
netsim_matlab_send_ascii_command("mcs=%d", assocInfo->downlinkAMCInfo[CA_ID][0]->mcsTable.mcsIndex);
}
if (isUplink)
info->bufferSize = fn_NetSim_LTENR_RLC_BufferStatusNotificaton(assocInfo->ueId, assocInfo->ueIf,
mac->gnbId, mac->gnbIf,
LTENR_LOGICALCHANNEL_DTCH);
else
info->bufferSize = fn_NetSim_LTENR_RLC_BufferStatusNotificaton(mac->gnbId, mac->gnbIf,
assocInfo->ueId, assocInfo->ueIf,
LTENR_LOGICALCHANNEL_DTCH);
}
Upon building the LTE_NR source codes with the above changes, and running any 5G network simulation, the parameters will be passed to the MATLAB workspace during runtime as shown below:
In a similar way, additional parameters such as the gNB ID, UE ID, Interface ID, etc can also be passed if required.
The parameters passed to the MATLAB workspace can then be passed as arguments to your MATLAB algorithm using the same API netsim_matlab_send_ascii_command() which was used to pass the parameters.
We recommend users start with the single band (no carrier aggregation) and a one Rx and Tx antenna at UE and BS (no MIMO) in which case, just one SNR, MCS, and BitsPerPRB per gNB-UE associated pair needs to be passed to MATLAB.
Useful Webpages
1. NetSim documentation: https://tetcos.com/netsim-documentation.html
2. NetSim 5G library overview: https://tetcos.com/5g.html