Fixed HO with ciphering

master
Ismael Gomez 7 years ago
parent 997a22a1c6
commit 5c31800ccb

@ -191,7 +191,6 @@ class rrc_interface_rlc
{ {
public: public:
virtual void max_retx_attempted() = 0; virtual void max_retx_attempted() = 0;
virtual std::string get_rb_name(uint32_t lcid) = 0;
}; };
// PDCP interface for GW // PDCP interface for GW
@ -215,6 +214,10 @@ public:
uint8_t *k_int_, uint8_t *k_int_,
srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_,
srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) = 0; srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) = 0;
virtual void config_security_all(uint8_t *k_enc_,
uint8_t *k_int_,
srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_,
srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) = 0;
virtual void enable_integrity(uint32_t lcid) = 0; virtual void enable_integrity(uint32_t lcid) = 0;
virtual void enable_encryption(uint32_t lcid) = 0; virtual void enable_encryption(uint32_t lcid) = 0;
}; };

@ -63,6 +63,10 @@ public:
uint8_t *k_int, uint8_t *k_int,
CIPHERING_ALGORITHM_ID_ENUM cipher_algo, CIPHERING_ALGORITHM_ID_ENUM cipher_algo,
INTEGRITY_ALGORITHM_ID_ENUM integ_algo); INTEGRITY_ALGORITHM_ID_ENUM integ_algo);
void config_security_all(uint8_t *k_enc,
uint8_t *k_int,
CIPHERING_ALGORITHM_ID_ENUM cipher_algo,
INTEGRITY_ALGORITHM_ID_ENUM integ_algo);
void enable_integrity(uint32_t lcid); void enable_integrity(uint32_t lcid);
void enable_encryption(uint32_t lcid); void enable_encryption(uint32_t lcid);

@ -66,7 +66,6 @@ public:
void write_sdu(uint32_t lcid, byte_buffer_t *sdu); void write_sdu(uint32_t lcid, byte_buffer_t *sdu);
bool rb_is_um(uint32_t lcid); bool rb_is_um(uint32_t lcid);
std::string get_rb_name(uint32_t lcid);
// MAC interface // MAC interface
uint32_t get_buffer_state(uint32_t lcid); uint32_t get_buffer_state(uint32_t lcid);

@ -116,6 +116,18 @@ void pdcp::config_security(uint32_t lcid,
pdcp_array[lcid].config_security(k_enc, k_int, cipher_algo, integ_algo); pdcp_array[lcid].config_security(k_enc, k_int, cipher_algo, integ_algo);
} }
void pdcp::config_security_all(uint8_t *k_enc,
uint8_t *k_int,
CIPHERING_ALGORITHM_ID_ENUM cipher_algo,
INTEGRITY_ALGORITHM_ID_ENUM integ_algo)
{
for(uint32_t i=0;i<SRSLTE_N_RADIO_BEARERS;i++) {
if (pdcp_array[i].is_active()) {
pdcp_array[i].config_security(k_enc, k_int, cipher_algo, integ_algo);
}
}
}
void pdcp::enable_integrity(uint32_t lcid) void pdcp::enable_integrity(uint32_t lcid)
{ {
if(valid_lcid(lcid)) if(valid_lcid(lcid))

@ -84,6 +84,7 @@ void pdcp_entity::reestablish() {
} else { } else {
if (rlc->rb_is_um(lcid)) { if (rlc->rb_is_um(lcid)) {
tx_count = 0; tx_count = 0;
rx_count = 0;
} }
} }
} }

@ -135,11 +135,6 @@ bool rlc::rb_is_um(uint32_t lcid) {
return rlc_array[lcid].get_mode()==RLC_MODE_UM; return rlc_array[lcid].get_mode()==RLC_MODE_UM;
} }
std::string rlc::get_rb_name(uint32_t lcid)
{
return rrc->get_rb_name(lcid);
}
/******************************************************************************* /*******************************************************************************
MAC interface MAC interface
*******************************************************************************/ *******************************************************************************/

@ -238,30 +238,6 @@ private:
bool thread_running; bool thread_running;
void run_thread(); void run_thread();
// Radio bearers
typedef enum{
RB_ID_SRB0 = 0,
RB_ID_SRB1,
RB_ID_SRB2,
RB_ID_DRB1,
RB_ID_DRB2,
RB_ID_DRB3,
RB_ID_DRB4,
RB_ID_DRB5,
RB_ID_DRB6,
RB_ID_DRB7,
RB_ID_DRB8,
RB_ID_MAX
} rb_id_t;
std::string get_rb_name(uint32_t lcid) {
if (lcid < RB_ID_MAX) {
return rb_id_str[lcid];
} else {
return std::string("INVALID_RB");
}
}
// Measurements sub-class // Measurements sub-class
class rrc_meas { class rrc_meas {
public: public:

@ -672,9 +672,9 @@ void phch_recv::run_thread()
workers_pool->start_worker(worker); workers_pool->start_worker(worker);
// Substract PSS/SSS from current cell before computing intra-frequency // Substract PSS/SSS from current cell before computing intra-frequency
if ((tti%5) == 0) { /*if ((tti%5) == 0) {
substract_sync(buffer[0], cell.nof_prb, &ue_sync.strack); substract_sync(buffer[0], cell.nof_prb, &ue_sync.strack);
} }*/
intra_freq_meas.write(tti, buffer[0], SRSLTE_SF_LEN_PRB(cell.nof_prb)); intra_freq_meas.write(tti, buffer[0], SRSLTE_SF_LEN_PRB(cell.nof_prb));
out_of_sync_cnt = 0; out_of_sync_cnt = 0;
break; break;
@ -1175,7 +1175,7 @@ phch_recv::measure::ret_code phch_recv::measure::run_subframe(uint32_t sf_idx)
} }
cnt++; cnt++;
log_h->info("SYNC: Measuring RSRP %d/%d, sf_idx=%d, RSRP=%.1f dBm, SNR=%.1f dB\n", log_h->debug("SYNC: Measuring RSRP %d/%d, sf_idx=%d, RSRP=%.1f dBm, SNR=%.1f dB\n",
cnt, nof_subframes, sf_idx, rsrp, snr); cnt, nof_subframes, sf_idx, rsrp, snr);
if (cnt >= nof_subframes) { if (cnt >= nof_subframes) {
@ -1259,11 +1259,10 @@ int phch_recv::scell_recv::find_cells(cf_t *input_buffer, float rx_gain_offset,
for (uint32_t n_id_2=0;n_id_2<3;n_id_2++) { for (uint32_t n_id_2=0;n_id_2<3;n_id_2++) {
if (cell.id%3 != n_id_2) {
srslte_sync_set_N_id_2(&sync_find, n_id_2); srslte_sync_set_N_id_2(&sync_find, n_id_2);
srslte_sync_find_ret_t sync_res; srslte_sync_find_ret_t sync_res;
do { //do {
srslte_sync_reset(&sync_find); srslte_sync_reset(&sync_find);
srslte_sync_cfo_reset(&sync_find); srslte_sync_cfo_reset(&sync_find);
@ -1281,7 +1280,7 @@ int phch_recv::scell_recv::find_cells(cf_t *input_buffer, float rx_gain_offset,
if (cell_id >= 0) { if (cell_id >= 0) {
// We found the same cell as before, look another N_id_2 // We found the same cell as before, look another N_id_2
if ((uint32_t) cell_id == found_cell.id) { if ((uint32_t) cell_id == found_cell.id || (uint32_t) cell_id == cell.id) {
sync_res = SRSLTE_SYNC_NOFOUND; sync_res = SRSLTE_SYNC_NOFOUND;
} else { } else {
// We found a new cell ID // We found a new cell ID
@ -1290,12 +1289,14 @@ int phch_recv::scell_recv::find_cells(cf_t *input_buffer, float rx_gain_offset,
measure_p.set_cell(found_cell); measure_p.set_cell(found_cell);
// Correct CFO // Correct CFO
/*
srslte_cfo_correct(&sync_find.cfo_corr_frame, srslte_cfo_correct(&sync_find.cfo_corr_frame,
input_buffer, input_buffer,
input_cfo_corrected, input_cfo_corrected,
-srslte_sync_get_cfo(&sync_find)/sync_find.fft_size); -srslte_sync_get_cfo(&sync_find)/sync_find.fft_size);
*/
switch(measure_p.run_multiple_subframes(input_cfo_corrected, peak_idx, sf_idx, nof_sf)) { switch(measure_p.run_multiple_subframes(input_buffer, peak_idx, sf_idx, nof_sf)) {
case measure::MEASURE_OK: case measure::MEASURE_OK:
cells[nof_cells].pci = found_cell.id; cells[nof_cells].pci = found_cell.id;
cells[nof_cells].rsrp = measure_p.rsrp(); cells[nof_cells].rsrp = measure_p.rsrp();
@ -1304,10 +1305,10 @@ int phch_recv::scell_recv::find_cells(cf_t *input_buffer, float rx_gain_offset,
nof_cells++; nof_cells++;
// Substract interference from input buffer (for the next cell) // Substract interference from input buffer (for the next cell)
substract_sync(&input_buffer[measure_p.frame_st_idx()], cell.nof_prb, &sync_find); //substract_sync(&input_buffer[measure_p.frame_st_idx()], cell.nof_prb, &sync_find);
Info("INTRA: Found neighbour cell: pci=%d, rsrp=%.1f dBm, peak_idx=%d, n_id_2=%d, cfo=%.1f Hz\n", Info("INTRA: Found neighbour cell: PCI=%03d, RSRP=%5.1f dBm, peak_idx=%5d, peak_value=%3.2f n_id_2=%d, CFO=%6.1f Hz\n",
cell_id, measure_p.rsrq(), peak_idx, n_id_2, 15000*srslte_sync_get_cfo(&sync_find)); cell_id, measure_p.rsrp(), measure_p.frame_st_idx(), sync_find.peak_value, n_id_2, 15000*srslte_sync_get_cfo(&sync_find));
break; break;
case measure::ERROR: case measure::ERROR:
@ -1327,8 +1328,7 @@ int phch_recv::scell_recv::find_cells(cf_t *input_buffer, float rx_gain_offset,
default: default:
break; break;
} }
} while(sync_res == SRSLTE_SYNC_FOUND); //} while(sync_res == SRSLTE_SYNC_FOUND);
}
} }
return nof_cells; return nof_cells;
} }
@ -1476,8 +1476,6 @@ void phch_recv::intra_measure::run_thread()
} }
if (running) { if (running) {
Info("INTRA: Running intra-frequency measurements\n");
// Read 15 ms data from buffer // Read 15 ms data from buffer
srslte_ringbuffer_read(&ring_buffer, search_buffer, CAPTURE_LEN_SF*current_sflen*sizeof(cf_t)); srslte_ringbuffer_read(&ring_buffer, search_buffer, CAPTURE_LEN_SF*current_sflen*sizeof(cf_t));
int found_cells = scell.find_cells(search_buffer, common->rx_gain_offset, primary_cell, CAPTURE_LEN_SF, info); int found_cells = scell.find_cells(search_buffer, common->rx_gain_offset, primary_cell, CAPTURE_LEN_SF, info);

@ -30,6 +30,7 @@
#include <sstream> #include <sstream>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <srslte/asn1/liblte_rrc.h>
#include "upper/rrc.h" #include "upper/rrc.h"
#include "srslte/asn1/liblte_rrc.h" #include "srslte/asn1/liblte_rrc.h"
#include "srslte/common/security.h" #include "srslte/common/security.h"
@ -1041,12 +1042,24 @@ bool rrc::ho_prepare() {
int ncc = -1; int ncc = -1;
if (mob_reconf.sec_cnfg_ho_present) { if (mob_reconf.sec_cnfg_ho_present) {
ncc = mob_reconf.sec_cnfg_ho.intra_lte.next_hop_chaining_count; ncc = mob_reconf.sec_cnfg_ho.intra_lte.next_hop_chaining_count;
if (mob_reconf.sec_cnfg_ho.intra_lte.key_change_ind) {
rrc_log->console("keyChangeIndicator in securityConfigHO not supported\n");
return false;
}
if (mob_reconf.sec_cnfg_ho.intra_lte.sec_alg_cnfg_present) {
cipher_algo = (CIPHERING_ALGORITHM_ID_ENUM) mob_reconf.sec_cnfg_ho.intra_lte.sec_alg_cnfg.cipher_alg;
integ_algo = (INTEGRITY_ALGORITHM_ID_ENUM) mob_reconf.sec_cnfg_ho.intra_lte.sec_alg_cnfg.int_alg;
rrc_log->console("Warning changed Cipering to %s and Integrity to %s\n",
ciphering_algorithm_id_text[cipher_algo],
integrity_algorithm_id_text[integ_algo]);
}
} }
usim->generate_as_keys_ho(mob_reconf.mob_ctrl_info.target_pci, phy->get_current_earfcn(), usim->generate_as_keys_ho(mob_reconf.mob_ctrl_info.target_pci, phy->get_current_earfcn(),
ncc, ncc,
k_rrc_enc, k_rrc_int, k_up_enc, k_up_int, cipher_algo, integ_algo); k_rrc_enc, k_rrc_int, k_up_enc, k_up_int, cipher_algo, integ_algo);
pdcp->config_security(1, k_rrc_enc, k_rrc_int, cipher_algo, integ_algo);
pdcp->config_security_all(k_rrc_enc, k_rrc_int, cipher_algo, integ_algo);
send_rrc_con_reconfig_complete(NULL); send_rrc_con_reconfig_complete(NULL);
} }
return true; return true;
@ -1423,7 +1436,7 @@ void rrc::send_ul_dcch_msg(byte_buffer_t *pdu)
void rrc::write_sdu(uint32_t lcid, byte_buffer_t *sdu) { void rrc::write_sdu(uint32_t lcid, byte_buffer_t *sdu) {
rrc_log->info_hex(sdu->msg, sdu->N_bytes, "TX %s SDU", get_rb_name(lcid).c_str()); rrc_log->info_hex(sdu->msg, sdu->N_bytes, "TX %s SDU", get_rb_name(lcid));
switch (state) { switch (state) {
case RRC_STATE_CONNECTING: case RRC_STATE_CONNECTING:
send_con_setup_complete(sdu); send_con_setup_complete(sdu);
@ -1438,7 +1451,7 @@ void rrc::write_sdu(uint32_t lcid, byte_buffer_t *sdu) {
} }
void rrc::write_pdu(uint32_t lcid, byte_buffer_t *pdu) { void rrc::write_pdu(uint32_t lcid, byte_buffer_t *pdu) {
rrc_log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU", get_rb_name(lcid).c_str()); rrc_log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU", get_rb_name(lcid));
switch (lcid) { switch (lcid) {
case RB_ID_SRB0: case RB_ID_SRB0:

Loading…
Cancel
Save