master
Xavier Arteaga 7 years ago
commit af5ca314d0

@ -189,21 +189,6 @@ if(ENABLE_GUI)
endif(SRSGUI_FOUND)
endif(ENABLE_GUI)
# VOLK
include(CheckFunctionExistsMath)
if(ENABLE_VOLK)
find_package(Volk)
if(VOLK_FOUND)
include_directories(${VOLK_INCLUDE_DIRS})
link_directories(${VOLK_LIBRARY_DIRS})
message(STATUS "Compiling with VOLK SIMD library.")
else(VOLK_FOUND)
message(STATUS "VOLK SIMD library NOT found. Using generic implementation.")
endif(VOLK_FOUND)
else(ENABLE_VOLK)
message(STATUS "VOLK library disabled")
endif(ENABLE_VOLK)
########################################################################
# Install Dirs
########################################################################

@ -50,6 +50,8 @@
#define TTI_TX(tti) ((tti+HARQ_DELAY_MS)%10240)
#define TTI_RX_ACK(tti) ((tti+(2*HARQ_DELAY_MS))%10240)
#define UL_PIDOF(tti) (tti%(2*HARQ_DELAY_MS))
#define TTIMOD_SZ (((2*HARQ_DELAY_MS) < 10)?10:20)
#define TTIMOD(tti) (tti%TTIMOD_SZ)

@ -57,9 +57,5 @@ set(srslte_srcs $<TARGET_OBJECTS:srslte_agc>
add_library(srslte_phy STATIC ${srslte_srcs})
target_link_libraries(srslte_phy ${FFT_LIBRARIES})
if(VOLK_FOUND)
target_link_libraries(srslte_phy ${VOLK_LIBRARIES})
endif(VOLK_FOUND)
target_link_libraries(srslte_phy pthread m)
install(TARGETS srslte_phy DESTINATION ${LIBRARY_DIR})

@ -309,7 +309,7 @@ static void copy_subdev_string(char *dst, char *src) {
int n = 0;
size_t len = strlen(src);
/* Copy until end of string or comma */
while (n < len && src != '\0' && src[n] != ',') {
while (n < len && src[n] != '\0' && src[n] != ',') {
dst[n] = src[n];
n++;
}
@ -383,8 +383,6 @@ int rf_uhd_open_multi(char *args, void **h, uint32_t nof_channels)
char *tx_subdev_ptr = strstr(args, tx_subdev_arg);
if (tx_subdev_ptr) {
copy_subdev_string(tx_subdev_str, tx_subdev_ptr + strlen(tx_subdev_arg));
remove_substring(args, tx_subdev_arg);
remove_substring(args, tx_subdev_str);
}
// Set receiver subdevice spec string
@ -393,6 +391,14 @@ int rf_uhd_open_multi(char *args, void **h, uint32_t nof_channels)
char *rx_subdev_ptr = strstr(args, rx_subdev_arg);
if (rx_subdev_ptr) {
copy_subdev_string(rx_subdev_str, rx_subdev_ptr + strlen(rx_subdev_arg));
}
if (tx_subdev_ptr) {
remove_substring(args, tx_subdev_arg);
remove_substring(args, tx_subdev_str);
}
if (rx_subdev_ptr) {
remove_substring(args, rx_subdev_arg);
remove_substring(args, rx_subdev_str);
}

@ -465,7 +465,7 @@ int srslte_ue_ul_pusch_encode_rnti_softbuffer(srslte_ue_ul_t *q,
if (srslte_pusch_encode(&q->pusch, &q->pusch_cfg, softbuffer, data, uci_data, rnti, q->sf_symbols)) {
fprintf(stderr, "Error encoding TB\n");
return ret;
return SRSLTE_ERROR;
}
if (q->signals_pregenerated) {

@ -199,7 +199,6 @@ void srslte_vec_lut_sss_simd(short *x, unsigned short *lut, short *y, int len) {
}
}
/* Modified from volk_32f_s32f_convert_16i_a_simd2. Removed clipping */
void srslte_vec_convert_fi_simd(float *x, int16_t *z, float scale, int len) {
int i = 0;

@ -97,7 +97,7 @@ private:
srslte_enb_dl_t enb_dl;
srslte_enb_ul_t enb_ul;
srslte_timestamp_t tx_time;
srslte_timestamp_t tx_time;
// Class to store user information
class ue {
@ -119,6 +119,11 @@ private:
void metrics_read(phy_metrics_t *metrics);
void metrics_dl(uint32_t mcs);
void metrics_ul(uint32_t mcs, float rssi, float sinr, uint32_t turbo_iters);
int last_dl_tbs[2*HARQ_DELAY_MS][SRSLTE_MAX_CODEWORDS];
int last_ul_tbs[2*HARQ_DELAY_MS];
srslte_mod_t last_ul_mod[2*HARQ_DELAY_MS];
private:
phy_metrics_t metrics;
};

@ -680,7 +680,8 @@ int sched::dl_sched_data(dl_sched_data_t data[MAX_DATA_LIST])
for(uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) {
h->reset(tb);
}
Warning("SCHED: Could not schedule DL DCI for rnti=0x%x, pid=%d\n", rnti, h->get_id());
Warning("SCHED: Could not schedule DL DCI for rnti=0x%x, pid=%d, L=%d, nof_candidates=%d\n",
rnti, h->get_id(), aggr_level, user->get_locations(current_cfi, sf_idx)->nof_loc[aggr_level] );
}
}
}
@ -825,7 +826,7 @@ int sched::ul_sched(uint32_t tti, srsenb::sched_interface::ul_sched_res_t* sched
{
ul_harq_proc::ul_alloc_t alloc = h->get_alloc();
bool is_newtx = h->is_empty(0);
bool needs_pdcch = !h->is_adaptive_retx() && !is_rar;
bool needs_pdcch = h->is_adaptive_retx() && !is_rar;
// Set number of retx
if (is_newtx) {

@ -200,13 +200,13 @@ ul_harq_proc::ul_alloc_t ul_harq_proc::get_alloc()
void ul_harq_proc::set_alloc(ul_harq_proc::ul_alloc_t alloc)
{
is_adaptive = false;
is_adaptive = true;
memcpy(&allocation, &alloc, sizeof(ul_alloc_t));
}
void ul_harq_proc::same_alloc()
{
is_adaptive = true;
is_adaptive = false;
}
bool ul_harq_proc::is_adaptive_retx()

@ -334,8 +334,8 @@ void sched_ue::set_dl_pmi(uint32_t tti, uint32_t pmi)
void sched_ue::set_dl_cqi(uint32_t tti, uint32_t cqi)
{
dl_cqi = cqi;
dl_cqi_tti = tti;
dl_cqi = cqi;
dl_cqi_tti = tti;
}
void sched_ue::set_dl_ant_info(LIBLTE_RRC_ANTENNA_INFO_DEDICATED_STRUCT *d)
@ -371,10 +371,10 @@ void sched_ue::tpc_dec() {
// Generates a Format1 grant
int sched_ue::generate_format1(dl_harq_proc *h,
sched_interface::dl_sched_data_t *data,
uint32_t tti,
uint32_t cfi)
int sched_ue::generate_format1(dl_harq_proc *h,
sched_interface::dl_sched_data_t *data,
uint32_t tti,
uint32_t cfi)
{
srslte_ra_dl_dci_t *dci = &data->dci;
bzero(dci, sizeof(srslte_ra_dl_dci_t));
@ -595,7 +595,8 @@ int sched_ue::generate_format0(ul_harq_proc *h,
int tbs = 0;
ul_harq_proc::ul_alloc_t allocation = h->get_alloc();
bool is_newtx = true;
if (h->get_rar_mcs(&mcs)) {
tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(mcs), allocation.L)/8;
h->new_tx(tti, mcs, tbs);
@ -614,7 +615,8 @@ int sched_ue::generate_format0(ul_harq_proc *h,
h->new_tx(tti, mcs, tbs);
} else {
} else {
is_newtx = false;
h->new_retx(0, tti, &mcs, NULL);
tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(mcs), allocation.L)/8;
}
@ -625,8 +627,12 @@ int sched_ue::generate_format0(ul_harq_proc *h,
if (tbs > 0) {
dci->type2_alloc.L_crb = allocation.L;
dci->type2_alloc.RB_start = allocation.RB_start;
dci->mcs_idx = mcs;
dci->rv_idx = sched::get_rvidx(h->nof_retx(0));
if (!is_newtx && h->is_adaptive_retx()) {
dci->mcs_idx = 28+dci->rv_idx;
} else {
dci->mcs_idx = mcs;
}
dci->ndi = h->get_ndi(0);
dci->cqi_request = cqi_request;
dci->freq_hop_fl = srslte_ra_ul_dci_t::SRSLTE_RA_PUSCH_HOP_DISABLED;

@ -441,16 +441,16 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch)
if (ue_db[rnti].cqi_en && ue_db[rnti].ri_en && srslte_ri_send(ue_db[rnti].pmi_idx, ue_db[rnti].ri_idx, tti_rx) ) {
uci_data.uci_ri_len = 1; /* Asumes only 1 bit for RI */
ri_enabled = true;
} else if (ue_db[rnti].cqi_en && srslte_cqi_send(ue_db[rnti].pmi_idx, tti_rx)) {
} else
#endif
if (ue_db[rnti].cqi_en && srslte_cqi_send(ue_db[rnti].pmi_idx, tti_rx)) {
cqi_value.type = SRSLTE_CQI_TYPE_WIDEBAND;
cqi_enabled = true;
if (ue_db[rnti].dedicated.antenna_info_explicit_value.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_4) {
//uci_data.uci_dif_cqi_len = 3;
uci_data.uci_pmi_len = 2;
}
} else
#endif
if (grants[i].grant.cqi_request) {
} else if (grants[i].grant.cqi_request) {
cqi_value.type = SRSLTE_CQI_TYPE_SUBBAND_HL;
cqi_value.subband_hl.N = (phy->cell.nof_prb > 7) ? srslte_cqi_hl_get_no_subbands(phy->cell.nof_prb) : 0;
cqi_value.subband_hl.four_antenna_ports = (phy->cell.nof_ports == 4);
@ -464,6 +464,22 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch)
srslte_ra_ul_grant_t phy_grant;
int res = -1;
if (!srslte_ra_ul_dci_to_grant(&grants[i].grant, enb_ul.cell.nof_prb, n_rb_ho, &phy_grant)) {
// Handle Format0 adaptive retx
// Use last TBS for this TB in case of mcs>28
if (phy_grant.mcs.idx > 28) {
phy_grant.mcs.tbs = ue_db[rnti].last_ul_tbs[TTI_RX(tti_rx)%(2*HARQ_DELAY_MS)];
Info("RETX: mcs=%d, old_tbs=%d pid=%d\n", phy_grant.mcs.idx, phy_grant.mcs.tbs, TTI_TX(tti_rx)%(2*HARQ_DELAY_MS));
}
ue_db[rnti].last_ul_tbs[TTI_RX(tti_rx)%(2*HARQ_DELAY_MS)] = phy_grant.mcs.tbs;
if (phy_grant.mcs.mod == SRSLTE_MOD_LAST) {
phy_grant.mcs.mod = ue_db[rnti].last_ul_mod[TTI_RX(tti_rx)%(2*HARQ_DELAY_MS)];
phy_grant.Qm = srslte_mod_bits_x_symbol(phy_grant.mcs.mod);
}
ue_db[rnti].last_ul_mod[TTI_RX(tti_rx)%(2*HARQ_DELAY_MS)] = phy_grant.mcs.mod;
if (phy_grant.mcs.mod == SRSLTE_MOD_64QAM) {
phy_grant.mcs.mod = SRSLTE_MOD_16QAM;
}

@ -44,39 +44,35 @@
namespace srsue {
template <std::size_t N, typename Tgrant, typename Taction, typename Tphygrant>
class ul_harq_entity
{
class ul_harq_entity {
public:
static uint32_t pidof(uint32_t tti)
{
return (uint32_t) tti%N;
static uint32_t pidof(uint32_t tti) {
return (uint32_t) tti % N;
}
ul_harq_entity() : proc(N)
{
ul_harq_entity() : proc(N) {
contention_timer = NULL;
pcap = NULL;
mux_unit = NULL;
log_h = NULL;
params = NULL;
rntis = NULL;
average_retx = 0;
nof_pkts = 0;
pcap = NULL;
mux_unit = NULL;
log_h = NULL;
params = NULL;
rntis = NULL;
average_retx = 0;
nof_pkts = 0;
}
bool init(srslte::log *log_h_,
bool init(srslte::log *log_h_,
mac_interface_rrc_common::ue_rnti_t *rntis_,
mac_interface_rrc_common::ul_harq_params_t *params_,
srslte::timers::timer* contention_timer_,
mux *mux_unit_)
{
log_h = log_h_;
mux_unit = mux_unit_;
params = params_;
rntis = rntis_;
srslte::timers::timer *contention_timer_,
mux *mux_unit_) {
log_h = log_h_;
mux_unit = mux_unit_;
params = params_;
rntis = rntis_;
contention_timer = contention_timer_;
for (uint32_t i=0;i<N;i++) {
for (uint32_t i = 0; i < N; i++) {
if (!proc[i].init(i, this)) {
return false;
}
@ -84,29 +80,29 @@ public:
return true;
}
void reset()
{
for (uint32_t i=0;i<N;i++) {
void reset() {
for (uint32_t i = 0; i < N; i++) {
proc[i].reset();
}
ul_sps_assig.clear();
}
void reset_ndi()
{
for (uint32_t i=0;i<N;i++) {
void reset_ndi() {
for (uint32_t i = 0; i < N; i++) {
proc[i].reset_ndi();
}
}
void start_pcap(srslte::mac_pcap* pcap_)
{
void start_pcap(srslte::mac_pcap *pcap_) {
pcap = pcap_;
}
/***************** PHY->MAC interface for UL processes **************************/
void new_grant_ul(Tgrant grant, Taction *action)
void new_grant_ul(Tgrant grant, Taction *action) {
new_grant_ul_ack(grant, NULL, action);
}
void new_grant_ul_ack(Tgrant grant, bool *ack, Taction *action)
{
if (grant.rnti_type == SRSLTE_RNTI_USER ||
grant.rnti_type == SRSLTE_RNTI_TEMP ||
@ -115,27 +111,20 @@ public:
if (grant.rnti_type == SRSLTE_RNTI_USER && proc[pidof(grant.tti)].is_sps()) {
grant.ndi[0] = true;
}
run_tti(grant.tti, &grant, action);
run_tti(grant.tti, &grant, ack, action);
} else if (grant.rnti_type == SRSLTE_RNTI_SPS) {
if (grant.ndi[0]) {
grant.ndi[0] = proc[pidof(grant.tti)].get_ndi();
run_tti(grant.tti, &grant, action);
run_tti(grant.tti, &grant, ack, action);
} else {
Info("Not implemented\n");
}
}
}
void new_grant_ul_ack(Tgrant grant, bool ack, Taction *action)
{
set_ack(grant.tti, ack, action);
new_grant_ul(grant, action);
}
void harq_recv(uint32_t tti, bool ack, Taction *action)
{
set_ack(tti, ack, action);
run_tti(tti, NULL, action);
run_tti(tti, NULL, &ack, action);
}
int get_current_tbs(uint32_t tti)
@ -206,10 +195,19 @@ private:
bzero(&cur_grant, sizeof(Tgrant));
}
void reset_ndi() { ndi = false; }
void run_tti(uint32_t tti_tx, Tgrant *grant, Taction* action)
void reset_ndi() { cur_grant.ndi[0] = false; }
void run_tti(uint32_t tti_tx, Tgrant *grant, bool *ack, Taction* action)
{
if (ack) {
if (grant) {
if (grant->ndi[0] == get_ndi()) {
*ack = false;
}
}
set_harq_feedback(*ack);
}
uint32_t max_retx;
if (is_msg3) {
max_retx = harq_entity->params->max_harq_msg3_tx;
@ -219,9 +217,9 @@ private:
// Receive and route HARQ feedbacks
if (grant) {
if ((!(grant->rnti_type == SRSLTE_RNTI_TEMP) && grant->ndi[0] != get_ndi() && grant->phy_grant.ul.mcs.idx < 29) ||
(grant->rnti_type == SRSLTE_RNTI_USER && !has_grant()) ||
grant->is_from_rar)
if ((!(grant->rnti_type == SRSLTE_RNTI_TEMP) && grant->ndi[0] != get_ndi() && ack) ||
(grant->rnti_type == SRSLTE_RNTI_USER && !has_grant()) ||
grant->is_from_rar)
{
// New transmission
@ -255,7 +253,7 @@ private:
generate_retx(tti_tx, grant, action);
}
} else {
Warning("UL %d: Received mcs=%d but no previous grant available for this PID.\n", pid, grant->phy_grant.ul.mcs.idx);
Warning("UL %d: Received retransmission but no previous grant available for this PID.\n", pid);
}
} else if (has_grant()) {
// Non-Adaptive Re-Tx
@ -294,9 +292,8 @@ private:
}
bool has_grant() { return is_grant_configured; }
bool get_ndi() { return ndi; }
bool get_ndi() { return cur_grant.ndi[0]; }
bool is_sps() { return false; }
uint32_t last_tx_tti() { return tti_last_tx; }
uint32_t get_nof_retx() { return current_tx_nb; }
int get_current_tbs() { return cur_grant.n_bytes[0]*8; }
@ -307,7 +304,6 @@ private:
uint32_t current_tx_nb;
uint32_t current_irv;
bool harq_feedback;
bool ndi;
srslte::log *log_h;
ul_harq_entity *harq_entity;
bool is_grant_configured;
@ -398,24 +394,12 @@ private:
// Implements Section 5.4.2.1
// Called with UL grant
void run_tti(uint32_t tti, Tgrant *grant, Taction* action)
void run_tti(uint32_t tti, Tgrant *grant, bool *ack, Taction* action)
{
uint32_t tti_tx = (tti+action->tti_offset)%10240;
proc[pidof(tti_tx)].run_tti(tti_tx, grant, action);
proc[pidof(tti_tx)].run_tti(tti_tx, grant, ack, action);
}
void set_ack(uint32_t tti, bool ack, Taction *action)
{
int tti_harq = (int) tti - action->tti_offset;
if (tti_harq < 0) {
tti_harq += 10240;
}
uint32_t pid_harq = pidof(tti_harq);
if (proc[pid_harq].has_grant() && (proc[pid_harq].last_tx_tti() <= (uint32_t)tti_harq)) {
proc[pid_harq].set_harq_feedback(ack);
}
}
ul_sps ul_sps_assig;
srslte::timers::timer *contention_timer;

@ -64,8 +64,16 @@ namespace srsue {
float rx_gain_offset;
float avg_snr_db;
float avg_noise;
float avg_rsrp;
float avg_rsrp;
// Save last TBS for mcs>28 cases
int last_dl_tbs[2*HARQ_DELAY_MS][SRSLTE_MAX_CODEWORDS];
uint32_t last_dl_tti[2*HARQ_DELAY_MS];
int last_ul_tbs[2*HARQ_DELAY_MS];
uint32_t last_ul_tti[2*HARQ_DELAY_MS];
srslte_mod_t last_ul_mod[2*HARQ_DELAY_MS];
phch_common(uint32_t max_mutex = 3);
void init(phy_interface_rrc::phy_cfg_t *config,
phy_args_t *args,
@ -139,7 +147,7 @@ namespace srsue {
uint32_t n_dmrs;
} pending_ack_t;
pending_ack_t pending_ack[TTIMOD_SZ];
bool is_first_tx;
uint32_t nof_workers;

@ -151,11 +151,6 @@ private:
float cfo;
bool rar_cqi_request;
// Save last TBS for mcs>28 cases
int last_dl_tbs[2*HARQ_DELAY_MS][SRSLTE_MAX_CODEWORDS];
int last_ul_tbs[2*HARQ_DELAY_MS];
srslte_mod_t last_ul_mod[2*HARQ_DELAY_MS];
// Metrics
dl_metrics_t dl_metrics;
ul_metrics_t ul_metrics;

@ -38,6 +38,7 @@
#include "srslte/radio/radio_multi.h"
#include "phy/phy.h"
#include "upper/usim.h"
#include "upper/rrc.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/common/logger.h"
@ -104,12 +105,11 @@ typedef struct {
typedef struct {
std::string ip_netmask;
phy_args_t phy;
float metrics_period_secs;
bool pregenerate_signals;
std::string ue_cateogry;
bool metrics_csv_enable;
std::string metrics_csv_filename;
phy_args_t phy;
float metrics_period_secs;
bool pregenerate_signals;
bool metrics_csv_enable;
std::string metrics_csv_filename;
}expert_args_t;
typedef struct {
@ -120,6 +120,8 @@ typedef struct {
log_args_t log;
gui_args_t gui;
usim_args_t usim;
rrc_args_t rrc;
std::string ue_category_str;
expert_args_t expert;
}all_args_t;

@ -39,6 +39,15 @@
#include <map>
typedef struct {
bool stmsi_attach;
LIBLTE_RRC_S_TMSI_STRUCT stmsi_value;
uint32_t ue_category;
uint32_t feature_group;
uint8_t supported_bands[LIBLTE_RRC_BAND_N_ITEMS];
uint32_t nof_supported_bands;
}rrc_args_t;
using srslte::byte_buffer_t;
namespace srsue {
@ -73,7 +82,7 @@ public:
rrc_state_t get_state();
void set_ue_category(int category);
void set_args(rrc_args_t *args);
// Timeout callback interface
void timer_expired(uint32_t timeout_id);
@ -98,6 +107,9 @@ private:
uint8_t transaction_id;
bool drb_up;
rrc_args_t args;
bool first_stimsi_attempt;
bool reestablishment_in_progress;
// timeouts in ms
@ -132,7 +144,6 @@ private:
uint32_t n310_cnt, N310;
uint32_t n311_cnt, N311;
uint32_t t301, t310, t311;
int ue_category;
typedef struct {
uint32_t earfcn;
@ -269,7 +280,11 @@ private:
void set_mac_default();
void set_rrc_default();
void set_bearers();
// s-tmsi persistent file
bool read_stimsi_file(LIBLTE_RRC_S_TMSI_STRUCT *s_tmsi);
bool write_stimsi_file(LIBLTE_RRC_S_TMSI_STRUCT s_tmsi);
};
} // namespace srsue

@ -308,7 +308,7 @@ void mac::new_grant_ul(mac_interface_phy::mac_grant_t grant, mac_interface_phy::
void mac::new_grant_ul_ack(mac_interface_phy::mac_grant_t grant, bool ack, mac_interface_phy::tb_action_ul_t* action)
{
int tbs = ul_harq.get_current_tbs(tti);
ul_harq.new_grant_ul_ack(grant, ack, action);
ul_harq.new_grant_ul_ack(grant, &ack, action);
if (!ack) {
metrics.tx_errors++;
} else {

@ -236,8 +236,7 @@ uint8_t* mux::pdu_get(uint8_t *payload, uint32_t pdu_sz, uint32_t tx_tti, uint32
// Now allocate the SDUs from the RLC
for (uint32_t i=0;i<lch.size();i++) {
if (lch[i].sched_len != 0) {
log_h->info("Allocating scheduled lch=%d len=%d\n", lch[i].id, lch[i].sched_len);
allocate_sdu(lch[i].id, &pdu_msg, lch[i].sched_len);
allocate_sdu(lch[i].id, &pdu_msg, lch[i].sched_len);
}
}
@ -285,7 +284,7 @@ bool mux::sched_sdu(lchid_t *ch, int *sdu_space, int max_sdu_sz)
sched_len = *sdu_space;
}
log_h->info("SDU: scheduled lcid=%d, rlc_buffer=%d, allocated=%d/%d\n",
log_h->debug("SDU: scheduled lcid=%d, rlc_buffer=%d, allocated=%d/%d\n",
ch->id, ch->buffer_len, sched_len, sdu_space?*sdu_space:0);
*sdu_space -= sched_len;
@ -317,7 +316,7 @@ bool mux::allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu_msg, int max_sdu_sz)
sdu_len = pdu_msg->get()->set_sdu(lcid, sdu_len, rlc);
if (sdu_len > 0) { // new SDU could be added
Info("SDU: allocated lcid=%d, rlc_buffer=%d, allocated=%d/%d, max_sdu_sz=%d, remaining=%d\n",
Debug("SDU: allocated lcid=%d, rlc_buffer=%d, allocated=%d/%d, max_sdu_sz=%d, remaining=%d\n",
lcid, buffer_state, sdu_len, sdu_space, max_sdu_sz, pdu_msg->rem_size());
return true;
} else {

@ -75,10 +75,19 @@ void parse_args(all_args_t *args, int argc, char *argv[]) {
("rf.device_args", bpo::value<string>(&args->rf.device_args)->default_value("auto"), "Front-end device arguments")
("rf.time_adv_nsamples", bpo::value<string>(&args->rf.time_adv_nsamples)->default_value("auto"),
"Transmission time advance")
("rf.burst_preamble_us", bpo::value<string>(&args->rf.burst_preamble)->default_value("auto"),
"Transmission time advance")
("rf.burst_preamble_us", bpo::value<string>(&args->rf.burst_preamble)->default_value("auto"), "Transmission time advance")
("rrc.stmsi_attach", bpo::value<bool>(&args->rrc.stmsi_attach)->default_value(false),"If enabled, always tries first an S-TMSI attach using the\n"
"S-TMSI value stored in .stimsi file generated in previous run")
("rrc.mmec_value", bpo::value<uint8_t>(&args->rrc.stmsi_value.mmec)->default_value(0), "If defined (non-zero), overwrites the value stored in .stimsi file")
("rrc.mtmsi_value", bpo::value<uint32_t>(&args->rrc.stmsi_value.m_tmsi)->default_value(0), "If defined (non-zero), overwrites the value stored in .stimsi file")
("rrc.feature_group", bpo::value<uint32_t>(&args->rrc.feature_group)->default_value(0xe6041c00), "Hex value of the featureGroupIndicators field in the"
"UECapabilityInformation message. Default 0xe6041c00")
("rrc.ue_category", bpo::value<string>(&args->ue_category_str)->default_value("4"), "UE Category (1 to 5)")
("pcap.enable", bpo::value<bool>(&args->pcap.enable)->default_value(false),
("pcap.enable", bpo::value<bool>(&args->pcap.enable)->default_value(false),
"Enable MAC packet captures for wireshark")
("pcap.filename", bpo::value<string>(&args->pcap.filename)->default_value("ue.pcap"), "MAC layer capture filename")
@ -134,10 +143,6 @@ void parse_args(all_args_t *args, int argc, char *argv[]) {
bpo::value<int>(&args->expert.phy.sync_cpu_affinity)->default_value(-1),
"index of the core used by the sync thread")
("expert.ue_category",
bpo::value<string>(&args->expert.ue_cateogry)->default_value("4"),
"UE Category (1 to 5)")
("expert.metrics_period_secs",
bpo::value<float>(&args->expert.metrics_period_secs)->default_value(1.0),
"Periodicity for metrics in seconds")

@ -289,9 +289,9 @@ void phch_worker::work_imp()
ul_action.tti_offset = HARQ_DELAY_MS;
/* Send UL grant or HARQ information (from PHICH) to MAC */
if (ul_grant_available && ul_ack_available && ul_mac_grant.phy_grant.ul.mcs.idx < 29) {
if (ul_grant_available && ul_ack_available) {
phy->mac->new_grant_ul_ack(ul_mac_grant, ul_ack, &ul_action);
} else if (ul_grant_available && (!ul_ack_available || ul_mac_grant.phy_grant.ul.mcs.idx < 29)) {
} else if (ul_grant_available && !ul_ack_available) {
phy->mac->new_grant_ul(ul_mac_grant, &ul_action);
} else if (!ul_grant_available && ul_ack_available) {
phy->mac->harq_recv(tti, ul_ack, &ul_action);
@ -480,19 +480,19 @@ bool phch_worker::decode_pdcch_dl(srsue::mac_interface_phy::mac_grant_t* grant)
return false;
}
grant->pid = ASYNC_DL_SCHED?dci_unpacked.harq_process:(tti%(2*HARQ_DELAY_MS));
grant->pid = ASYNC_DL_SCHED?dci_unpacked.harq_process:(UL_PIDOF(TTI_TX(tti)));
// Set last TBS for this TB (pid) in case of mcs>28 (7.1.7.2 of 36.213)
for (int i=0;i<SRSLTE_MAX_CODEWORDS;i++) {
if (grant->phy_grant.dl.mcs[i].idx > 28) {
grant->phy_grant.dl.mcs[i].tbs = last_dl_tbs[grant->pid%(2*HARQ_DELAY_MS)][i];
grant->phy_grant.dl.mcs[i].tbs = phy->last_dl_tbs[grant->pid][i];
}
if(grant->phy_grant.dl.mcs[i].tbs < 0) {
Info("Invalid TBS size for PDSCH grant\n");
grant->phy_grant.dl.mcs[i].tbs = 0;
}
// save it
last_dl_tbs[grant->pid%(2*HARQ_DELAY_MS)][i] = grant->phy_grant.dl.mcs[i].tbs;
phy->last_dl_tbs[grant->pid][i] = grant->phy_grant.dl.mcs[i].tbs;
}
/* Fill MAC grant structure */
@ -752,30 +752,30 @@ bool phch_worker::decode_pdcch_ul(mac_interface_phy::mac_grant_t* grant)
}
}
if (ret) {
// Handle Format0 adaptive retx
if (ret) {
// Use last TBS for this TB in case of mcs>28
if (grant->phy_grant.ul.mcs.idx > 28) {
grant->phy_grant.ul.mcs.tbs = last_ul_tbs[TTI_RX(tti)%(2*HARQ_DELAY_MS)];
Info("RETX: mcs=%d, old_tbs=%d pid=%d\n", grant->phy_grant.ul.mcs.idx, grant->phy_grant.ul.mcs.tbs, TTI_TX(tti)%(2*HARQ_DELAY_MS));
}
last_ul_tbs[TTI_RX(tti)%(2*HARQ_DELAY_MS)] = grant->phy_grant.ul.mcs.tbs;
if (grant->phy_grant.ul.mcs.mod == SRSLTE_MOD_LAST) {
grant->phy_grant.ul.mcs.mod = last_ul_mod[TTI_RX(tti)%(2*HARQ_DELAY_MS)];
// Make sure we received a grant in the previous TTI for this PID
grant->phy_grant.ul.mcs.tbs = phy->last_ul_tbs[UL_PIDOF(TTI_TX(tti))];
grant->phy_grant.ul.mcs.mod = phy->last_ul_mod[UL_PIDOF(TTI_TX(tti))];
grant->phy_grant.ul.Qm = srslte_mod_bits_x_symbol(grant->phy_grant.ul.mcs.mod);
}
last_ul_mod[TTI_RX(tti)%(2*HARQ_DELAY_MS)] = grant->phy_grant.ul.mcs.mod;
}
/* Limit UL modulation if not supported by the UE or disabled by higher layers */
if (!phy->config->enable_64qam) {
if (grant->phy_grant.ul.mcs.mod >= SRSLTE_MOD_64QAM) {
grant->phy_grant.ul.mcs.mod = SRSLTE_MOD_16QAM;
grant->phy_grant.ul.Qm = 4;
if (ret) {
phy->last_ul_tbs[UL_PIDOF(TTI_TX(tti))] = grant->phy_grant.ul.mcs.tbs;
phy->last_ul_mod[UL_PIDOF(TTI_TX(tti))] = grant->phy_grant.ul.mcs.mod;
phy->last_ul_tti[UL_PIDOF(TTI_TX(tti))] = TTI_RX_ACK(tti);
/* Limit UL modulation if not supported by the UE or disabled by higher layers */
if (!phy->config->enable_64qam) {
if (grant->phy_grant.ul.mcs.mod >= SRSLTE_MOD_64QAM) {
grant->phy_grant.ul.mcs.mod = SRSLTE_MOD_16QAM;
grant->phy_grant.ul.Qm = 4;
}
}
}
/* Make sure the grant is valid */
if (ret && !srslte_dft_precoding_valid_prb(grant->phy_grant.ul.L_prb) && grant->phy_grant.ul.L_prb <= cell.nof_prb) {
Warning("Received invalid UL grant. L=%d\n", grant->phy_grant.ul.L_prb);
@ -792,11 +792,9 @@ bool phch_worker::decode_pdcch_ul(mac_interface_phy::mac_grant_t* grant)
if (SRSLTE_VERBOSE_ISINFO()) {
srslte_ra_pusch_fprint(stdout, &dci_unpacked, cell.nof_prb);
}
return true;
} else {
return false;
}
}
return ret;
}
void phch_worker::reset_uci()

@ -188,7 +188,12 @@ bool ue::init(all_args_t *args_)
gw.set_netmask(args->expert.ip_netmask);
rrc.init(&phy, &mac, &rlc, &pdcp, &nas, &usim, &mac, &rrc_log);
rrc.set_ue_category(atoi(args->expert.ue_cateogry.c_str()));
// Get current band from provided EARFCN
args->rrc.supported_bands[0] = srslte_band_get_band(args->rf.dl_earfcn);
args->rrc.nof_supported_bands = 1;
args->rrc.ue_category = atoi(args->ue_category_str.c_str());
rrc.set_args(&args->rrc);
// Currently EARFCN list is set to only one frequency as indicated in ue.conf
std::vector<uint32_t> earfcn_list;

@ -26,12 +26,11 @@
#include <unistd.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include "srslte/asn1/liblte_rrc.h"
#include "upper/rrc.h"
#include <boost/assign.hpp>
#include <upper/rrc.h>
#include <srslte/asn1/liblte_rrc.h>
#include "srslte/asn1/liblte_rrc.h"
#include "srslte/common/security.h"
#include "srslte/common/bcd_helpers.h"
@ -93,9 +92,15 @@ void rrc::init(phy_interface_rrc *phy_,
pthread_mutex_init(&mutex, NULL);
first_stimsi_attempt = false;
reestablishment_in_progress = false;
ue_category = SRSLTE_UE_CATEGORY;
args.ue_category = SRSLTE_UE_CATEGORY;
args.supported_bands[0] = 7;
args.nof_supported_bands = 1;
args.feature_group = 0xe6041c00;
args.stmsi_attach = false;
t301 = mac_timers->timer_get_unique_id();
t310 = mac_timers->timer_get_unique_id();
t311 = mac_timers->timer_get_unique_id();
@ -131,12 +136,8 @@ bool rrc::have_drb() {
return drb_up;
}
void rrc::set_ue_category(int category) {
if (category >= 1 && category <= 5) {
ue_category = category;
} else {
rrc_log->error("Unsupported UE category %d\n", category);
}
void rrc::set_args(rrc_args_t *args) {
memcpy(&this->args, args, sizeof(rrc_args_t));
}
/*
@ -591,6 +592,66 @@ void rrc::timer_expired(uint32_t timeout_id) {
*
*******************************************************************************/
bool rrc::read_stimsi_file(LIBLTE_RRC_S_TMSI_STRUCT *s_tmsi) {
std::ifstream file;
std::string line;
if (!s_tmsi) {
return false;
}
const char *mmec_str = "mmec=";
size_t mmec_str_len = strlen(mmec_str);
const char *mtmsi_str = "mtmsi=";
size_t mtmsi_str_len = strlen(mtmsi_str);
file.open(".stmsi", std::ios::in);
if (file.is_open()) {
bool read_ok = true;
if (std::getline(file, line)) {
if (!line.substr(0,mmec_str_len).compare(mmec_str)) {
s_tmsi->mmec = atoi(line.substr(5).c_str());
} else {
read_ok = false;
}
} else {
read_ok = false;
}
if (std::getline(file, line)) {
if (!line.substr(0,mtmsi_str_len).compare(mtmsi_str)) {
s_tmsi->m_tmsi = atoi(line.substr(mtmsi_str_len).c_str());
} else {
read_ok = false;
}
} else {
read_ok = false;
}
file.close();
if (read_ok) {
rrc_log->info("Read S-TMSI value: %x:%x\n", s_tmsi->mmec, s_tmsi->m_tmsi);
return true;
} else {
rrc_log->error("Invalid s-tmsi persistent file format\n");
return false;
}
} else {
return false;
}
}
bool rrc::write_stimsi_file(LIBLTE_RRC_S_TMSI_STRUCT s_tmsi) {
std::ofstream file;
file.open(".stmsi", std::ios::out | std::ios::trunc);
if (file.is_open()) {
file << "mmec=" << (int) s_tmsi.mmec << std::endl;
file << "mtmsi=" << (int) s_tmsi.m_tmsi << std::endl;
rrc_log->info("Saved S-TMSI in persistent file: %x:%x\n", s_tmsi.mmec, s_tmsi.m_tmsi);
file.close();
return true;
} else {
return false;
}
}
void rrc::send_con_request() {
rrc_log->debug("Preparing RRC Connection Request\n");
LIBLTE_RRC_UL_CCCH_MSG_STRUCT ul_ccch_msg;
@ -598,13 +659,32 @@ void rrc::send_con_request() {
// Prepare ConnectionRequest packet
ul_ccch_msg.msg_type = LIBLTE_RRC_UL_CCCH_MSG_TYPE_RRC_CON_REQ;
if (nas->get_s_tmsi(&s_tmsi)) {
bool valid_stmsi = false;
if (nas->get_s_tmsi(&s_tmsi) || (args.stmsi_attach && !first_stimsi_attempt)) {
ul_ccch_msg.msg.rrc_con_req.ue_id_type = LIBLTE_RRC_CON_REQ_UE_ID_TYPE_S_TMSI;
ul_ccch_msg.msg.rrc_con_req.ue_id.s_tmsi = s_tmsi;
} else {
if (nas->get_s_tmsi(&s_tmsi)) {
ul_ccch_msg.msg.rrc_con_req.ue_id.s_tmsi = s_tmsi;
valid_stmsi = true;
} else {
first_stimsi_attempt = true;
if (args.stmsi_value.m_tmsi) {
ul_ccch_msg.msg.rrc_con_req.ue_id.s_tmsi = args.stmsi_value;
valid_stmsi = true;
} else {
if (!read_stimsi_file(&ul_ccch_msg.msg.rrc_con_req.ue_id.s_tmsi)) {
rrc_log->warning("Could not read S-TMSI from persistent file. Trying normal attach.\n");
} else {
valid_stmsi = true;
}
}
}
}
if (!valid_stmsi) {
ul_ccch_msg.msg.rrc_con_req.ue_id_type = LIBLTE_RRC_CON_REQ_UE_ID_TYPE_RANDOM_VALUE;
ul_ccch_msg.msg.rrc_con_req.ue_id.random = 1000;
}
ul_ccch_msg.msg.rrc_con_req.cause = LIBLTE_RRC_CON_REQ_EST_CAUSE_MO_SIGNALLING;
liblte_rrc_pack_ul_ccch_msg(&ul_ccch_msg, (LIBLTE_BIT_MSG_STRUCT *) &bit_buf);
@ -876,6 +956,14 @@ void rrc::handle_rrc_con_reconfig(uint32_t lcid, LIBLTE_RRC_CONNECTION_RECONFIGU
nas_sdu->N_bytes = reconfig->ded_info_nas_list[i].N_bytes;
nas->write_pdu(lcid, nas_sdu);
}
// Get S-TMSI from NAS and store it in persistent file
LIBLTE_RRC_S_TMSI_STRUCT s_tmsi;
if (nas->get_s_tmsi(&s_tmsi)) {
if (!write_stimsi_file(s_tmsi)) {
rrc_log->warning("Could not store S-TMSI in persistent file\n");
}
}
}
/* Actions upon reception of RRCConnectionRelease 5.3.8.3 */
@ -1022,10 +1110,12 @@ void rrc::write_pdu_pcch(byte_buffer_t *pdu) {
LIBLTE_RRC_S_TMSI_STRUCT *s_tmsi_paged;
for (uint32_t i = 0; i < pcch_msg.paging_record_list_size; i++) {
s_tmsi_paged = &pcch_msg.paging_record_list[i].ue_identity.s_tmsi;
rrc_log->info("Received paging (%d/%d) for UE 0x%x\n", i + 1, pcch_msg.paging_record_list_size,
pcch_msg.paging_record_list[i].ue_identity.s_tmsi);
rrc_log->console("Received paging (%d/%d) for UE 0x%x\n", i + 1, pcch_msg.paging_record_list_size,
pcch_msg.paging_record_list[i].ue_identity.s_tmsi);
rrc_log->info("Received paging (%d/%d) for UE %x:%x\n", i + 1, pcch_msg.paging_record_list_size,
pcch_msg.paging_record_list[i].ue_identity.s_tmsi.mmec,
pcch_msg.paging_record_list[i].ue_identity.s_tmsi.m_tmsi);
rrc_log->console("Received paging (%d/%d) for UE %x:%x\n", i + 1, pcch_msg.paging_record_list_size,
pcch_msg.paging_record_list[i].ue_identity.s_tmsi.mmec,
pcch_msg.paging_record_list[i].ue_identity.s_tmsi.m_tmsi);
if (s_tmsi.mmec == s_tmsi_paged->mmec && s_tmsi.m_tmsi == s_tmsi_paged->m_tmsi) {
rrc_log->info("S-TMSI match in paging message\n");
rrc_log->console("S-TMSI match in paging message\n");
@ -1200,7 +1290,7 @@ void rrc::parse_dl_dcch(uint32_t lcid, byte_buffer_t *pdu) {
*
*******************************************************************************/
void rrc::enable_capabilities() {
bool enable_ul_64 = ue_category >= 5 && current_cell->sib2.rr_config_common_sib.pusch_cnfg.enable_64_qam;
bool enable_ul_64 = args.ue_category >= 5 && current_cell->sib2.rr_config_common_sib.pusch_cnfg.enable_64_qam;
rrc_log->info("%s 64QAM PUSCH\n", enable_ul_64 ? "Enabling" : "Disabling");
phy->set_config_64qam_en(enable_ul_64);
}
@ -1218,7 +1308,7 @@ void rrc::send_rrc_ue_cap_info(uint32_t lcid, byte_buffer_t *pdu) {
LIBLTE_RRC_UE_EUTRA_CAPABILITY_STRUCT *cap = &info->ue_capability_rat[0].eutra_capability;
cap->access_stratum_release = LIBLTE_RRC_ACCESS_STRATUM_RELEASE_REL8;
cap->ue_category = ue_category;
cap->ue_category = args.ue_category;
cap->pdcp_params.max_rohc_ctxts_present = false;
cap->pdcp_params.supported_rohc_profiles[0] = false;
@ -1234,31 +1324,17 @@ void rrc::send_rrc_ue_cap_info(uint32_t lcid, byte_buffer_t *pdu) {
cap->phy_params.specific_ref_sigs_supported = false;
cap->phy_params.tx_antenna_selection_supported = false;
//TODO: Generate this from user input?
cap->rf_params.N_supported_band_eutras = 3;
cap->rf_params.supported_band_eutra[0].band_eutra = 3;
cap->rf_params.supported_band_eutra[0].half_duplex = false;
cap->rf_params.supported_band_eutra[1].band_eutra = 7;
cap->rf_params.supported_band_eutra[1].half_duplex = false;
cap->rf_params.supported_band_eutra[2].band_eutra = 20;
cap->rf_params.supported_band_eutra[2].half_duplex = false;
cap->meas_params.N_band_list_eutra = 3;
cap->meas_params.band_list_eutra[0].N_inter_freq_need_for_gaps = 3;
cap->meas_params.band_list_eutra[0].inter_freq_need_for_gaps[0] = true;
cap->meas_params.band_list_eutra[0].inter_freq_need_for_gaps[1] = true;
cap->meas_params.band_list_eutra[0].inter_freq_need_for_gaps[2] = true;
cap->meas_params.band_list_eutra[1].N_inter_freq_need_for_gaps = 3;
cap->meas_params.band_list_eutra[1].inter_freq_need_for_gaps[0] = true;
cap->meas_params.band_list_eutra[1].inter_freq_need_for_gaps[1] = true;
cap->meas_params.band_list_eutra[1].inter_freq_need_for_gaps[2] = true;
cap->meas_params.band_list_eutra[2].N_inter_freq_need_for_gaps = 3;
cap->meas_params.band_list_eutra[2].inter_freq_need_for_gaps[0] = true;
cap->meas_params.band_list_eutra[2].inter_freq_need_for_gaps[1] = true;
cap->meas_params.band_list_eutra[2].inter_freq_need_for_gaps[2] = true;
cap->rf_params.N_supported_band_eutras = args.nof_supported_bands;
cap->meas_params.N_band_list_eutra = args.nof_supported_bands;
for (uint32_t i=0;i<args.nof_supported_bands;i++) {
cap->rf_params.supported_band_eutra[i].band_eutra = args.supported_bands[i];
cap->rf_params.supported_band_eutra[i].half_duplex = false;
cap->meas_params.band_list_eutra[i].N_inter_freq_need_for_gaps = 1;
cap->meas_params.band_list_eutra[i].inter_freq_need_for_gaps[0] = true;
}
cap->feature_group_indicator_present = true;
cap->feature_group_indicator = 0x62001000;
cap->feature_group_indicator = args.feature_group;
cap->inter_rat_params.utra_fdd_present = false;
cap->inter_rat_params.utra_tdd128_present = false;
cap->inter_rat_params.utra_tdd384_present = false;

@ -92,19 +92,36 @@ k = 00112233445566778899aabbccddeeff
imsi = 001010123456789
imei = 353490069873319
#####################################################################
# RRC configuration
#
# stimsi_attach: If enabled, always tries first an S-TMSI attach using the
# S-TMSI value stored in .stimsi file generated in previous run
# mmec_value: If defined (non-zero), overwrites the value stored in .stimsi file
# m_tmsi_value: If defined (non-zero), overwrites the value stored in .stimsi file
#
# ue_category: Sets UE category (range 1-5). Default: 4
# feature_group: Hex value of the featureGroupIndicators field in the
# UECapabilityInformation message. Default 0xe6041c00
#####################################################################
[rrc]
#stmsi_attach = false
#mmec_value = 0
#mtmsi_value = 0
#ue_category = 4
#feature_group = 0xe6041c00
[gui]
enable = false
#####################################################################
# Expert configuration options
#
# ue_category: Sets UE category (range 1-5). Default: 4
# ip_netmask: Netmask of the tun_srsue device. Default: 255.255.255.0
# rssi_sensor_enabled: Enable or disable RF frontend RSSI sensor. Required for RSRP metrics but
# can cause UHD instability for long-duration testing. Default true.
# ue_category: Sets UE category (range 1-5). Default: 4
#
# prach_gain: PRACH gain (dB). If defined, forces a gain for the tranmsission of PRACH only.,
# prach_gain: PRACH gain (dB). If defined, forces a gain for the tranmsission of PRACH only.,
# Default is to use tx_gain in [rf] section.
# cqi_max: Upper bound on the maximum CQI to be reported. Default 15.
# cqi_fixed: Fixes the reported CQI to a constant value. Default disabled.
@ -146,7 +163,6 @@ enable = false
[expert]
#ip_netmask = 255.255.255.0
#rssi_sensor_enabled = false
#ue_category = 4
#prach_gain = 30
#cqi_max = 15
#cqi_fixed = 10

Loading…
Cancel
Save