|
|
@ -312,8 +312,8 @@ static uint32_t rsrp_num_plot = RSRP_TABLE_MAX_IDX;
|
|
|
|
#endif // HAVE_RSRP_PLOT
|
|
|
|
#endif // HAVE_RSRP_PLOT
|
|
|
|
#endif // ENABLE_GUI
|
|
|
|
#endif // ENABLE_GUI
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t sfn = 0; // system frame number
|
|
|
|
static uint32_t system_frame_number = 0;
|
|
|
|
uint32_t hfn = 0; // Hyper frame number
|
|
|
|
static uint32_t hyper_frame_number = 0;
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -544,7 +544,7 @@ int main(int argc, char** argv)
|
|
|
|
srslte_npbch_mib_unpack(bch_payload, &mib);
|
|
|
|
srslte_npbch_mib_unpack(bch_payload, &mib);
|
|
|
|
|
|
|
|
|
|
|
|
// update SFN and set deployment mode
|
|
|
|
// update SFN and set deployment mode
|
|
|
|
sfn = (mib.sfn + sfn_offset) % 1024;
|
|
|
|
system_frame_number = (mib.sfn + sfn_offset) % 1024;
|
|
|
|
cell.mode = mib.mode;
|
|
|
|
cell.mode = mib.mode;
|
|
|
|
|
|
|
|
|
|
|
|
// set number of ports of base cell to that of NB-IoT cell (FIXME: read eutra-NumCRS-Ports-r13)
|
|
|
|
// set number of ports of base cell to that of NB-IoT cell (FIXME: read eutra-NumCRS-Ports-r13)
|
|
|
@ -584,11 +584,18 @@ int main(int argc, char** argv)
|
|
|
|
|
|
|
|
|
|
|
|
#if HAVE_PCAP
|
|
|
|
#if HAVE_PCAP
|
|
|
|
// write to PCAP
|
|
|
|
// write to PCAP
|
|
|
|
pcap_pack_and_write(
|
|
|
|
pcap_pack_and_write(pcap_file,
|
|
|
|
pcap_file, data, SRSLTE_MIB_NB_CRC_LEN, 0, true, sfn * 10, 0, DIRECTION_DOWNLINK, NO_RNTI);
|
|
|
|
data,
|
|
|
|
|
|
|
|
SRSLTE_MIB_NB_CRC_LEN,
|
|
|
|
|
|
|
|
0,
|
|
|
|
|
|
|
|
true,
|
|
|
|
|
|
|
|
system_frame_number * 10,
|
|
|
|
|
|
|
|
0,
|
|
|
|
|
|
|
|
DIRECTION_DOWNLINK,
|
|
|
|
|
|
|
|
NO_RNTI);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
// activate SIB1 decoding
|
|
|
|
// activate SIB1 decoding
|
|
|
|
srslte_nbiot_ue_dl_decode_sib1(&ue_dl, sfn);
|
|
|
|
srslte_nbiot_ue_dl_decode_sib1(&ue_dl, system_frame_number);
|
|
|
|
state = DECODE_SIB;
|
|
|
|
state = DECODE_SIB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -599,14 +606,14 @@ int main(int argc, char** argv)
|
|
|
|
int dec_ret = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl,
|
|
|
|
int dec_ret = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl,
|
|
|
|
&buff_ptrs[0][prog_args.time_offset],
|
|
|
|
&buff_ptrs[0][prog_args.time_offset],
|
|
|
|
data,
|
|
|
|
data,
|
|
|
|
sfn,
|
|
|
|
system_frame_number,
|
|
|
|
srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
SRSLTE_SIRNTI);
|
|
|
|
SRSLTE_SIRNTI);
|
|
|
|
if (dec_ret == SRSLTE_SUCCESS) {
|
|
|
|
if (dec_ret == SRSLTE_SUCCESS) {
|
|
|
|
printf("SIB1 received\n");
|
|
|
|
printf("SIB1 received\n");
|
|
|
|
srslte_sys_info_block_type_1_nb_t sib = {};
|
|
|
|
srslte_sys_info_block_type_1_nb_t sib = {};
|
|
|
|
srslte_npdsch_sib1_unpack(data, &sib);
|
|
|
|
srslte_npdsch_sib1_unpack(data, &sib);
|
|
|
|
hfn = sib.hyper_sfn;
|
|
|
|
hyper_frame_number = sib.hyper_sfn;
|
|
|
|
|
|
|
|
|
|
|
|
have_sib1 = true;
|
|
|
|
have_sib1 = true;
|
|
|
|
|
|
|
|
|
|
|
@ -621,14 +628,15 @@ int main(int argc, char** argv)
|
|
|
|
get_sib2_params(data, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, &sib2_params);
|
|
|
|
get_sib2_params(data, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, &sib2_params);
|
|
|
|
|
|
|
|
|
|
|
|
// Activate SIB2 decoding
|
|
|
|
// Activate SIB2 decoding
|
|
|
|
srslte_nbiot_ue_dl_decode_sib(&ue_dl, hfn, sfn, SRSLTE_NBIOT_SI_TYPE_SIB2, sib2_params);
|
|
|
|
srslte_nbiot_ue_dl_decode_sib(
|
|
|
|
|
|
|
|
&ue_dl, hyper_frame_number, system_frame_number, SRSLTE_NBIOT_SI_TYPE_SIB2, sib2_params);
|
|
|
|
#if HAVE_PCAP
|
|
|
|
#if HAVE_PCAP
|
|
|
|
pcap_pack_and_write(pcap_file,
|
|
|
|
pcap_pack_and_write(pcap_file,
|
|
|
|
data,
|
|
|
|
data,
|
|
|
|
ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8,
|
|
|
|
ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
sfn * 10 + srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
system_frame_number * 10 + srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
SRSLTE_SIRNTI,
|
|
|
|
SRSLTE_SIRNTI,
|
|
|
|
DIRECTION_DOWNLINK,
|
|
|
|
DIRECTION_DOWNLINK,
|
|
|
|
SI_RNTI);
|
|
|
|
SI_RNTI);
|
|
|
@ -638,16 +646,16 @@ int main(int argc, char** argv)
|
|
|
|
} else if (dec_ret == SRSLTE_ERROR) {
|
|
|
|
} else if (dec_ret == SRSLTE_ERROR) {
|
|
|
|
// reactivate SIB1 grant
|
|
|
|
// reactivate SIB1 grant
|
|
|
|
if (srslte_nbiot_ue_dl_has_grant(&ue_dl) == false) {
|
|
|
|
if (srslte_nbiot_ue_dl_has_grant(&ue_dl) == false) {
|
|
|
|
srslte_nbiot_ue_dl_decode_sib1(&ue_dl, sfn);
|
|
|
|
srslte_nbiot_ue_dl_decode_sib1(&ue_dl, system_frame_number);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (!have_sib2 &&
|
|
|
|
} else if (!have_sib2 && !srslte_nbiot_ue_dl_is_sib1_sf(
|
|
|
|
!srslte_nbiot_ue_dl_is_sib1_sf(&ue_dl, sfn, srslte_ue_sync_nbiot_get_sfidx(&ue_sync))) {
|
|
|
|
&ue_dl, system_frame_number, srslte_ue_sync_nbiot_get_sfidx(&ue_sync))) {
|
|
|
|
// SIB2 is transmitted over multiple subframes, so this needs to be called more than once ..
|
|
|
|
// SIB2 is transmitted over multiple subframes, so this needs to be called more than once ..
|
|
|
|
int dec_ret = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl,
|
|
|
|
int dec_ret = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl,
|
|
|
|
&buff_ptrs[0][prog_args.time_offset],
|
|
|
|
&buff_ptrs[0][prog_args.time_offset],
|
|
|
|
data,
|
|
|
|
data,
|
|
|
|
sfn,
|
|
|
|
system_frame_number,
|
|
|
|
srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
SRSLTE_SIRNTI);
|
|
|
|
SRSLTE_SIRNTI);
|
|
|
|
if (dec_ret == SRSLTE_SUCCESS) {
|
|
|
|
if (dec_ret == SRSLTE_SUCCESS) {
|
|
|
@ -667,7 +675,7 @@ int main(int argc, char** argv)
|
|
|
|
ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8,
|
|
|
|
ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
sfn * 10 + srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
system_frame_number * 10 + srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
SRSLTE_SIRNTI,
|
|
|
|
SRSLTE_SIRNTI,
|
|
|
|
DIRECTION_DOWNLINK,
|
|
|
|
DIRECTION_DOWNLINK,
|
|
|
|
SI_RNTI);
|
|
|
|
SI_RNTI);
|
|
|
@ -675,14 +683,15 @@ int main(int argc, char** argv)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// reactivate SIB2 grant
|
|
|
|
// reactivate SIB2 grant
|
|
|
|
if (srslte_nbiot_ue_dl_has_grant(&ue_dl) == false) {
|
|
|
|
if (srslte_nbiot_ue_dl_has_grant(&ue_dl) == false) {
|
|
|
|
srslte_nbiot_ue_dl_decode_sib(&ue_dl, hfn, sfn, SRSLTE_NBIOT_SI_TYPE_SIB2, sib2_params);
|
|
|
|
srslte_nbiot_ue_dl_decode_sib(
|
|
|
|
|
|
|
|
&ue_dl, hyper_frame_number, system_frame_number, SRSLTE_NBIOT_SI_TYPE_SIB2, sib2_params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (have_sib1 && have_sib2) {
|
|
|
|
if (have_sib1 && have_sib2) {
|
|
|
|
if (prog_args.rnti == SRSLTE_SIRNTI)
|
|
|
|
if (prog_args.rnti == SRSLTE_SIRNTI)
|
|
|
|
srslte_nbiot_ue_dl_decode_sib1(&ue_dl, sfn);
|
|
|
|
srslte_nbiot_ue_dl_decode_sib1(&ue_dl, system_frame_number);
|
|
|
|
state = DECODE_NPDSCH;
|
|
|
|
state = DECODE_NPDSCH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -693,7 +702,7 @@ int main(int argc, char** argv)
|
|
|
|
n = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl,
|
|
|
|
n = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl,
|
|
|
|
&buff_ptrs[0][prog_args.time_offset],
|
|
|
|
&buff_ptrs[0][prog_args.time_offset],
|
|
|
|
data,
|
|
|
|
data,
|
|
|
|
sfn,
|
|
|
|
system_frame_number,
|
|
|
|
srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
prog_args.rnti);
|
|
|
|
prog_args.rnti);
|
|
|
|
if (n == SRSLTE_SUCCESS) {
|
|
|
|
if (n == SRSLTE_SUCCESS) {
|
|
|
@ -704,7 +713,7 @@ int main(int argc, char** argv)
|
|
|
|
srslte_dci_msg_t dci_msg;
|
|
|
|
srslte_dci_msg_t dci_msg;
|
|
|
|
n = srslte_nbiot_ue_dl_decode_npdcch(&ue_dl,
|
|
|
|
n = srslte_nbiot_ue_dl_decode_npdcch(&ue_dl,
|
|
|
|
&buff_ptrs[0][prog_args.time_offset],
|
|
|
|
&buff_ptrs[0][prog_args.time_offset],
|
|
|
|
sfn,
|
|
|
|
system_frame_number,
|
|
|
|
srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
prog_args.rnti,
|
|
|
|
prog_args.rnti,
|
|
|
|
&dci_msg);
|
|
|
|
&dci_msg);
|
|
|
@ -717,7 +726,7 @@ int main(int argc, char** argv)
|
|
|
|
prog_args.rnti,
|
|
|
|
prog_args.rnti,
|
|
|
|
&dci_unpacked,
|
|
|
|
&dci_unpacked,
|
|
|
|
&grant,
|
|
|
|
&grant,
|
|
|
|
sfn,
|
|
|
|
system_frame_number,
|
|
|
|
srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
64 /* TODO: remove */,
|
|
|
|
64 /* TODO: remove */,
|
|
|
|
cell.mode)) {
|
|
|
|
cell.mode)) {
|
|
|
@ -733,7 +742,7 @@ int main(int argc, char** argv)
|
|
|
|
n = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl,
|
|
|
|
n = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl,
|
|
|
|
&buff_ptrs[0][prog_args.time_offset],
|
|
|
|
&buff_ptrs[0][prog_args.time_offset],
|
|
|
|
data,
|
|
|
|
data,
|
|
|
|
sfn,
|
|
|
|
system_frame_number,
|
|
|
|
srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
|
|
|
|
prog_args.rnti);
|
|
|
|
prog_args.rnti);
|
|
|
|
|
|
|
|
|
|
|
@ -748,7 +757,7 @@ int main(int argc, char** argv)
|
|
|
|
|
|
|
|
|
|
|
|
// reactivate SIB1 grant
|
|
|
|
// reactivate SIB1 grant
|
|
|
|
if (srslte_nbiot_ue_dl_has_grant(&ue_dl) == false) {
|
|
|
|
if (srslte_nbiot_ue_dl_has_grant(&ue_dl) == false) {
|
|
|
|
srslte_nbiot_ue_dl_decode_sib1(&ue_dl, sfn);
|
|
|
|
srslte_nbiot_ue_dl_decode_sib1(&ue_dl, system_frame_number);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -774,7 +783,8 @@ int main(int argc, char** argv)
|
|
|
|
if (gain < 0) {
|
|
|
|
if (gain < 0) {
|
|
|
|
gain = 10 * log10(srslte_agc_get_gain(&ue_sync.agc));
|
|
|
|
gain = 10 * log10(srslte_agc_get_gain(&ue_sync.agc));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("CFO: %+6.2f kHz, RSRP: %4.1f dBm "
|
|
|
|
printf(
|
|
|
|
|
|
|
|
"CFO: %+6.2f kHz, RSRP: %4.1f dBm "
|
|
|
|
"SNR: %4.1f dB, RSRQ: %4.1f dB, "
|
|
|
|
"SNR: %4.1f dB, RSRQ: %4.1f dB, "
|
|
|
|
"NPDCCH detected: %d, NPDSCH-BLER: %5.2f%% (%d of total %d), NPDSCH-Rate: %5.2f kbit/s\r",
|
|
|
|
"NPDCCH detected: %d, NPDSCH-BLER: %5.2f%% (%d of total %d), NPDSCH-Rate: %5.2f kbit/s\r",
|
|
|
|
srslte_ue_sync_nbiot_get_cfo(&ue_sync) / 1000,
|
|
|
|
srslte_ue_sync_nbiot_get_cfo(&ue_sync) / 1000,
|
|
|
@ -785,15 +795,16 @@ int main(int argc, char** argv)
|
|
|
|
(float)100 * ue_dl.pkt_errors / ue_dl.pkts_total,
|
|
|
|
(float)100 * ue_dl.pkt_errors / ue_dl.pkts_total,
|
|
|
|
ue_dl.pkt_errors,
|
|
|
|
ue_dl.pkt_errors,
|
|
|
|
ue_dl.pkts_total,
|
|
|
|
ue_dl.pkts_total,
|
|
|
|
(ue_dl.bits_total / ((sfn * 10 + srslte_ue_sync_nbiot_get_sfidx(&ue_sync)) / 1000.0)) / 1000.0);
|
|
|
|
(ue_dl.bits_total / ((system_frame_number * 10 + srslte_ue_sync_nbiot_get_sfidx(&ue_sync)) / 1000.0)) /
|
|
|
|
|
|
|
|
1000.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (srslte_ue_sync_nbiot_get_sfidx(&ue_sync) == 9) {
|
|
|
|
if (srslte_ue_sync_nbiot_get_sfidx(&ue_sync) == 9) {
|
|
|
|
sfn++;
|
|
|
|
system_frame_number++;
|
|
|
|
if (sfn == 1024) {
|
|
|
|
if (system_frame_number == 1024) {
|
|
|
|
sfn = 0;
|
|
|
|
system_frame_number = 0;
|
|
|
|
hfn++;
|
|
|
|
hyper_frame_number++;
|
|
|
|
printf("\n");
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
|
|
|
|
// don't reset counter when reading from file to maintain complete stats
|
|
|
|
// don't reset counter when reading from file to maintain complete stats
|
|
|
@ -809,7 +820,7 @@ int main(int argc, char** argv)
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_GUI
|
|
|
|
#ifdef ENABLE_GUI
|
|
|
|
if (!prog_args.disable_plots) {
|
|
|
|
if (!prog_args.disable_plots) {
|
|
|
|
if ((sfn % 4) == 0) {
|
|
|
|
if ((system_frame_number % 4) == 0) {
|
|
|
|
plot_sf_idx = srslte_ue_sync_nbiot_get_sfidx(&ue_sync);
|
|
|
|
plot_sf_idx = srslte_ue_sync_nbiot_get_sfidx(&ue_sync);
|
|
|
|
plot_track = true;
|
|
|
|
plot_track = true;
|
|
|
|
sem_post(&plot_sem);
|
|
|
|
sem_post(&plot_sem);
|
|
|
@ -1030,7 +1041,7 @@ void* plot_thread_run(void* arg)
|
|
|
|
|
|
|
|
|
|
|
|
key_value_setValueText(&mode_label, srslte_nbiot_mode_string(cell.mode));
|
|
|
|
key_value_setValueText(&mode_label, srslte_nbiot_mode_string(cell.mode));
|
|
|
|
|
|
|
|
|
|
|
|
snprintf(lable_buf, LABLE_MAX_LEN, "%d / %d", hfn, sfn);
|
|
|
|
snprintf(lable_buf, LABLE_MAX_LEN, "%d / %d", hyper_frame_number, system_frame_number);
|
|
|
|
key_value_setValueText(&hfn_label, lable_buf);
|
|
|
|
key_value_setValueText(&hfn_label, lable_buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|