Merge branch 'next' into raa

master
Ismael Gomez 7 years ago
commit 737802c959

@ -75,9 +75,11 @@ public:
void print_all_buffers() void print_all_buffers()
{ {
printf("%d buffers in queue\n", (int) used.size()); printf("%d buffers in queue\n", (int) used.size());
#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED
for (uint32_t i=0;i<used.size();i++) { for (uint32_t i=0;i<used.size();i++) {
printf("%s\n", strlen(used[i]->debug_name)?used[i]->debug_name:"Undefined"); printf("%s\n", strlen(used[i]->debug_name)?used[i]->debug_name:"Undefined");
} }
#endif
} }
bool is_almost_empty() { bool is_almost_empty() {

@ -63,7 +63,7 @@
#define SRSLTE_MAX_BUFFER_SIZE_BYTES 12756 #define SRSLTE_MAX_BUFFER_SIZE_BYTES 12756
#define SRSLTE_BUFFER_HEADER_OFFSET 1024 #define SRSLTE_BUFFER_HEADER_OFFSET 1024
#define SRSLTE_BUFFER_POOL_LOG_ENABLED //#define SRSLTE_BUFFER_POOL_LOG_ENABLED
#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED #ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED
#define pool_allocate (pool->allocate(__FUNCTION__)) #define pool_allocate (pool->allocate(__FUNCTION__))

@ -10,6 +10,7 @@
#include <vector> #include <vector>
#include "srslte/common/threads.h" #include "srslte/common/threads.h"
#include "srslte/srslte.h"
namespace srslte { namespace srslte {
@ -24,7 +25,7 @@ template<typename metrics_t>
class metrics_listener class metrics_listener
{ {
public: public:
virtual void set_metrics(metrics_t &m) = 0; virtual void set_metrics(metrics_t &m, const uint32_t period_usec) = 0;
virtual void stop() = 0; virtual void stop() = 0;
}; };
@ -34,13 +35,12 @@ class metrics_hub : public periodic_thread
public: public:
metrics_hub() metrics_hub()
:m(NULL) :m(NULL)
,report_period_secs(1) ,sleep_period_start()
{} {}
bool init(metrics_interface<metrics_t> *m_, float report_period_secs_=1.0) { bool init(metrics_interface<metrics_t> *m_, float report_period_secs_=1.0) {
m = m_; m = m_;
report_period_secs = report_period_secs_;
// Start with user-default priority // Start with user-default priority
start_periodic(report_period_secs*1e6, -2); start_periodic(report_period_secs_*1e6, -2);
return true; return true;
} }
void stop() { void stop() {
@ -57,18 +57,24 @@ public:
} }
private: private:
void run_period() { void run_period(){
// get current time and check how long we slept
gettimeofday(&sleep_period_start[2], NULL);
get_time_interval(sleep_period_start);
uint32_t period = sleep_period_start[0].tv_sec*1e6 + sleep_period_start[0].tv_usec;
if (m) { if (m) {
metrics_t metric = {}; metrics_t metric = {};
m->get_metrics(metric); m->get_metrics(metric);
for (uint32_t i=0;i<listeners.size();i++) { for (uint32_t i=0;i<listeners.size();i++) {
listeners[i]->set_metrics(metric); listeners[i]->set_metrics(metric, period);
} }
} }
// store start of sleep period
gettimeofday(&sleep_period_start[1], NULL);
} }
metrics_interface<metrics_t> *m; metrics_interface<metrics_t> *m;
std::vector<metrics_listener<metrics_t>*> listeners; std::vector<metrics_listener<metrics_t>*> listeners;
float report_period_secs; struct timeval sleep_period_start[3];
}; };
} // namespace srslte } // namespace srslte

@ -180,8 +180,8 @@ private:
int build_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_retx_t retx); int build_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_retx_t retx);
int build_data_pdu(uint8_t *payload, uint32_t nof_bytes); int build_data_pdu(uint8_t *payload, uint32_t nof_bytes);
void handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t header); void handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t &header);
void handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t header); void handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t &header);
void handle_control_pdu(uint8_t *payload, uint32_t nof_bytes); void handle_control_pdu(uint8_t *payload, uint32_t nof_bytes);
void reassemble_rx_sdus(); void reassemble_rx_sdus();

@ -2243,6 +2243,12 @@ LIBLTE_ERROR_ENUM liblte_s1ap_pack_imsi(
if(ie != NULL && if(ie != NULL &&
ptr != NULL) ptr != NULL)
{ {
// max length of IE buffer is 32, so limit
if (ie->n_octets > 31) {
printf("Length in struct exceeds buffer (%d > 31).\n", ie->n_octets);
return LIBLTE_ERROR_ENCODE_FAIL;
}
// Dynamic octet string - IMSI // Dynamic octet string - IMSI
// Length // Length
if(ie->n_octets < 128) { if(ie->n_octets < 128) {

@ -90,6 +90,7 @@ uint32_t srslte_sch_find_Ioffset_cqi(float beta) {
int srslte_sch_init(srslte_sch_t *q) { int srslte_sch_init(srslte_sch_t *q) {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q) { if (q) {
ret = SRSLTE_ERROR;
bzero(q, sizeof(srslte_sch_t)); bzero(q, sizeof(srslte_sch_t));
if (srslte_crc_init(&q->crc_tb, SRSLTE_LTE_CRC24A, 24)) { if (srslte_crc_init(&q->crc_tb, SRSLTE_LTE_CRC24A, 24)) {
@ -754,6 +755,10 @@ int srslte_ulsch_uci_encode(srslte_sch_t *q,
uint32_t nb_q = cfg->nbits.nof_bits; uint32_t nb_q = cfg->nbits.nof_bits;
uint32_t Qm = cfg->grant.Qm; uint32_t Qm = cfg->grant.Qm;
if (Qm == 0) {
return SRSLTE_ERROR_INVALID_INPUTS;
}
if (uci_data.uci_ri_len > 0) { if (uci_data.uci_ri_len > 0) {
float beta = beta_ri_offset[cfg->uci_cfg.I_offset_ri]; float beta = beta_ri_offset[cfg->uci_cfg.I_offset_ri];
if (cfg->cb_segm.tbs == 0) { if (cfg->cb_segm.tbs == 0) {

@ -178,21 +178,10 @@ int main(int argc, char **argv) {
goto quit; goto quit;
} }
switch(mimo_type) { if (mimo_type == SRSLTE_MIMO_TYPE_SINGLE_ANTENNA) {
cell.nof_ports = 1;
case SRSLTE_MIMO_TYPE_SINGLE_ANTENNA: } else {
cell.nof_ports = 1; cell.nof_ports = 2;
break;
case SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX:
case SRSLTE_MIMO_TYPE_CDD:
if (nof_rx_antennas < 2) {
ERROR("At least two receiving antennas are required");
goto quit;
}
case SRSLTE_MIMO_TYPE_TX_DIVERSITY:
default:
cell.nof_ports = 2;
break;
} }
srslte_ra_dl_dci_t dci; srslte_ra_dl_dci_t dci;
@ -250,7 +239,7 @@ int main(int argc, char **argv) {
for (i=0;i<SRSLTE_MAX_PORTS;i++) { for (i=0;i<SRSLTE_MAX_PORTS;i++) {
for (j = 0; j < SRSLTE_MAX_PORTS; j++) { for (j = 0; j < SRSLTE_MAX_PORTS; j++) {
ce[i][j] = srslte_vec_malloc(sizeof(cf_t) * NOF_CE_SYMBOLS); ce[i][j] = srslte_vec_malloc(sizeof(cf_t) * NOF_CE_SYMBOLS);
if (!ce[i]) { if (!ce[i][j]) {
perror("srslte_vec_malloc"); perror("srslte_vec_malloc");
goto quit; goto quit;
} }

@ -176,8 +176,8 @@ int main(int argc, char **argv) {
srslte_rf_set_rx_freq(&rf, uhd_freq); srslte_rf_set_rx_freq(&rf, uhd_freq);
srslte_rf_set_tx_freq(&rf, uhd_freq); srslte_rf_set_tx_freq(&rf, uhd_freq);
if (srate > 1e6) { if (srate > 1e6 && (srate/1000) > 0) {
if (30720%((int) srate/1000) == 0) { if (30720%(srate/1000) == 0) {
srslte_rf_set_master_clock_rate(&rf, 30.72e6); srslte_rf_set_master_clock_rate(&rf, 30.72e6);
} else { } else {
srslte_rf_set_master_clock_rate(&rf, 23.04e6); srslte_rf_set_master_clock_rate(&rf, 23.04e6);

@ -655,11 +655,19 @@ int srslte_uci_encode_ack(srslte_pusch_cfg_t *cfg, uint8_t acks[2], uint32_t nof
uint32_t nof_encoded_bits = encode_ri_ack(acks, nof_acks, q_encoded_bits, cfg->grant.Qm); uint32_t nof_encoded_bits = encode_ri_ack(acks, nof_acks, q_encoded_bits, cfg->grant.Qm);
for (uint32_t i=0;i<Qprime;i++) { if (nof_encoded_bits > 0) {
uci_ulsch_interleave_ack_gen(i, cfg->grant.Qm, H_prime_total, cfg->nbits.nof_symb, cfg->cp, &ack_bits[cfg->grant.Qm*i]); for (uint32_t i = 0; i < Qprime; i++) {
uci_ulsch_interleave_put(&q_encoded_bits[(i*cfg->grant.Qm)%nof_encoded_bits], cfg->grant.Qm, &ack_bits[cfg->grant.Qm*i]); uci_ulsch_interleave_ack_gen(i,
cfg->grant.Qm,
H_prime_total,
cfg->nbits.nof_symb,
cfg->cp,
&ack_bits[cfg->grant.Qm * i]);
uci_ulsch_interleave_put(&q_encoded_bits[(i * cfg->grant.Qm) % nof_encoded_bits],
cfg->grant.Qm,
&ack_bits[cfg->grant.Qm * i]);
}
} }
return (int) Qprime; return (int) Qprime;
} }
@ -706,25 +714,27 @@ int srslte_uci_encode_ack_ri(srslte_pusch_cfg_t *cfg,
uint32_t nof_encoded_bits = encode_ri_ack(data, data_len, q_encoded_bits, cfg->grant.Qm); uint32_t nof_encoded_bits = encode_ri_ack(data, data_len, q_encoded_bits, cfg->grant.Qm);
for (uint32_t i = 0; i < Qprime; i++) { if (nof_encoded_bits > 0) {
if (ack_ri) { for (uint32_t i = 0; i < Qprime; i++) {
uci_ulsch_interleave_ri_gen(i, if (ack_ri) {
cfg->grant.Qm, uci_ulsch_interleave_ri_gen(i,
H_prime_total, cfg->grant.Qm,
cfg->nbits.nof_symb, H_prime_total,
cfg->cp, cfg->nbits.nof_symb,
&bits[cfg->grant.Qm * i]); cfg->cp,
} else { &bits[cfg->grant.Qm * i]);
uci_ulsch_interleave_ack_gen(i, } else {
cfg->grant.Qm, uci_ulsch_interleave_ack_gen(i,
H_prime_total, cfg->grant.Qm,
cfg->nbits.nof_symb, H_prime_total,
cfg->cp, cfg->nbits.nof_symb,
&bits[cfg->grant.Qm * i]); cfg->cp,
&bits[cfg->grant.Qm * i]);
}
uci_ulsch_interleave_put(&q_encoded_bits[(i * cfg->grant.Qm) % nof_encoded_bits],
cfg->grant.Qm,
&bits[cfg->grant.Qm * i]);
} }
uci_ulsch_interleave_put(&q_encoded_bits[(i * cfg->grant.Qm) % nof_encoded_bits],
cfg->grant.Qm,
&bits[cfg->grant.Qm * i]);
} }
return (int) Qprime; return (int) Qprime;

@ -59,7 +59,7 @@ void usage(char *prog) {
printf("Usage: %s [nlestodv] -i cell_id -f input_file_name\n", prog); printf("Usage: %s [nlestodv] -i cell_id -f input_file_name\n", prog);
printf("\t-n nof_frames [Default %d]\n", nof_frames); printf("\t-n nof_frames [Default %d]\n", nof_frames);
printf("\t-l N_id_2 to sync [Default use cell_id]\n"); printf("\t-l N_id_2 to sync [Default use cell_id]\n");
printf("\t-e Extended CP [Default Normal]\n", fft_size); printf("\t-e Extended CP [Default Normal]\n");
printf("\t-s symbol_sz [Default %d]\n", fft_size); printf("\t-s symbol_sz [Default %d]\n", fft_size);
printf("\t-t threshold [Default %.2f]\n", threshold); printf("\t-t threshold [Default %.2f]\n", threshold);
printf("\t-o file read offset [Default %d]\n", file_offset); printf("\t-o file read offset [Default %d]\n", file_offset);
@ -266,7 +266,7 @@ int main(int argc, char **argv) {
} }
} else { } else {
INFO("No space for CFO computation. Frame starts at \n",peak_idx); INFO("No space for CFO computation. Frame starts at \n");
} }
if(srslte_sss_subframe(m0,m1) == 0) if(srslte_sss_subframe(m0,m1) == 0)

@ -61,7 +61,7 @@ void usage(char *prog) {
printf("\t-g RF Gain [Default %.2f dB]\n", rf_gain); printf("\t-g RF Gain [Default %.2f dB]\n", rf_gain);
printf("\t-n nof_frames [Default %d]\n", nof_frames); printf("\t-n nof_frames [Default %d]\n", nof_frames);
printf("\t-l N_id_2 to sync [Default use cell_id]\n"); printf("\t-l N_id_2 to sync [Default use cell_id]\n");
printf("\t-e Extended CP [Default Normal]\n", fft_size); printf("\t-e Extended CP [Default Normal]\n");
printf("\t-s symbol_sz [Default %d]\n", fft_size); printf("\t-s symbol_sz [Default %d]\n", fft_size);
printf("\t-t threshold [Default %.2f]\n", threshold); printf("\t-t threshold [Default %.2f]\n", threshold);
#ifndef DISABLE_GRAPHICS #ifndef DISABLE_GRAPHICS
@ -291,7 +291,7 @@ int main(int argc, char **argv) {
} }
} else { } else {
INFO("No space for CFO computation. Frame starts at \n",peak_idx); INFO("No space for CFO computation. Frame starts at \n");
} }
if(srslte_sss_subframe(m0,m1) == 0) if(srslte_sss_subframe(m0,m1) == 0)

@ -896,7 +896,7 @@ static int find_dl_dci_type_crnti(srslte_ue_dl_t *q, uint32_t tm, uint32_t cfi,
dci_blind_search_t *current_ss = &search_space; dci_blind_search_t *current_ss = &search_space;
if (cfi < 1 || cfi > 3) { if (cfi < 1 || cfi > 3) {
ERROR("CFI must be 1 ≤ cfi ≤ 3", cfi); ERROR("CFI must be 1 ≤ cfi ≤ 3 (cfi=%d)", cfi);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -30,7 +30,14 @@
namespace srslte { namespace srslte {
pdcp::pdcp() pdcp::pdcp()
{} {
rlc = NULL;
rrc = NULL;
gw = NULL;
pdcp_log = NULL;
lcid = 0;
direction = 0;
}
void pdcp::init(srsue::rlc_interface_pdcp *rlc_, srsue::rrc_interface_pdcp *rrc_, srsue::gw_interface_pdcp *gw_, log *pdcp_log_, uint32_t lcid_, uint8_t direction_) void pdcp::init(srsue::rlc_interface_pdcp *rlc_, srsue::rrc_interface_pdcp *rrc_, srsue::gw_interface_pdcp *gw_, log *pdcp_log_, uint32_t lcid_, uint8_t direction_)
{ {

@ -35,6 +35,17 @@ pdcp_entity::pdcp_entity()
,tx_count(0) ,tx_count(0)
{ {
pool = byte_buffer_pool::get_instance(); pool = byte_buffer_pool::get_instance();
log = NULL;
rlc = NULL;
rrc = NULL;
gw = NULL;
lcid = 0;
sn_len_bytes = 0;
do_integrity = false;
do_encryption = false;
rx_count = 0;
cipher_algo = CIPHERING_ALGORITHM_ID_EEA0;
integ_algo = INTEGRITY_ALGORITHM_ID_EIA0;
} }
void pdcp_entity::init(srsue::rlc_interface_pdcp *rlc_, void pdcp_entity::init(srsue::rlc_interface_pdcp *rlc_,

@ -35,6 +35,15 @@ namespace srslte {
rlc::rlc() rlc::rlc()
{ {
pool = byte_buffer_pool::get_instance(); pool = byte_buffer_pool::get_instance();
rlc_log = NULL;
pdcp = NULL;
rrc = NULL;
mac_timers = NULL;
ue = NULL;
default_lcid = 0;
bzero(metrics_time, sizeof(metrics_time));
bzero(ul_tput_bytes, sizeof(ul_tput_bytes));
bzero(dl_tput_bytes, sizeof(dl_tput_bytes));
} }
void rlc::init(srsue::pdcp_interface_rlc *pdcp_, void rlc::init(srsue::pdcp_interface_rlc *pdcp_,
@ -233,7 +242,7 @@ void rlc::add_bearer(uint32_t lcid)
void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg) void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg)
{ {
if(lcid < 0 || lcid >= SRSLTE_N_RADIO_BEARERS) { if(lcid >= SRSLTE_N_RADIO_BEARERS) {
rlc_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid); rlc_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid);
return; return;
} }
@ -271,10 +280,9 @@ void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg)
*******************************************************************************/ *******************************************************************************/
bool rlc::valid_lcid(uint32_t lcid) bool rlc::valid_lcid(uint32_t lcid)
{ {
if(lcid < 0 || lcid >= SRSLTE_N_RADIO_BEARERS) { if(lcid >= SRSLTE_N_RADIO_BEARERS) {
return false; return false;
} } else if(!rlc_array[lcid].active()) {
if(!rlc_array[lcid].active()) {
return false; return false;
} }
return true; return true;

@ -38,6 +38,12 @@ namespace srslte {
rlc_am::rlc_am() : tx_sdu_queue(16) rlc_am::rlc_am() : tx_sdu_queue(16)
{ {
log = NULL;
pdcp = NULL;
rrc = NULL;
lcid = 0;
bzero(&cfg, sizeof(srslte_rlc_am_config_t));
tx_sdu = NULL; tx_sdu = NULL;
rx_sdu = NULL; rx_sdu = NULL;
pool = byte_buffer_pool::get_instance(); pool = byte_buffer_pool::get_instance();
@ -768,7 +774,7 @@ int rlc_am::build_data_pdu(uint8_t *payload, uint32_t nof_bytes)
return (ptr-payload) + pdu->N_bytes; return (ptr-payload) + pdu->N_bytes;
} }
void rlc_am::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t header) void rlc_am::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t &header)
{ {
std::map<uint32_t, rlc_amd_rx_pdu_t>::iterator it; std::map<uint32_t, rlc_amd_rx_pdu_t>::iterator it;
@ -806,7 +812,7 @@ void rlc_am::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_h
memcpy(pdu.buf->msg, payload, nof_bytes); memcpy(pdu.buf->msg, payload, nof_bytes);
pdu.buf->N_bytes = nof_bytes; pdu.buf->N_bytes = nof_bytes;
pdu.header = header; memcpy(&pdu.header, &header, sizeof(rlc_amd_pdu_header_t));
rx_window[header.sn] = pdu; rx_window[header.sn] = pdu;
@ -865,7 +871,7 @@ void rlc_am::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_h
debug_state(); debug_state();
} }
void rlc_am::handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t header) void rlc_am::handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t &header)
{ {
std::map<uint32_t, rlc_amd_rx_pdu_segments_t>::iterator it; std::map<uint32_t, rlc_amd_rx_pdu_segments_t>::iterator it;
@ -891,7 +897,7 @@ void rlc_am::handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_a
} }
memcpy(segment.buf->msg, payload, nof_bytes); memcpy(segment.buf->msg, payload, nof_bytes);
segment.buf->N_bytes = nof_bytes; segment.buf->N_bytes = nof_bytes;
segment.header = header; memcpy(&segment.header, &header, sizeof(rlc_amd_pdu_header_t));
// Check if we already have a segment from the same PDU // Check if we already have a segment from the same PDU
it = rx_segments.find(header.sn); it = rx_segments.find(header.sn);

@ -31,6 +31,10 @@ namespace srslte {
rlc_tm::rlc_tm() : ul_queue(16) rlc_tm::rlc_tm() : ul_queue(16)
{ {
log = NULL;
pdcp = NULL;
rrc = NULL;
lcid = 0;
pool = byte_buffer_pool::get_instance(); pool = byte_buffer_pool::get_instance();
} }

@ -33,6 +33,14 @@ namespace srslte {
rlc_um::rlc_um() : tx_sdu_queue(16) rlc_um::rlc_um() : tx_sdu_queue(16)
{ {
log = NULL;
pdcp = NULL;
rrc = NULL;
reordering_timer = NULL;
lcid = 0;
reordering_timer_id = 0;
bzero(&cfg, sizeof(srslte_rlc_um_config_t));
tx_sdu = NULL; tx_sdu = NULL;
rx_sdu = NULL; rx_sdu = NULL;
pool = byte_buffer_pool::get_instance(); pool = byte_buffer_pool::get_instance();

@ -67,7 +67,7 @@ void write(std::string filename) {
bool read(std::string filename) { bool read(std::string filename) {
bool pass = true; bool pass = true;
bool written[NTHREADS][NMSGS]; bool written[NTHREADS][NMSGS];
int thread, msg; int thread = 0, msg = 0;
int r; int r;
for(int i=0;i<NTHREADS;i++) { for(int i=0;i<NTHREADS;i++) {
@ -78,7 +78,12 @@ bool read(std::string filename) {
FILE *f = fopen(filename.c_str(), "r"); FILE *f = fopen(filename.c_str(), "r");
if(f!=NULL) { if(f!=NULL) {
while(fscanf(f, "Thread %d: %d\n", &thread, &msg)) { while(fscanf(f, "Thread %d: %d\n", &thread, &msg)) {
written[thread][msg] = true; if (thread < NTHREADS && msg < NMSGS) {
written[thread][msg] = true;
} else {
perror("Wrong thread and/or msg");
return false;
}
} }
fclose(f); fclose(f);
} }
@ -95,7 +100,11 @@ int main(int argc, char **argv) {
std::string f("log.txt"); std::string f("log.txt");
write(f); write(f);
result = read(f); result = read(f);
remove(f.c_str());
if (remove(f.c_str())) {
perror("Removing file");
}
if(result) { if(result) {
printf("Passed\n"); printf("Passed\n");
exit(0); exit(0);

@ -39,6 +39,7 @@ public:
finished = false; finished = false;
pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&cvar, NULL); pthread_cond_init(&cvar, NULL);
bzero(&start_time, sizeof(start_time));
} }
void timeout_expired(uint32_t timeout_id) void timeout_expired(uint32_t timeout_id)

@ -54,7 +54,10 @@ class rlc_am_tester
,public rrc_interface_rlc ,public rrc_interface_rlc
{ {
public: public:
rlc_am_tester(){n_sdus = 0;} rlc_am_tester(){
bzero(sdus, sizeof(sdus));
n_sdus = 0;
}
// PDCP interface // PDCP interface
void write_pdu(uint32_t lcid, byte_buffer_t *sdu) void write_pdu(uint32_t lcid, byte_buffer_t *sdu)

@ -57,7 +57,10 @@ class rlc_um_tester
,public rrc_interface_rlc ,public rrc_interface_rlc
{ {
public: public:
rlc_um_tester(){n_sdus = 0;} rlc_um_tester(){
bzero(sdus, sizeof(sdus));
n_sdus = 0;
}
// PDCP interface // PDCP interface
void write_pdu(uint32_t lcid, byte_buffer_t *sdu) void write_pdu(uint32_t lcid, byte_buffer_t *sdu)

@ -43,7 +43,14 @@ class ue : public srslte::read_pdu_interface,
{ {
public: public:
ue() : mac_msg_dl(20), mac_msg_ul(20), pdus(128) { ue() : mac_msg_dl(20), mac_msg_ul(20), conres_id_available(false),
dl_ri_counter(0),
dl_pmi_counter(0),
conres_id(0),
last_tti(0),
pdus(128) {
rrc = NULL;
sched = NULL;
rlc = NULL; rlc = NULL;
log_h = NULL; log_h = NULL;
rnti = 0; rnti = 0;
@ -55,6 +62,14 @@ public:
for (int i=0;i<NOF_HARQ_PROCESSES;i++) { for (int i=0;i<NOF_HARQ_PROCESSES;i++) {
pending_buffers[i] = NULL; pending_buffers[i] = NULL;
} }
bzero(&metrics, sizeof(mac_metrics_t));
bzero(&mutex, sizeof(pthread_mutex_t));
bzero(softbuffer_tx, sizeof(softbuffer_tx));
bzero(softbuffer_rx, sizeof(softbuffer_rx));
for (int i = 0; i < SRSLTE_MAX_TB; ++i) {
bzero(tx_payload_buffer, sizeof(uint8_t) * payload_buffer_len);
}
pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&mutex, NULL);
} }

@ -57,6 +57,16 @@ public:
nof_mutex = 0; nof_mutex = 0;
max_mutex = max_mutex_; max_mutex = max_mutex_;
params.max_prach_offset_us = 20; params.max_prach_offset_us = 20;
radio = NULL;
mac = NULL;
is_first_tx = false;
is_first_of_burst = false;
pdsch_p_b = 0;
nof_workers = 0;
bzero(&pusch_cfg, sizeof(pusch_cfg));
bzero(&hopping_cfg, sizeof(hopping_cfg));
bzero(&pucch_cfg, sizeof(pucch_cfg));
bzero(&ul_grants, sizeof(ul_grants));
} }
bool init(srslte_cell_t *cell, srslte::radio *radio_handler, mac_interface_phy *mac); bool init(srslte_cell_t *cell, srslte::radio *radio_handler, mac_interface_phy *mac);

@ -103,7 +103,11 @@ private:
class ue { class ue {
public: public:
ue() : I_sr(0), I_sr_en(false), cqi_en(false), pucch_cqi_ack(false), pmi_idx(0), has_grant_tti(0), ue() : I_sr(0), I_sr_en(false), cqi_en(false), pucch_cqi_ack(false), pmi_idx(0), has_grant_tti(0),
dedicated_ack(false) {bzero(&metrics, sizeof(phy_metrics_t));} dedicated_ack(false), ri_idx(0), ri_en(false), rnti(0) {
bzero(&dedicated, sizeof(LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT));
bzero(&phich_info, sizeof(srslte_enb_ul_phich_info_t));
bzero(&metrics, sizeof(phy_metrics_t));
}
uint32_t I_sr; uint32_t I_sr;
uint32_t pmi_idx; uint32_t pmi_idx;
uint32_t ri_idx; uint32_t ri_idx;

@ -36,7 +36,20 @@ namespace srsenb {
class prach_worker : thread class prach_worker : thread
{ {
public: public:
prach_worker() : initiated(false),max_prach_offset_us(0) {} prach_worker() : initiated(false), prach_nof_det(0), max_prach_offset_us(0), pending_tti(0), processed_tti(0),
running(false), nof_sf(0), sf_cnt(0) {
log_h = NULL;
mac = NULL;
signal_buffer_rx = NULL;
bzero(&prach, sizeof(srslte_prach_t));
bzero(&prach_indices, sizeof(prach_indices));
bzero(&prach_offsets, sizeof(prach_offsets));
bzero(&prach_p2avg, sizeof(prach_p2avg));
bzero(&cell, sizeof(cell));
bzero(&prach_cfg, sizeof(prach_cfg));
bzero(&mutex, sizeof(mutex));
bzero(&cvar, sizeof(cvar));
}
int init(srslte_cell_t *cell, srslte_prach_cfg_t *prach_cfg, mac_interface_phy *mac, srslte::log *log_h, int priority); int init(srslte_cell_t *cell, srslte_prach_cfg_t *prach_cfg, mac_interface_phy *mac, srslte::log *log_h, int priority);
int new_tti(uint32_t tti, cf_t *buffer); int new_tti(uint32_t tti, cf_t *buffer);

@ -104,7 +104,27 @@ class rrc : public rrc_interface_pdcp,
{ {
public: public:
rrc() : act_monitor(this), cnotifier(NULL) {} rrc() : act_monitor(this), cnotifier(NULL), running(false), nof_si_messages(0) {
users.clear();
pending_paging.clear();
pool = NULL;
phy = NULL;
mac = NULL;
rlc = NULL;
pdcp = NULL;
gtpu = NULL;
s1ap = NULL;
rrc_log = NULL;
bzero(&sr_sched, sizeof(sr_sched));
bzero(&cqi_sched, sizeof(cqi_sched));
bzero(&cfg, sizeof(cfg));
bzero(&sib2, sizeof(sib2));
bzero(&user_mutex, sizeof(user_mutex));
bzero(&paging_mutex, sizeof(paging_mutex));
}
void init(rrc_cfg_t *cfg, void init(rrc_cfg_t *cfg,
phy_interface_rrc *phy, phy_interface_rrc *phy,

@ -54,11 +54,14 @@ void enb::cleanup(void)
} }
} }
enb::enb() enb::enb() : started(false) {
:started(false)
{
srslte_dft_load(); srslte_dft_load();
pool = srslte::byte_buffer_pool::get_instance(); pool = srslte::byte_buffer_pool::get_instance();
logger = NULL;
args = NULL;
bzero(&rf_metrics, sizeof(rf_metrics));
} }
enb::~enb() enb::~enb()

@ -55,8 +55,8 @@ int enb::parse_cell_cfg(all_args_t *args, srslte_cell_t *cell) {
); );
parser::parse_section(args->enb_files.rr_config, &phy_cnfg); parser::parse_section(args->enb_files.rr_config, &phy_cnfg);
cell->phich_length = (srslte_phich_length_t) phichcfg.dur; cell->phich_length = (srslte_phich_length_t) (int) phichcfg.dur;
cell->phich_resources = (srslte_phich_resources_t) phichcfg.res; cell->phich_resources = (srslte_phich_resources_t) (int) phichcfg.res;
if (!srslte_cell_isvalid(cell)) { if (!srslte_cell_isvalid(cell)) {
fprintf(stderr, "Invalid cell parameters: nof_prb=%d, cell_id=%d\n", args->enb.n_prb, args->enb.s1ap.cell_id); fprintf(stderr, "Invalid cell parameters: nof_prb=%d, cell_id=%d\n", args->enb.n_prb, args->enb.s1ap.cell_id);
@ -845,7 +845,7 @@ int enb::parse_rr(all_args_t* args, rrc_cfg_t* rrc_cfg)
{ {
/* Transmission mode config section */ /* Transmission mode config section */
if (args->enb.transmission_mode < 0 || args->enb.transmission_mode > 4) { if (args->enb.transmission_mode < 1 || args->enb.transmission_mode > 4) {
ERROR("Invalid transmission mode (%d). Only indexes 1-4 are implemented.\n", args->enb.transmission_mode); ERROR("Invalid transmission mode (%d). Only indexes 1-4 are implemented.\n", args->enb.transmission_mode);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} else if (args->enb.transmission_mode == 1 && args->enb.nof_ports > 1) { } else if (args->enb.transmission_mode == 1 && args->enb.nof_ports > 1) {

@ -42,13 +42,26 @@
namespace srsenb { namespace srsenb {
mac::mac() : timers_db(128), mac::mac() : timers_db(128), timers_thread(&timers_db), tti(0), last_rnti(0),
timers_thread(&timers_db), rar_pdu_msg(sched_interface::MAX_RAR_LIST), rar_payload(),
rar_pdu_msg(sched_interface::MAX_RAR_LIST),
pdu_process_thread(this) pdu_process_thread(this)
{ {
started = false; started = false;
pcap = NULL; pcap = NULL;
phy_h = NULL;
rlc_h = NULL;
rrc_h = NULL;
log_h = NULL;
bzero(&locations, sizeof(locations));
bzero(&cell, sizeof(cell));
bzero(&args, sizeof(args));
bzero(&pending_rars, sizeof(pending_rars));
bzero(&bcch_dlsch_payload, sizeof(bcch_dlsch_payload));
bzero(&pcch_payload_buffer, sizeof(pcch_payload_buffer));
bzero(&bcch_softbuffer_tx, sizeof(bcch_softbuffer_tx));
bzero(&pcch_softbuffer_tx, sizeof(pcch_softbuffer_tx));
bzero(&rar_softbuffer_tx, sizeof(rar_softbuffer_tx));
} }
bool mac::init(mac_args_t *args_, srslte_cell_t *cell_, phy_interface_mac *phy, rlc_interface_mac *rlc, rrc_interface_mac *rrc, srslte::log *log_h_) bool mac::init(mac_args_t *args_, srslte_cell_t *cell_, phy_interface_mac *phy, rlc_interface_mac *rlc, rrc_interface_mac *rrc, srslte::log *log_h_)
@ -722,8 +735,7 @@ void mac::timer_thread::tti_clock()
* DEMU unit * DEMU unit
* *
*******************************************************/ *******************************************************/
mac::pdu_process::pdu_process(pdu_process_handler *h) mac::pdu_process::pdu_process(pdu_process_handler *h) : running(false) {
{
handler = h; handler = h;
pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&cvar, NULL); pthread_cond_init(&cvar, NULL);

@ -18,10 +18,26 @@ namespace srsenb {
* Initialization and sched configuration functions * Initialization and sched configuration functions
* *
*******************************************************/ *******************************************************/
sched::sched() sched::sched() : bc_aggr_level(0), rar_aggr_level(0), avail_rbg(0), P(0), start_rbg(0), si_n_rbg(0), rar_n_rb(0),
{ nof_rbg(0), sf_idx(0), sfn(0), current_cfi(0) {
current_tti = 0; current_tti = 0;
log_h = NULL; log_h = NULL;
dl_metric = NULL;
ul_metric = NULL;
rrc = NULL;
bzero(&cfg, sizeof(cfg));
bzero(&regs, sizeof(regs));
bzero(&used_cce, sizeof(used_cce));
bzero(&sched_cfg, sizeof(sched_cfg));
bzero(&common_locations, sizeof(common_locations));
bzero(&pdsch_re, sizeof(pdsch_re));
bzero(&mutex, sizeof(mutex));
for (int i = 0; i < 3; i++) {
bzero(rar_locations[i], sizeof(sched_ue::sched_dci_cce_t) * 10);
}
pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&mutex, NULL);
reset(); reset();
} }
@ -80,7 +96,10 @@ int sched::cell_cfg(sched_interface::cell_cfg_t* cell_cfg)
memcpy(&cfg, cell_cfg, sizeof(sched_interface::cell_cfg_t)); memcpy(&cfg, cell_cfg, sizeof(sched_interface::cell_cfg_t));
// Get DCI locations // Get DCI locations
srslte_regs_init(&regs, cfg.cell); if (srslte_regs_init(&regs, cfg.cell)) {
Error("Getting DCI locations\n");
return SRSLTE_ERROR;
}
P = srslte_ra_type0_P(cfg.cell.nof_prb); P = srslte_ra_type0_P(cfg.cell.nof_prb);
si_n_rbg = 4/P; si_n_rbg = 4/P;

@ -49,8 +49,17 @@ namespace srsenb {
* *
*******************************************************/ *******************************************************/
sched_ue::sched_ue() sched_ue::sched_ue() : ue_idx(0), has_pucch(false), power_headroom(0), rnti(0), max_mcs_dl(0), max_mcs_ul(0),
fixed_mcs_ul(0), fixed_mcs_dl(0), phy_config_dedicated_enabled(false)
{ {
log_h = NULL;
bzero(&cell, sizeof(cell));
bzero(&lch, sizeof(lch));
bzero(&dci_locations, sizeof(dci_locations));
bzero(&dl_harq, sizeof(dl_harq));
bzero(&ul_harq, sizeof(ul_harq));
bzero(&dl_ant_info, sizeof(dl_ant_info));
reset(); reset();
} }
@ -102,6 +111,10 @@ void sched_ue::reset()
ul_cqi = 1; ul_cqi = 1;
dl_cqi_tti = 0; dl_cqi_tti = 0;
ul_cqi_tti = 0; ul_cqi_tti = 0;
dl_ri = 0;
dl_ri_tti = 0;
dl_pmi = 0;
dl_pmi_tti = 0;
cqi_request_tti = 0; cqi_request_tti = 0;
for (int i=0;i<SCHED_MAX_HARQ_PROC;i++) { for (int i=0;i<SCHED_MAX_HARQ_PROC;i++) {
for(uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { for(uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) {

@ -368,8 +368,7 @@ uint8_t* ue::generate_pdu(uint32_t tb_idx, sched_interface::dl_sched_pdu_t pdu[s
{ {
uint8_t *ret = NULL; uint8_t *ret = NULL;
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
if (rlc) if (rlc) {
{
mac_msg_dl.init_tx(tx_payload_buffer[tb_idx], grant_size, false); mac_msg_dl.init_tx(tx_payload_buffer[tb_idx], grant_size, false);
for (uint32_t i=0;i<nof_pdu_elems;i++) { for (uint32_t i=0;i<nof_pdu_elems;i++) {
if (pdu[i].lcid <= srslte::sch_subh::PHR_REPORT) { if (pdu[i].lcid <= srslte::sch_subh::PHR_REPORT) {
@ -383,7 +382,6 @@ uint8_t* ue::generate_pdu(uint32_t tb_idx, sched_interface::dl_sched_pdu_t pdu[s
} else { } else {
std::cout << "Error ue not configured (must call config() first" << std::endl; std::cout << "Error ue not configured (must call config() first" << std::endl;
return NULL;
} }
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);

@ -35,6 +35,7 @@
#include <iostream> #include <iostream>
#include <stdio.h> #include <stdio.h>
#include <string.h>
using namespace std; using namespace std;
@ -46,11 +47,11 @@ char const * const prefixes[2][9] =
{ "", "k", "M", "G", "T", "P", "E", "Z", "Y", }, { "", "k", "M", "G", "T", "P", "E", "Z", "Y", },
}; };
metrics_stdout::metrics_stdout() metrics_stdout::metrics_stdout() : started(false) ,do_print(false), metrics_report_period(0.0f),n_reports(10)
:started(false)
,do_print(false)
,n_reports(10)
{ {
enb_ = NULL;
bzero(&metrics_thread, sizeof(metrics_thread));
bzero(&metrics, sizeof(metrics));
} }
bool metrics_stdout::init(enb_metrics_interface *u, float report_period_secs) bool metrics_stdout::init(enb_metrics_interface *u, float report_period_secs)
@ -101,6 +102,8 @@ void metrics_stdout::metrics_thread_run()
void metrics_stdout::print_metrics() void metrics_stdout::print_metrics()
{ {
std::ios::fmtflags f(cout.flags()); // For avoiding Coverity defect: Not restoring ostream format
if(!do_print) if(!do_print)
return; return;
@ -158,6 +161,7 @@ void metrics_stdout::print_metrics()
printf("RF status: O=%d, U=%d, L=%d\n", metrics.rf.rf_o, metrics.rf.rf_u, metrics.rf.rf_l); printf("RF status: O=%d, U=%d, L=%d\n", metrics.rf.rf_o, metrics.rf.rf_u, metrics.rf.rf_l);
} }
cout.flags(f); // For avoiding Coverity defect: Not restoring ostream format
} }
void metrics_stdout::print_disconnect() void metrics_stdout::print_disconnect()

@ -73,6 +73,11 @@ namespace srsenb {
phch_worker::phch_worker() phch_worker::phch_worker()
{ {
phy = NULL; phy = NULL;
bzero(&enb_dl, sizeof(enb_dl));
bzero(&enb_ul, sizeof(enb_ul));
bzero(&tx_time, sizeof(tx_time));
reset(); reset();
} }

@ -48,8 +48,11 @@ namespace srsenb {
phy::phy() : workers_pool(MAX_WORKERS), phy::phy() : workers_pool(MAX_WORKERS),
workers(MAX_WORKERS), workers(MAX_WORKERS),
workers_common(txrx::MUTEX_X_WORKER*MAX_WORKERS) workers_common(txrx::MUTEX_X_WORKER*MAX_WORKERS),
nof_workers(0)
{ {
radio_handler = NULL;
bzero(&prach_cfg, sizeof(prach_cfg));
} }
void phy::parse_config(phy_cfg_t* cfg) void phy::parse_config(phy_cfg_t* cfg)

@ -42,13 +42,13 @@ using namespace std;
namespace srsenb { namespace srsenb {
txrx::txrx() txrx::txrx() : tx_mutex_cnt(0), nof_tx_mutex(0), tti(0) {
{
running = false; running = false;
radio_h = NULL; radio_h = NULL;
log_h = NULL; log_h = NULL;
workers_pool = NULL; workers_pool = NULL;
worker_com = NULL; worker_com = NULL;
prach = NULL;
} }
bool txrx::init(srslte::radio* radio_h_, srslte::thread_pool* workers_pool_, phch_common* worker_com_, prach_worker *prach_, srslte::log* log_h_, uint32_t prio_) bool txrx::init(srslte::radio* radio_h_, srslte::thread_pool* workers_pool_, phch_common* worker_com_, prach_worker *prach_, srslte::log* log_h_, uint32_t prio_)

@ -554,60 +554,66 @@ void rrc::parse_ul_ccch(uint16_t rnti, byte_buffer_t *pdu)
{ {
uint16_t old_rnti = 0; uint16_t old_rnti = 0;
LIBLTE_RRC_UL_CCCH_MSG_STRUCT ul_ccch_msg; if (pdu) {
bzero(&ul_ccch_msg, sizeof(LIBLTE_RRC_UL_CCCH_MSG_STRUCT)); LIBLTE_RRC_UL_CCCH_MSG_STRUCT ul_ccch_msg;
bzero(&ul_ccch_msg, sizeof(LIBLTE_RRC_UL_CCCH_MSG_STRUCT));
srslte_bit_unpack_vector(pdu->msg, bit_buf.msg, pdu->N_bytes*8); srslte_bit_unpack_vector(pdu->msg, bit_buf.msg, pdu->N_bytes * 8);
bit_buf.N_bits = pdu->N_bytes*8; bit_buf.N_bits = pdu->N_bytes * 8;
liblte_rrc_unpack_ul_ccch_msg((LIBLTE_BIT_MSG_STRUCT*)&bit_buf, &ul_ccch_msg); liblte_rrc_unpack_ul_ccch_msg((LIBLTE_BIT_MSG_STRUCT *) &bit_buf, &ul_ccch_msg);
rrc_log->info_hex(pdu->msg, pdu->N_bytes, rrc_log->info_hex(pdu->msg, pdu->N_bytes,
"SRB0 - Rx: %s", "SRB0 - Rx: %s",
liblte_rrc_ul_ccch_msg_type_text[ul_ccch_msg.msg_type]); liblte_rrc_ul_ccch_msg_type_text[ul_ccch_msg.msg_type]);
switch(ul_ccch_msg.msg_type) { switch (ul_ccch_msg.msg_type) {
case LIBLTE_RRC_UL_CCCH_MSG_TYPE_RRC_CON_REQ: case LIBLTE_RRC_UL_CCCH_MSG_TYPE_RRC_CON_REQ:
if (users.count(rnti)) { if (users.count(rnti)) {
users[rnti].handle_rrc_con_req(&ul_ccch_msg.msg.rrc_con_req); users[rnti].handle_rrc_con_req(&ul_ccch_msg.msg.rrc_con_req);
} else {
rrc_log->error("Received ConnectionSetup for rnti=0x%x without context\n", rnti);
}
break;
case LIBLTE_RRC_UL_CCCH_MSG_TYPE_RRC_CON_REEST_REQ:
rrc_log->debug("rnti=0x%x, phyid=0x%x, smac=0x%x, cause=%s\n",
ul_ccch_msg.msg.rrc_con_reest_req.ue_id.c_rnti, ul_ccch_msg.msg.rrc_con_reest_req.ue_id.phys_cell_id,
ul_ccch_msg.msg.rrc_con_reest_req.ue_id.short_mac_i, liblte_rrc_con_reest_req_cause_text[ul_ccch_msg.msg.rrc_con_reest_req.cause]
);
if (users[rnti].is_idle()) {
old_rnti = ul_ccch_msg.msg.rrc_con_reest_req.ue_id.c_rnti;
if (users.count(old_rnti)) {
rrc_log->error("Not supported: ConnectionReestablishment. Sending Connection Reject\n", old_rnti);
users[rnti].send_connection_reest_rej();
rem_user_thread(old_rnti);
} else { } else {
rrc_log->error("Received ConnectionReestablishment for rnti=0x%x without context\n", old_rnti); rrc_log->error("Received ConnectionSetup for rnti=0x%x without context\n", rnti);
users[rnti].send_connection_reest_rej();
} }
// remove temporal rnti break;
rem_user_thread(rnti); case LIBLTE_RRC_UL_CCCH_MSG_TYPE_RRC_CON_REEST_REQ:
} else { rrc_log->debug("rnti=0x%x, phyid=0x%x, smac=0x%x, cause=%s\n",
rrc_log->error("Received ReestablishmentRequest from an rnti=0x%x not in IDLE\n", rnti); ul_ccch_msg.msg.rrc_con_reest_req.ue_id.c_rnti,
} ul_ccch_msg.msg.rrc_con_reest_req.ue_id.phys_cell_id,
break; ul_ccch_msg.msg.rrc_con_reest_req.ue_id.short_mac_i,
default: liblte_rrc_con_reest_req_cause_text[ul_ccch_msg.msg.rrc_con_reest_req.cause]
rrc_log->error("UL CCCH message not recognised\n"); );
break; if (users[rnti].is_idle()) {
} old_rnti = ul_ccch_msg.msg.rrc_con_reest_req.ue_id.c_rnti;
if (users.count(old_rnti)) {
rrc_log->error("Not supported: ConnectionReestablishment. Sending Connection Reject\n", old_rnti);
users[rnti].send_connection_reest_rej();
rem_user_thread(old_rnti);
} else {
rrc_log->error("Received ConnectionReestablishment for rnti=0x%x without context\n", old_rnti);
users[rnti].send_connection_reest_rej();
}
// remove temporal rnti
rem_user_thread(rnti);
} else {
rrc_log->error("Received ReestablishmentRequest from an rnti=0x%x not in IDLE\n", rnti);
}
break;
default:
rrc_log->error("UL CCCH message not recognised\n");
break;
}
pool->deallocate(pdu); pool->deallocate(pdu);
}
} }
void rrc::parse_ul_dcch(uint16_t rnti, uint32_t lcid, byte_buffer_t *pdu) void rrc::parse_ul_dcch(uint16_t rnti, uint32_t lcid, byte_buffer_t *pdu)
{ {
if (users.count(rnti)) { if (pdu) {
users[rnti].parse_ul_dcch(lcid, pdu); if (users.count(rnti)) {
} else { users[rnti].parse_ul_dcch(lcid, pdu);
rrc_log->error("Processing %s: Unkown rnti=0x%x\n", rb_id_text[lcid], rnti); } else {
rrc_log->error("Processing %s: Unkown rnti=0x%x\n", rb_id_text[lcid], rnti);
}
} }
} }
@ -1757,7 +1763,7 @@ int rrc::ue::cqi_allocate(uint32_t period, uint32_t *pmi_idx, uint32_t *n_pucch)
*pmi_idx = 318 + parent->cfg.cqi_cfg.sf_mapping[j_min]; *pmi_idx = 318 + parent->cfg.cqi_cfg.sf_mapping[j_min];
} else if (period == 64) { } else if (period == 64) {
*pmi_idx = 350 + parent->cfg.cqi_cfg.sf_mapping[j_min]; *pmi_idx = 350 + parent->cfg.cqi_cfg.sf_mapping[j_min];
} else if (period == 64) { } else if (period == 128) {
*pmi_idx = 414 + parent->cfg.cqi_cfg.sf_mapping[j_min]; *pmi_idx = 414 + parent->cfg.cqi_cfg.sf_mapping[j_min];
} }
} }

@ -193,6 +193,7 @@ s1ap::enb_listen()
evnts.sctp_data_io_event = 1; evnts.sctp_data_io_event = 1;
evnts.sctp_shutdown_event=1; evnts.sctp_shutdown_event=1;
if(setsockopt(sock_fd, IPPROTO_SCTP, SCTP_EVENTS, &evnts, sizeof (evnts))){ if(setsockopt(sock_fd, IPPROTO_SCTP, SCTP_EVENTS, &evnts, sizeof (evnts))){
close(sock_fd);
m_s1ap_log->console("Subscribing to sctp_data_io_events failed\n"); m_s1ap_log->console("Subscribing to sctp_data_io_events failed\n");
return -1; return -1;
} }
@ -204,6 +205,7 @@ s1ap::enb_listen()
s1mme_addr.sin_port = htons(S1MME_PORT); s1mme_addr.sin_port = htons(S1MME_PORT);
err = bind(sock_fd, (struct sockaddr*) &s1mme_addr, sizeof (s1mme_addr)); err = bind(sock_fd, (struct sockaddr*) &s1mme_addr, sizeof (s1mme_addr));
if (err != 0){ if (err != 0){
close(sock_fd);
m_s1ap_log->error("Error binding SCTP socket\n"); m_s1ap_log->error("Error binding SCTP socket\n");
m_s1ap_log->console("Error binding SCTP socket\n"); m_s1ap_log->console("Error binding SCTP socket\n");
return -1; return -1;
@ -212,6 +214,7 @@ s1ap::enb_listen()
//Listen for connections //Listen for connections
err = listen(sock_fd,SOMAXCONN); err = listen(sock_fd,SOMAXCONN);
if (err != 0){ if (err != 0){
close(sock_fd);
m_s1ap_log->error("Error in SCTP socket listen\n"); m_s1ap_log->error("Error in SCTP socket listen\n");
m_s1ap_log->console("Error in SCTP socket listen\n"); m_s1ap_log->console("Error in SCTP socket listen\n");
return -1; return -1;

@ -428,22 +428,19 @@ s1ap_nas_transport::handle_nas_authentication_response(srslte::byte_buffer_t *na
bool ue_valid=true; bool ue_valid=true;
m_s1ap_log->console("Authentication Response -- IMSI %015lu\n", ue_ctx->imsi); m_s1ap_log->console("Authentication Response -- IMSI %015lu\n", ue_ctx->imsi);
m_s1ap_log->console("Authentication Response -- RES 0x%x%x%x%x%x%x%x%x\n",
auth_resp.res[0],
auth_resp.res[1],
auth_resp.res[2],
auth_resp.res[3],
auth_resp.res[4],
auth_resp.res[5],
auth_resp.res[6],
auth_resp.res[7]
);
//Get NAS authentication response //Get NAS authentication response
LIBLTE_ERROR_ENUM err = liblte_mme_unpack_authentication_response_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_msg, &auth_resp); LIBLTE_ERROR_ENUM err = liblte_mme_unpack_authentication_response_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_msg, &auth_resp);
if(err != LIBLTE_SUCCESS){ if(err != LIBLTE_SUCCESS){
m_s1ap_log->error("Error unpacking NAS authentication response. Error: %s\n", liblte_error_text[err]); m_s1ap_log->error("Error unpacking NAS authentication response. Error: %s\n", liblte_error_text[err]);
return false; return false;
} }
m_s1ap_log->console("Authentication Response -- RES 0x%x%x%x%x%x%x%x%x\n",
auth_resp.res[0], auth_resp.res[1], auth_resp.res[2], auth_resp.res[3],
auth_resp.res[4], auth_resp.res[5], auth_resp.res[6], auth_resp.res[7]);
m_s1ap_log->info("Authentication Response -- RES 0x%x%x%x%x%x%x%x%x\n",
auth_resp.res[0], auth_resp.res[1], auth_resp.res[2], auth_resp.res[3],
auth_resp.res[4], auth_resp.res[5], auth_resp.res[6], auth_resp.res[7]);
for(int i=0; i<8;i++) for(int i=0; i<8;i++)
{ {
@ -547,7 +544,7 @@ s1ap_nas_transport::handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, u
m_s1ap_log->console("Unpacked Attached Complete Message\n"); m_s1ap_log->console("Unpacked Attached Complete Message\n");
m_s1ap_log->console("Unpacked Activavate Default EPS Bearer message. EPS Bearer id %d\n",act_bearer.eps_bearer_id); m_s1ap_log->console("Unpacked Activavate Default EPS Bearer message. EPS Bearer id %d\n",act_bearer.eps_bearer_id);
//ue_ctx->erabs_ctx[act_bearer->eps_bearer_id].enb_fteid; //ue_ctx->erabs_ctx[act_bearer->eps_bearer_id].enb_fteid;
if(act_bearer.eps_bearer_id < 5 || act_bearer.eps_bearer_id > 16) if(act_bearer.eps_bearer_id < 5 || act_bearer.eps_bearer_id > 15)
{ {
m_s1ap_log->error("EPS Bearer ID out of range\n"); m_s1ap_log->error("EPS Bearer ID out of range\n");
return false; return false;
@ -1091,6 +1088,14 @@ s1ap_nas_transport::pack_attach_accept(ue_ctx_t *ue_ctx, LIBLTE_S1AP_E_RABTOBESE
act_def_eps_bearer_context_req.protocol_cnfg_opts.opt[0].contents[2] = 8; act_def_eps_bearer_context_req.protocol_cnfg_opts.opt[0].contents[2] = 8;
act_def_eps_bearer_context_req.protocol_cnfg_opts.opt[0].contents[3] = 8; act_def_eps_bearer_context_req.protocol_cnfg_opts.opt[0].contents[3] = 8;
//Make sure all unused options are set to false
act_def_eps_bearer_context_req.negotiated_qos_present = false;
act_def_eps_bearer_context_req.llc_sapi_present = false;
act_def_eps_bearer_context_req.radio_prio_present = false;
act_def_eps_bearer_context_req.packet_flow_id_present = false;
act_def_eps_bearer_context_req.apn_ambr_present = false;
act_def_eps_bearer_context_req.esm_cause_present = false;
uint8_t sec_hdr_type =2; uint8_t sec_hdr_type =2;
ue_ctx->security_ctxt.dl_nas_count++; ue_ctx->security_ctxt.dl_nas_count++;
liblte_mme_pack_activate_default_eps_bearer_context_request_msg(&act_def_eps_bearer_context_req, &attach_accept.esm_msg); liblte_mme_pack_activate_default_eps_bearer_context_request_msg(&act_def_eps_bearer_context_req, &attach_accept.esm_msg);

@ -175,7 +175,9 @@ spgw::init_sgi_if(spgw_args_t *args)
memset(&ifr, 0, sizeof(ifr)); memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TUN | IFF_NO_PI; ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
strncpy(ifr.ifr_ifrn.ifrn_name, dev, IFNAMSIZ); strncpy(ifr.ifr_ifrn.ifrn_name, dev, IFNAMSIZ-1);
ifr.ifr_ifrn.ifrn_name[IFNAMSIZ-1]='\0';
if(ioctl(m_sgi_if, TUNSETIFF, &ifr) < 0) if(ioctl(m_sgi_if, TUNSETIFF, &ifr) < 0)
{ {
m_spgw_log->error("Failed to set TUN device name: %s\n", strerror(errno)); m_spgw_log->error("Failed to set TUN device name: %s\n", strerror(errno));

@ -49,8 +49,7 @@ public:
metrics_csv(std::string filename); metrics_csv(std::string filename);
~metrics_csv(); ~metrics_csv();
void set_periodicity(float metrics_report_period_sec); void set_metrics(ue_metrics_t &m, const uint32_t period_usec);
void set_metrics(ue_metrics_t &m);
void set_ue_handle(ue_metrics_interface *ue_); void set_ue_handle(ue_metrics_interface *ue_);
void stop(); void stop();

@ -48,7 +48,7 @@ public:
void set_periodicity(float metrics_report_period_sec); void set_periodicity(float metrics_report_period_sec);
void toggle_print(bool b); void toggle_print(bool b);
void set_metrics(ue_metrics_t &m); void set_metrics(ue_metrics_t &m, const uint32_t period_usec);
void set_ue_handle(ue_metrics_interface *ue_); void set_ue_handle(ue_metrics_interface *ue_);
void stop() {}; void stop() {};

@ -447,13 +447,11 @@ int main(int argc, char *argv[])
metricshub.init(ue, args.expert.metrics_period_secs); metricshub.init(ue, args.expert.metrics_period_secs);
metricshub.add_listener(&metrics_screen); metricshub.add_listener(&metrics_screen);
metrics_screen.set_ue_handle(ue); metrics_screen.set_ue_handle(ue);
metrics_screen.set_periodicity(args.expert.metrics_period_secs);
metrics_csv metrics_file(args.expert.metrics_csv_filename); metrics_csv metrics_file(args.expert.metrics_csv_filename);
if (args.expert.metrics_csv_enable) { if (args.expert.metrics_csv_enable) {
metricshub.add_listener(&metrics_file); metricshub.add_listener(&metrics_file);
metrics_file.set_ue_handle(ue); metrics_file.set_ue_handle(ue);
metrics_file.set_periodicity(args.expert.metrics_period_secs);
} }
pthread_t input; pthread_t input;

@ -68,11 +68,7 @@ void metrics_csv::stop()
} }
} }
void metrics_csv::set_periodicity(float metrics_report_period_sec) { void metrics_csv::set_metrics(ue_metrics_t &metrics, const uint32_t period_usec)
this->metrics_report_period = metrics_report_period_sec;
}
void metrics_csv::set_metrics(ue_metrics_t &metrics)
{ {
if (file.is_open() && ue != NULL) { if (file.is_open() && ue != NULL) {
if(n_reports == 0) { if(n_reports == 0) {
@ -85,7 +81,7 @@ void metrics_csv::set_metrics(ue_metrics_t &metrics)
file << float_to_string(metrics.phy.dl.mcs, 2); file << float_to_string(metrics.phy.dl.mcs, 2);
file << float_to_string(metrics.phy.dl.sinr, 2); file << float_to_string(metrics.phy.dl.sinr, 2);
file << float_to_string(metrics.phy.dl.turbo_iters, 2); file << float_to_string(metrics.phy.dl.turbo_iters, 2);
file << float_to_string((float) metrics.mac.rx_brate/metrics_report_period, 2); file << float_to_string((float) metrics.mac.rx_brate/period_usec*1e6, 2);
if (metrics.mac.rx_pkts > 0) { if (metrics.mac.rx_pkts > 0) {
file << float_to_string((float) 100*metrics.mac.rx_errors/metrics.mac.rx_pkts, 1); file << float_to_string((float) 100*metrics.mac.rx_errors/metrics.mac.rx_pkts, 1);
} else { } else {
@ -93,7 +89,7 @@ void metrics_csv::set_metrics(ue_metrics_t &metrics)
} }
file << float_to_string(metrics.phy.ul.mcs, 2); file << float_to_string(metrics.phy.ul.mcs, 2);
file << float_to_string((float) metrics.mac.ul_buffer, 2); file << float_to_string((float) metrics.mac.ul_buffer, 2);
file << float_to_string((float) metrics.mac.tx_brate/metrics_report_period, 2); file << float_to_string((float) metrics.mac.tx_brate/period_usec*1e6, 2);
if (metrics.mac.tx_pkts > 0) { if (metrics.mac.tx_pkts > 0) {
file << float_to_string((float) 100*metrics.mac.tx_errors/metrics.mac.tx_pkts, 1); file << float_to_string((float) 100*metrics.mac.tx_errors/metrics.mac.tx_pkts, 1);
} else { } else {

@ -50,7 +50,6 @@ char const * const prefixes[2][9] =
metrics_stdout::metrics_stdout() metrics_stdout::metrics_stdout()
:do_print(false) :do_print(false)
,n_reports(10) ,n_reports(10)
,metrics_report_period(1.0)
,ue(NULL) ,ue(NULL)
{ {
} }
@ -65,11 +64,7 @@ void metrics_stdout::toggle_print(bool b)
do_print = b; do_print = b;
} }
void metrics_stdout::set_periodicity(float metrics_report_period_sec) { void metrics_stdout::set_metrics(ue_metrics_t &metrics, const uint32_t period_usec)
this->metrics_report_period = metrics_report_period_sec;
}
void metrics_stdout::set_metrics(ue_metrics_t &metrics)
{ {
if(!do_print || ue == NULL) if(!do_print || ue == NULL)
return; return;
@ -92,7 +87,7 @@ void metrics_stdout::set_metrics(ue_metrics_t &metrics)
cout << float_to_string(metrics.phy.dl.mcs, 2); cout << float_to_string(metrics.phy.dl.mcs, 2);
cout << float_to_string(metrics.phy.dl.sinr, 2); cout << float_to_string(metrics.phy.dl.sinr, 2);
cout << float_to_string(metrics.phy.dl.turbo_iters, 2); cout << float_to_string(metrics.phy.dl.turbo_iters, 2);
cout << float_to_eng_string((float) metrics.mac.rx_brate/metrics_report_period, 2); cout << float_to_eng_string((float) metrics.mac.rx_brate/period_usec*1e6, 2);
if (metrics.mac.rx_pkts > 0) { if (metrics.mac.rx_pkts > 0) {
cout << float_to_string((float) 100*metrics.mac.rx_errors/metrics.mac.rx_pkts, 1) << "%"; cout << float_to_string((float) 100*metrics.mac.rx_errors/metrics.mac.rx_pkts, 1) << "%";
} else { } else {
@ -100,7 +95,7 @@ void metrics_stdout::set_metrics(ue_metrics_t &metrics)
} }
cout << float_to_string(metrics.phy.ul.mcs, 2); cout << float_to_string(metrics.phy.ul.mcs, 2);
cout << float_to_eng_string((float) metrics.mac.ul_buffer, 2); cout << float_to_eng_string((float) metrics.mac.ul_buffer, 2);
cout << float_to_eng_string((float) metrics.mac.tx_brate/metrics_report_period, 2); cout << float_to_eng_string((float) metrics.mac.tx_brate/period_usec*1e6, 2);
if (metrics.mac.tx_pkts > 0) { if (metrics.mac.tx_pkts > 0) {
cout << float_to_string((float) 100*metrics.mac.tx_errors/metrics.mac.tx_pkts, 1) << "%"; cout << float_to_string((float) 100*metrics.mac.tx_errors/metrics.mac.tx_pkts, 1) << "%";
} else { } else {

@ -81,6 +81,7 @@ bool ue::init(all_args_t *args_)
// Init logs // Init logs
rf_log.set_level(srslte::LOG_LEVEL_INFO); rf_log.set_level(srslte::LOG_LEVEL_INFO);
rf_log.info("Starting UE\n");
for (int i=0;i<args->expert.phy.nof_phy_threads;i++) { for (int i=0;i<args->expert.phy.nof_phy_threads;i++) {
((srslte::log_filter*) phy_log[i])->set_level(level(args->log.phy_level)); ((srslte::log_filter*) phy_log[i])->set_level(level(args->log.phy_level));
} }

Loading…
Cancel
Save