Adding PDCP NR Tx test.

master
Pedro Alvarez 6 years ago committed by Andre Puschmann
parent 4bb99464ed
commit c9e99443d8

@ -212,19 +212,18 @@ public:
virtual void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) = 0; virtual void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) = 0;
virtual void write_pdu_pcch(srslte::unique_byte_buffer_t pdu) = 0; virtual void write_pdu_pcch(srslte::unique_byte_buffer_t pdu) = 0;
virtual void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; virtual void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0;
virtual std::string get_rb_name(uint32_t lcid) = 0; virtual std::string get_rb_name(uint32_t lcid) = 0;
}; };
// RRC interface for RLC // RRC interface for RLC
class rrc_interface_rlc 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; virtual std::string get_rb_name(uint32_t lcid) = 0;
virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0;
}; };
// PDCP interface for RRC // PDCP interface for RRC
class pdcp_interface_rrc class pdcp_interface_rrc
{ {

@ -52,14 +52,6 @@ public:
// RRC interface // RRC interface
void write_sdu(unique_byte_buffer_t sdu, bool blocking); void write_sdu(unique_byte_buffer_t sdu, bool blocking);
void config_security(uint8_t* k_rrc_enc_,
uint8_t* k_rrc_int_,
uint8_t* k_up_enc_,
uint8_t* k_up_int_,
CIPHERING_ALGORITHM_ID_ENUM cipher_algo_,
INTEGRITY_ALGORITHM_ID_ENUM integ_algo_);
void enable_integrity();
void enable_encryption();
uint32_t get_dl_count(); uint32_t get_dl_count();
uint32_t get_ul_count(); uint32_t get_ul_count();

@ -35,8 +35,6 @@ void pdcp_entity_base::config_security(uint8_t* k_rrc_enc_,
CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, CIPHERING_ALGORITHM_ID_ENUM cipher_algo_,
INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) INTEGRITY_ALGORITHM_ID_ENUM integ_algo_)
{ {
// TODO add mutex
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
k_rrc_enc[i] = k_rrc_enc_[i]; k_rrc_enc[i] = k_rrc_enc_[i];
k_rrc_int[i] = k_rrc_int_[i]; k_rrc_int[i] = k_rrc_int_[i];

@ -19,7 +19,9 @@
* *
*/ */
#include "srslte/common/buffer_pool.h"
#include "srslte/common/log_filter.h" #include "srslte/common/log_filter.h"
#include "srslte/common/security.h"
#include "srslte/upper/pdcp_entity_nr.h" #include "srslte/upper/pdcp_entity_nr.h"
#include <iostream> #include <iostream>
@ -45,58 +47,91 @@ uint32_t SDU1_LEN = 2;
class rlc_dummy : public srsue::rlc_interface_pdcp class rlc_dummy : public srsue::rlc_interface_pdcp
{ {
public: public:
rlc_dummy(srslte::log_filter* log_) : log(log_) {} rlc_dummy(srslte::log* log_) : log(log_) {}
private: private:
srslte::log_filter* log; srslte::log* log;
void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu, bool blocking = true) {}
bool rb_is_um(uint32_t lcid) { return false; }
}; };
class rrc_dummy : public srsue::rrc_interface_pdcp class rrc_dummy : public srsue::rrc_interface_pdcp
{ {
public: public:
rrc_dummy(srslte::log_filter* log_) : log(log_) {} rrc_dummy(srslte::log* log_) : log(log_) {}
void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {}
void write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) {}
void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) {}
void write_pdu_pcch(srslte::unique_byte_buffer_t pdu) {}
void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {}
std::string get_rb_name(uint32_t lcid) { return "None"; }
private: private:
srslte::log_filter* log; srslte::log* log;
}; };
class gw_dummy : public srsue::gw_interface_pdcp class gw_dummy : public srsue::gw_interface_pdcp
{ {
public: public:
gw_dummy(srslte::log_filter* log_) : log(log_) {} gw_dummy(srslte::log* log_) : log(log_) {}
void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {}
void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {}
private: private:
srslte::log_filter* log; srslte::log* log;
}; };
// Setup all tests
int run_all_tests()
{
srslte::log_filter log("PDCP NR Test");
log.set_level(srslte::LOG_LEVEL_DEBUG);
log.set_hex_limit(128);
TESTASSERT(test_tx_basic(&log));
}
/* /*
* Test 1: PDCP Entity TX * Test 1: PDCP Entity TX
* Configure PDCP entity with EIA2 and EEA2
* TX_NEXT initially at 0.
* Input: {0x18, 0xE2}
* Output: PDCP Header {0x80,0x00}, Ciphered Text {}, MAC-I {}
*/ */
bool test_tx_basic(srslte::log_filter* log) bool test_tx_basic(srslte::byte_buffer_pool* pool, srslte::log* log)
{ {
srslte::pdcp_entity_nr pdcp; srslte::pdcp_entity_nr pdcp;
srslte::srslte_pdcp_config_nr_t cfg = {0, false, true, SECURITY_DIRECTION_UPLINK, srslte::PDCP_SN_LEN_12}; srslte::srslte_pdcp_config_nr_t cfg = {0, false, true, SECURITY_DIRECTION_UPLINK, srslte::PDCP_SN_LEN_12};
rlc_dummy rlc; rlc_dummy rlc(log);
rrc_dummy rrc; rrc_dummy rrc(log);
gw_dummy gw; gw_dummy gw(log);
pdcp.init(rlc, rrc, gw, log, 0, cfg); pdcp.init(&rlc, &rrc, &gw, log, 0, cfg);
pdcp.config_security(k_enc, k_int, k_enc, k_int, srslte::CIPHERING_ALGORITHM_ID_128_EEA2, srslte::INTEGRITY_ALGORITHM_ID_128_EIA2);
pdcp.enable_integrity();
pdcp.enable_encryption();
uint8_t mac_exp[4];
srslte::unique_byte_buffer_t msg = allocate_unique_buffer(*pool);
srslte::unique_byte_buffer_t ct = allocate_unique_buffer(*pool);
memcpy(msg->msg, sdu1, SDU1_LEN);
msg->N_bytes = SDU1_LEN;
srslte::security_128_eia2(&k_int[16], 0, 0, SECURITY_DIRECTION_UPLINK, msg->msg, msg->N_bytes, mac_exp);
srslte::security_128_eea2(&k_enc[16], 0, 0, SECURITY_DIRECTION_UPLINK, msg->msg, msg->N_bytes, ct->msg);
return true; return true;
} }
// Setup all tests
int run_all_tests(srslte::byte_buffer_pool* pool)
{
// Setup log
srslte::log_filter log("PDCP NR Test");
log.set_level(srslte::LOG_LEVEL_DEBUG);
log.set_hex_limit(128);
TESTASSERT(test_tx_basic(pool, &log));
return 0;
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
run_all_tests(); run_all_tests(srslte::byte_buffer_pool::get_instance());
srslte::pool::cleanup(); srslte::byte_buffer_pool::cleanup();
} }

Loading…
Cancel
Save