add TimingInfo support for remaining SS commands

This commit is contained in:
Andre Puschmann 2020-02-28 12:57:05 +01:00
parent 5b31c1db43
commit 89d5876470
3 changed files with 91 additions and 42 deletions

View File

@ -48,18 +48,24 @@ class ss_sys_interface
public: public:
virtual void add_bcch_dlsch_pdu(const std::string cell_name, srslte::unique_byte_buffer_t pdu) = 0; virtual void add_bcch_dlsch_pdu(const std::string cell_name, srslte::unique_byte_buffer_t pdu) = 0;
virtual void add_pch_pdu(srslte::unique_byte_buffer_t pdu) = 0; virtual void add_pch_pdu(srslte::unique_byte_buffer_t pdu) = 0;
virtual void set_cell_attenuation(std::string cell_name, const float attenuation) = 0; virtual void
virtual void set_cell_config(std::string cell_name, uint32_t earfcn, srslte_cell_t cell, const float power) = 0; set_cell_attenuation(const timing_info_t timing, const std::string cell_name, const float attenuation) = 0;
virtual void set_cell_config(const timing_info_t timing,
const std::string cell_name,
const uint32_t earfcn,
const srslte_cell_t cell,
const float power) = 0;
virtual void add_srb(const timing_info_t timing, const uint32_t lcid, const srslte::pdcp_config_t pdcp_config) = 0; virtual void add_srb(const timing_info_t timing, const uint32_t lcid, const srslte::pdcp_config_t pdcp_config) = 0;
virtual void del_srb(const timing_info_t timing, const uint32_t lcid) = 0; virtual void del_srb(const timing_info_t timing, const uint32_t lcid) = 0;
virtual uint32_t get_tti() = 0; virtual uint32_t get_tti() = 0;
virtual int set_as_security(const uint32_t lcid, virtual void set_as_security(const timing_info_t timing,
const uint32_t lcid,
const std::array<uint8_t, 32> k_rrc_enc, const std::array<uint8_t, 32> k_rrc_enc,
const std::array<uint8_t, 32> k_rrc_int, const std::array<uint8_t, 32> k_rrc_int,
const std::array<uint8_t, 32> k_up_enc, const std::array<uint8_t, 32> k_up_enc,
const srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo, const srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo,
const srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo) = 0; const srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo) = 0;
virtual void release_as_security() = 0; virtual void release_as_security(const timing_info_t timing) = 0;
}; };
class ss_srb_interface class ss_srb_interface

View File

@ -160,7 +160,8 @@ private:
assert(cell_name.IsString()); assert(cell_name.IsString());
// Now configure cell // Now configure cell
syssim->set_cell_config(cell_name.GetString(), earfcn.GetInt(), cell, ref_power.GetInt()); syssim->set_cell_config(
ttcn3_helpers::get_timing_info(document), cell_name.GetString(), earfcn.GetInt(), cell, ref_power.GetInt());
// Pull out SIBs and send to syssim // Pull out SIBs and send to syssim
uint16_t consumed_bytes = 0; uint16_t consumed_bytes = 0;
@ -212,10 +213,6 @@ private:
const Value& b = a["ControlInfo"]; const Value& b = a["ControlInfo"];
assert(b.HasMember("CnfFlag")); assert(b.HasMember("CnfFlag"));
if (ttcn3_helpers::get_timing_info(document).now == false) {
log->error("Timing info not supported in %s\n", __FUNCTION__);
}
// Handle cell creation // Handle cell creation
if (document["Request"]["Cell"].HasMember("AddOrReconfigure")) { if (document["Request"]["Cell"].HasMember("AddOrReconfigure")) {
if (document["Request"]["Cell"]["AddOrReconfigure"].HasMember("Basic")) { if (document["Request"]["Cell"]["AddOrReconfigure"].HasMember("Basic")) {
@ -338,10 +335,6 @@ private:
const Value& cells = req["CellAttenuationList"]; const Value& cells = req["CellAttenuationList"];
assert(cells.IsArray()); assert(cells.IsArray());
if (ttcn3_helpers::get_timing_info(document).now == false) {
log->error("Timing info not supported in %s\n", __FUNCTION__);
}
// iterate over all bearers and configure them // iterate over all bearers and configure them
for (Value::ConstValueIterator itr = cells.Begin(); itr != cells.End(); ++itr) { for (Value::ConstValueIterator itr = cells.Begin(); itr != cells.End(); ++itr) {
assert(itr->HasMember("CellId")); assert(itr->HasMember("CellId"));
@ -363,7 +356,7 @@ private:
} }
log->info("Configuring attenuation of %s to %.2f dB\n", id.GetString(), att_value); log->info("Configuring attenuation of %s to %.2f dB\n", id.GetString(), att_value);
syssim->set_cell_attenuation(id.GetString(), att_value); syssim->set_cell_attenuation(ttcn3_helpers::get_timing_info(document), id.GetString(), att_value);
} }
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "CellAttenuationList"); std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "CellAttenuationList");
@ -428,11 +421,6 @@ private:
const Value& req = document["Request"]; const Value& req = document["Request"];
assert(req.HasMember("AS_Security")); assert(req.HasMember("AS_Security"));
if (ttcn3_helpers::get_timing_info(document).now == false) {
log->error("Timing info not supported in %s\n", __FUNCTION__);
// continue ...
}
// check AS security start // check AS security start
const Value& as_sec = req["AS_Security"]; const Value& as_sec = req["AS_Security"];
if (as_sec.HasMember("StartRestart")) { if (as_sec.HasMember("StartRestart")) {
@ -491,10 +479,11 @@ private:
} }
// configure SS to use AS security // configure SS to use AS security
syssim->set_as_security(lcid, k_rrc_enc, k_rrc_int, k_up_enc, cipher_algo, integ_algo); syssim->set_as_security(
ttcn3_helpers::get_timing_info(document), lcid, k_rrc_enc, k_rrc_int, k_up_enc, cipher_algo, integ_algo);
} else if (as_sec.HasMember("Release")) { } else if (as_sec.HasMember("Release")) {
// release all security configs // release all security configs
syssim->release_as_security(); syssim->release_as_security(ttcn3_helpers::get_timing_info(document));
} }
if (config_flag.GetBool() == true) { if (config_flag.GetBool() == true) {

View File

@ -699,16 +699,34 @@ public:
void process_pdu(uint8_t* buff, uint32_t len, pdu_queue::channel_t channel) {} void process_pdu(uint8_t* buff, uint32_t len, pdu_queue::channel_t channel) {}
void set_cell_config(std::string name, uint32_t earfcn_, srslte_cell_t cell_, const float power) void set_cell_config(const timing_info_t timing,
const std::string cell_name,
const uint32_t earfcn,
const srslte_cell_t cell,
const float power)
{
if (timing.now) {
set_cell_config_impl(cell_name, earfcn, cell, power);
} else {
log.debug("Scheduling Cell configuration of %s for TTI=%d\n", cell_name.c_str(), timing.tti);
tti_actions[timing.tti].push_back(
[this, cell_name, earfcn, cell, power]() { set_cell_config_impl(cell_name, earfcn, cell, power); });
}
}
void set_cell_config_impl(const std::string cell_name_,
const uint32_t earfcn_,
const srslte_cell_t cell_,
const float power_)
{ {
// check if cell already exists // check if cell already exists
if (not syssim_has_cell(name)) { if (not syssim_has_cell(cell_name_)) {
// insert new cell // insert new cell
log.info("Adding cell %s with cellId=%d and power=%.2f dBm\n", name.c_str(), cell_.id, power); log.info("Adding cell %s with cellId=%d and power=%.2f dBm\n", cell_name_.c_str(), cell_.id, power_);
unique_syssim_cell_t cell = unique_syssim_cell_t(new syssim_cell_t); unique_syssim_cell_t cell = unique_syssim_cell_t(new syssim_cell_t);
cell->name = name; cell->name = cell_name_;
cell->cell = cell_; cell->cell = cell_;
cell->initial_power = power; cell->initial_power = power_;
cell->earfcn = earfcn_; cell->earfcn = earfcn_;
cells.push_back(std::move(cell)); cells.push_back(std::move(cell));
} else { } else {
@ -730,7 +748,17 @@ public:
return false; return false;
} }
void set_cell_attenuation(std::string cell_name, const float value) void set_cell_attenuation(const timing_info_t timing, const std::string cell_name, const float value)
{
if (timing.now) {
set_cell_attenuation_impl(cell_name, value);
} else {
log.debug("Scheduling Cell attenuation reconfiguration of %s for TTI=%d\n", cell_name.c_str(), timing.tti);
tti_actions[timing.tti].push_back([this, cell_name, value]() { set_cell_attenuation_impl(cell_name, value); });
}
}
void set_cell_attenuation_impl(const std::string cell_name, const float value)
{ {
if (not syssim_has_cell(cell_name)) { if (not syssim_has_cell(cell_name)) {
log.error("Can't set cell power. Cell not found.\n"); log.error("Can't set cell power. Cell not found.\n");
@ -957,7 +985,25 @@ public:
bool rb_is_um(uint32_t lcid) { return false; } bool rb_is_um(uint32_t lcid) { return false; }
int set_as_security(const uint32_t lcid, void set_as_security(const timing_info_t timing,
const uint32_t lcid,
std::array<uint8_t, 32> k_rrc_enc_,
std::array<uint8_t, 32> k_rrc_int_,
std::array<uint8_t, 32> k_up_enc_,
const srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_,
const srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_)
{
if (timing.now) {
set_as_security_impl(lcid, k_rrc_enc_, k_rrc_int_, k_up_enc_, cipher_algo_, integ_algo_);
} else {
log.debug("Scheduling AS security configuration of lcid=%d for TTI=%d\n", lcid, timing.tti);
tti_actions[timing.tti].push_back([this, lcid, k_rrc_enc_, k_rrc_int_, k_up_enc_, cipher_algo_, integ_algo_]() {
set_as_security_impl(lcid, k_rrc_enc_, k_rrc_int_, k_up_enc_, cipher_algo_, integ_algo_);
});
}
}
void set_as_security_impl(const uint32_t lcid,
std::array<uint8_t, 32> k_rrc_enc_, std::array<uint8_t, 32> k_rrc_enc_,
std::array<uint8_t, 32> k_rrc_int_, std::array<uint8_t, 32> k_rrc_int_,
std::array<uint8_t, 32> k_up_enc_, std::array<uint8_t, 32> k_up_enc_,
@ -984,11 +1030,19 @@ public:
k_up_enc = k_up_enc_; k_up_enc = k_up_enc_;
cipher_algo = cipher_algo_; cipher_algo = cipher_algo_;
integ_algo = integ_algo_; integ_algo = integ_algo_;
return 0;
} }
void release_as_security() void release_as_security(const timing_info_t timing)
{
if (timing.now) {
release_as_security_impl();
} else {
log.debug("Scheduling Release of AS security for TTI=%d\n", timing.tti);
tti_actions[timing.tti].push_back([this]() { release_as_security_impl(); });
}
}
void release_as_security_impl()
{ {
log.info("Releasing AS security\n"); log.info("Releasing AS security\n");
as_security_enabled = false; as_security_enabled = false;