Disabled subframe average

master
Ismael Gomez 7 years ago
parent f1c6bcd252
commit 6b264732d2

@ -958,7 +958,7 @@ void *plot_thread_run(void *arg) {
plot_real_init(&pce);
plot_real_setTitle(&pce, "Channel Response - Magnitude");
plot_real_setLabels(&pce, "Index", "dB");
plot_real_setYAxisScale(&pce, -M_PI, M_PI);
plot_real_setYAxisScale(&pce, -40, 40);
plot_real_init(&p_sync);
plot_real_setTitle(&p_sync, "PSS Cross-Corr abs value");
@ -994,11 +994,7 @@ void *plot_thread_run(void *arg) {
tmp_plot2[g+i] = -80;
}
}
uint32_t nrefs = 2*ue_dl.cell.nof_prb;
for (i=0;i<nrefs;i++) {
tmp_plot2[i] = cargf(ue_dl.chest.tmp_cfo_estimate[i]);
}
plot_real_setNewData(&pce, tmp_plot2, nrefs);
plot_real_setNewData(&pce, tmp_plot2, sz);
if (!prog_args.input_file_name) {
if (plot_track) {

@ -257,7 +257,7 @@ int srslte_ue_dl_set_cell(srslte_ue_dl_t *q, srslte_cell_t cell)
}
ret = SRSLTE_SUCCESS;
} else {
fprintf(stderr, "Invalid cell properties: Id=%d, Ports=%d, PRBs=%d\n",
fprintf(stderr, "Invalid cell properties ue_dl: Id=%d, Ports=%d, PRBs=%d\n",
cell.id, cell.nof_ports, cell.nof_prb);
}
return ret;

@ -178,7 +178,7 @@ int srslte_ue_ul_set_cell(srslte_ue_ul_t *q,
}
ret = SRSLTE_SUCCESS;
} else {
fprintf(stderr, "Invalid cell properties: Id=%d, Ports=%d, PRBs=%d\n",
fprintf(stderr, "Invalid cell properties ue_ul: Id=%d, Ports=%d, PRBs=%d\n",
cell.id, cell.nof_ports, cell.nof_prb);
}
return ret;

@ -318,6 +318,8 @@ private:
int cur_earfcn_index;
bool cell_search_in_progress;
uint32_t out_of_sync_cnt;
float dl_freq;
float ul_freq;

@ -149,6 +149,8 @@ private:
uint8_t transaction_id;
bool drb_up;
bool paging_received;
rrc_args_t args;
bool first_stimsi_attempt;
@ -208,7 +210,8 @@ private:
const static int MAX_KNOWN_CELLS = 64;
cell_t known_cells[MAX_KNOWN_CELLS];
cell_t *current_cell;
void add_new_cell(uint32_t earfcn, srslte_cell_t phy_cell, float rsrp);
cell_t* add_new_cell(uint32_t earfcn, srslte_cell_t phy_cell, float rsrp);
uint32_t find_best_cell(uint32_t earfcn, srslte_cell_t *cell);
typedef enum {
SI_ACQUIRE_IDLE = 0,
@ -365,6 +368,7 @@ private:
float get_srxlev(float Qrxlevmeas);
float get_squal(float Qqualmeas);
void cell_reselection_eval(float rsrp, float rsrq);
bool cell_selection_eval(float rsrp, float rsrq = 0);

@ -237,7 +237,7 @@ void parse_args(all_args_t *args, int argc, char *argv[]) {
"After the PSS estimation is below cfo_loop_pss_tol for cfo_loop_pss_timeout times consecutively, RS adjustments are allowed.")
("expert.average_subframe_enabled",
bpo::value<bool>(&args->expert.phy.average_subframe_enabled)->default_value(true),
bpo::value<bool>(&args->expert.phy.average_subframe_enabled)->default_value(false),
"Averages in the time domain the channel estimates within 1 subframe. Needs accurate CFO correction.")
("expert.time_correct_period",

@ -399,22 +399,24 @@ bool phch_recv::cell_select(uint32_t earfcn, srslte_cell_t cell) {
log_h->warning("Still not in idle\n");
}
current_earfcn = earfcn;
if (earfcn != current_earfcn) {
if (set_frequency()) {
log_h->error("Cell Select: Configuring cell in EARFCN=%d, PCI=%d\n", earfcn, cell.id);
return false;
}
current_earfcn = earfcn;
}
if (set_frequency()) {
this->cell = cell;
log_h->info("Cell Select: Configuring cell...\n");
this->cell = cell;
log_h->info("Cell Select: Configuring cell...\n");
if (set_cell()) {
log_h->info("Cell Select: Synchronizing on cell...\n");
if (set_cell()) {
log_h->info("Cell Select: Synchronizing on cell...\n");
resync_sfn();
resync_sfn();
usleep(500000); // Time offset we set start_rx to start receiving samples
return true;
} else {
log_h->error("Cell Select: Configuring cell in EARFCN=%d, PCI=%d\n", earfcn, cell.id);
}
usleep(500000); // Time offset we set start_rx to start receiving samples
return true;
}
return false;
}
@ -669,13 +671,21 @@ void phch_recv::run_thread()
workers_pool->start_worker(worker);
intra_freq_meas.write(tti, buffer[0], SRSLTE_SF_LEN_PRB(cell.nof_prb));
out_of_sync_cnt = 0;
break;
case 0:
log_h->error("SYNC: Sync error. Sending out-of-sync to RRC\n");
// Notify RRC of out-of-sync frame
rrc->out_of_sync();
// Signal every 5 errors only (PSS is every 5)
if (out_of_sync_cnt == 0) {
// Notify RRC of out-of-sync frame
log_h->error("SYNC: Sync error. Sending out-of-sync to RRC\n");
rrc->out_of_sync();
}
worker->release();
worker_com->reset_ul();
out_of_sync_cnt++;
if (out_of_sync_cnt >= 5) {
out_of_sync_cnt = 0;
}
break;
default:
radio_error();
@ -1203,7 +1213,7 @@ int phch_recv::scell_recv::find_cells(cf_t *input_buffer, float rx_gain_offset,
int nof_cells = 0;
uint32_t peak_idx = 0;
uint32_t sf_idx = 0;
uint32_t cell_id = 0;
int cell_id = 0;
srslte_cell_t found_cell;
memcpy(&found_cell, &cell, sizeof(srslte_cell_t));
@ -1226,29 +1236,28 @@ int phch_recv::scell_recv::find_cells(cf_t *input_buffer, float rx_gain_offset,
sf_idx = srslte_sync_get_sf_idx(&sync_find);
cell_id = srslte_sync_get_cell_id(&sync_find);
Info("INTRA: found peak_idx=%d, n_id_2=%d, cell_id=%d, sf=%d\n",
if (cell_id != -1) {
Info("INTRA: found peak_idx=%d, n_id_2=%d, cell_id=%d, sf=%d\n",
peak_idx, n_id_2, cell_id, sf_idx);
found_cell.id = cell_id;
found_cell.nof_ports = 1; // Use port 0 only for measurement
measure_p.set_cell(found_cell);
//printf("cell_id=%d, correcting cfo=%f Hz\n", cell_id, 15000*sync_find.mean_cfo2);
//srslte_cfo_correct(&sync_find.cfocorr, input_buffer, input_buffer, -sync_find.mean_cfo2 / sync_find.fft_size);
switch(measure_p.run_multiple_subframes(input_buffer, peak_idx, sf_idx, nof_sf)) {
case measure::MEASURE_OK:
cells[nof_cells].pci = found_cell.id;
cells[nof_cells].rsrp = measure_p.rsrp();
cells[nof_cells].rsrq = measure_p.rsrq();
cells[nof_cells].offset = peak_idx;
nof_cells++;
break;
case measure::ERROR:
Error("Measuring neighbour cell\n");
return SRSLTE_ERROR;
default:
break;
found_cell.id = cell_id;
found_cell.nof_ports = 1; // Use port 0 only for measurement
measure_p.set_cell(found_cell);
switch(measure_p.run_multiple_subframes(input_buffer, peak_idx, sf_idx, nof_sf)) {
case measure::MEASURE_OK:
cells[nof_cells].pci = found_cell.id;
cells[nof_cells].rsrp = measure_p.rsrp();
cells[nof_cells].rsrq = measure_p.rsrq();
cells[nof_cells].offset = peak_idx;
nof_cells++;
break;
case measure::ERROR:
Error("Measuring neighbour cell\n");
return SRSLTE_ERROR;
default:
break;
}
}
break;
case SRSLTE_SYNC_FOUND_NOSPACE:
@ -1347,7 +1356,7 @@ void phch_recv::intra_measure::add_cell(int pci) {
receive_enabled = true;
Info("INTRA: Starting intra-frequency measurement for pci=%d\n", pci);
} else {
Warning("INTRA: Requested to start already existing intra-frequency measurement for PCI=%d\n", pci);
Debug("INTRA: Requested to start already existing intra-frequency measurement for PCI=%d\n", pci);
}
}

@ -230,7 +230,7 @@ void phch_worker::work_imp()
/* Do FFT and extract PDCCH LLR, or quit if no actions are required in this subframe */
bool chest_ok = extract_fft_and_pdcch_llr();
bool snr_th_ok = 10*log10(srslte_chest_dl_get_snr(&ue_dl.chest))>-10.0;
bool snr_th_ok = 10*log10(srslte_chest_dl_get_snr(&ue_dl.chest))>-20.0;
// Call feedback loop for chest
if (chest_loop && ((1<<(tti%10)) & phy->args->cfo_ref_mask)) {
@ -1227,18 +1227,13 @@ int phch_worker::read_ce_abs(float *ce_abs) {
int sz = srslte_symbol_sz(cell.nof_prb);
bzero(ce_abs, sizeof(float)*sz);
int g = (sz - 12*cell.nof_prb)/2;
/* for (i = 0; i < 12*cell.nof_prb; i++) {
for (i = 0; i < 12*cell.nof_prb; i++) {
ce_abs[g+i] = 20 * log10f(cabsf(ue_dl.ce_m[0][0][i]));
if (isinf(ce_abs[g+i])) {
ce_abs[g+i] = -80;
}
}
*/
uint32_t nrefs = 2*ue_dl.cell.nof_prb;
for (i=0;i<nrefs;i++) {
ce_abs[i] = 15000*0.463208685*cargf(ue_dl.chest.tmp_cfo_estimate[i])/M_PI;
}
return nrefs;
return sz;
}
int phch_worker::read_pdsch_d(cf_t* pdsch_d)
@ -1294,7 +1289,7 @@ void phch_worker::update_measurements()
phy->avg_rsrp_dbm= rsrp_dbm;
} else {
phy->avg_rsrp_dbm = SRSLTE_VEC_EMA(rsrp_dbm, phy->avg_rsrp_dbm, snr_ema_coeff);
}
}
if ((tti%phy->pcell_report_period) == 0 && phy->pcell_meas_enabled) {
phy->rrc->new_phy_meas(phy->avg_rsrp_dbm, phy->avg_rsrq_db, tti);
}
@ -1388,7 +1383,7 @@ void *plot_thread_run(void *arg) {
plot_real_init(&pce);
plot_real_setTitle(&pce, (char*) "Channel Response - Magnitude");
plot_real_setLabels(&pce, (char*) "Index", (char*) "dB");
plot_real_setYAxisScale(&pce, -1000, 1000);
plot_real_setYAxisScale(&pce, -40, 40);
plot_scatter_init(&pconst);
plot_scatter_setTitle(&pconst, (char*) "PDSCH - Equalized Symbols");

@ -225,14 +225,22 @@ void rrc::run_thread() {
}
break;
case RRC_STATE_CELL_SELECTED:
rrc_log->info("RRC Cell Selected: Sending connection request...\n");
if (reestablishment_in_progress) {
if (!nas->is_attached() || paging_received) {
paging_received = false;
rrc_log->info("RRC Cell Selected: Sending connection request...\n");
send_con_request();
state = RRC_STATE_CONNECTING;
connecting_timeout = 0;
} else if (reestablishment_in_progress) {
rrc_log->info("RRC Cell Selected: Sending connection reestablishment...\n");
con_restablish_cell_reselected();
state = RRC_STATE_CONNECTING;
connecting_timeout = 0;
} else {
send_con_request();
rrc_log->console("RRC Cell Selected: New PCI=%d\n", current_cell->phy_cell.id);
mac->pcch_start_rx();
state = RRC_STATE_IDLE;
}
state = RRC_STATE_CONNECTING;
connecting_timeout = 0;
break;
case RRC_STATE_CONNECTING:
connecting_timeout++;
@ -471,7 +479,34 @@ void rrc::new_phy_meas(float rsrp, float rsrq, uint32_t tti, uint32_t earfcn, ui
if (state == RRC_STATE_CONNECTED) {
measurements.new_phy_meas(earfcn, pci, rsrp, rsrq, tti);
} else {
cell_reselection_eval(rsrp, rsrq);
// If measurement is of the serving cell, evaluate cell reselection criteria
if ((earfcn == phy->get_current_earfcn() && pci == phy->get_current_pci()) || (earfcn == 0 && pci == 0)) {
cell_reselection_eval(rsrp, rsrq);
current_cell->rsrp = rsrp;
rrc_log->info("MEAS: New measurement serving cell, rsrp=%f, rsrq=%f, tti=%d\n", rsrp, rsrq, tti);
} else {
// Add/update cell measurement
srslte_cell_t cell;
phy->get_current_cell(&cell, NULL);
cell.id = pci;
add_new_cell(earfcn, cell, rsrp);
rrc_log->info("MEAS: New measurement PCI=%d, RSRP=%.1f dBm.\n", pci, rsrp);
}
srslte_cell_t best_cell;
uint32_t best_cell_idx = find_best_cell(phy->get_current_earfcn(), &best_cell);
// Verify cell selection criteria
if (cell_selection_eval(known_cells[best_cell_idx].rsrp) &&
known_cells[best_cell_idx].rsrp > current_cell->rsrp + 5 &&
best_cell.id != phy->get_current_pci())
{
rrc_log->info("Selecting best neighbour cell PCI=%d, rsrp=%.1f dBm\n", best_cell.id, known_cells[best_cell_idx].rsrp);
state = RRC_STATE_CELL_SELECTING;
current_cell = &known_cells[best_cell_idx];
phy->cell_select(phy->get_current_earfcn(), best_cell);
}
}
}
@ -498,8 +533,13 @@ void rrc::cell_found(uint32_t earfcn, srslte_cell_t phy_cell, float rsrp) {
return;
}
}
// add to list of known cells
add_new_cell(earfcn, phy_cell, rsrp);
// add to list of known cells and set current_cell
current_cell = add_new_cell(earfcn, phy_cell, rsrp);
if(!current_cell) {
current_cell = &known_cells[0];
rrc_log->error("Couldn't add new cell\n");
return;
}
si_acquire_state = SI_ACQUIRE_SIB1;
@ -508,22 +548,52 @@ void rrc::cell_found(uint32_t earfcn, srslte_cell_t phy_cell, float rsrp) {
current_cell->earfcn, current_cell->rsrp, current_cell);
}
void rrc::add_new_cell(uint32_t earfcn, srslte_cell_t phy_cell, float rsrp) {
uint32_t rrc::find_best_cell(uint32_t earfcn, srslte_cell_t *cell) {
float best_rsrp = -INFINITY;
uint32_t best_cell_idx = 0;
for (int i=0;i<MAX_KNOWN_CELLS;i++) {
if (known_cells[i].earfcn == earfcn) {
if (known_cells[i].rsrp > best_rsrp) {
best_rsrp = known_cells[i].rsrp;
best_cell_idx = i;
}
}
}
if (cell) {
memcpy(cell, &known_cells[best_cell_idx].phy_cell, sizeof(srslte_cell_t));
}
return best_cell_idx;
}
rrc::cell_t* rrc::add_new_cell(uint32_t earfcn, srslte_cell_t phy_cell, float rsrp) {
if (earfcn == 0) {
return NULL;
}
// First check it does not exist already
int j=0;
while(j<MAX_KNOWN_CELLS && (known_cells[j].earfcn != earfcn || known_cells[j].phy_cell.id != phy_cell.id)) {
j++;
}
if (j<MAX_KNOWN_CELLS) {
known_cells[j].rsrp = rsrp;
return &known_cells[j];
}
int i=0;
while(i<MAX_KNOWN_CELLS && known_cells[i].earfcn) {
i++;
}
if (i==MAX_KNOWN_CELLS) {
rrc_log->error("Can't add more cells\n");
return;
return NULL;
}
current_cell = &known_cells[i];
current_cell->phy_cell = phy_cell;
current_cell->rsrp = rsrp;
current_cell->earfcn = earfcn;
current_cell->has_valid_sib1 = false;
current_cell->has_valid_sib2 = false;
current_cell->has_valid_sib3 = false;
known_cells[i].phy_cell = phy_cell;
known_cells[i].rsrp = rsrp;
known_cells[i].earfcn = earfcn;
known_cells[i].has_valid_sib1 = false;
known_cells[i].has_valid_sib2 = false;
known_cells[i].has_valid_sib3 = false;
return &known_cells[i];
}
// PHY indicates that has gone through all known EARFCN
@ -551,14 +621,16 @@ void rrc::add_neighbour_cell(uint32_t earfcn, uint32_t pci, float rsrp) {
add_new_cell(earfcn, cell, rsrp);
}
// Cell reselection in IDLE Section 5.2.4 of 36.304
// Cell reselction in IDLE Section 5.2.4 of 36.304
void rrc::cell_reselection_eval(float rsrp, float rsrq)
{
// Intra-frequency cell-reselection criteria
if (get_srxlev(rsrp) > cell_resel_cfg.s_intrasearchP) {
// UE may not perform intra-frequency measurements
if (get_srxlev(rsrp) > cell_resel_cfg.s_intrasearchP && rsrp > -80.0) {
// UE may not perform intra-frequency measurements.
phy->meas_reset();
// keep measuring serving cell
phy->meas_start(phy->get_current_earfcn(), phy->get_current_pci());
} else {
// UE must start intra-frequency measurements
phy->meas_start(phy->get_current_earfcn(), -1);
@ -567,6 +639,16 @@ void rrc::cell_reselection_eval(float rsrp, float rsrq)
// TODO: Inter-frequency cell reselection
}
// Cell selection in IDLE Section 5.2.3.2 of 36.304
bool rrc::cell_selection_eval(float rsrp, float rsrq)
{
if (get_srxlev(rsrp) > 0) {
return true;
} else {
return false;
}
}
float rrc::get_srxlev(float Qrxlevmeas) {
// TODO: Do max power limitation
float Pcompensation = 0;
@ -1144,12 +1226,12 @@ void rrc::handle_sib3()
cell_resel_cfg.q_hyst = liblte_rrc_q_hyst_num[sib3->q_hyst];
// cellReselectionServingFreqInfo
cell_resel_cfg.threshservinglow = 2*sib3->thresh_serving_low;
cell_resel_cfg.threshservinglow = sib3->thresh_serving_low;
// intraFreqCellReselectionInfo
cell_resel_cfg.Qrxlevmin = 2*sib3->q_rx_lev_min;
cell_resel_cfg.Qrxlevmin = sib3->q_rx_lev_min;
if (sib3->s_intra_search_present) {
cell_resel_cfg.s_intrasearchP = 2*sib3->s_intra_search;
cell_resel_cfg.s_intrasearchP = sib3->s_intra_search;
} else {
cell_resel_cfg.s_intrasearchP = INFINITY;
}
@ -1214,6 +1296,7 @@ void rrc::write_pdu_pcch(byte_buffer_t *pdu) {
mac->pcch_stop_rx();
if (RRC_STATE_IDLE == state) {
rrc_log->info("RRC in IDLE state - sending connection request.\n");
paging_received = true;
state = RRC_STATE_CELL_SELECTING;
}
}

@ -188,7 +188,7 @@ enable = false
#sfo_correct_disable = false
#sss_algorithm = full
#estimator_fil_w = 0.1
#average_subframe_enabled = true
#average_subframe_enabled = false
#pregenerate_signals = false
#metrics_csv_enable = false
#metrics_csv_filename = /tmp/ue_metrics.csv

Loading…
Cancel
Save