Merge branch 'mobility' of github.com:softwareradiosystems/srsLTE into mobility

master
Ismael Gomez 7 years ago
commit 05da1ac480

@ -585,6 +585,10 @@ int main(int argc, char **argv) {
/* If a new line is detected set verbose level to Debug */
if (fgets(input, sizeof(input), stdin)) {
srslte_verbose = SRSLTE_VERBOSE_DEBUG;
ue_dl.pkt_errors = 0;
ue_dl.pkts_total = 0;
ue_dl.nof_detected = 0;
nof_trials = 0;
}
}
@ -779,10 +783,12 @@ int main(int argc, char **argv) {
if (sfn == 1024) {
sfn = 0;
PRINT_LINE_ADVANCE_CURSOR();
/*
ue_dl.pkt_errors = 0;
ue_dl.pkts_total = 0;
ue_dl.nof_detected = 0;
nof_trials = 0;
nof_trials = 0;
*/
}
}

@ -87,6 +87,7 @@ typedef struct SRSLTE_API {
uint32_t cp_len;
srslte_cfo_t cfocorr;
srslte_cfo_t cfocorr2;
float current_cfo_tol;
sss_alg_t sss_alg;
bool detect_cp;
bool sss_en;
@ -147,6 +148,9 @@ SRSLTE_API srslte_cp_t srslte_sync_detect_cp(srslte_sync_t *q,
SRSLTE_API void srslte_sync_set_threshold(srslte_sync_t *q,
float threshold);
SRSLTE_API void srslte_sync_set_cfo_tol(srslte_sync_t *q,
float tol);
/* Gets the subframe idx (0 or 5) */
SRSLTE_API uint32_t srslte_sync_get_sf_idx(srslte_sync_t *q);

@ -181,6 +181,9 @@ SRSLTE_API int srslte_ue_sync_zerocopy(srslte_ue_sync_t *q,
SRSLTE_API int srslte_ue_sync_zerocopy_multi(srslte_ue_sync_t *q,
cf_t *input_buffer[SRSLTE_MAX_PORTS]);
SRSLTE_API void srslte_ue_sync_set_cfo_tol(srslte_ue_sync_t *q,
float tol);
SRSLTE_API void srslte_ue_sync_set_cfo(srslte_ue_sync_t *q,
float cfo);

@ -75,7 +75,8 @@ typedef struct SRSLTE_API {
bool normalize_en;
bool cfo_en;
float current_cfo_tol;
float current_cfo;
srslte_pucch_format_t last_pucch_format;
@ -114,10 +115,13 @@ SRSLTE_API void srslte_ue_ul_free(srslte_ue_ul_t *q);
SRSLTE_API int srslte_ue_ul_set_cell(srslte_ue_ul_t *q,
srslte_cell_t cell);
SRSLTE_API void srslte_ue_ul_set_cfo(srslte_ue_ul_t *q,
SRSLTE_API void srslte_ue_ul_set_cfo_tol(srslte_ue_ul_t *q,
float tol);
SRSLTE_API void srslte_ue_ul_set_cfo(srslte_ue_ul_t *q,
float cur_cfo);
SRSLTE_API void srslte_ue_ul_set_cfo_enable(srslte_ue_ul_t *q,
SRSLTE_API void srslte_ue_ul_set_cfo_enable(srslte_ue_ul_t *q,
bool enabled);
SRSLTE_API void srslte_ue_ul_set_normalization(srslte_ue_ul_t *q,

@ -98,16 +98,16 @@ namespace srslte {
void set_tx_rx_gain_offset(float offset);
double set_rx_gain_th(float gain);
void set_freq_offset(float freq);
void set_tx_freq(float freq);
void set_rx_freq(float freq);
void set_freq_offset(double freq);
void set_tx_freq(double freq);
void set_rx_freq(double freq);
float get_tx_freq();
float get_rx_freq();
double get_tx_freq();
double get_rx_freq();
void set_master_clock_rate(float rate);
void set_tx_srate(float srate);
void set_rx_srate(float srate);
void set_master_clock_rate(double rate);
void set_tx_srate(double srate);
void set_rx_srate(double srate);
float get_tx_gain();
float get_rx_gain();
@ -157,9 +157,9 @@ namespace srslte {
const static double blade_default_burst_preamble_sec = 0.0;
const static double blade_default_tx_adv_samples = 27;
const static double blade_default_tx_adv_offset_sec = 1e-6;
float tx_freq, rx_freq, freq_offset;
const static double blade_default_tx_adv_offset_sec = 1e-6;
double tx_freq, rx_freq, freq_offset;
trace<uint32_t> tr_local_time;
trace<uint32_t> tr_usrp_time;

@ -272,10 +272,10 @@ float srslte_cqi_to_coderate(uint32_t cqi) {
* Table III.
*/
// From paper
static float cqi_to_snr_table[15] = { 1.95, 4, 6, 8, 10, 11.95, 14.05, 16, 17.9, 19.9, 21.5, 23.45, 25.0, 27.30, 29};
//static float cqi_to_snr_table[15] = { 1.95, 4, 6, 8, 10, 11.95, 14.05, 16, 17.9, 19.9, 21.5, 23.45, 25.0, 27.30, 29};
// From experimental measurements @ 5 MHz
//static float cqi_to_snr_table[15] = { 1, 1.75, 3, 4, 5, 6, 7.5, 9, 11.5, 13.0, 15.0, 18, 20, 22.5, 26.5};
static float cqi_to_snr_table[15] = { 1, 1.75, 3, 4, 5, 6, 7.5, 9, 11.5, 13.0, 15.0, 18, 20, 22.5, 26.5};
uint8_t srslte_cqi_from_snr(float snr)
{

@ -30,6 +30,7 @@
#include <stdlib.h>
#include <complex.h>
#include <math.h>
#include <srslte/phy/sync/pss.h>
#include "srslte/phy/sync/pss.h"
#include "srslte/phy/dft/dft.h"
@ -95,9 +96,9 @@ int srslte_pss_synch_init_fft_offset(srslte_pss_synch_t *q, uint32_t frame_size,
*/
int srslte_pss_synch_init_fft_offset_decim(srslte_pss_synch_t *q,
uint32_t max_frame_size, uint32_t max_fft_size,
int offset, int decimate) {
int offset, int decimate)
{
int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL) {
@ -121,7 +122,7 @@ int srslte_pss_synch_init_fft_offset_decim(srslte_pss_synch_t *q,
q->frame_size = frame_size;
buffer_size = fft_size + frame_size + 1;
if(q->decimate > 1) {
int filter_order = 3;
srslte_filt_decim_cc_init(&q->filter,q->decimate,filter_order);
@ -183,16 +184,15 @@ int srslte_pss_synch_init_fft_offset_decim(srslte_pss_synch_t *q,
#ifdef CONVOLUTION_FFT
for(N_id_2 = 0; N_id_2<3; N_id_2++)
for(N_id_2=0; N_id_2<3; N_id_2++)
q->pss_signal_freq_full[N_id_2] = srslte_vec_malloc(buffer_size * sizeof(cf_t));
if (srslte_conv_fft_cc_init(&q->conv_fft, frame_size, fft_size)) {
fprintf(stderr, "Error initiating convolution FFT\n");
goto clean_and_exit;
}
for(int i =0; i< 3; i++)
{
srslte_dft_run_c(&q->conv_fft.filter_plan, q->pss_signal_time[i], q->pss_signal_freq_full[i]);
for(int i=0; i<3; i++) {
srslte_dft_run_c(&q->conv_fft.filter_plan, q->pss_signal_time[i], q->pss_signal_freq_full[i]);
}
#endif

@ -38,9 +38,11 @@
#include "srslte/phy/sync/cfo.h"
#define MEANPEAK_EMA_ALPHA 0.1
#define CFO_EMA_ALPHA 0.2
#define CFO_EMA_ALPHA 0.1
#define CP_EMA_ALPHA 0.1
#define DEFAULT_CFO_TOL 50.0 // Hz
static bool fft_size_isvalid(uint32_t fft_size) {
if (fft_size >= SRSLTE_SYNC_FFT_SZ_MIN && fft_size <= SRSLTE_SYNC_FFT_SZ_MAX && (fft_size%64) == 0) {
return true;
@ -94,9 +96,8 @@ int srslte_sync_init_decim(srslte_sync_t *q, uint32_t frame_size, uint32_t max_o
goto clean_exit;
}
// Set a CFO tolerance of approx 50 Hz
srslte_cfo_set_tol(&q->cfocorr, 50.0/(15000.0*q->fft_size));
srslte_cfo_set_tol(&q->cfocorr2, 50.0/(15000.0*q->fft_size));
// Set default CFO tolerance
srslte_sync_set_cfo_tol(q, DEFAULT_CFO_TOL);
for (int i=0;i<2;i++) {
q->cfo_i_corr[i] = srslte_vec_malloc(sizeof(cf_t)*q->frame_size);
@ -114,10 +115,11 @@ int srslte_sync_init_decim(srslte_sync_t *q, uint32_t frame_size, uint32_t max_o
srslte_sync_set_cp(q, SRSLTE_CP_NORM);
q->decimate = decimate;
if(!decimate)
if(!decimate) {
decimate = 1;
}
if (srslte_pss_synch_init_fft_offset_decim(&q->pss, max_offset, fft_size,0,decimate)) {
if (srslte_pss_synch_init_fft_offset_decim(&q->pss, max_offset, fft_size, 0, decimate)) {
fprintf(stderr, "Error initializing PSS object\n");
goto clean_exit;
}
@ -220,9 +222,7 @@ int srslte_sync_resize(srslte_sync_t *q, uint32_t frame_size, uint32_t max_offse
}
// Update CFO tolerance
srslte_cfo_set_tol(&q->cfocorr, 50.0/(15000.0*q->fft_size));
srslte_cfo_set_tol(&q->cfocorr2, 50.0/(15000.0*q->fft_size));
srslte_sync_set_cfo_tol(q, q->current_cfo_tol);
DEBUG("SYNC init with frame_size=%d, max_offset=%d and fft_size=%d\n", frame_size, max_offset, fft_size);
@ -234,6 +234,11 @@ int srslte_sync_resize(srslte_sync_t *q, uint32_t frame_size, uint32_t max_offse
return ret;
}
void srslte_sync_set_cfo_tol(srslte_sync_t *q, float tol) {
q->current_cfo_tol = tol;
srslte_cfo_set_tol(&q->cfocorr, tol/(15000.0*q->fft_size));
srslte_cfo_set_tol(&q->cfocorr2, tol/(15000.0*q->fft_size));
}
void srslte_sync_set_threshold(srslte_sync_t *q, float threshold) {
q->threshold = threshold;
@ -591,7 +596,7 @@ srslte_sync_find_ret_t srslte_sync_find(srslte_sync_t *q, cf_t *input, uint32_t
} else {
q->mean_cfo2 = SRSLTE_VEC_EMA(cfo2, q->mean_cfo2, q->cfo_ema_alpha);
}
ret = SRSLTE_SYNC_FOUND;
} else {
ret = SRSLTE_SYNC_FOUND_NOSPACE;
@ -612,8 +617,6 @@ srslte_sync_find_ret_t srslte_sync_find(srslte_sync_t *q, cf_t *input, uint32_t
}
void srslte_sync_reset(srslte_sync_t *q) {
q->mean_cfo2_isunset = true;
q->mean_cfo_isunset = true;
q->M_ext_avg = 0;
q->M_norm_avg = 0;
srslte_pss_synch_reset(&q->pss);

@ -210,7 +210,7 @@ int srslte_ue_sync_init_multi_decim(srslte_ue_sync_t *q,
if(srslte_sync_init(&q->strack, q->frame_len, TRACK_FRAME_SIZE, q->fft_size)) {
fprintf(stderr, "Error initiating sync track\n");
goto clean_exit;
}
}
} else {
if(srslte_sync_init(&q->strack, q->frame_len, SRSLTE_CP_LEN_NORM(1,q->fft_size), q->fft_size)) {
fprintf(stderr, "Error initiating sync track\n");
@ -220,12 +220,12 @@ int srslte_ue_sync_init_multi_decim(srslte_ue_sync_t *q,
ret = SRSLTE_SUCCESS;
}
clean_exit:
if (ret == SRSLTE_ERROR) {
srslte_ue_sync_free(q);
}
return ret;
return ret;
}
uint32_t srslte_ue_sync_sf_len(srslte_ue_sync_t *q) {
@ -238,7 +238,7 @@ void srslte_ue_sync_free(srslte_ue_sync_t *q) {
}
if (!q->file_mode) {
srslte_sync_free(&q->sfind);
srslte_sync_free(&q->strack);
srslte_sync_free(&q->strack);
} else {
srslte_filesource_free(&q->file_source);
}
@ -380,6 +380,8 @@ void srslte_ue_sync_set_cfo(srslte_ue_sync_t *q, float cfo) {
srslte_sync_set_cfo(&q->strack, cfo/15000);
}
void srslte_ue_sync_set_cfo_tol(srslte_ue_sync_t *q, float cfo_tol) {}
float srslte_ue_sync_get_sfo(srslte_ue_sync_t *q) {
return q->mean_sfo/5e-3;
}

@ -38,6 +38,8 @@
#define MAX_SFLEN SRSLTE_SF_LEN(srslte_symbol_sz(max_prb))
#define DEFAULT_CFO_TOL 50.0 // Hz
int srslte_ue_ul_init(srslte_ue_ul_t *q,
uint32_t max_prb)
{
@ -62,8 +64,8 @@ int srslte_ue_ul_init(srslte_ue_ul_t *q,
fprintf(stderr, "Error creating CFO object\n");
goto clean_exit;
}
srslte_cfo_set_tol(&q->cfo, 0);
srslte_ue_ul_set_cfo_tol(q, DEFAULT_CFO_TOL);
if (srslte_pusch_init_ue(&q->pusch, max_prb)) {
fprintf(stderr, "Error creating PUSCH object\n");
@ -155,7 +157,9 @@ int srslte_ue_ul_set_cell(srslte_ue_ul_t *q,
fprintf(stderr, "Error resizing CFO object\n");
return SRSLTE_ERROR;
}
srslte_cfo_set_tol(&q->cfo, 50.0/(15000.0*srslte_symbol_sz(q->cell.nof_prb)));
srslte_ue_ul_set_cfo_tol(q, q->current_cfo_tol);
if (srslte_pusch_set_cell(&q->pusch, q->cell)) {
fprintf(stderr, "Error resizing PUSCH object\n");
return SRSLTE_ERROR;
@ -178,6 +182,10 @@ int srslte_ue_ul_set_cell(srslte_ue_ul_t *q,
return ret;
}
void srslte_ue_ul_set_cfo_tol(srslte_ue_ul_t *q, float tol) {
q->current_cfo_tol = tol;
srslte_cfo_set_tol(&q->cfo, tol/(15000.0*srslte_symbol_sz(q->cell.nof_prb)));
}
void srslte_ue_ul_set_cfo(srslte_ue_ul_t *q, float cur_cfo) {
q->current_cfo = cur_cfo;

@ -250,11 +250,11 @@ void radio::save_trace(uint32_t is_eob, srslte_timestamp_t *tx_time) {
}
}
void radio::set_freq_offset(float freq) {
void radio::set_freq_offset(double freq) {
freq_offset = freq;
}
void radio::set_rx_freq(float freq)
void radio::set_rx_freq(double freq)
{
rx_freq = srslte_rf_set_rx_freq(&rf_device, freq+freq_offset);
}
@ -269,17 +269,17 @@ double radio::set_rx_gain_th(float gain)
return srslte_rf_set_rx_gain_th(&rf_device, gain);
}
void radio::set_master_clock_rate(float rate)
void radio::set_master_clock_rate(double rate)
{
srslte_rf_set_master_clock_rate(&rf_device, rate);
}
void radio::set_rx_srate(float srate)
void radio::set_rx_srate(double srate)
{
srslte_rf_set_rx_srate(&rf_device, srate);
}
void radio::set_tx_freq(float freq)
void radio::set_tx_freq(double freq)
{
tx_freq = srslte_rf_set_tx_freq(&rf_device, freq+freq_offset);
}
@ -289,12 +289,12 @@ void radio::set_tx_gain(float gain)
srslte_rf_set_tx_gain(&rf_device, gain);
}
float radio::get_rx_freq()
double radio::get_rx_freq()
{
return rx_freq;
}
float radio::get_tx_freq()
double radio::get_tx_freq()
{
return tx_freq;
}
@ -309,7 +309,7 @@ float radio::get_rx_gain()
return srslte_rf_get_rx_gain(&rf_device);
}
void radio::set_tx_srate(float srate)
void radio::set_tx_srate(double srate)
{
cur_tx_srate = srslte_rf_set_tx_srate(&rf_device, srate);
burst_preamble_samples = (uint32_t) (cur_tx_srate * burst_preamble_sec);

@ -397,7 +397,7 @@ int sched_ue::generate_format1(dl_harq_proc *h,
if (fixed_mcs_dl < 0) {
tbs = alloc_tbs_dl(nof_prb, nof_re, req_bytes, &mcs);
} else {
tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(fixed_mcs_dl), nof_prb);
tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(fixed_mcs_dl), nof_prb)/8;
mcs = fixed_mcs_dl;
}
@ -468,7 +468,7 @@ int sched_ue::generate_format0(ul_harq_proc *h,
if (fixed_mcs_ul < 0) {
tbs = alloc_tbs_ul(allocation.L, nof_re, req_bytes, &mcs);
} else {
tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(fixed_mcs_ul), allocation.L);
tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(fixed_mcs_ul), allocation.L)/8;
mcs = fixed_mcs_ul;
}
@ -607,12 +607,12 @@ uint32_t sched_ue::get_required_prb_dl(uint32_t req_bytes, uint32_t nof_ctrl_sym
uint32_t nof_re = 0;
int tbs = 0;
for (n=1;n<cell.nof_prb && nbytes < req_bytes;n++) {
for (n=1;n<=cell.nof_prb && nbytes < req_bytes;n++) {
nof_re = srslte_ra_dl_approx_nof_re(cell, n, nof_ctrl_symbols);
if (fixed_mcs_dl < 0) {
tbs = alloc_tbs_dl(n, nof_re, 0, &mcs);
} else {
tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(fixed_mcs_dl), n);
tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(fixed_mcs_dl), n)/8;
}
if (tbs > 0) {
nbytes = tbs;
@ -635,13 +635,13 @@ uint32_t sched_ue::get_required_prb_ul(uint32_t req_bytes)
return 0;
}
for (n=1;n<cell.nof_prb && nbytes < req_bytes + 4;n++) {
for (n=1;n<=cell.nof_prb && nbytes < req_bytes + 4;n++) {
uint32_t nof_re = (2*(SRSLTE_CP_NSYMB(cell.cp)-1) - N_srs)*n*SRSLTE_NRE;
int tbs = 0;
if (fixed_mcs_ul < 0) {
tbs = alloc_tbs_ul(n, nof_re, 0, &mcs);
} else {
tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(fixed_mcs_ul), n);
tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(fixed_mcs_ul), n)/8;
}
if (tbs > 0) {
nbytes = tbs;
@ -814,7 +814,7 @@ int sched_ue::alloc_tbs(uint32_t nof_prb,
uint32_t max_Qm = is_ul?4:6; // Allow 16-QAM in PUSCH Only
// TODO: Compute real spectral efficiency based on PUSCH-UCI configuration
if (has_pucch) {
if (has_pucch && is_ul) {
cqi-=2;
}

@ -169,9 +169,7 @@ void phch_recv::set_ue_sync_opts(srslte_ue_sync_t *q) {
srslte_ue_sync_cfo_i_detec_en(q, true);
}
float cfo_tol = worker_com->args->cfo_correct_tol_hz;
srslte_cfo_set_tol(&q->strack.cfocorr, cfo_tol / (15000 * q->fft_size));
srslte_cfo_set_tol(&q->sfind.cfocorr, cfo_tol / (15000 * q->fft_size));
srslte_ue_sync_set_cfo_tol(q, worker_com->args->cfo_correct_tol_hz);
int time_correct_period = worker_com->args->time_correct_period;
if (time_correct_period > 0) {
@ -499,8 +497,8 @@ bool phch_recv::cell_select(uint32_t earfcn, srslte_cell_t cell) {
bool phch_recv::set_frequency()
{
float dl_freq = 1e6*srslte_band_fd(current_earfcn);
float ul_freq = 1e6*srslte_band_fu(srslte_band_ul_earfcn(current_earfcn));
double dl_freq = 1e6*srslte_band_fd(current_earfcn);
double ul_freq = 1e6*srslte_band_fu(srslte_band_ul_earfcn(current_earfcn));
if (dl_freq > 0 && ul_freq > 0) {
log_h->info("SYNC: Set DL EARFCN=%d, f_dl=%.1f MHz, f_ul=%.1f MHz\n",
current_earfcn, dl_freq / 1e6, ul_freq / 1e6);
@ -510,7 +508,7 @@ bool phch_recv::set_frequency()
radio_h->set_rx_freq(dl_freq);
radio_h->set_tx_freq(ul_freq);
ul_dl_factor = ul_freq / dl_freq;
ul_dl_factor = radio_h->get_tx_freq()/radio_h->get_rx_freq();
srslte_ue_sync_reset(&ue_sync);

Loading…
Cancel
Save