From d5ec07185d3bfb5a658c1e44292877c743d34b05 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 11 Apr 2018 15:51:28 +0100 Subject: [PATCH 01/40] Making sure that the UE is EMM-DEREGISTERED if the eNB is terminated. --- srsepc/src/mme/s1ap.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index ccd2536c1..c8f95d706 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -434,8 +434,15 @@ s1ap::release_ues_ecm_ctx_in_enb(uint16_t enb_id) while(ue_id != ues_in_enb->second.end() ) { std::map::iterator ue_ctx = m_mme_ue_s1ap_id_to_ue_ctx.find(*ue_id); + ue_emm_ctx_t *emm_ctx = &ue_ctx->second->emm_ctx; ue_ecm_ctx_t *ecm_ctx = &ue_ctx->second->ecm_ctx; - m_s1ap_log->info("Releasing UE ECM context. UE-MME S1AP Id: %d\n", ecm_ctx->mme_ue_s1ap_id); + + m_s1ap_log->info("Releasing UE context. IMSI: %015lu, UE-MME S1AP Id: %d\n", emm_ctx->imsi, ecm_ctx->mme_ue_s1ap_id); + if(emm_ctx->state == EMM_STATE_REGISTERED) + { + m_mme_gtpc->send_delete_session_request(emm_ctx->imsi); + emm_ctx->state = EMM_STATE_DEREGISTERED; + } m_s1ap_log->console("Releasing UE ECM context. UE-MME S1AP Id: %d\n", ecm_ctx->mme_ue_s1ap_id); ues_in_enb->second.erase(ecm_ctx->mme_ue_s1ap_id); ecm_ctx->state = ECM_STATE_IDLE; From 609881855d9eee272918747b3bcc7793ad1148d5 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 12 Apr 2018 10:19:25 +0100 Subject: [PATCH 02/40] Adding a debug print --- srsepc/src/mme/s1ap.cc | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index c8f95d706..3a52e2cbe 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -431,23 +431,28 @@ s1ap::release_ues_ecm_ctx_in_enb(uint16_t enb_id) //delete UEs ctx std::map >::iterator ues_in_enb = m_enb_id_to_ue_ids.find(enb_id); std::set::iterator ue_id = ues_in_enb->second.begin(); - while(ue_id != ues_in_enb->second.end() ) + if(ue_id == ues_in_enb.end()) { - std::map::iterator ue_ctx = m_mme_ue_s1ap_id_to_ue_ctx.find(*ue_id); - ue_emm_ctx_t *emm_ctx = &ue_ctx->second->emm_ctx; - ue_ecm_ctx_t *ecm_ctx = &ue_ctx->second->ecm_ctx; - - m_s1ap_log->info("Releasing UE context. IMSI: %015lu, UE-MME S1AP Id: %d\n", emm_ctx->imsi, ecm_ctx->mme_ue_s1ap_id); - if(emm_ctx->state == EMM_STATE_REGISTERED) + m_s1ap_log->console("No UEs to be released\n"); + } else{ + while(ue_id != ues_in_enb->second.end() ) { - m_mme_gtpc->send_delete_session_request(emm_ctx->imsi); - emm_ctx->state = EMM_STATE_DEREGISTERED; + std::map::iterator ue_ctx = m_mme_ue_s1ap_id_to_ue_ctx.find(*ue_id); + ue_emm_ctx_t *emm_ctx = &ue_ctx->second->emm_ctx; + ue_ecm_ctx_t *ecm_ctx = &ue_ctx->second->ecm_ctx; + + m_s1ap_log->info("Releasing UE context. IMSI: %015lu, UE-MME S1AP Id: %d\n", emm_ctx->imsi, ecm_ctx->mme_ue_s1ap_id); + if(emm_ctx->state == EMM_STATE_REGISTERED) + { + m_mme_gtpc->send_delete_session_request(emm_ctx->imsi); + emm_ctx->state = EMM_STATE_DEREGISTERED; + } + m_s1ap_log->console("Releasing UE ECM context. UE-MME S1AP Id: %d\n", ecm_ctx->mme_ue_s1ap_id); + ues_in_enb->second.erase(ecm_ctx->mme_ue_s1ap_id); + ecm_ctx->state = ECM_STATE_IDLE; + ecm_ctx->mme_ue_s1ap_id = 0; + ecm_ctx->enb_ue_s1ap_id = 0; } - m_s1ap_log->console("Releasing UE ECM context. UE-MME S1AP Id: %d\n", ecm_ctx->mme_ue_s1ap_id); - ues_in_enb->second.erase(ecm_ctx->mme_ue_s1ap_id); - ecm_ctx->state = ECM_STATE_IDLE; - ecm_ctx->mme_ue_s1ap_id = 0; - ecm_ctx->enb_ue_s1ap_id = 0; } } From 3b5dd5176af5766af49a1517c5038465014a6d02 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 12 Apr 2018 12:08:40 +0100 Subject: [PATCH 03/40] More debug prints. --- srsepc/src/mme/s1ap.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 3a52e2cbe..9af4bff5d 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -428,10 +428,11 @@ s1ap::find_ue_ctx_from_imsi(uint64_t imsi) void s1ap::release_ues_ecm_ctx_in_enb(uint16_t enb_id) { + m_s1ap_log->console("Releasing UEs context\n"); //delete UEs ctx std::map >::iterator ues_in_enb = m_enb_id_to_ue_ids.find(enb_id); std::set::iterator ue_id = ues_in_enb->second.begin(); - if(ue_id == ues_in_enb.end()) + if(ue_id == ues_in_enb->second.end()) { m_s1ap_log->console("No UEs to be released\n"); } else{ From a6fbdb62cdea244a8e92b62e93096778a694c530 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 12 Apr 2018 17:17:49 +0100 Subject: [PATCH 04/40] Adding function to mark the UE as present to in the eNB --- srsepc/hdr/mme/s1ap.h | 1 + srsepc/src/mme/s1ap.cc | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/srsepc/hdr/mme/s1ap.h b/srsepc/hdr/mme/s1ap.h index 5036c18cd..39d3bb9ce 100644 --- a/srsepc/hdr/mme/s1ap.h +++ b/srsepc/hdr/mme/s1ap.h @@ -81,6 +81,7 @@ public: bool add_ue_ctx_to_imsi_map(ue_ctx_t *ue_ctx); bool add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx_t *ue_ctx); + bool add_ue_to_enb_set(uint16_t enb_id, uint32_t mme_ue_s1ap_id); ue_ctx_t* find_ue_ctx_from_imsi(uint64_t imsi); ue_ctx_t* find_ue_ctx_from_mme_ue_s1ap_id(uint32_t mme_ue_s1ap_id); diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 9af4bff5d..337f58b79 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -397,6 +397,27 @@ s1ap::add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx_t *ue_ctx) return true; } +bool +s1ap::add_ue_to_enb_set(uint16_t enb_id, uint32_t mme_ue_s1ap_id) +{ + + std::map >::iterator ues_in_enb = m_enb_id_to_ue_ids.find(enb_id); + if(ues_in_enb == m_enb_id_to_ue_ids.end()) + { + m_s1ap_log->error("Could not find eNB from eNB Id 0x%x",enb_id); + return false; + } + std::set::iterator ue_id = ues_in_enb->second.find(mme_ue_s1ap_id); + if(ue_id != ues_in_enb->second.end()) + { + m_s1ap_log->error("Could not find eNB from eNB Id %d",enb_id); + return false; + } + ues_in_enb->second.insert(mme_ue_s1ap_id); + m_s1ap_log->debug("Added UE with MME-UE S1AP Id %d to eNB 0x%xcontext %d\n", mme_ue_s1ap_id, enb_id); + return true; +} + ue_ctx_t* s1ap::find_ue_ctx_from_mme_ue_s1ap_id(uint32_t mme_ue_s1ap_id) { @@ -435,7 +456,7 @@ s1ap::release_ues_ecm_ctx_in_enb(uint16_t enb_id) if(ue_id == ues_in_enb->second.end()) { m_s1ap_log->console("No UEs to be released\n"); - } else{ + } else { while(ue_id != ues_in_enb->second.end() ) { std::map::iterator ue_ctx = m_mme_ue_s1ap_id_to_ue_ctx.find(*ue_id); From 300b9e7757c360f4ec39a9191dd009debfc0da9c Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Mon, 16 Apr 2018 14:54:55 +0100 Subject: [PATCH 05/40] Starting to add UEs to the eNB context again. --- srsepc/hdr/mme/s1ap.h | 20 +------------------- srsepc/src/mme/s1ap_nas_transport.cc | 5 ++++- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/srsepc/hdr/mme/s1ap.h b/srsepc/hdr/mme/s1ap.h index 39d3bb9ce..7b05a7a1e 100644 --- a/srsepc/hdr/mme/s1ap.h +++ b/srsepc/hdr/mme/s1ap.h @@ -78,6 +78,7 @@ public: uint32_t get_next_mme_ue_s1ap_id(); enb_ctx_t* find_enb_ctx(uint16_t enb_id); void add_new_enb_ctx(const enb_ctx_t &enb_ctx, const struct sctp_sndrcvinfo* enb_sri); + void get_enb_ctx(uint16_t sctp_stream); bool add_ue_ctx_to_imsi_map(ue_ctx_t *ue_ctx); bool add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx_t *ue_ctx); @@ -90,20 +91,6 @@ public: void release_ues_ecm_ctx_in_enb(uint16_t enb_id); bool delete_ue_ctx(uint64_t imsi); - //ue_ctx_t* find_ue_ctx(uint32_t mme_ue_s1ap_id); - //void add_new_ue_ctx(const ue_ctx_t &ue_ctx); - - //void add_new_ue_emm_ctx(const ue_emm_ctx_t &ue_emm_ctx); - //void add_new_ue_ecm_ctx(const ue_ecm_ctx_t &ue_ecm_ctx); - //ue_emm_ctx_t* find_ue_emm_ctx_from_imsi(uint64_t imsi); - //ue_ecm_ctx_t* find_ue_ecm_ctx_from_mme_ue_s1ap_id(uint32_t mme_ue_s1ap_id); - //bool delete_ue_emm_ctx(uint64_t imsi); - //bool delete_ue_ecm_ctx(uint32_t mme_ue_s1ap_id); - //void delete_ues_ecm_ctx_in_enb(uint16_t enb_id); - - //void store_tmp_ue_emm_ctx(const ue_emm_ctx_t &ue_ecm_ctx); - //bool get_tmp_ue_emm_ctx(uint32_t mme_ue_s1ap_id, ue_emm_ctx_t* ue_emm_ptr); - uint32_t allocate_m_tmsi(uint64_t imsi); s1ap_args_t m_s1ap_args; @@ -130,14 +117,9 @@ private: std::map m_sctp_to_enb_id; std::map > m_enb_id_to_ue_ids; - std::map m_imsi_to_ue_ctx; std::map m_mme_ue_s1ap_id_to_ue_ctx; - //std::map m_imsi_to_ue_emm_ctx; - //std::map m_mme_ue_s1ap_id_to_ue_ecm_ctx; - //std::map m_mme_ue_s1ap_id_to_tmp_ue_emm_ctx; - uint32_t m_next_mme_ue_s1ap_id; uint32_t m_next_m_tmsi; diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index 687ced63b..85c833a8b 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -498,6 +498,7 @@ s1ap_nas_transport::handle_nas_imsi_attach_request(uint32_t enb_ue_s1ap_id, memcpy(new_ctx,&ue_ctx,sizeof(ue_ctx_t)); m_s1ap->add_ue_ctx_to_imsi_map(new_ctx); m_s1ap->add_ue_ctx_to_mme_ue_s1ap_id_map(new_ctx); + m_s1ap->add_ue_to_enb_set(enb_id,mme_ue_s1ap_id); //Pack NAS Authentication Request in Downlink NAS Transport msg pack_authentication_request(reply_buffer, ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id, autn, rand); @@ -611,6 +612,7 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id, ue_ctx_t *new_ctx = new ue_ctx_t; memcpy(new_ctx,&ue_ctx,sizeof(ue_ctx_t)); m_s1ap->add_ue_ctx_to_mme_ue_s1ap_id_map(new_ctx); + m_s1ap->add_ue_to_enb_set(enb_id,mme_ue_s1ap_id); pack_identity_request(reply_buffer, ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id); *reply_flag = true; @@ -660,7 +662,8 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id, //Store context based on MME UE S1AP id m_s1ap->add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx); - + m_s1ap->add_ue_to_enb_set(enb_id,mme_ue_s1ap_id); + //Re-generate K_eNB liblte_security_generate_k_enb(emm_ctx->security_ctxt.k_asme, emm_ctx->security_ctxt.ul_nas_count, emm_ctx->security_ctxt.k_enb); m_s1ap_log->info("Generating KeNB with UL NAS COUNT: %d\n",emm_ctx->security_ctxt.ul_nas_count); From 362c856e5316d1261bd4c77aba2c515135d0a8bf Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 18 Apr 2018 11:28:01 +0100 Subject: [PATCH 06/40] Changed UE set to be accessible from SCTP association. --- srsepc/hdr/mme/s1ap.h | 6 +++--- srsepc/src/mme/s1ap.cc | 24 ++++++++++++------------ srsepc/src/mme/s1ap_nas_transport.cc | 10 +++++----- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/srsepc/hdr/mme/s1ap.h b/srsepc/hdr/mme/s1ap.h index 7b05a7a1e..ebedc9fec 100644 --- a/srsepc/hdr/mme/s1ap.h +++ b/srsepc/hdr/mme/s1ap.h @@ -82,13 +82,13 @@ public: bool add_ue_ctx_to_imsi_map(ue_ctx_t *ue_ctx); bool add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx_t *ue_ctx); - bool add_ue_to_enb_set(uint16_t enb_id, uint32_t mme_ue_s1ap_id); + bool add_ue_to_enb_set(int32_t enb_assoc, uint32_t mme_ue_s1ap_id); ue_ctx_t* find_ue_ctx_from_imsi(uint64_t imsi); ue_ctx_t* find_ue_ctx_from_mme_ue_s1ap_id(uint32_t mme_ue_s1ap_id); bool release_ue_ecm_ctx(uint32_t mme_ue_s1ap_id); - void release_ues_ecm_ctx_in_enb(uint16_t enb_id); + void release_ues_ecm_ctx_in_enb(int32_t enb_assoc); bool delete_ue_ctx(uint64_t imsi); uint32_t allocate_m_tmsi(uint64_t imsi); @@ -115,7 +115,7 @@ private: int m_s1mme; std::map m_active_enbs; std::map m_sctp_to_enb_id; - std::map > m_enb_id_to_ue_ids; + std::map > m_enb_assoc_to_ue_ids; std::map m_imsi_to_ue_ctx; std::map m_mme_ue_s1ap_id_to_ue_ctx; diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 337f58b79..2a23fa6eb 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -299,7 +299,7 @@ s1ap::add_new_enb_ctx(const enb_ctx_t &enb_ctx, const struct sctp_sndrcvinfo *en memcpy(enb_ptr,&enb_ctx,sizeof(enb_ctx_t)); m_active_enbs.insert(std::pair(enb_ptr->enb_id,enb_ptr)); m_sctp_to_enb_id.insert(std::pair(enb_sri->sinfo_assoc_id, enb_ptr->enb_id)); - m_enb_id_to_ue_ids.insert(std::pair >(enb_ptr->enb_id,ue_set)); + m_enb_assoc_to_ue_ids.insert(std::pair >(enb_sri->sinfo_assoc_id,ue_set)); return; } @@ -335,7 +335,7 @@ s1ap::delete_enb_ctx(int32_t assoc_id) m_s1ap_log->console("Deleting eNB context. eNB Id: 0x%x\n", enb_id); //Delete connected UEs ctx - release_ues_ecm_ctx_in_enb(enb_id); + release_ues_ecm_ctx_in_enb(assoc_id); //Delete eNB delete it_ctx->second; @@ -398,23 +398,23 @@ s1ap::add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx_t *ue_ctx) } bool -s1ap::add_ue_to_enb_set(uint16_t enb_id, uint32_t mme_ue_s1ap_id) +s1ap::add_ue_to_enb_set(int32_t enb_assoc, uint32_t mme_ue_s1ap_id) { - std::map >::iterator ues_in_enb = m_enb_id_to_ue_ids.find(enb_id); - if(ues_in_enb == m_enb_id_to_ue_ids.end()) + std::map >::iterator ues_in_enb = m_enb_assoc_to_ue_ids.find(enb_assoc); + if(ues_in_enb == m_enb_assoc_to_ue_ids.end()) { - m_s1ap_log->error("Could not find eNB from eNB Id 0x%x",enb_id); + m_s1ap_log->error("Could not find eNB from eNB SCTP association %d",enb_assoc); return false; } std::set::iterator ue_id = ues_in_enb->second.find(mme_ue_s1ap_id); if(ue_id != ues_in_enb->second.end()) { - m_s1ap_log->error("Could not find eNB from eNB Id %d",enb_id); + m_s1ap_log->error("UE with MME UE S1AP Id already exists %d",mme_ue_s1ap_id); return false; } ues_in_enb->second.insert(mme_ue_s1ap_id); - m_s1ap_log->debug("Added UE with MME-UE S1AP Id %d to eNB 0x%xcontext %d\n", mme_ue_s1ap_id, enb_id); + m_s1ap_log->debug("Added UE with MME-UE S1AP Id %d to eNB with association %d\n", mme_ue_s1ap_id, enb_assoc); return true; } @@ -447,11 +447,11 @@ s1ap::find_ue_ctx_from_imsi(uint64_t imsi) } void -s1ap::release_ues_ecm_ctx_in_enb(uint16_t enb_id) +s1ap::release_ues_ecm_ctx_in_enb(int32_t enb_assoc) { m_s1ap_log->console("Releasing UEs context\n"); //delete UEs ctx - std::map >::iterator ues_in_enb = m_enb_id_to_ue_ids.find(enb_id); + std::map >::iterator ues_in_enb = m_enb_assoc_to_ue_ids.find(enb_assoc); std::set::iterator ue_id = ues_in_enb->second.begin(); if(ue_id == ues_in_enb->second.end()) { @@ -497,8 +497,8 @@ s1ap::release_ue_ecm_ctx(uint32_t mme_ue_s1ap_id) return false; } uint16_t enb_id = it->second; - std::map >::iterator ue_set = m_enb_id_to_ue_ids.find(enb_id); - if(ue_set == m_enb_id_to_ue_ids.end()) + std::map >::iterator ue_set = m_enb_assoc_to_ue_ids.find(ecm_ctx->enb_sri.sinfo_assoc_id); + if(ue_set == m_enb_assoc_to_ue_ids.end()) { m_s1ap_log->error("Could not find the eNB's UEs.\n"); return false; diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index 85c833a8b..783768d0d 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -359,7 +359,7 @@ s1ap_nas_transport::handle_nas_attach_request(uint32_t enb_ue_s1ap_id, //Get attach type from attach request if(attach_req.eps_mobile_id.type_of_id == LIBLTE_MME_EPS_MOBILE_ID_TYPE_IMSI) - { + { m_s1ap_log->console("Attach Request -- IMSI-style attach request\n"); m_s1ap_log->info("Attach Request -- IMSI-style attach request\n"); handle_nas_imsi_attach_request(enb_ue_s1ap_id, attach_req, pdn_con_req, reply_buffer, reply_flag, enb_sri); @@ -498,7 +498,7 @@ s1ap_nas_transport::handle_nas_imsi_attach_request(uint32_t enb_ue_s1ap_id, memcpy(new_ctx,&ue_ctx,sizeof(ue_ctx_t)); m_s1ap->add_ue_ctx_to_imsi_map(new_ctx); m_s1ap->add_ue_ctx_to_mme_ue_s1ap_id_map(new_ctx); - m_s1ap->add_ue_to_enb_set(enb_id,mme_ue_s1ap_id); + m_s1ap->add_ue_to_enb_set(enb_sri->sinfo_assoc_id,ecm_ctx->mme_ue_s1ap_id); //Pack NAS Authentication Request in Downlink NAS Transport msg pack_authentication_request(reply_buffer, ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id, autn, rand); @@ -612,7 +612,7 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id, ue_ctx_t *new_ctx = new ue_ctx_t; memcpy(new_ctx,&ue_ctx,sizeof(ue_ctx_t)); m_s1ap->add_ue_ctx_to_mme_ue_s1ap_id_map(new_ctx); - m_s1ap->add_ue_to_enb_set(enb_id,mme_ue_s1ap_id); + m_s1ap->add_ue_to_enb_set(enb_sri->sinfo_assoc_id,ecm_ctx->mme_ue_s1ap_id); pack_identity_request(reply_buffer, ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id); *reply_flag = true; @@ -636,7 +636,7 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id, if(msg_valid == true && emm_ctx->state == EMM_STATE_DEREGISTERED) { m_s1ap_log->console("GUTI Attach Integrity valid. UL count %d, DL count %d\n",emm_ctx->security_ctxt.ul_nas_count, emm_ctx->security_ctxt.dl_nas_count); - + //Create new MME UE S1AP Identity emm_ctx->mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id(); ecm_ctx->mme_ue_s1ap_id = emm_ctx->mme_ue_s1ap_id; @@ -662,7 +662,7 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id, //Store context based on MME UE S1AP id m_s1ap->add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx); - m_s1ap->add_ue_to_enb_set(enb_id,mme_ue_s1ap_id); + m_s1ap->add_ue_to_enb_set(enb_sri->sinfo_assoc_id,ecm_ctx->mme_ue_s1ap_id); //Re-generate K_eNB liblte_security_generate_k_enb(emm_ctx->security_ctxt.k_asme, emm_ctx->security_ctxt.ul_nas_count, emm_ctx->security_ctxt.k_enb); From 5bd8509ce0b48921e5cab87e5dd9ef7e169c80e4 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 18 Apr 2018 13:40:38 +0100 Subject: [PATCH 07/40] Making sure UE is erased from UE set. --- srsepc/src/mme/s1ap.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 2a23fa6eb..07f80d98a 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -474,6 +474,7 @@ s1ap::release_ues_ecm_ctx_in_enb(int32_t enb_assoc) ecm_ctx->state = ECM_STATE_IDLE; ecm_ctx->mme_ue_s1ap_id = 0; ecm_ctx->enb_ue_s1ap_id = 0; + ues_in_enb->second.erase(++ue_id); } } } From 3c44bc3b2ce8ea3c1066ed3f52adc244c016b89a Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 18 Apr 2018 14:26:52 +0100 Subject: [PATCH 08/40] Fixed double erease mistake. The SIGPIPE seems to be gone. --- srsepc/src/mme/s1ap.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 07f80d98a..180859f08 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -470,11 +470,10 @@ s1ap::release_ues_ecm_ctx_in_enb(int32_t enb_assoc) emm_ctx->state = EMM_STATE_DEREGISTERED; } m_s1ap_log->console("Releasing UE ECM context. UE-MME S1AP Id: %d\n", ecm_ctx->mme_ue_s1ap_id); - ues_in_enb->second.erase(ecm_ctx->mme_ue_s1ap_id); ecm_ctx->state = ECM_STATE_IDLE; ecm_ctx->mme_ue_s1ap_id = 0; ecm_ctx->enb_ue_s1ap_id = 0; - ues_in_enb->second.erase(++ue_id); + ues_in_enb->second.erase(ue_id++); } } } From cca8362a692a7f6ac80883e92cc0dfefde951ad7 Mon Sep 17 00:00:00 2001 From: yagoda Date: Thu, 14 Jun 2018 11:33:43 +0200 Subject: [PATCH 09/40] adding mbsfn conditional to gtpu to create mch thread only if mbsfn is enabled --- srsenb/hdr/upper/gtpu.h | 6 +++--- srsenb/src/enb.cc | 2 +- srsenb/src/upper/gtpu.cc | 15 +++++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/srsenb/hdr/upper/gtpu.h b/srsenb/hdr/upper/gtpu.h index c097b190a..ea2726fbe 100644 --- a/srsenb/hdr/upper/gtpu.h +++ b/srsenb/hdr/upper/gtpu.h @@ -71,7 +71,7 @@ class gtpu { public: - bool init(std::string gtp_bind_addr_, std::string mme_addr_, pdcp_interface_gtpu *pdcp_, srslte::log *gtpu_log_); + bool init(std::string gtp_bind_addr_, std::string mme_addr_, pdcp_interface_gtpu *pdcp_, srslte::log *gtpu_log_, bool enable_mbsfn = false); void stop(); // gtpu_interface_rrc @@ -90,9 +90,9 @@ private: bool running; bool run_enable; - bool mch_running; + bool mch_running; bool mch_run_enable; - + bool _enable_mbsfn; std::string gtp_bind_addr; std::string mme_addr; srsenb::pdcp_interface_gtpu *pdcp; diff --git a/srsenb/src/enb.cc b/srsenb/src/enb.cc index 1bdfafb41..3b41672a0 100644 --- a/srsenb/src/enb.cc +++ b/srsenb/src/enb.cc @@ -219,7 +219,7 @@ bool enb::init(all_args_t *args_) pdcp.init(&rlc, &rrc, >pu, &pdcp_log); rrc.init(&rrc_cfg, &phy, &mac, &rlc, &pdcp, &s1ap, >pu, &rrc_log); s1ap.init(args->enb.s1ap, &rrc, &s1ap_log); - gtpu.init(args->enb.s1ap.gtp_bind_addr, args->enb.s1ap.mme_addr, &pdcp, >pu_log); + gtpu.init(args->enb.s1ap.gtp_bind_addr, args->enb.s1ap.mme_addr, &pdcp, >pu_log, args->expert.enable_mbsfn); started = true; return true; diff --git a/srsenb/src/upper/gtpu.cc b/srsenb/src/upper/gtpu.cc index 62b25a29c..6e487a715 100644 --- a/srsenb/src/upper/gtpu.cc +++ b/srsenb/src/upper/gtpu.cc @@ -34,7 +34,7 @@ using namespace srslte; namespace srsenb { -bool gtpu::init(std::string gtp_bind_addr_, std::string mme_addr_, srsenb::pdcp_interface_gtpu* pdcp_, srslte::log* gtpu_log_) +bool gtpu::init(std::string gtp_bind_addr_, std::string mme_addr_, srsenb::pdcp_interface_gtpu* pdcp_, srslte::log* gtpu_log_, bool enable_mbsfn) { pdcp = pdcp_; gtpu_log = gtpu_log_; @@ -95,11 +95,13 @@ bool gtpu::init(std::string gtp_bind_addr_, std::string mme_addr_, srsenb::pdcp_ //Setup M1-u init_m1u(gtpu_log_); - mch_lcid_counter = 1; + _enable_mbsfn = enable_mbsfn; // Setup a thread to receive packets from the src socket start(THREAD_PRIO); - pthread_create(&mch_thread ,NULL ,mch_thread_routine , this); - + if(_enable_mbsfn){ + mch_lcid_counter = 1; + pthread_create(&mch_thread ,NULL ,mch_thread_routine , this); + } return true; } @@ -224,8 +226,9 @@ void gtpu::stop() } } wait_thread_finish(); - pthread_join(mch_thread, NULL); - + if(_enable_mbsfn) { + pthread_join(mch_thread, NULL); + } } if (snk_fd) { From 940671560929bedf6f728e3fab4ba9693c275620 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Thu, 14 Jun 2018 11:35:02 +0200 Subject: [PATCH 10/40] Minor fix on timestammp substraction --- lib/src/phy/common/timestamp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/phy/common/timestamp.c b/lib/src/phy/common/timestamp.c index 8c2fbe39f..ea8b6113d 100644 --- a/lib/src/phy/common/timestamp.c +++ b/lib/src/phy/common/timestamp.c @@ -66,7 +66,7 @@ int srslte_timestamp_sub(srslte_timestamp_t *t, time_t full_secs, double frac_se t->frac_secs -= frac_secs; t->full_secs -= full_secs; if(t->frac_secs < 0){ - t->frac_secs = 1-t->frac_secs; + t->frac_secs = t->frac_secs + 1; t->full_secs--; } if(t->full_secs < 0) From fb82e00289af65ced9ce7d0e7f191c18fcd0ba99 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 18 Jun 2018 18:05:20 +0200 Subject: [PATCH 11/40] print poll retx timer expired only in debug logs --- lib/src/upper/rlc_am.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index a29f54216..77e81d96a 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -277,7 +277,7 @@ uint32_t rlc_am::get_buffer_state() // check if pollRetx timer expired (Section 5.2.2.3 in TS 36.322) if (poll_retx()) { // if both tx and retx buffer are empty, retransmit next PDU to be ack'ed - log->info("Poll reTx timer expired (lcid=%d)\n", lcid); + log->debug("Poll reTx timer expired (lcid=%d)\n", lcid); if ((tx_window.size() > 0 && retx_queue.size() == 0 && tx_sdu_queue.size() == 0)) { std::map::iterator it = tx_window.find(vt_s - 1); if (it != tx_window.end()) { From 01f6395d70d996fb9c4bf185959adc9f1e8608e4 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 19 Jun 2018 14:23:47 +0200 Subject: [PATCH 12/40] add option to force IMSI attach by not loading NAS ctxt from file --- lib/include/srslte/common/interfaces_common.h | 6 ++++-- srsue/hdr/ue_base.h | 5 ++--- srsue/hdr/upper/nas.h | 7 +++++++ srsue/src/main.cc | 8 +++++--- srsue/src/ue.cc | 2 +- srsue/src/upper/nas.cc | 5 +++++ srsue/ue.conf.example | 11 ++++++++--- 7 files changed, 32 insertions(+), 12 deletions(-) diff --git a/lib/include/srslte/common/interfaces_common.h b/lib/include/srslte/common/interfaces_common.h index 5051cacbe..b0d55dba9 100644 --- a/lib/include/srslte/common/interfaces_common.h +++ b/lib/include/srslte/common/interfaces_common.h @@ -38,17 +38,19 @@ namespace srslte { class srslte_nas_config_t { public: - srslte_nas_config_t(uint32_t lcid_ = 0, std::string apn_ = "", std::string user_ = "", std::string pass_ = "") + srslte_nas_config_t(uint32_t lcid_ = 0, std::string apn_ = "", std::string user_ = "", std::string pass_ = "", bool force_imsi_attach_ = false) :lcid(lcid_), apn(apn_), user(user_), - pass(pass_) + pass(pass_), + force_imsi_attach(force_imsi_attach_) {} uint32_t lcid; std::string apn; std::string user; std::string pass; + bool force_imsi_attach; }; diff --git a/srsue/hdr/ue_base.h b/srsue/hdr/ue_base.h index 4c71ba38f..c41a951bb 100644 --- a/srsue/hdr/ue_base.h +++ b/srsue/hdr/ue_base.h @@ -39,6 +39,7 @@ #include "phy/phy.h" #include "upper/usim.h" #include "upper/rrc.h" +#include "upper/nas.h" #include "srslte/interfaces/ue_interfaces.h" #include "srslte/common/logger.h" @@ -129,9 +130,7 @@ typedef struct { usim_args_t usim; rrc_args_t rrc; std::string ue_category_str; - std::string apn_name; - std::string apn_user; - std::string apn_pass; + nas_args_t nas; expert_args_t expert; }all_args_t; diff --git a/srsue/hdr/upper/nas.h b/srsue/hdr/upper/nas.h index e84b4002a..85c7a2f8e 100644 --- a/srsue/hdr/upper/nas.h +++ b/srsue/hdr/upper/nas.h @@ -39,6 +39,13 @@ using srslte::byte_buffer_t; namespace srsue { +typedef struct { + std::string apn_name; + std::string apn_user; + std::string apn_pass; + bool force_imsi_attach; +} nas_args_t; + // EMM states (3GPP 24.302 v10.0.0) typedef enum { EMM_STATE_NULL = 0, diff --git a/srsue/src/main.cc b/srsue/src/main.cc index bf624c432..25b43f590 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -84,9 +84,11 @@ void parse_args(all_args_t *args, int argc, char *argv[]) { "UECapabilityInformation message. Default 0xe6041000") ("rrc.ue_category", bpo::value(&args->ue_category_str)->default_value("4"), "UE Category (1 to 5)") - ("nas.apn", bpo::value(&args->apn_name)->default_value(""), "Set Access Point Name (APN) for data services") - ("nas.user", bpo::value(&args->apn_user)->default_value(""), "Username for CHAP authentication") - ("nas.pass", bpo::value(&args->apn_pass)->default_value(""), "Password for CHAP authentication") + ("nas.apn", bpo::value(&args->nas.apn_name)->default_value(""), "Set Access Point Name (APN) for data services") + ("nas.user", bpo::value(&args->nas.apn_user)->default_value(""), "Username for CHAP authentication") + ("nas.pass", bpo::value(&args->nas.apn_pass)->default_value(""), "Password for CHAP authentication") + ("nas.force_imsi_attach", bpo::value(&args->nas.force_imsi_attach)->default_value(false), "Whether to always perform an IMSI attach") + ("pcap.enable", bpo::value(&args->pcap.enable)->default_value(false), "Enable MAC packet captures for wireshark") ("pcap.filename", bpo::value(&args->pcap.filename)->default_value("ue.pcap"), "MAC layer capture filename") diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index 6fa4bed6c..ae06eae26 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -210,7 +210,7 @@ bool ue::init(all_args_t *args_) { rlc.init(&pdcp, &rrc, this, &rlc_log, &mac, 0 /* RB_ID_SRB0 */); pdcp.init(&rlc, &rrc, &gw, &pdcp_log, 0 /* RB_ID_SRB0 */, SECURITY_DIRECTION_UPLINK); - srslte_nas_config_t nas_cfg(1, args->apn_name, args->apn_user, args->apn_pass); /* RB_ID_SRB1 */ + srslte_nas_config_t nas_cfg(1, args->nas.apn_name, args->nas.apn_user, args->nas.apn_pass, args->nas.force_imsi_attach); /* RB_ID_SRB1 */ nas.init(usim, &rrc, &gw, &nas_log, nas_cfg); gw.init(&pdcp, &nas, &gw_log, 3 /* RB_ID_DRB1 */); gw.set_netmask(args->expert.ip_netmask); diff --git a/srsue/src/upper/nas.cc b/srsue/src/upper/nas.cc index a6b47fca5..2e491b733 100644 --- a/srsue/src/upper/nas.cc +++ b/srsue/src/upper/nas.cc @@ -1364,6 +1364,11 @@ bool nas::read_ctxt_file(nas_sec_ctxt *ctxt) return false; } + if (cfg.force_imsi_attach) { + nas_log->info("Skip reading context from file.\n"); + return false; + } + file.open(".ctxt", std::ios::in); if(file.is_open()) { if(!readvar(file, "m_tmsi=", &ctxt->guti.m_tmsi)) {return false;} diff --git a/srsue/ue.conf.example b/srsue/ue.conf.example index 01169a474..395a6e21d 100644 --- a/srsue/ue.conf.example +++ b/srsue/ue.conf.example @@ -119,11 +119,16 @@ imei = 353490069873319 ##################################################################### # NAS configuration # -# apn: Set Access Point Name (APN) +# apn: Set Access Point Name (APN) +# user: Username for CHAP authentication +# pass: Password for CHAP authentication +# force_imsi_attach: Whether to always perform an IMSI ##################################################################### [nas] -# apn = internetinternet - +#apn = internetinternet +#user = srsuser +#pass = srspass +#force_imsi_attach = false [gui] enable = false From 4eb9d1abacd124d737f01070ac85870c3c3ddb78 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 19 Jun 2018 18:11:26 +0100 Subject: [PATCH 13/40] Revert "fix USIM test by replacing OP with OPc" This reverts commit 16b2172e3683d6db8c1f3985bdd74e1f0e678d37. --- srsue/test/upper/usim_test.cc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/srsue/test/upper/usim_test.cc b/srsue/test/upper/usim_test.cc index c3b13a09c..9e49dc173 100644 --- a/srsue/test/upper/usim_test.cc +++ b/srsue/test/upper/usim_test.cc @@ -27,6 +27,7 @@ #include #include "srsue/hdr/upper/usim.h" #include "srslte/common/log_filter.h" +#include using namespace srsue; @@ -67,8 +68,6 @@ uint16 mnc = 93; int main(int argc, char **argv) { srslte::log_filter usim_log("USIM"); - usim_log.set_level(srslte::LOG_LEVEL_DEBUG); - usim_log.set_hex_limit(100000); bool net_valid; uint8_t res[16]; int res_len; @@ -79,17 +78,10 @@ int main(int argc, char **argv) args.imei = "356092040793011"; args.imsi = "208930000000001"; args.k = "8BAF473F2F8FD09487CCCBD7097C6862"; - args.op = "8e27b6af0e692e750f32667a3b14605d"; // OPc + args.op = "11111111111111111111111111111111"; srsue::usim usim; usim.init(&args, &usim_log); - if (usim.generate_authentication_response(rand_enb, autn_enb, mcc, mnc, res, &res_len, k_asme) != AUTH_OK) { - printf("USIM test failed.\n"); - return -1; - }; - - printf("USIM test ok.\n"); - - return 0; + //assert(usim.generate_authentication_response(rand_enb, autn_enb, mcc, mnc, res, &res_len, k_asme) == AUTH_OK); } From c717148d5444593e346c6afa507c5007ee53395d Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 19 Jun 2018 18:14:09 +0100 Subject: [PATCH 14/40] Revert "Do not print OPc debug" This reverts commit 5fe329971a5b5f38a3204fc06ade2eb5238dc5c0. --- lib/src/common/liblte_security.cc | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/src/common/liblte_security.cc b/lib/src/common/liblte_security.cc index d8f76bf2c..020f019c9 100644 --- a/lib/src/common/liblte_security.cc +++ b/lib/src/common/liblte_security.cc @@ -1124,11 +1124,14 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1(uint8 *k, rijndael_key_schedule(k, &round_keys); // Compute OPc + printf("OPc 0x: "); for(i=0;i<16;i++) - { + { op_c[i] = op[i]; - } - + printf("%02x", op_c[i]); + } + printf("\n"); + //compute_OPc(&round_keys, op, op_c); // Compute temp @@ -1212,11 +1215,14 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1_star(uint8 *k, // Initialize the round keys rijndael_key_schedule(k, &round_keys); + printf("OPc 0x: "); for(i=0;i<16;i++) { op_c[i] = op[i]; + printf("%02x", op_c[i]); } - + printf("\n"); + // Compute OPc //compute_OPc(&round_keys, op, op_c); @@ -1304,10 +1310,13 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f2345(uint8 *k, // Compute OPc //compute_OPc(&round_keys, op, op_c); + printf("OPc 0x: "); for(i=0;i<16;i++) { op_c[i] = op[i]; + printf("%02x", op_c[i]); } + printf("\n"); // Compute temp for(i=0; i<16; i++) { @@ -1412,11 +1421,14 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f5_star(uint8 *k, // Compute OPc //compute_OPc(&round_keys, op, op_c); + printf("OPc 0x: "); for(i=0;i<16;i++) - { + { op_c[i] = op[i]; - } - + printf("%02x", op_c[i]); + } + printf("\n"); + // Compute temp for(i=0; i<16; i++) { From 8d07709069fc9f8edbeb3e7dbf9f5bb0aa9844ed Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 19 Jun 2018 18:15:58 +0100 Subject: [PATCH 15/40] Revert "Changed ue.conf op to opc" This reverts commit 3631c4a83f5fb72daaad69c0b6ab067692235c13. --- srsue/src/main.cc | 2 +- srsue/ue.conf.example | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/srsue/src/main.cc b/srsue/src/main.cc index 25b43f590..fd754a4b3 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -131,7 +131,7 @@ void parse_args(all_args_t *args, int argc, char *argv[]) { ("usim.mode", bpo::value(&args->usim.mode)->default_value("soft"), "USIM mode (soft or pcsc)") ("usim.algo", bpo::value(&args->usim.algo), "USIM authentication algorithm") - ("usim.opc", bpo::value(&args->usim.op), "USIM operator ciphered variant") + ("usim.op", bpo::value(&args->usim.op), "USIM operator variant") ("usim.imsi", bpo::value(&args->usim.imsi), "USIM IMSI") ("usim.imei", bpo::value(&args->usim.imei), "USIM IMEI") ("usim.k", bpo::value(&args->usim.k), "USIM K") diff --git a/srsue/ue.conf.example b/srsue/ue.conf.example index 395a6e21d..cbeca8541 100644 --- a/srsue/ue.conf.example +++ b/srsue/ue.conf.example @@ -88,7 +88,7 @@ file_max_size = -1 # # mode: USIM mode (soft/pcsc) # algo: Authentication algorithm (xor/milenage) -# opc: 128-bit Operator Ciphered Variant Algorithm Configuration Field (hex) +# op: 128-bit Operator Variant Algorithm Configuration Field (hex) # k: 128-bit subscriber key (hex) # imsi: 15 digit International Mobile Subscriber Identity # imei: 15 digit International Mobile Station Equipment Identity @@ -98,7 +98,7 @@ file_max_size = -1 [usim] mode = soft algo = xor -opc = 63BFA50EE6523365FF14C1F45F88737D +op = 63BFA50EE6523365FF14C1F45F88737D k = 00112233445566778899aabbccddeeff imsi = 001010123456789 imei = 353490069873319 From fd97caadb372b53681e89933b8e3501aec431475 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 19 Jun 2018 18:17:11 +0100 Subject: [PATCH 16/40] Revert "Merge branch 'op_vs_opc' into next" This reverts commit be2276b8da5670544824eb6905da2d721cedaa8a, reversing changes made to 4d3fd342f73c9f8847594c035142a189c5c2fb8e. --- lib/src/common/liblte_security.cc | 43 +++++-------------------------- srsepc/src/hss/hss.cc | 24 ++++++++++++----- 2 files changed, 25 insertions(+), 42 deletions(-) diff --git a/lib/src/common/liblte_security.cc b/lib/src/common/liblte_security.cc index 020f019c9..1cf83e5b3 100644 --- a/lib/src/common/liblte_security.cc +++ b/lib/src/common/liblte_security.cc @@ -37,7 +37,7 @@ #include "srslte/common/liblte_security.h" #include "srslte/common/liblte_ssl.h" #include "math.h" -#include + /******************************************************************************* DEFINES *******************************************************************************/ @@ -1124,15 +1124,7 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1(uint8 *k, rijndael_key_schedule(k, &round_keys); // Compute OPc - printf("OPc 0x: "); - for(i=0;i<16;i++) - { - op_c[i] = op[i]; - printf("%02x", op_c[i]); - } - printf("\n"); - - //compute_OPc(&round_keys, op, op_c); + compute_OPc(&round_keys, op, op_c); // Compute temp for(i=0; i<16; i++) @@ -1215,16 +1207,8 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1_star(uint8 *k, // Initialize the round keys rijndael_key_schedule(k, &round_keys); - printf("OPc 0x: "); - for(i=0;i<16;i++) - { - op_c[i] = op[i]; - printf("%02x", op_c[i]); - } - printf("\n"); - // Compute OPc - //compute_OPc(&round_keys, op, op_c); + compute_OPc(&round_keys, op, op_c); // Compute temp for(i=0; i<16; i++) @@ -1309,14 +1293,8 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f2345(uint8 *k, rijndael_key_schedule(k, &round_keys); // Compute OPc - //compute_OPc(&round_keys, op, op_c); - printf("OPc 0x: "); - for(i=0;i<16;i++) - { - op_c[i] = op[i]; - printf("%02x", op_c[i]); - } - printf("\n"); + compute_OPc(&round_keys, op, op_c); + // Compute temp for(i=0; i<16; i++) { @@ -1420,15 +1398,8 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f5_star(uint8 *k, rijndael_key_schedule(k, &round_keys); // Compute OPc - //compute_OPc(&round_keys, op, op_c); - printf("OPc 0x: "); - for(i=0;i<16;i++) - { - op_c[i] = op[i]; - printf("%02x", op_c[i]); - } - printf("\n"); - + compute_OPc(&round_keys, op, op_c); + // Compute temp for(i=0; i<16; i++) { diff --git a/srsepc/src/hss/hss.cc b/srsepc/src/hss/hss.cc index cb15cebf0..9a8db0e3a 100644 --- a/srsepc/src/hss/hss.cc +++ b/srsepc/src/hss/hss.cc @@ -354,7 +354,7 @@ hss::gen_auth_info_answer_milenage(uint64_t imsi, uint8_t *k_asme, uint8_t *autn return false; } gen_rand(rand); - + security_milenage_f2345( k, op, rand, @@ -498,7 +498,7 @@ hss::gen_auth_info_answer_xor(uint64_t imsi, uint8_t *k_asme, uint8_t *autn, uin mcc, mnc, k_asme); - + m_hss_log->debug("User MCC : %x MNC : %x \n", mcc, mnc); m_hss_log->debug_hex(k_asme, 32, "User k_asme : "); @@ -545,7 +545,7 @@ hss::get_k_amf_op_sqn(uint64_t imsi, uint8_t *k, uint8_t *amf, uint8_t *op, uint return true; } -void +void hss::increment_sqn(uint64_t imsi) { hss_ue_ctx_t *ue_ctx = NULL; @@ -562,9 +562,9 @@ hss::increment_sqn(uint64_t imsi) for(int i = 0; i < 6; i++) { p[5-i] = (uint8_t) ((ue_ctx->sqn[i])); } - + sqn++; - + m_hss_log->debug("Incremented SQN (IMSI: %" PRIu64 ") SQN: %" PRIu64 "\n", imsi, sqn); for(int i = 0; i < 6; i++){ @@ -627,7 +627,7 @@ bool hss::get_ue_ctx(uint64_t imsi, hss_ue_ctx_t **ue_ctx) m_hss_log->info("User not found. IMSI: %015lu\n",imsi); return false; } - + *ue_ctx = ue_ctx_it->second; return true; } @@ -660,6 +660,7 @@ hss::get_uint_vec_from_hex_str(const std::string &key_str, uint8_t *key, uint le return; } + std::string hss::hex_string(uint8_t *hex, int size) { @@ -671,4 +672,15 @@ hss::hex_string(uint8_t *hex, int size) } return ss.str(); } + /* +uint64_t +string_to_imsi() +{ + uint64_t imsi = 0; + for(int i=0;i<=14;i++){ + imsi += attach_req.eps_mobile_id.imsi[i]*std::pow(10,14-i); + } + return imsi; +} + */ } //namespace srsepc From 2605c9066b857462290447a456319b121ed8425e Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 6 Jun 2018 14:37:35 +0200 Subject: [PATCH 17/40] improve lime support for srsUE by stopping/starting rx streaming during rate changes --- lib/src/phy/rf/rf_soapy_imp.c | 46 +++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/lib/src/phy/rf/rf_soapy_imp.c b/lib/src/phy/rf/rf_soapy_imp.c index 15854682f..08d89b60a 100644 --- a/lib/src/phy/rf/rf_soapy_imp.c +++ b/lib/src/phy/rf/rf_soapy_imp.c @@ -109,7 +109,7 @@ bool rf_soapy_rx_wait_lo_locked(void *h) void rf_soapy_set_tx_cal(void *h, srslte_rf_cal_t *cal) { - printf("TODO: implement rf_soapy_rx_wait_lo_locked()\n"); + printf("TODO: implement rf_soapy_set_tx_cal()\n"); // not supported } @@ -268,6 +268,9 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) handler->info.min_rx_gain = rx_range.minimum; handler->info.max_rx_gain = rx_range.maximum; + // init Rx rate to lowest LTE rate + rf_soapy_set_rx_srate(handler, 1.92e6); + return SRSLTE_SUCCESS; } @@ -314,20 +317,44 @@ bool rf_soapy_is_master_clock_dynamic(void *h) double rf_soapy_set_rx_srate(void *h, double rate) { rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + + // Restart streaming, as the Lime seems to have problems reconfiguring the sample rate during streaming + bool rx_stream_active = handler->rx_stream_active; + if (rx_stream_active) { + rf_soapy_stop_rx_stream(handler); + } + if (SoapySDRDevice_setSampleRate(handler->device, SOAPY_SDR_RX, 0, rate) != 0) { printf("setSampleRate Rx fail: %s\n", SoapySDRDevice_lastError()); return SRSLTE_ERROR; } + + if (rx_stream_active) { + rf_soapy_start_rx_stream(handler, true); + } + return SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_RX,0); } double rf_soapy_set_tx_srate(void *h, double rate) { rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + + // stop/start streaming during rate reconfiguration + bool rx_stream_active = handler->rx_stream_active; + if (handler->rx_stream_active) { + rf_soapy_stop_rx_stream(handler); + } + if (SoapySDRDevice_setSampleRate(handler->device, SOAPY_SDR_TX, 0, rate) != 0) { printf("setSampleRate Tx fail: %s\n", SoapySDRDevice_lastError()); return SRSLTE_ERROR; } + + if (rx_stream_active) { + rf_soapy_start_rx_stream(handler, true); + } + return SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_TX,0); } @@ -389,15 +416,19 @@ double rf_soapy_set_rx_freq(void *h, double freq) printf("setFrequency fail: %s\n", SoapySDRDevice_lastError()); return SRSLTE_ERROR; } + printf("Tuning receiver to %.2f MHz\n", SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_RX, 0)/1e6); // Todo: expose antenna setting - if (SoapySDRDevice_setAntenna(handler->device, SOAPY_SDR_RX, 0, "LNAH") != 0) { + if (SoapySDRDevice_setAntenna(handler->device, SOAPY_SDR_RX, 0, "LNAL") != 0) { fprintf(stderr, "Failed to set Rx antenna.\n"); } char *ant = SoapySDRDevice_getAntenna(handler->device, SOAPY_SDR_RX, 0); printf("Rx antenna set to %s\n", ant); + // wait until LO is locked + rf_soapy_rx_wait_lo_locked(handler); + return SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_RX, 0); } @@ -411,7 +442,7 @@ double rf_soapy_set_tx_freq(void *h, double freq) } // Todo: expose antenna name in arguments - if (SoapySDRDevice_setAntenna(handler->device, SOAPY_SDR_TX, 0, "BAND1") != 0) { + if (SoapySDRDevice_setAntenna(handler->device, SOAPY_SDR_TX, 0, "BAND2") != 0) { fprintf(stderr, "Failed to set Tx antenna.\n"); } @@ -439,7 +470,7 @@ int rf_soapy_recv_with_time_multi(void *h, rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; int flags; //flags set by receive operation int num_channels = 1; // temp - const long timeoutUs = 1000000; // arbitrarily chosen + const long timeoutUs = 4000000; // arbitrarily chosen int trials = 0; int ret = 0; @@ -458,12 +489,17 @@ int rf_soapy_recv_with_time_multi(void *h, } ret = SoapySDRDevice_readStream(handler->device, handler->rxStream, buffs_ptr, rx_samples, &flags, &timeNs, timeoutUs); if(ret < 0) { - // continue when getting overflows + // continue when getting overflows and timeouts if (ret == SOAPY_SDR_OVERFLOW) { fprintf(stderr, "O"); fflush(stderr); continue; + } else if (SOAPY_SDR_TIMEOUT) { + fprintf(stderr, "T"); + fflush(stderr); + continue; } else { + printf("rx error in soapy, ret=%d, flags=%d, timeNs=%lld\n", ret, flags, timeNs); return SRSLTE_ERROR; } } From 764c3b574e9f5b193d1048a4fc19ff4c0d81e26d Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Tue, 1 May 2018 12:52:43 +0200 Subject: [PATCH 18/40] Add limeSDR mini devname --- lib/src/phy/rf/rf_soapy_imp.c | 2 ++ lib/src/phy/rf/rf_soapy_imp.h | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/src/phy/rf/rf_soapy_imp.c b/lib/src/phy/rf/rf_soapy_imp.c index 08d89b60a..b935cc03b 100644 --- a/lib/src/phy/rf/rf_soapy_imp.c +++ b/lib/src/phy/rf/rf_soapy_imp.c @@ -209,6 +209,8 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) printf("%s=%s, ", soapy_args[i].keys[j], soapy_args[i].vals[j]); if(!strcmp(soapy_args[i].keys[j],"name") && !strcmp(soapy_args[i].vals[j], "LimeSDR-USB")){ devname = DEVNAME_LIME; + } else if (!strcmp(soapy_args[i].keys[j],"name") && !strcmp(soapy_args[i].vals[j], "LimeSDR Mini")){ + devname = DEVNAME_LIME_MINI; } } printf("\n"); diff --git a/lib/src/phy/rf/rf_soapy_imp.h b/lib/src/phy/rf/rf_soapy_imp.h index a2ccf106a..935340953 100644 --- a/lib/src/phy/rf/rf_soapy_imp.h +++ b/lib/src/phy/rf/rf_soapy_imp.h @@ -29,6 +29,7 @@ #include "srslte/config.h" #include "srslte/phy/rf/rf.h" #define DEVNAME_LIME "lime" +#define DEVNAME_LIME_MINI "lime_mini" SRSLTE_API int rf_soapy_open(char *args, void **handler); From 1c3017771ff0d6090f81f4d9ec8b88081d4eb93e Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 7 Jun 2018 09:55:58 +0200 Subject: [PATCH 19/40] move helper functions for processing args to own header --- lib/src/phy/rf/rf_helper.h | 52 +++++++++++++++++++++++++++++++++++++ lib/src/phy/rf/rf_uhd_imp.c | 27 +------------------ 2 files changed, 53 insertions(+), 26 deletions(-) create mode 100644 lib/src/phy/rf/rf_helper.h diff --git a/lib/src/phy/rf/rf_helper.h b/lib/src/phy/rf/rf_helper.h new file mode 100644 index 000000000..7cc721df8 --- /dev/null +++ b/lib/src/phy/rf/rf_helper.h @@ -0,0 +1,52 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2015 Software Radio Systems Limited + * + * \section LICENSE + * + * This file is part of the srsLTE library. + * + * srsLTE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsLTE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +// A bunch of helper functions to process device arguments + + +#define REMOVE_SUBSTRING_WITHCOMAS(S, TOREMOVE) \ + remove_substring(S, TOREMOVE ",");\ + remove_substring(S, TOREMOVE ", ");\ + remove_substring(S, "," TOREMOVE);\ + remove_substring(S, ", " TOREMOVE);\ + remove_substring(S, TOREMOVE) + +static void remove_substring(char *s,const char *toremove) { + while((s=strstr(s,toremove))) { + memmove(s,s+strlen(toremove),1+strlen(s+strlen(toremove))); + } +} + +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[n] != '\0' && src[n] != ',') { + dst[n] = src[n]; + n++; + } + dst[n] = '\0'; +} \ No newline at end of file diff --git a/lib/src/phy/rf/rf_uhd_imp.c b/lib/src/phy/rf/rf_uhd_imp.c index a0548347e..19f810133 100644 --- a/lib/src/phy/rf/rf_uhd_imp.c +++ b/lib/src/phy/rf/rf_uhd_imp.c @@ -32,7 +32,7 @@ #include "srslte/srslte.h" #include "rf_uhd_imp.h" -#include "srslte/phy/rf/rf.h" +#include "rf_helper.h" #include "uhd_c_api.h" #define HAVE_ASYNC_THREAD 1 @@ -320,31 +320,6 @@ int rf_uhd_open(char *args, void **h) return rf_uhd_open_multi(args, h, 1); } -#define REMOVE_SUBSTRING_WITHCOMAS(S, TOREMOVE) \ - remove_substring(S, TOREMOVE ",");\ - remove_substring(S, TOREMOVE ", ");\ - remove_substring(S, "," TOREMOVE);\ - remove_substring(S, ", " TOREMOVE);\ - remove_substring(S, TOREMOVE) - -static void remove_substring(char *s,const char *toremove) -{ - while((s=strstr(s,toremove))) { - memmove(s,s+strlen(toremove),1+strlen(s+strlen(toremove))); - } -} - -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[n] != '\0' && src[n] != ',') { - dst[n] = src[n]; - n++; - } - dst[n] = '\0'; -} - int rf_uhd_open_multi(char *args, void **h, uint32_t nof_channels) { if (h) { From da55c6a71c70a60b2333aafc466a953aa05a871c Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 7 Jun 2018 09:56:36 +0200 Subject: [PATCH 20/40] expose antenna port selection for soapy through device arguments --- lib/src/phy/rf/rf_soapy_imp.c | 56 ++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/lib/src/phy/rf/rf_soapy_imp.c b/lib/src/phy/rf/rf_soapy_imp.c index b935cc03b..06c0043a8 100644 --- a/lib/src/phy/rf/rf_soapy_imp.c +++ b/lib/src/phy/rf/rf_soapy_imp.c @@ -32,7 +32,7 @@ #include "srslte/srslte.h" #include "rf_soapy_imp.h" -#include "srslte/phy/rf/rf.h" +#include "rf_helper.h" #include #include @@ -270,6 +270,44 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) handler->info.min_rx_gain = rx_range.minimum; handler->info.max_rx_gain = rx_range.maximum; + // Check device arguments + if (args) { + // rx antenna + const char rx_ant_arg[] = "rxant="; + char rx_ant_str[64] = {0}; + char *rx_ant_ptr = strstr(args, rx_ant_arg); + if (rx_ant_ptr) { + copy_subdev_string(rx_ant_str, rx_ant_ptr + strlen(rx_ant_arg)); + printf("Setting Rx antenna to %s\n", rx_ant_str); + if (SoapySDRDevice_setAntenna(handler->device, SOAPY_SDR_RX, 0, rx_ant_str) != 0) { + fprintf(stderr, "Failed to set Rx antenna.\n"); + } + remove_substring(args, rx_ant_arg); + remove_substring(args, rx_ant_str); + } + + // tx antenna + const char tx_ant_arg[] = "txant="; + char tx_ant_str[64] = {0}; + char *tx_ant_ptr = strstr(args, tx_ant_arg); + if (tx_ant_ptr) { + copy_subdev_string(tx_ant_str, tx_ant_ptr + strlen(tx_ant_arg)); + printf("Setting Tx antenna to %s\n", tx_ant_str); + if (SoapySDRDevice_setAntenna(handler->device, SOAPY_SDR_TX, 0, tx_ant_str) != 0) { + fprintf(stderr, "Failed to set Tx antenna.\n"); + } + remove_substring(args, tx_ant_arg); + remove_substring(args, tx_ant_str); + } + } + + // print actual antenna configuration + char *ant = SoapySDRDevice_getAntenna(handler->device, SOAPY_SDR_RX, 0); + printf("Rx antenna set to %s\n", ant); + + ant = SoapySDRDevice_getAntenna(handler->device, SOAPY_SDR_TX, 0); + printf("Tx antenna set to %s\n", ant); + // init Rx rate to lowest LTE rate rf_soapy_set_rx_srate(handler, 1.92e6); @@ -420,14 +458,6 @@ double rf_soapy_set_rx_freq(void *h, double freq) } printf("Tuning receiver to %.2f MHz\n", SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_RX, 0)/1e6); - // Todo: expose antenna setting - if (SoapySDRDevice_setAntenna(handler->device, SOAPY_SDR_RX, 0, "LNAL") != 0) { - fprintf(stderr, "Failed to set Rx antenna.\n"); - } - - char *ant = SoapySDRDevice_getAntenna(handler->device, SOAPY_SDR_RX, 0); - printf("Rx antenna set to %s\n", ant); - // wait until LO is locked rf_soapy_rx_wait_lo_locked(handler); @@ -443,14 +473,6 @@ double rf_soapy_set_tx_freq(void *h, double freq) return SRSLTE_ERROR; } - // Todo: expose antenna name in arguments - if (SoapySDRDevice_setAntenna(handler->device, SOAPY_SDR_TX, 0, "BAND2") != 0) { - fprintf(stderr, "Failed to set Tx antenna.\n"); - } - - char *ant = SoapySDRDevice_getAntenna(handler->device, SOAPY_SDR_TX, 0); - printf("Tx antenna set to %s\n", ant); - return SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_TX, 0); } From b8391d20a4b18814107b7a07a56af0d4fb6aae1a Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 7 Jun 2018 16:37:20 +0200 Subject: [PATCH 21/40] fix tx/rx calibration for Lime --- lib/src/phy/rf/rf_soapy_imp.c | 20 +++++++++++++++----- lib/src/radio/radio.cc | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/src/phy/rf/rf_soapy_imp.c b/lib/src/phy/rf/rf_soapy_imp.c index 06c0043a8..5f2c082e8 100644 --- a/lib/src/phy/rf/rf_soapy_imp.c +++ b/lib/src/phy/rf/rf_soapy_imp.c @@ -311,6 +311,10 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) // init Rx rate to lowest LTE rate rf_soapy_set_rx_srate(handler, 1.92e6); + // set default tx gain and leave some time to calibrate tx + rf_soapy_set_tx_gain(handler, 35); + usleep(10000); + return SRSLTE_SUCCESS; } @@ -342,8 +346,12 @@ int rf_soapy_close(void *h) void rf_soapy_set_master_clock_rate(void *h, double rate) { - // Allow the soapy to automatically set the appropriate clock rate + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + if (SoapySDRDevice_setMasterClockRate(handler->device, rate) != 0) { + printf("rf_soapy_set_master_clock_rate Rx fail: %s\n", SoapySDRDevice_lastError()); + } + printf("Set master clock rate to %.2f MHz\n", SoapySDRDevice_getMasterClockRate(handler->device)/1e6); } @@ -426,14 +434,14 @@ double rf_soapy_set_tx_gain(void *h, double gain) double rf_soapy_get_rx_gain(void *h) { rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - return SoapySDRDevice_getGain(handler->device,SOAPY_SDR_RX,0); + return SoapySDRDevice_getGain(handler->device,SOAPY_SDR_RX, 0); } double rf_soapy_get_tx_gain(void *h) { rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - return SoapySDRDevice_getGain(handler->device,SOAPY_SDR_TX,0); + return SoapySDRDevice_getGain(handler->device,SOAPY_SDR_TX, 0); } @@ -456,7 +464,7 @@ double rf_soapy_set_rx_freq(void *h, double freq) printf("setFrequency fail: %s\n", SoapySDRDevice_lastError()); return SRSLTE_ERROR; } - printf("Tuning receiver to %.2f MHz\n", SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_RX, 0)/1e6); + printf("Tuned Rx to %.2f MHz\n", SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_RX, 0)/1e6); // wait until LO is locked rf_soapy_rx_wait_lo_locked(handler); @@ -473,6 +481,8 @@ double rf_soapy_set_tx_freq(void *h, double freq) return SRSLTE_ERROR; } + printf("Tuned Tx to %.2f MHz\n", SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_TX, 0)/1e6); + return SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_TX, 0); } @@ -582,7 +592,7 @@ int rf_soapy_send_timed_multi(void *h, { rf_soapy_handler_t *handler = (rf_soapy_handler_t *) h; int flags = 0; - const long timeoutUs = 2000; // arbitrarily chosen + const long timeoutUs = 5000; // arbitrarily chosen long long timeNs = 0; int trials = 0; int ret = 0; diff --git a/lib/src/radio/radio.cc b/lib/src/radio/radio.cc index 1b114968b..f7bd05862 100644 --- a/lib/src/radio/radio.cc +++ b/lib/src/radio/radio.cc @@ -59,7 +59,7 @@ bool radio::init(char *args, char *devname, uint32_t nof_channels) } else if (strstr(srslte_rf_name(&rf_device), "bladerf")) { burst_preamble_sec = blade_default_burst_preamble_sec; } else { - burst_preamble_sec = 0; + burst_preamble_sec = 0; printf("\nWarning burst preamble is not calibrated for device %s. Set a value manually\n\n", srslte_rf_name(&rf_device)); } From 727d26e75f19bebf986af52e472656e0c813e384 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 14 Jun 2018 14:46:29 +0200 Subject: [PATCH 22/40] init Soapy with LTE rates before creating streams --- lib/src/phy/rf/rf_soapy_imp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/src/phy/rf/rf_soapy_imp.c b/lib/src/phy/rf/rf_soapy_imp.c index 5f2c082e8..ba0043ac5 100644 --- a/lib/src/phy/rf/rf_soapy_imp.c +++ b/lib/src/phy/rf/rf_soapy_imp.c @@ -230,6 +230,11 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) handler->tx_stream_active = false; handler->rx_stream_active = false; handler->devname = devname; + + // init rx/tx rate to lowest LTE rate + rf_soapy_set_rx_srate(handler, 1.92e6); + rf_soapy_set_tx_srate(handler, 1.92e6); + if(SoapySDRDevice_getNumChannels(handler->device,SOAPY_SDR_RX) > 0){ printf("Setting up RX stream\n"); if(SoapySDRDevice_setupStream(handler->device, &(handler->rxStream), SOAPY_SDR_RX, SOAPY_SDR_CF32, NULL, 0, NULL) != 0) { @@ -308,9 +313,6 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) ant = SoapySDRDevice_getAntenna(handler->device, SOAPY_SDR_TX, 0); printf("Tx antenna set to %s\n", ant); - // init Rx rate to lowest LTE rate - rf_soapy_set_rx_srate(handler, 1.92e6); - // set default tx gain and leave some time to calibrate tx rf_soapy_set_tx_gain(handler, 35); usleep(10000); From 5d2a947aac5386593be1eb1cd17e41551acdbc04 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Fri, 15 Jun 2018 16:44:51 +0200 Subject: [PATCH 23/40] soapy: rework rx/tx timing --- lib/src/phy/rf/rf_soapy_imp.c | 169 +++++++++++++++++++++++----------- lib/src/phy/rf/rf_soapy_imp.h | 1 + 2 files changed, 114 insertions(+), 56 deletions(-) diff --git a/lib/src/phy/rf/rf_soapy_imp.c b/lib/src/phy/rf/rf_soapy_imp.c index ba0043ac5..53cfa44aa 100644 --- a/lib/src/phy/rf/rf_soapy_imp.c +++ b/lib/src/phy/rf/rf_soapy_imp.c @@ -36,17 +36,27 @@ #include #include +#include + +#define USE_TX_MTU 0 + +#define PRINT_RX_STATS 0 +#define PRINT_TX_STATS 0 + +#define MIN(a,b) (((a)<(b))?(a):(b)) typedef struct { - char *devname; - SoapySDRKwargs args; - SoapySDRDevice *device; - SoapySDRRange *ranges; - SoapySDRStream *rxStream; - SoapySDRStream *txStream; - bool tx_stream_active; - bool rx_stream_active; - srslte_rf_info_t info; + char *devname; + SoapySDRKwargs args; + SoapySDRDevice *device; + SoapySDRRange *ranges; + SoapySDRStream *rxStream; + SoapySDRStream *txStream; + bool tx_stream_active; + bool rx_stream_active; + srslte_rf_info_t info; + double tx_rate; + size_t rx_mtu, tx_mtu; } rf_soapy_handler_t; @@ -61,31 +71,31 @@ int soapy_error(void *h) void rf_soapy_get_freq_range(void *h) { - + // not supported } void rf_soapy_suppress_handler(const char *x) { - // not supported + // not supported } void rf_soapy_msg_handler(const char *msg) { - // not supported + // not supported } void rf_soapy_suppress_stdout(void *h) { - // not supported + // not supported } void rf_soapy_register_error_handler(void *notused, srslte_rf_error_handler_t new_handler) { - // not supported + // not supported } @@ -109,14 +119,13 @@ bool rf_soapy_rx_wait_lo_locked(void *h) void rf_soapy_set_tx_cal(void *h, srslte_rf_cal_t *cal) { - printf("TODO: implement rf_soapy_set_tx_cal()\n"); // not supported } void rf_soapy_set_rx_cal(void *h, srslte_rf_cal_t *cal) { - printf("TODO: implement rf_soapy_set_rx_cal()\n"); + // not supported } @@ -202,7 +211,7 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) printf("No Soapy devices found.\n"); return SRSLTE_ERROR; } - char* devname = NULL; + char* devname = DEVNAME_NONE; for (size_t i = 0; i < length; i++) { printf("Soapy has found device #%d: ", (int)i); for (size_t j = 0; j < soapy_args[i].size; j++) { @@ -235,20 +244,22 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) rf_soapy_set_rx_srate(handler, 1.92e6); rf_soapy_set_tx_srate(handler, 1.92e6); - if(SoapySDRDevice_getNumChannels(handler->device,SOAPY_SDR_RX) > 0){ + if(SoapySDRDevice_getNumChannels(handler->device, SOAPY_SDR_RX) > 0){ printf("Setting up RX stream\n"); if(SoapySDRDevice_setupStream(handler->device, &(handler->rxStream), SOAPY_SDR_RX, SOAPY_SDR_CF32, NULL, 0, NULL) != 0) { printf("Rx setupStream fail: %s\n", SoapySDRDevice_lastError()); return SRSLTE_ERROR; - } + } + handler->rx_mtu = SoapySDRDevice_getStreamMTU(handler->device, handler->rxStream); } - if(SoapySDRDevice_getNumChannels(handler->device,SOAPY_SDR_TX) > 0){ + if(SoapySDRDevice_getNumChannels(handler->device, SOAPY_SDR_TX) > 0){ printf("Setting up TX stream\n"); if (SoapySDRDevice_setupStream(handler->device, &(handler->txStream), SOAPY_SDR_TX, SOAPY_SDR_CF32, NULL, 0, NULL) != 0) { printf("Tx setupStream fail: %s\n", SoapySDRDevice_lastError()); return SRSLTE_ERROR; - } + } + handler->tx_mtu = SoapySDRDevice_getStreamMTU(handler->device, handler->txStream); } // list device sensors @@ -405,7 +416,8 @@ double rf_soapy_set_tx_srate(void *h, double rate) rf_soapy_start_rx_stream(handler, true); } - return SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_TX,0); + handler->tx_rate = SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_TX, 0); + return handler->tx_rate; } @@ -506,23 +518,29 @@ int rf_soapy_recv_with_time_multi(void *h, rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; int flags; //flags set by receive operation int num_channels = 1; // temp - const long timeoutUs = 4000000; // arbitrarily chosen + const long timeoutUs = 400000; // arbitrarily chosen int trials = 0; int ret = 0; long long timeNs; //timestamp for receive buffer int n = 0; + +#if PRINT_RX_STATS + printf("rx: nsamples=%d rx_mtu=%zd\n", nsamples, handler->rx_mtu); +#endif + do { - size_t rx_samples = nsamples; - - if (rx_samples > nsamples - n){ - rx_samples = nsamples - n; - } + size_t rx_samples = MIN(nsamples - n, handler->rx_mtu); +#if PRINT_RX_STATS + printf(" - rx_samples=%zd\n", rx_samples); +#endif + void *buffs_ptr[4]; for (int i=0; idevice, handler->rxStream, buffs_ptr, rx_samples, &flags, &timeNs, timeoutUs); if(ret < 0) { // continue when getting overflows and timeouts @@ -540,13 +558,17 @@ int rf_soapy_recv_with_time_multi(void *h, } } - // update rx time - if (secs != NULL && frac_secs != NULL) { + // update rx time only for first segment + if (secs != NULL && frac_secs != NULL && n == 0) { *secs = timeNs / 1e9; *frac_secs = (timeNs % 1000000000)/1e9; - //printf("rx_time: secs=%d, frac_secs=%lf timeNs=%lld\n", *secs, *frac_secs, timeNs); + //printf("rx_time: secs=%lld, frac_secs=%lf timeNs=%llu\n", *secs, *frac_secs, timeNs); } +#if PRINT_RX_STATS + printf(" - rx: %d/%zd\n", ret, rx_samples); +#endif + n += ret; trials++; } while (n < nsamples && trials < 100); @@ -594,58 +616,93 @@ int rf_soapy_send_timed_multi(void *h, { rf_soapy_handler_t *handler = (rf_soapy_handler_t *) h; int flags = 0; - const long timeoutUs = 5000; // arbitrarily chosen + const long timeoutUs = 100000; // arbitrarily chosen long long timeNs = 0; int trials = 0; int ret = 0; int n = 0; +#if PRINT_TX_STATS + printf("tx: namples=%d, mtu=%zd\n", nsamples, handler->tx_mtu); +#endif if (!handler->tx_stream_active) { rf_soapy_start_tx_stream(h); } - if (is_start_of_burst && is_end_of_burst) { - flags |= SOAPY_SDR_ONE_PACKET; - } - - if (is_end_of_burst) { - flags |= SOAPY_SDR_END_BURST; - } - + // Convert initial tx time if (has_time_spec) { - flags |= SOAPY_SDR_HAS_TIME; timeNs = secs * 1000000000; timeNs = timeNs + (frac_secs * 1000000000); - //printf("time_spec: secs=%d, frac_secs=%lf timeNs=%lld\n", secs, frac_secs, timeNs); } do { +#if USE_TX_MTU + size_t tx_samples = MIN(nsamples - n, handler->tx_mtu); +#else size_t tx_samples = nsamples; if (tx_samples > nsamples - n) { tx_samples = nsamples - n; } +#endif - ret = SoapySDRDevice_writeStream(handler->device, handler->txStream, (const void *)data, tx_samples, &flags, timeNs, timeoutUs); - if (ret == SOAPY_SDR_TIMEOUT) { - printf("L"); - continue; + // (re-)set stream flags + flags = 0; + if (is_start_of_burst && is_end_of_burst) { + flags |= SOAPY_SDR_ONE_PACKET; } - if (ret == SOAPY_SDR_OVERFLOW) { - printf("O"); - continue; + + if (is_end_of_burst) { + flags |= SOAPY_SDR_END_BURST; } - if (ret == SOAPY_SDR_UNDERFLOW) { - printf("U"); - continue; + + // only set time flag for first tx + if(has_time_spec && n == 0) { + flags |= SOAPY_SDR_HAS_TIME; } + +#if PRINT_TX_STATS + printf(" - tx_samples=%zd at timeNs=%llu flags=%d\n", tx_samples, timeNs, flags); +#endif + + ret = SoapySDRDevice_writeStream(handler->device, handler->txStream, (const void *)data, tx_samples, &flags, timeNs, timeoutUs); + if (ret >= 0) { + // Tx was ok +#if PRINT_TX_STATS + printf(" - tx: %d/%zd\n", ret, tx_samples); +#endif + // Advance tx time + if (has_time_spec && ret < nsamples) { + long long adv = SoapySDR_ticksToTimeNs(ret, handler->tx_rate); +#if PRINT_TX_STATS + printf(" - tx: timeNs_old=%llu, adv=%llu, timeNs_new=%llu, tx_rate=%f\n", timeNs, adv, timeNs+adv, handler->tx_rate); +#endif + timeNs += adv; + } + n += ret; + } else if (ret < 0) { - fprintf(stderr, "Error during writeStream\n"); - exit(-1); - return SRSLTE_ERROR; + // An error has occured + switch (ret) { + case SOAPY_SDR_TIMEOUT: + printf("L"); + break; + case SOAPY_SDR_STREAM_ERROR: + printf("E"); + break; + case SOAPY_SDR_TIME_ERROR: + printf("T"); + break; + case SOAPY_SDR_UNDERFLOW: + printf("U"); + break; + default: + fprintf(stderr, "Error during writeStream\n"); + exit(-1); + return SRSLTE_ERROR; + } } - n += ret; trials++; } while (n < nsamples && trials < 100); diff --git a/lib/src/phy/rf/rf_soapy_imp.h b/lib/src/phy/rf/rf_soapy_imp.h index 935340953..5b1787304 100644 --- a/lib/src/phy/rf/rf_soapy_imp.h +++ b/lib/src/phy/rf/rf_soapy_imp.h @@ -28,6 +28,7 @@ #include #include "srslte/config.h" #include "srslte/phy/rf/rf.h" +#define DEVNAME_NONE "none" #define DEVNAME_LIME "lime" #define DEVNAME_LIME_MINI "lime_mini" From ecfa685ddeed78e993cd13a34ed6ac531c01120c Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 18 Jun 2018 12:20:26 +0200 Subject: [PATCH 24/40] add ctor to radio_multi, fix tearing down radio when not initialized --- lib/include/srslte/radio/radio_multi.h | 3 ++- lib/src/radio/radio.cc | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/include/srslte/radio/radio_multi.h b/lib/include/srslte/radio/radio_multi.h index efb1e31b6..097fe55e2 100644 --- a/lib/include/srslte/radio/radio_multi.h +++ b/lib/include/srslte/radio/radio_multi.h @@ -45,7 +45,8 @@ namespace srslte { class radio_multi : public radio { public: - + radio_multi() {} + ~radio_multi() {} bool init_multi(uint32_t nof_rx_antennas, char *args = NULL, char *devname = NULL); bool rx_now(cf_t *buffer[SRSLTE_MAX_PORTS], uint32_t nof_samples, srslte_timestamp_t *rxd_time); }; diff --git a/lib/src/radio/radio.cc b/lib/src/radio/radio.cc index f7bd05862..117c626bc 100644 --- a/lib/src/radio/radio.cc +++ b/lib/src/radio/radio.cc @@ -81,7 +81,9 @@ bool radio::is_init() { void radio::stop() { - srslte_rf_close(&rf_device); + if (is_initialized) { + srslte_rf_close(&rf_device); + } } void radio::reset() From 937cb4d7a8ed534d66eff8306a4eaae81504ae67 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 18 Jun 2018 12:21:27 +0200 Subject: [PATCH 25/40] rework error handling in Soapy and add statistics --- lib/src/phy/rf/rf_soapy_imp.c | 59 +++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/lib/src/phy/rf/rf_soapy_imp.c b/lib/src/phy/rf/rf_soapy_imp.c index 53cfa44aa..5264b5065 100644 --- a/lib/src/phy/rf/rf_soapy_imp.c +++ b/lib/src/phy/rf/rf_soapy_imp.c @@ -57,6 +57,13 @@ typedef struct { srslte_rf_info_t info; double tx_rate; size_t rx_mtu, tx_mtu; + + uint32_t num_time_errors; + uint32_t num_lates; + uint32_t num_overflows; + uint32_t num_underflows; + uint32_t num_other_errors; + uint32_t num_stream_curruption; } rf_soapy_handler_t; @@ -353,7 +360,14 @@ int rf_soapy_close(void *h) SoapySDRDevice_unmake(handler->device); free(handler); - + + // print statistics + if (handler->num_lates) printf("#lates=%d\n", handler->num_lates); + if (handler->num_overflows) printf("#overflows=%d\n", handler->num_overflows); + if (handler->num_underflows) printf("#underflows=%d\n", handler->num_underflows); + if (handler->num_time_errors) printf("#time_errors=%d\n", handler->num_time_errors); + if (handler->num_other_errors) printf("#other_errors=%d\n", handler->num_other_errors); + return SRSLTE_SUCCESS; } @@ -542,20 +556,22 @@ int rf_soapy_recv_with_time_multi(void *h, } ret = SoapySDRDevice_readStream(handler->device, handler->rxStream, buffs_ptr, rx_samples, &flags, &timeNs, timeoutUs); - if(ret < 0) { - // continue when getting overflows and timeouts - if (ret == SOAPY_SDR_OVERFLOW) { - fprintf(stderr, "O"); - fflush(stderr); - continue; - } else if (SOAPY_SDR_TIMEOUT) { - fprintf(stderr, "T"); - fflush(stderr); - continue; - } else { - printf("rx error in soapy, ret=%d, flags=%d, timeNs=%lld\n", ret, flags, timeNs); - return SRSLTE_ERROR; - } + if (ret == SOAPY_SDR_OVERFLOW || (ret > 0 && (flags & SOAPY_SDR_END_ABRUPT) != 0)) { + handler->num_overflows++; + fprintf(stderr, "O"); + fflush(stderr); + continue; + } else + if (ret == SOAPY_SDR_TIMEOUT) { + handler->num_time_errors++; + fprintf(stderr, "T"); + fflush(stderr); + continue; + } else + if (ret < 0) { + // unspecific error + printf("SoapySDRDevice_readStream returned %d: %s\n", ret, SoapySDR_errToStr(ret)); + handler->num_other_errors++; } // update rx time only for first segment @@ -680,20 +696,25 @@ int rf_soapy_send_timed_multi(void *h, timeNs += adv; } n += ret; - } else + } + else if (ret < 0) { // An error has occured switch (ret) { case SOAPY_SDR_TIMEOUT: + handler->num_lates++; printf("L"); break; case SOAPY_SDR_STREAM_ERROR: + handler->num_stream_curruption++; printf("E"); break; case SOAPY_SDR_TIME_ERROR: + handler->num_time_errors++; printf("T"); break; case SOAPY_SDR_UNDERFLOW: + handler->num_underflows++; printf("U"); break; default: @@ -702,14 +723,12 @@ int rf_soapy_send_timed_multi(void *h, return SRSLTE_ERROR; } } - trials++; } while (n < nsamples && trials < 100); if (n != nsamples) { - fprintf(stderr, "Couldn't write all samples.\n"); - return SRSLTE_ERROR; + fprintf(stderr, "Couldn't write all samples after %d trials.\n", trials); } - return ret; + return n; } From a68758ab0d7ea9424abd23877e7a11627904e461 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 18 Jun 2018 15:54:11 +0200 Subject: [PATCH 26/40] soapy: set RF bandwidth during rate change --- lib/src/phy/rf/rf_soapy_imp.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/src/phy/rf/rf_soapy_imp.c b/lib/src/phy/rf/rf_soapy_imp.c index 5264b5065..80f1b70d1 100644 --- a/lib/src/phy/rf/rf_soapy_imp.c +++ b/lib/src/phy/rf/rf_soapy_imp.c @@ -37,13 +37,16 @@ #include #include #include +#include #define USE_TX_MTU 0 +#define SET_RF_BW 1 #define PRINT_RX_STATS 0 #define PRINT_TX_STATS 0 #define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) typedef struct { char *devname; @@ -247,7 +250,7 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) handler->rx_stream_active = false; handler->devname = devname; - // init rx/tx rate to lowest LTE rate + // init rx/tx rate to lowest LTE rate to avoid decimation warnings rf_soapy_set_rx_srate(handler, 1.92e6); rf_soapy_set_tx_srate(handler, 1.92e6); @@ -404,6 +407,21 @@ double rf_soapy_set_rx_srate(void *h, double rate) return SRSLTE_ERROR; } +#if SET_RF_BW + // Set bandwidth close to current rate + size_t bw_length; + SoapySDRRange *bw_range = SoapySDRDevice_getBandwidthRange(handler->device, SOAPY_SDR_RX, 0, &bw_length); + double bw = rate; + bw = MIN(bw, bw_range->maximum); + bw = MAX(bw, bw_range->minimum); + bw = MAX(bw, 2.5e6); // For the Lime to avoid warnings + if (SoapySDRDevice_setBandwidth(handler->device, SOAPY_SDR_RX, 0, bw) != 0) { + printf("setBandwidth fail: %s\n", SoapySDRDevice_lastError()); + return SRSLTE_ERROR; + } + printf("Set Rx bandwidth to %.2f MHz\n", SoapySDRDevice_getBandwidth(handler->device, SOAPY_SDR_RX, 0)/1e6); +#endif + if (rx_stream_active) { rf_soapy_start_rx_stream(handler, true); } @@ -426,6 +444,20 @@ double rf_soapy_set_tx_srate(void *h, double rate) return SRSLTE_ERROR; } +#if SET_RF_BW + size_t bw_length; + SoapySDRRange *bw_range = SoapySDRDevice_getBandwidthRange(handler->device, SOAPY_SDR_TX, 0, &bw_length); + // try to set the BW to the actual sampling rate but make sure to stay within device boundaries + double bw = rate; + bw = MIN(rate, bw_range->maximum); + bw = MAX(rate, bw_range->minimum); + if (SoapySDRDevice_setBandwidth(handler->device, SOAPY_SDR_TX, 0, bw) != 0) { + printf("setBandwidth fail: %s\n", SoapySDRDevice_lastError()); + return SRSLTE_ERROR; + } + printf("Set Tx bandwidth to %.2f MHz\n", SoapySDRDevice_getBandwidth(handler->device, SOAPY_SDR_TX, 0)/1e6); +#endif + if (rx_stream_active) { rf_soapy_start_rx_stream(handler, true); } From f8fb176ff53ed4ec41bbfdc001e89ad5193eeebc Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 18 Jun 2018 16:34:55 +0200 Subject: [PATCH 27/40] soapy: use log-level error to suppress late warning on console --- lib/src/phy/rf/rf_soapy_imp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/phy/rf/rf_soapy_imp.c b/lib/src/phy/rf/rf_soapy_imp.c index 80f1b70d1..ef191e119 100644 --- a/lib/src/phy/rf/rf_soapy_imp.c +++ b/lib/src/phy/rf/rf_soapy_imp.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #define USE_TX_MTU 0 @@ -338,6 +339,8 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) rf_soapy_set_tx_gain(handler, 35); usleep(10000); + SoapySDR_setLogLevel(SOAPY_SDR_ERROR); + return SRSLTE_SUCCESS; } From e6b12cb1db0fd14903e19a547ce3ec7690a329f7 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 19 Jun 2018 15:35:26 +0200 Subject: [PATCH 28/40] adding basic radio benchmark test --- lib/src/radio/CMakeLists.txt | 2 + lib/src/radio/test/CMakeLists.txt | 26 ++++ lib/src/radio/test/benchmark_radio.cc | 182 ++++++++++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 lib/src/radio/test/CMakeLists.txt create mode 100644 lib/src/radio/test/benchmark_radio.cc diff --git a/lib/src/radio/CMakeLists.txt b/lib/src/radio/CMakeLists.txt index 1e7829e87..7fa479f8c 100644 --- a/lib/src/radio/CMakeLists.txt +++ b/lib/src/radio/CMakeLists.txt @@ -23,3 +23,5 @@ if(RF_FOUND) target_link_libraries(srslte_radio srslte_rf) install(TARGETS srslte_radio DESTINATION ${LIBRARY_DIR}) endif(RF_FOUND) + +add_subdirectory(test) \ No newline at end of file diff --git a/lib/src/radio/test/CMakeLists.txt b/lib/src/radio/test/CMakeLists.txt new file mode 100644 index 000000000..c44fd826e --- /dev/null +++ b/lib/src/radio/test/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright 2013-2017 Software Radio Systems Limited +# +# This file is part of srsLTE +# +# srsLTE is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# srsLTE is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# A copy of the GNU Affero General Public License can be found in +# the LICENSE file in the top-level directory of this distribution +# and at http://www.gnu.org/licenses/. +# + +if(RF_FOUND) + add_executable(benchmark_radio benchmark_radio.cc) + target_link_libraries(benchmark_radio srslte_radio) +endif(RF_FOUND) + + diff --git a/lib/src/radio/test/benchmark_radio.cc b/lib/src/radio/test/benchmark_radio.cc new file mode 100644 index 000000000..d9279a351 --- /dev/null +++ b/lib/src/radio/test/benchmark_radio.cc @@ -0,0 +1,182 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2015 Software Radio Systems Limited + * + * \section LICENSE + * + * This file is part of the srsLTE library. + * + * srsLTE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsLTE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +#include +#include "srslte/srslte.h" +#include "srslte/radio/radio_multi.h" + +using namespace srslte; + +std::string device_args = "auto"; + +double freq = 2630e6; +uint32_t nof_ports = 1; +double srate = 1.92e6; /* Hz */ +double duration = 0.01; /* in seconds, 10 ms by default */ +cf_t *buffers[SRSLTE_MAX_PORTS]; +bool tx_enable = false; + + +void usage(char *prog) { + printf("Usage: %s [rpstvh]\n", prog); + printf("\t-f Carrier frequency in Hz [Default %f]\n", freq); + printf("\t-a Arguments for first radio [Default %s]\n", device_args.c_str()); + printf("\t-p number of ports 1-%d [Default %d]\n", SRSLTE_MAX_PORTS, nof_ports); + printf("\t-s sampling rate [Default %.0f]\n", srate); + printf("\t-t duration in seconds [Default %.3f]\n", duration); + printf("\t-x enable transmit [Default %s]\n", (tx_enable) ? "enabled" : "disabled"); + printf("\t-v Set srslte_verbose to info (v) or debug (vv) [Default none]\n"); + printf("\t-h show this message\n"); +} + +void parse_args(int argc, char **argv) { + int opt; + while ((opt = getopt(argc, argv, "foabcderpstvhmxw")) != -1) { + switch (opt) { + case 'f': + freq = atof(argv[optind]); + break; + case 'a': + device_args = std::string(argv[optind]); + break; + case 'p': + nof_ports = (uint32_t) atoi(argv[optind]); + break; + case 's': + srate = atof(argv[optind]); + break; + case 't': + duration = atof(argv[optind]); + break; + case 'x': + tx_enable ^= true; + break; + case 'v': + srslte_verbose++; + break; + case 'h': + default: + usage(argv[0]); + exit(-1); + } + } +} + +int main(int argc, char **argv) +{ + int ret = SRSLTE_ERROR; + srslte::radio_multi *radio_h = NULL; + srslte_timestamp_t ts_rx = {}, ts_tx = {}; + + /* Parse args */ + parse_args(argc, argv); + + uint32_t nof_samples = (uint32_t) (duration * srate); + uint32_t frame_size = (uint32_t) (srate / 1000.0); /* 1 ms at srate */ + uint32_t nof_frames = (uint32_t) ceil(nof_samples / frame_size); + + radio_h = new radio_multi(); + if (!radio_h) { + fprintf(stderr, "Error: Calling radio_multi constructor\n"); + goto clean_exit; + } + + for (uint32_t p = 0; p < SRSLTE_MAX_PORTS; p++) { + buffers[p] = NULL; + } + + for (uint32_t p = 0; p < nof_ports; p++) { + buffers[p] = (cf_t *) srslte_vec_malloc(sizeof(cf_t) * frame_size); + if (!buffers[p]) { + fprintf(stderr, "Error: Allocating buffer (%d)\n", p); + goto clean_exit; + } + } + + /* Initialise instances */ + printf("Initialising instances...\n"); + if (!radio_h->init((char*)device_args.c_str(), NULL, nof_ports)) { + fprintf(stderr, "Error: Calling radio_multi constructor\n"); + goto clean_exit; + } + + radio_h->set_rx_freq(freq); + + /* Set radio */ + printf("Setting radio...\n"); + if (srate < 10e6) { + radio_h->set_master_clock_rate(4 * srate); + } else { + radio_h->set_master_clock_rate(srate); + } + + radio_h->set_rx_srate(srate); + if (tx_enable) { + radio_h->set_tx_srate(srate); + } + + /* Receive */ + printf("Initial receive for aligning radios...\n"); + radio_h->rx_now(buffers, frame_size, &ts_rx); + + printf("Start capturing %d frames of %d samples...\n", nof_frames, frame_size); + + for (uint32_t i = 0; i < nof_frames; i++) { + frame_size = SRSLTE_MIN(frame_size, nof_samples); + radio_h->rx_now(buffers, frame_size, &ts_rx); + + if (tx_enable) { + srslte_timestamp_copy(&ts_tx, &ts_rx); + srslte_timestamp_add(&ts_tx, 0, 0.004); + radio_h->tx_single(buffers[0], frame_size, ts_tx); + } + + nof_samples -= frame_size; + } + + printf("Finished streaming ...\n"); + + ret = SRSLTE_SUCCESS; + +clean_exit: + printf("Tearing down...\n"); + + radio_h->stop(); + + for (uint32_t p = 0; p < nof_ports; p++) { + if (buffers[p]) { + free(buffers[p]); + } + } + + if (ret) { + printf("Failed!\n"); + } else { + printf("Ok!\n"); + } + + return ret; +} From 81882aae8b5ebf73c69a71ccd3d9b82023f9d4cd Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 20 Jun 2018 16:39:06 +0200 Subject: [PATCH 29/40] white-space fix --- lib/src/common/thread_pool.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/common/thread_pool.cc b/lib/src/common/thread_pool.cc index 6f4fa5d8b..17b539232 100644 --- a/lib/src/common/thread_pool.cc +++ b/lib/src/common/thread_pool.cc @@ -81,7 +81,6 @@ thread_pool::thread_pool(uint32_t max_workers_) : status(max_workers_), cvar(max_workers_), mutex(max_workers_) - { max_workers = max_workers_; for (uint32_t i=0;i Date: Fri, 22 Jun 2018 14:01:51 +0100 Subject: [PATCH 30/40] Fix for use before check error --- lib/src/asn1/liblte_rrc.cc | 333 ++++++++++++++++++++++++++----------- 1 file changed, 237 insertions(+), 96 deletions(-) diff --git a/lib/src/asn1/liblte_rrc.cc b/lib/src/asn1/liblte_rrc.cc index eb264a0ec..a9fe1f46c 100644 --- a/lib/src/asn1/liblte_rrc.cc +++ b/lib/src/asn1/liblte_rrc.cc @@ -1384,11 +1384,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_ue_eutra_capability_ie(LIBLTE_RRC_UE_EUTRA_CAP LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(ue_eutra_capability != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Option indicator - featureGroupIndicators liblte_value_2_bits(ue_eutra_capability->feature_group_indicator_present, &msg_ptr, 1); @@ -10548,11 +10550,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_ul_information_transfer_msg(LIBLTE_RRC_UL_INFO LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(ul_info_transfer != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Extension choice liblte_value_2_bits(0, &msg_ptr, 1); @@ -10586,11 +10590,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_ul_information_transfer_msg(LIBLTE_BIT_MSG_S LIBLTE_RRC_UL_INFORMATION_TRANSFER_STRUCT *ul_info_transfer) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && ul_info_transfer != NULL) { + msg_ptr = msg->msg; + // Extension choice bool ext = liblte_bits_2_value(&msg_ptr, 1); @@ -10598,7 +10604,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_ul_information_transfer_msg(LIBLTE_BIT_MSG_S liblte_bits_2_value(&msg_ptr, 2); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); // Dedicated info type choice ul_info_transfer->dedicated_info_type = (LIBLTE_RRC_UL_INFORMATION_TRANSFER_TYPE_ENUM)liblte_bits_2_value(&msg_ptr, 2); @@ -10652,11 +10658,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_ue_information_request_msg(LIBLTE_RRC_UE_INFOR LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(ue_info_req != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(ue_info_req->rrc_transaction_id, &msg_ptr); @@ -10688,11 +10696,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_ue_information_request_msg(LIBLTE_BIT_MSG_ST LIBLTE_RRC_UE_INFORMATION_REQUEST_STRUCT *ue_info_req) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && ue_info_req != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &ue_info_req->rrc_transaction_id); @@ -10704,7 +10714,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_ue_information_request_msg(LIBLTE_BIT_MSG_ST liblte_bits_2_value(&msg_ptr, 2); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); // RACH report required ue_info_req->rach_report_req = liblte_bits_2_value(&msg_ptr, 1); @@ -10732,12 +10742,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_ue_capability_information_msg(LIBLTE_RRC_UE_CA LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 i; if(ue_capability_info != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(ue_capability_info->rrc_transaction_id, &msg_ptr); @@ -10797,12 +10809,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_ue_capability_information_msg(LIBLTE_BIT_MSG LIBLTE_RRC_UE_CAPABILITY_INFORMATION_STRUCT *ue_capability_info) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 i; if(msg != NULL && ue_capability_info != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &ue_capability_info->rrc_transaction_id); @@ -10814,7 +10828,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_ue_capability_information_msg(LIBLTE_BIT_MSG liblte_bits_2_value(&msg_ptr, 3); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); ue_capability_info->N_ue_caps = liblte_bits_2_value(&msg_ptr, 4); for(i=0; iN_ue_caps; i++) @@ -10861,12 +10875,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_ue_capability_enquiry_msg(LIBLTE_RRC_UE_CAPABI LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 i; if(ue_cap_enquiry != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(ue_cap_enquiry->rrc_transaction_id, &msg_ptr); @@ -10899,12 +10915,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_ue_capability_enquiry_msg(LIBLTE_BIT_MSG_STR LIBLTE_RRC_UE_CAPABILITY_ENQUIRY_STRUCT *ue_cap_enquiry) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 i; if(msg != NULL && ue_cap_enquiry != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &ue_cap_enquiry->rrc_transaction_id); @@ -10916,7 +10934,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_ue_capability_enquiry_msg(LIBLTE_BIT_MSG_STR liblte_bits_2_value(&msg_ptr, 2); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); ue_cap_enquiry->N_ue_cap_reqs = liblte_bits_2_value(&msg_ptr, 3) + 1; for(i=0; iN_ue_cap_reqs; i++) @@ -10946,7 +10964,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_sys_info_block_type_1_msg(LIBLTE_RRC_SYS_INFO_ LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 i; uint32 j; uint8 non_crit_ext_opt = false; @@ -10957,6 +10975,8 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_sys_info_block_type_1_msg(LIBLTE_RRC_SYS_INFO_ if(sib1 != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Optional indicators liblte_value_2_bits(sib1->p_max_present, &msg_ptr, 1); liblte_value_2_bits(sib1->tdd, &msg_ptr, 1); @@ -11038,7 +11058,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_sys_info_block_type_1_msg(LIBLTE_BIT_MSG_STR uint32 *N_bits_used) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 i; uint32 j; bool tdd_config_opt; @@ -11051,6 +11071,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_sys_info_block_type_1_msg(LIBLTE_BIT_MSG_STR sib1 != NULL && N_bits_used != NULL) { + msg_ptr = msg->msg; // Optional indicators sib1->p_max_present = liblte_bits_2_value(&msg_ptr, 1); @@ -11152,7 +11173,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_sys_info_msg(LIBLTE_RRC_SYS_INFO_MSG_STRUCT *s LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 *length_ptr; uint32 length; uint32 pad_bits; @@ -11161,6 +11182,8 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_sys_info_msg(LIBLTE_RRC_SYS_INFO_MSG_STRUCT *s if(sibs != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Critical extensions choice liblte_value_2_bits(0, &msg_ptr, 1); @@ -11275,7 +11298,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_sys_info_msg(LIBLTE_BIT_MSG_STRUCT LIBLTE_RRC_SYS_INFO_MSG_STRUCT *sibs) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 *head_ptr; uint32 i; uint32 length_determinant_octets; @@ -11284,6 +11307,8 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_sys_info_msg(LIBLTE_BIT_MSG_STRUCT if(msg != NULL && sibs != NULL) { + msg_ptr = msg->msg; + // Critical extensions choice if(0 == liblte_bits_2_value(&msg_ptr, 1)) { @@ -11398,11 +11423,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_security_mode_failure_msg(LIBLTE_RRC_SECURITY_ LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(security_mode_failure != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(security_mode_failure->rrc_transaction_id, &msg_ptr); @@ -11425,11 +11452,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_security_mode_failure_msg(LIBLTE_BIT_MSG_STR LIBLTE_RRC_SECURITY_MODE_FAILURE_STRUCT *security_mode_failure) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && security_mode_failure != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &security_mode_failure->rrc_transaction_id); @@ -11438,7 +11467,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_security_mode_failure_msg(LIBLTE_BIT_MSG_STR bool ext = liblte_bits_2_value(&msg_ptr, 1); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); liblte_rrc_consume_noncrit_extension(ext, __func__, &msg_ptr); @@ -11460,11 +11489,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_security_mode_complete_msg(LIBLTE_RRC_SECURITY LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(security_mode_complete != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(security_mode_complete->rrc_transaction_id, &msg_ptr); @@ -11487,11 +11518,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_security_mode_complete_msg(LIBLTE_BIT_MSG_ST LIBLTE_RRC_SECURITY_MODE_COMPLETE_STRUCT *security_mode_complete) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && security_mode_complete != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &security_mode_complete->rrc_transaction_id); @@ -11500,7 +11533,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_security_mode_complete_msg(LIBLTE_BIT_MSG_ST bool ext = liblte_bits_2_value(&msg_ptr, 1); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); liblte_rrc_consume_noncrit_extension(ext, __func__, &msg_ptr); @@ -11521,11 +11554,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_security_mode_command_msg(LIBLTE_RRC_SECURITY_ LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(security_mode_cmd != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(security_mode_cmd->rrc_transaction_id, &msg_ptr); @@ -11558,11 +11593,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_security_mode_command_msg(LIBLTE_BIT_MSG_STR LIBLTE_RRC_SECURITY_MODE_COMMAND_STRUCT *security_mode_cmd) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg_ptr != NULL && security_mode_cmd != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &security_mode_cmd->rrc_transaction_id); @@ -11574,7 +11611,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_security_mode_command_msg(LIBLTE_BIT_MSG_STR liblte_bits_2_value(&msg_ptr, 2); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); // Extension indicator bool ext2 = liblte_bits_2_value(&msg_ptr, 1); @@ -11605,11 +11642,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_rrc_connection_setup_complete_msg(LIBLTE_RRC_C LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(con_setup_complete != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(con_setup_complete->rrc_transaction_id, &msg_ptr); @@ -11662,11 +11701,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_setup_complete_msg(LIBLTE_BIT LIBLTE_RRC_CONNECTION_SETUP_COMPLETE_STRUCT *con_setup_complete) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && con_setup_complete != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &con_setup_complete->rrc_transaction_id); @@ -11679,7 +11720,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_setup_complete_msg(LIBLTE_BIT // Optional indicators con_setup_complete->registered_mme_present = liblte_bits_2_value(&msg_ptr, 1); - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); // Selected PLMN identity con_setup_complete->selected_plmn_id = liblte_bits_2_value(&msg_ptr, 3) + 1; @@ -11726,11 +11767,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_rrc_connection_setup_msg(LIBLTE_RRC_CONNECTION LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(con_setup != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(con_setup->rrc_transaction_id, &msg_ptr); @@ -11759,11 +11802,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_setup_msg(LIBLTE_BIT_MSG_STRU LIBLTE_RRC_CONNECTION_SETUP_STRUCT *con_setup) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && con_setup != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &con_setup->rrc_transaction_id); @@ -11775,7 +11820,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_setup_msg(LIBLTE_BIT_MSG_STRU liblte_bits_2_value(&msg_ptr, 3); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); // Radio Resource Config Dedicated liblte_rrc_unpack_rr_config_dedicated_ie(&msg_ptr, &con_setup->rr_cnfg); @@ -11800,12 +11845,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_rrc_connection_request_msg(LIBLTE_RRC_CONNECTI LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 ext = false; if(con_req != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Extension choice liblte_value_2_bits(ext, &msg_ptr, 1); @@ -11843,11 +11890,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_request_msg(LIBLTE_BIT_MSG_ST LIBLTE_RRC_CONNECTION_REQUEST_STRUCT *con_req) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && con_req != NULL) { + msg_ptr = msg->msg; + // Extension Choice bool ext = liblte_bits_2_value(&msg_ptr, 1); @@ -11886,11 +11935,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_rrc_connection_release_msg(LIBLTE_RRC_CONNECTI LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(con_release != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(con_release->rrc_transaction_id, &msg_ptr); @@ -11921,11 +11972,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_release_msg(LIBLTE_BIT_MSG_ST LIBLTE_RRC_CONNECTION_RELEASE_STRUCT *con_release) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && con_release != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &con_release->rrc_transaction_id); @@ -11937,9 +11990,9 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_release_msg(LIBLTE_BIT_MSG_ST liblte_bits_2_value(&msg_ptr, 2); // Optional indicators - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); // Release cause con_release->release_cause = (LIBLTE_RRC_RELEASE_CAUSE_ENUM)liblte_bits_2_value(&msg_ptr, 2); @@ -11963,11 +12016,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_rrc_connection_reject_msg(LIBLTE_RRC_CONNECTIO LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(con_rej != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Extension choice liblte_value_2_bits(0, &msg_ptr, 1); @@ -11992,11 +12047,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_reject_msg(LIBLTE_BIT_MSG_STR LIBLTE_RRC_CONNECTION_REJECT_STRUCT *con_rej) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && con_rej != NULL) { + msg_ptr = msg->msg; + // Extension choice bool ext = liblte_bits_2_value(&msg_ptr, 1); @@ -12004,7 +12061,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_reject_msg(LIBLTE_BIT_MSG_STR liblte_bits_2_value(&msg_ptr, 2); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); // Wait Time con_rej->wait_time = liblte_bits_2_value(&msg_ptr, 4) + 1; @@ -12029,12 +12086,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_rrc_connection_reestablishment_request_msg(LIB LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 ext = false; if(con_reest_req != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Extension choice liblte_value_2_bits(ext, &msg_ptr, 1); @@ -12064,11 +12123,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_reestablishment_request_msg(L LIBLTE_RRC_CONNECTION_REESTABLISHMENT_REQUEST_STRUCT *con_reest_req) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && con_reest_req != NULL) { + msg_ptr = msg->msg; + // Extension Choice bool ext = liblte_bits_2_value(&msg_ptr, 1); @@ -12100,11 +12161,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_rrc_connection_reestablishment_reject_msg(LIBL LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(con_reest_rej != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Extension choice liblte_value_2_bits(0, &msg_ptr, 1); @@ -12123,16 +12186,18 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_reestablishment_reject_msg(LI LIBLTE_RRC_CONNECTION_REESTABLISHMENT_REJECT_STRUCT *con_reest_rej) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && con_reest_rej != NULL) { + msg_ptr = msg->msg; + // Extension choice bool ext = liblte_bits_2_value(&msg_ptr, 1); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); liblte_rrc_consume_noncrit_extension(ext, __func__, &msg_ptr); @@ -12154,11 +12219,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_rrc_connection_reestablishment_complete_msg(LI LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(con_reest_complete != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(con_reest_complete->rrc_transaction_id, &msg_ptr); @@ -12181,11 +12248,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_reestablishment_complete_msg( LIBLTE_RRC_CONNECTION_REESTABLISHMENT_COMPLETE_STRUCT *con_reest_complete) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && con_reest_complete != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &con_reest_complete->rrc_transaction_id); @@ -12194,7 +12263,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_reestablishment_complete_msg( bool ext = liblte_bits_2_value(&msg_ptr, 1); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); liblte_rrc_consume_noncrit_extension(ext, __func__, &msg_ptr); @@ -12215,11 +12284,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_rrc_connection_reestablishment_msg(LIBLTE_RRC_ LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(con_reest != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(con_reest->rrc_transaction_id, &msg_ptr); @@ -12251,11 +12322,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_reestablishment_msg(LIBLTE_BI LIBLTE_RRC_CONNECTION_REESTABLISHMENT_STRUCT *con_reest) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && con_reest != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &con_reest->rrc_transaction_id); @@ -12267,7 +12340,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_reestablishment_msg(LIBLTE_BI liblte_bits_2_value(&msg_ptr, 3); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); // Radio Resource Config Dedicated liblte_rrc_unpack_rr_config_dedicated_ie(&msg_ptr, &con_reest->rr_cnfg); @@ -12295,11 +12368,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_rrc_connection_reconfiguration_complete_msg(LI LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(con_reconfig_complete != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(con_reconfig_complete->rrc_transaction_id, &msg_ptr); @@ -12322,11 +12397,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_reconfiguration_complete_msg( LIBLTE_RRC_CONNECTION_RECONFIGURATION_COMPLETE_STRUCT *con_reconfig_complete) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && con_reconfig_complete != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &con_reconfig_complete->rrc_transaction_id); @@ -12335,7 +12412,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_reconfiguration_complete_msg( bool ext = liblte_bits_2_value(&msg_ptr, 1); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); liblte_rrc_consume_noncrit_extension(ext, __func__, &msg_ptr); @@ -12356,12 +12433,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_rrc_connection_reconfiguration_msg(LIBLTE_RRC_ LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 i; if(con_reconfig != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(con_reconfig->rrc_transaction_id, &msg_ptr); @@ -12461,13 +12540,15 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_reconfiguration_msg(LIBLTE_BI LIBLTE_RRC_CONNECTION_RECONFIGURATION_STRUCT *con_reconfig) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 i; bool ded_info_nas_list_present; if(msg != NULL && con_reconfig != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &con_reconfig->rrc_transaction_id); @@ -12483,7 +12564,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rrc_connection_reconfiguration_msg(LIBLTE_BI ded_info_nas_list_present = liblte_bits_2_value(&msg_ptr, 1); con_reconfig->rr_cnfg_ded_present = liblte_bits_2_value(&msg_ptr, 1); con_reconfig->sec_cnfg_ho_present = liblte_bits_2_value(&msg_ptr, 1); - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); // Meas Config if(con_reconfig->meas_cnfg_present) @@ -12574,11 +12655,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_rn_reconfiguration_complete_msg(LIBLTE_RRC_RN_ LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(rn_reconfig_complete != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(rn_reconfig_complete->rrc_transaction_id, &msg_ptr); @@ -12605,11 +12688,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rn_reconfiguration_complete_msg(LIBLTE_BIT_M LIBLTE_RRC_RN_RECONFIGURATION_COMPLETE_STRUCT *rn_reconfig_complete) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && rn_reconfig_complete != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &rn_reconfig_complete->rrc_transaction_id); @@ -12621,8 +12706,8 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_rn_reconfiguration_complete_msg(LIBLTE_BIT_M liblte_bits_2_value(&msg_ptr, 2); // Optional indicators - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); liblte_rrc_consume_noncrit_extension(ext, __func__, &msg_ptr); @@ -12655,11 +12740,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_proximity_indication_msg(LIBLTE_RRC_PROXIMITY_ LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(proximity_ind != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Extension choice liblte_value_2_bits(0, &msg_ptr, 1); @@ -12700,11 +12787,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_proximity_indication_msg(LIBLTE_BIT_MSG_STRU LIBLTE_RRC_PROXIMITY_INDICATION_STRUCT *proximity_ind) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && proximity_ind != NULL) { + msg_ptr = msg->msg; + // Extension choice bool ext = liblte_bits_2_value(&msg_ptr, 1); @@ -12712,13 +12801,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_proximity_indication_msg(LIBLTE_BIT_MSG_STRU liblte_bits_2_value(&msg_ptr, 2); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); // Proximity indication type proximity_ind->type = (LIBLTE_RRC_PROXIMITY_INDICATION_TYPE_ENUM)liblte_bits_2_value(&msg_ptr, 1); // Carrier frequency type extension indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); // Carrier frequency type proximity_ind->carrier_freq_type = (LIBLTE_RRC_PROXIMITY_INDICATION_CARRIER_FREQ_TYPE_ENUM)liblte_bits_2_value(&msg_ptr, 1); @@ -12752,13 +12841,15 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_paging_msg(LIBLTE_RRC_PAGING_STRUCT *page, LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 i; uint32 j; if(page != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Optional indicators if(page->paging_record_list_size != 0) { @@ -12850,7 +12941,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_paging_msg(LIBLTE_BIT_MSG_STRUCT *msg, LIBLTE_RRC_PAGING_STRUCT *page) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 i; uint32 j; uint8 paging_record_list_present; @@ -12858,6 +12949,8 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_paging_msg(LIBLTE_BIT_MSG_STRUCT *msg, if(msg != NULL && page != NULL) { + msg_ptr = msg->msg; + // Optional indicators paging_record_list_present = liblte_bits_2_value(&msg_ptr, 1); page->system_info_modification_present = liblte_bits_2_value(&msg_ptr, 1); @@ -13113,11 +13206,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_measurement_report_msg(LIBLTE_RRC_MEASUREMENT_ LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(meas_report != NULL && msg != NULL) { + msg_ptr = msg->msg; + //MeasurementReport liblte_value_2_bits(0, &msg_ptr, 1); //critical extensions liblte_value_2_bits(0, &msg_ptr, 3); //c1 @@ -13157,11 +13252,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_measurement_report_msg(LIBLTE_BIT_MSG_STRUCT LIBLTE_RRC_MEASUREMENT_REPORT_STRUCT *meas_report) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && meas_report != NULL) { + msg_ptr = msg->msg; + //MeasurementReport bool crit_ext = liblte_bits_2_value(&msg_ptr, 1); //critical extensions liblte_bits_2_value(&msg_ptr, 3); //c1 @@ -13212,12 +13309,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_mbsfn_area_configuration_r9_msg(LIBLTE_RRC_MBS LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 i; if(mbsfn_area_cnfg != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Non-critical extension liblte_value_2_bits(0, &msg_ptr, 1); @@ -13248,13 +13347,15 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_mbsfn_area_configuration_r9_msg(LIBLTE_BIT_M LIBLTE_RRC_MBSFN_AREA_CONFIGURATION_R9_STRUCT *mbsfn_area_cnfg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 i; bool ext; if(msg != NULL && mbsfn_area_cnfg != NULL) { + msg_ptr = msg->msg; + // Non-critical extension ext = liblte_bits_2_value(&msg_ptr, 1); liblte_rrc_warning_not_handled(ext, __func__); @@ -13324,11 +13425,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_dl_information_transfer_msg(LIBLTE_RRC_DL_INFO LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(dl_info_transfer != NULL && msg != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_pack_rrc_transaction_identifier_ie(dl_info_transfer->rrc_transaction_id, &msg_ptr); @@ -13366,11 +13469,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_dl_information_transfer_msg(LIBLTE_BIT_MSG_S LIBLTE_RRC_DL_INFORMATION_TRANSFER_STRUCT *dl_info_transfer) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && dl_info_transfer != NULL) { + msg_ptr = msg->msg; + // RRC Transaction ID liblte_rrc_unpack_rrc_transaction_identifier_ie(&msg_ptr, &dl_info_transfer->rrc_transaction_id); @@ -13427,11 +13532,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_csfb_parameters_request_cdma2000_msg(LIBLTE_RR LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(csfb_params_req_cdma2000 != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Extension choice liblte_value_2_bits(0, &msg_ptr, 1); @@ -13450,16 +13557,18 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_csfb_parameters_request_cdma2000_msg(LIBLTE_ LIBLTE_RRC_CSFB_PARAMETERS_REQUEST_CDMA2000_STRUCT *csfb_params_req_cdma2000) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && csfb_params_req_cdma2000 != NULL) { + msg_ptr = msg->msg; + // Extension choice bool ext = liblte_bits_2_value(&msg_ptr, 1); // Optional indicator - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); liblte_rrc_consume_noncrit_extension(ext, __func__, &msg_ptr); @@ -13503,11 +13612,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_bcch_bch_msg(LIBLTE_RRC_MIB_STRUCT *mib, LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(mib != NULL && msg != NULL) { + msg_ptr = msg->msg; + // DL Bandwidth liblte_value_2_bits(mib->dl_bw, &msg_ptr, 3); @@ -13532,11 +13643,13 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_bcch_bch_msg(LIBLTE_BIT_MSG_STRUCT *msg, LIBLTE_RRC_MIB_STRUCT *mib) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; if(msg != NULL && mib != NULL) { + msg_ptr = msg->msg; + // DL Bandwidth mib->dl_bw = (LIBLTE_RRC_DL_BANDWIDTH_ENUM)liblte_bits_2_value(&msg_ptr, 3); @@ -13565,12 +13678,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_bcch_dlsch_msg(LIBLTE_RRC_BCCH_DLSCH_MSG_STRUC LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 ext = false; if(bcch_dlsch_msg != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Extension indicator liblte_value_2_bits(ext, &msg_ptr, 1); @@ -13612,13 +13727,15 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_bcch_dlsch_msg(LIBLTE_BIT_MSG_STRUCT LIBLTE_RRC_BCCH_DLSCH_MSG_STRUCT *bcch_dlsch_msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 N_bits_used; uint8 ext; if(msg != NULL && bcch_dlsch_msg != NULL) { + msg_ptr = msg->msg; + // Extension indicator ext = liblte_bits_2_value(&msg_ptr, 1); @@ -13664,12 +13781,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_mcch_msg(LIBLTE_RRC_MCCH_MSG_STRUCT *mcch_msg, LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 ext = false; if(mcch_msg != NULL && msg != NULL) { + msg_ptr = msg->msg; + // MCCH choice liblte_value_2_bits(0, &msg_ptr, 1); @@ -13691,14 +13810,16 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_mcch_msg(LIBLTE_BIT_MSG_STRUCT *msg, LIBLTE_RRC_MCCH_MSG_STRUCT *mcch_msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 N_bits_used; if(msg != NULL && mcch_msg != NULL) { + msg_ptr = msg->msg; + // MCCH choice - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); if((msg->N_bits-(msg_ptr-msg->msg)) <= (LIBLTE_MAX_MSG_SIZE_BITS - 1)) { @@ -13724,12 +13845,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_pcch_msg(LIBLTE_RRC_PCCH_MSG_STRUCT *pcch_msg, LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 ext = false; if(pcch_msg != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Paging choice liblte_value_2_bits(0, &msg_ptr, 1); @@ -13751,14 +13874,16 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_pcch_msg(LIBLTE_BIT_MSG_STRUCT *msg, LIBLTE_RRC_PCCH_MSG_STRUCT *pcch_msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint32 N_bits_used; if(msg != NULL && pcch_msg != NULL) { + msg_ptr = msg->msg; + // Paging choice - liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__);; + liblte_rrc_warning_not_handled(liblte_bits_2_value(&msg_ptr, 1), __func__); if((msg->N_bits-(msg_ptr-msg->msg)) <= (LIBLTE_MAX_MSG_SIZE_BITS - 1)) { @@ -13784,12 +13909,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_dl_ccch_msg(LIBLTE_RRC_DL_CCCH_MSG_STRUCT *dl_ LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 ext = false; if(dl_ccch_msg != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Extension indicator liblte_value_2_bits(ext, &msg_ptr, 1); @@ -13827,12 +13954,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_dl_ccch_msg(LIBLTE_BIT_MSG_STRUCT *m LIBLTE_RRC_DL_CCCH_MSG_STRUCT *dl_ccch_msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 ext; if(msg != NULL && dl_ccch_msg != NULL) { + msg_ptr = msg->msg; + // Extension indicator ext = liblte_bits_2_value(&msg_ptr, 1); @@ -13876,12 +14005,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_dl_dcch_msg(LIBLTE_RRC_DL_DCCH_MSG_STRUCT *dl_ LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 ext = false; if(dl_dcch_msg != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Extension indicator liblte_value_2_bits(ext, &msg_ptr, 1); @@ -13950,12 +14081,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_dl_dcch_msg(LIBLTE_BIT_MSG_STRUCT *m LIBLTE_RRC_DL_DCCH_MSG_STRUCT *dl_dcch_msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 ext; if(msg != NULL && dl_dcch_msg != NULL) { + msg_ptr = msg->msg; + // Extension indicator ext = liblte_bits_2_value(&msg_ptr, 1); @@ -14029,12 +14162,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_ul_ccch_msg(LIBLTE_RRC_UL_CCCH_MSG_STRUCT *ul_ LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 ext = false; if(ul_ccch_msg != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Extension indicator liblte_value_2_bits(ext, &msg_ptr, 1); @@ -14066,12 +14201,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_ul_ccch_msg(LIBLTE_BIT_MSG_STRUCT *m LIBLTE_RRC_UL_CCCH_MSG_STRUCT *ul_ccch_msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 ext; if(msg != NULL && ul_ccch_msg != NULL) { + msg_ptr = msg->msg; + // Extension indicator ext = liblte_bits_2_value(&msg_ptr, 1); @@ -14109,12 +14246,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_pack_ul_dcch_msg(LIBLTE_RRC_UL_DCCH_MSG_STRUCT *ul_ LIBLTE_BIT_MSG_STRUCT *msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 ext = false; if(ul_dcch_msg != NULL && msg != NULL) { + msg_ptr = msg->msg; + // Extension indicator liblte_value_2_bits(ext, &msg_ptr, 1); @@ -14186,12 +14325,14 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_ul_dcch_msg(LIBLTE_BIT_MSG_STRUCT *m LIBLTE_RRC_UL_DCCH_MSG_STRUCT *ul_dcch_msg) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; - uint8 *msg_ptr = msg->msg; + uint8 *msg_ptr; uint8 ext; if(msg != NULL && ul_dcch_msg != NULL) { + msg_ptr = msg->msg; + // Extension indicator ext = liblte_bits_2_value(&msg_ptr, 1); From 2a0c98c82ae0e07b2de1459c0d3387baa13fdcc5 Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Fri, 22 Jun 2018 14:52:04 +0100 Subject: [PATCH 31/40] minor uninitialized variable fix --- lib/src/asn1/liblte_rrc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/asn1/liblte_rrc.cc b/lib/src/asn1/liblte_rrc.cc index a9fe1f46c..488a23e51 100644 --- a/lib/src/asn1/liblte_rrc.cc +++ b/lib/src/asn1/liblte_rrc.cc @@ -11595,7 +11595,7 @@ LIBLTE_ERROR_ENUM liblte_rrc_unpack_security_mode_command_msg(LIBLTE_BIT_MSG_STR LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; uint8 *msg_ptr; - if(msg_ptr != NULL && + if(msg != NULL && security_mode_cmd != NULL) { msg_ptr = msg->msg; From 6542f56cba9314727137eb8fd3997d4d5fcece6c Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Fri, 15 Jun 2018 16:49:49 +0200 Subject: [PATCH 32/40] Fix: no RI when periodic report in PUSCH --- srsue/src/phy/phch_worker.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/srsue/src/phy/phch_worker.cc b/srsue/src/phy/phch_worker.cc index e6e7727fd..64e3a9e5e 100644 --- a/srsue/src/phy/phch_worker.cc +++ b/srsue/src/phy/phch_worker.cc @@ -1110,6 +1110,8 @@ void phch_worker::set_uci_periodic_cqi() Debug("PUCCH: Periodic CQI=%d, SNR=%.1f dB\n", cqi_report.wideband.wideband_cqi, phy->avg_snr_db_cqi); } uci_data.uci_cqi_len = (uint32_t) srslte_cqi_value_pack(&cqi_report, uci_data.uci_cqi); + uci_data.uci_ri = phy->last_ri; + uci_data.uci_ri_len = 0; rar_cqi_request = false; } } From 22c0a67b976977f1e10942a79c4d48ae987285bf Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Fri, 22 Jun 2018 13:27:19 +0200 Subject: [PATCH 33/40] Fixed minor issues --- lib/examples/pdsch_ue.c | 2 +- lib/src/phy/enb/enb_dl.c | 4 ++-- lib/src/phy/ue/ue_dl.c | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/examples/pdsch_ue.c b/lib/examples/pdsch_ue.c index 50fb0807e..4bf8dc2e0 100644 --- a/lib/examples/pdsch_ue.c +++ b/lib/examples/pdsch_ue.c @@ -599,7 +599,7 @@ int main(int argc, char **argv) { } #ifndef DISABLE_RF - if (prog_args.rf_gain < 0) { + if (prog_args.rf_gain < 0 && !prog_args.input_file_name) { srslte_rf_info_t *rf_info = srslte_rf_get_info(&rf); srslte_ue_sync_start_agc(&ue_sync, srslte_rf_set_rx_gain_th_wrapper_, diff --git a/lib/src/phy/enb/enb_dl.c b/lib/src/phy/enb/enb_dl.c index 6d92db83a..ae169602c 100644 --- a/lib/src/phy/enb/enb_dl.c +++ b/lib/src/phy/enb/enb_dl.c @@ -416,7 +416,7 @@ int srslte_enb_dl_put_pdcch_dl(srslte_enb_dl_t *q, srslte_ra_dl_dci_t *grant, srslte_dci_format_t format, srslte_dci_location_t location, uint16_t rnti, uint32_t sf_idx) { - srslte_dci_msg_t dci_msg; + srslte_dci_msg_t dci_msg = {}; bool rnti_is_user = true; if (rnti == SRSLTE_SIRNTI || rnti == SRSLTE_PRNTI || (rnti >= SRSLTE_RARNTI_START && rnti <= SRSLTE_RARNTI_END)) { @@ -436,7 +436,7 @@ int srslte_enb_dl_put_pdcch_ul(srslte_enb_dl_t *q, srslte_ra_ul_dci_t *grant, srslte_dci_location_t location, uint16_t rnti, uint32_t sf_idx) { - srslte_dci_msg_t dci_msg; + srslte_dci_msg_t dci_msg = {}; srslte_dci_msg_pack_pusch(grant, &dci_msg, q->cell.nof_prb); if (srslte_pdcch_encode(&q->pdcch, &dci_msg, location, rnti, q->sf_symbols, sf_idx, q->cfi)) { diff --git a/lib/src/phy/ue/ue_dl.c b/lib/src/phy/ue/ue_dl.c index 7bcbbf578..558f8b5fe 100644 --- a/lib/src/phy/ue/ue_dl.c +++ b/lib/src/phy/ue/ue_dl.c @@ -491,6 +491,9 @@ int srslte_ue_dl_decode_rnti(srslte_ue_dl_t *q, int found_dci = srslte_ue_dl_find_dl_dci(q, tm, cfi, sf_idx, rnti, &dci_msg); if (found_dci == 1) { + INFO("PDCCH: DL DCI %s rnti=0x%x, cce_index=%d, L=%d, tti=%d\n", srslte_dci_format_string(dci_msg.format), + q->current_rnti, q->last_location.ncce, (1<last_location.L), tti); + if (srslte_dci_msg_to_dl_grant(&dci_msg, rnti, q->cell.nof_prb, q->cell.nof_ports, &dci_unpacked, &grant)) { fprintf(stderr, "Error unpacking DCI\n"); return SRSLTE_ERROR; From 337857df5f24e0c1df1439814abb387f0c6b5d74 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Thu, 21 Jun 2018 18:39:35 +0100 Subject: [PATCH 34/40] added a normalization factor --- lib/src/phy/enb/enb_dl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/phy/enb/enb_dl.c b/lib/src/phy/enb/enb_dl.c index ae169602c..e406983c3 100644 --- a/lib/src/phy/enb/enb_dl.c +++ b/lib/src/phy/enb/enb_dl.c @@ -388,7 +388,7 @@ void srslte_enb_dl_put_mbsfn_base(srslte_enb_dl_t *q, uint32_t tti) void srslte_enb_dl_gen_signal(srslte_enb_dl_t *q) { // TODO: PAPR control - float norm_factor = (float) sqrt(q->cell.nof_prb)/15/sqrt(q->ifft[0].symbol_sz); + float norm_factor = 0.05f / sqrt(q->cell.nof_prb); for (int i = 0; i < q->cell.nof_ports; i++) { srslte_ofdm_tx_sf(&q->ifft[i]); srslte_vec_sc_prod_cfc(q->ifft[i].out_buffer, norm_factor, q->ifft[i].out_buffer, (uint32_t) SRSLTE_SF_LEN_PRB(q->cell.nof_prb)); @@ -397,7 +397,7 @@ void srslte_enb_dl_gen_signal(srslte_enb_dl_t *q) void srslte_enb_dl_gen_signal_mbsfn(srslte_enb_dl_t *q) { - float norm_factor = (float) sqrt(q->cell.nof_prb)/15/sqrt(q->ifft_mbsfn.symbol_sz); + float norm_factor = 0.05f / sqrt(q->cell.nof_prb); srslte_ofdm_tx_sf(&q->ifft_mbsfn); srslte_vec_sc_prod_cfc(q->ifft_mbsfn.out_buffer, norm_factor, q->ifft_mbsfn.out_buffer, (uint32_t) SRSLTE_SF_LEN_PRB(q->cell.nof_prb)); } From 5e4fb481842a57c7ca27196b3d9bb4484610cd99 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Mon, 25 Jun 2018 14:51:54 +0200 Subject: [PATCH 35/40] Refactored CQI reporting logging in UE. Fixes #199 --- lib/include/srslte/phy/phch/cqi.h | 5 +- lib/src/phy/phch/cqi.c | 81 +++++++++++++++++++++++++++++++ srsue/hdr/phy/phch_worker.h | 1 + srsue/src/phy/phch_worker.cc | 23 ++++----- 4 files changed, 98 insertions(+), 12 deletions(-) diff --git a/lib/include/srslte/phy/phch/cqi.h b/lib/include/srslte/phy/phch/cqi.h index 4363ccaa7..481fce494 100644 --- a/lib/include/srslte/phy/phch/cqi.h +++ b/lib/include/srslte/phy/phch/cqi.h @@ -43,7 +43,7 @@ #define SRSLTE_CQI_MAX_BITS 64 #define SRSLTE_DIF_CQI_MAX_BITS 3 #define SRSLTE_PMI_MAX_BITS 4 -#define SRSLTE_CQI_STR_MAX_CHAR 32 +#define SRSLTE_CQI_STR_MAX_CHAR 64 typedef struct { bool configured; @@ -150,6 +150,9 @@ SRSLTE_API int srslte_cqi_format2_subband_pack(srslte_cqi_format2_subband_t *msg SRSLTE_API int srslte_cqi_value_unpack(uint8_t buff[SRSLTE_CQI_MAX_BITS], srslte_cqi_value_t *value); +SRSLTE_API int srslte_cqi_value_tostring(srslte_cqi_value_t *value, char *buff, uint32_t buff_len); + + SRSLTE_API int srslte_cqi_hl_subband_unpack(uint8_t buff[SRSLTE_CQI_MAX_BITS], srslte_cqi_hl_subband_t *msg); diff --git a/lib/src/phy/phch/cqi.c b/lib/src/phy/phch/cqi.c index 683144439..7c945850a 100644 --- a/lib/src/phy/phch/cqi.c +++ b/lib/src/phy/phch/cqi.c @@ -234,6 +234,87 @@ int srslte_cqi_value_unpack(uint8_t buff[SRSLTE_CQI_MAX_BITS], srslte_cqi_value_ return -1; } +/******************************************************* + * TO STRING FUNCTIONS * + *******************************************************/ + +static int srslte_cqi_format2_wideband_tostring(srslte_cqi_format2_wideband_t *msg, char *buff, uint32_t buff_len) { + int n = 0; + + n += snprintf(buff + n, buff_len - n, ", cqi=%d", msg->wideband_cqi); + + if (msg->pmi_present) { + if (msg->rank_is_not_one) { + n += snprintf(buff + n, buff_len - n, ", diff_cqi=%d", msg->spatial_diff_cqi); + } + n += snprintf(buff + n, buff_len - n, ", pmi=%d", msg->pmi); + } + + return n; +} + +static int srslte_cqi_format2_subband_tostring(srslte_cqi_format2_subband_t *msg, char *buff, uint32_t buff_len) { + int n = 0; + + n += snprintf(buff + n, buff_len - n, ", cqi=%d", msg->subband_cqi); + n += snprintf(buff + n, buff_len - n, ", label=%d", msg->subband_label); + + return n; +} + +static int srslte_cqi_ue_subband_tostring(srslte_cqi_ue_subband_t *msg, char *buff, uint32_t buff_len) { + int n = 0; + + n += snprintf(buff + n, buff_len - n, ", cqi=%d", msg->wideband_cqi); + n += snprintf(buff + n, buff_len - n, ", diff_cqi=%d", msg->subband_diff_cqi); + n += snprintf(buff + n, buff_len - n, ", L=%d", msg->L); + + return n; +} + +static int srslte_cqi_hl_subband_tostring(srslte_cqi_hl_subband_t *msg, char *buff, uint32_t buff_len) { + int n = 0; + + n += snprintf(buff + n, buff_len - n, ", cqi=%d", msg->wideband_cqi_cw0); + n += snprintf(buff + n, buff_len - n, ", diff=%d", msg->subband_diff_cqi_cw0); + + if (msg->rank_is_not_one) { + n += snprintf(buff + n, buff_len - n, ", cqi1=%d", msg->wideband_cqi_cw1); + n += snprintf(buff + n, buff_len - n, ", diff1=%d", msg->subband_diff_cqi_cw1); + } + + if (msg->pmi_present) { + n += snprintf(buff + n, buff_len - n, ", pmi=%d", msg->pmi); + } + + n += snprintf(buff + n, buff_len - n, ", N=%d", msg->N); + + return n; +} + +int srslte_cqi_value_tostring(srslte_cqi_value_t *value, char *buff, uint32_t buff_len) { + int ret = -1; + + switch (value->type) { + case SRSLTE_CQI_TYPE_WIDEBAND: + ret = srslte_cqi_format2_wideband_tostring(&value->wideband, buff, buff_len); + break; + case SRSLTE_CQI_TYPE_SUBBAND: + ret = srslte_cqi_format2_subband_tostring(&value->subband, buff, buff_len); + break; + case SRSLTE_CQI_TYPE_SUBBAND_UE: + ret = srslte_cqi_ue_subband_tostring(&value->subband_ue, buff, buff_len); + break; + case SRSLTE_CQI_TYPE_SUBBAND_HL: + ret = srslte_cqi_hl_subband_tostring(&value->subband_hl, buff, buff_len); + break; + default: + /* Do nothing */; + } + + return ret; +} + int srslte_cqi_size(srslte_cqi_value_t *value) { int size = 0; diff --git a/srsue/hdr/phy/phch_worker.h b/srsue/hdr/phy/phch_worker.h index ce53e8833..244657975 100644 --- a/srsue/hdr/phy/phch_worker.h +++ b/srsue/hdr/phy/phch_worker.h @@ -162,6 +162,7 @@ private: srslte_ue_ul_t ue_ul; srslte_timestamp_t tx_time; srslte_uci_data_t uci_data; + srslte_cqi_value_t cqi_report; uint16_t ul_rnti; // UL configuration parameters diff --git a/srsue/src/phy/phch_worker.cc b/srsue/src/phy/phch_worker.cc index 64e3a9e5e..43a31ba0e 100644 --- a/srsue/src/phy/phch_worker.cc +++ b/srsue/src/phy/phch_worker.cc @@ -1032,7 +1032,8 @@ bool phch_worker::decode_pdcch_ul(mac_interface_phy::mac_grant_t* grant) void phch_worker::reset_uci() { - bzero(&uci_data, sizeof(srslte_uci_data_t)); + ZERO_OBJECT(uci_data); + ZERO_OBJECT(cqi_report); } void phch_worker::set_uci_ack(bool ack[SRSLTE_MAX_CODEWORDS], bool tb_en[SRSLTE_MAX_CODEWORDS]) @@ -1082,7 +1083,6 @@ void phch_worker::set_uci_periodic_cqi() compute_ri(NULL, NULL, NULL); phy->last_pmi = (uint8_t) ue_dl.pmi[phy->last_ri % SRSLTE_MAX_LAYERS]; - srslte_cqi_value_t cqi_report; ZERO_OBJECT(cqi_report); if (period_cqi.format_is_subband) { @@ -1137,7 +1137,6 @@ void phch_worker::set_uci_aperiodic_cqi() reported RI. For other transmission modes they are reported conditioned on rank 1. */ if (rnti_is_set) { - srslte_cqi_value_t cqi_report; ZERO_OBJECT(cqi_report); cqi_report.type = SRSLTE_CQI_TYPE_SUBBAND_HL; @@ -1291,11 +1290,13 @@ void phch_worker::encode_pusch(srslte_ra_ul_grant_t *grant, uint8_t *payload, ui #endif char cqi_str[SRSLTE_CQI_STR_MAX_CHAR] = ""; - srslte_cqi_to_str(uci_data.uci_cqi, uci_data.uci_cqi_len, cqi_str, SRSLTE_CQI_STR_MAX_CHAR); + if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) { + srslte_cqi_value_tostring(&cqi_report, cqi_str, SRSLTE_CQI_STR_MAX_CHAR); + } uint8_t dummy[2] = {0,0}; log_h->info_hex(payload, grant->mcs.tbs/8, - "PUSCH: tti_tx=%d, alloc=(%d,%d), tbs=%d, mcs=%d, rv=%d%s%s%s, cfo=%.1f KHz%s%s%s\n", + "PUSCH: tti_tx=%d, alloc=(%d,%d), tbs=%d, mcs=%d, rv=%d%s%s%s, cfo=%.1f KHz%s%s\n", (tti + HARQ_DELAY_MS) % 10240, grant->n_prb[0], grant->n_prb[0] + grant->L_prb, grant->mcs.tbs / 8, grant->mcs.idx, rv, @@ -1303,7 +1304,6 @@ void phch_worker::encode_pusch(srslte_ra_ul_grant_t *grant, uint8_t *payload, ui uci_data.uci_ack_len > 1 ? (uci_data.uci_ack_2 ? "1" : "0") : "", uci_data.uci_ri_len > 0 ? (uci_data.uci_ri ? ", ri=1" : ", ri=0") : "", cfo * 15, timestr, - uci_data.uci_cqi_len > 0 ? ", cqi=" : "", uci_data.uci_cqi_len > 0 ? cqi_str : ""); // Store metrics @@ -1345,17 +1345,18 @@ void phch_worker::encode_pucch() float tx_power = srslte_ue_ul_pucch_power(&ue_ul, phy->pathloss, ue_ul.last_pucch_format, uci_data.uci_cqi_len, uci_data.uci_ack_len); float gain = set_power(tx_power); - char str_cqi[SRSLTE_CQI_STR_MAX_CHAR] = ""; - srslte_cqi_to_str(uci_data.uci_cqi, uci_data.uci_cqi_len, str_cqi, SRSLTE_CQI_STR_MAX_CHAR); + char cqi_str[SRSLTE_CQI_STR_MAX_CHAR] = ""; + if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) { + srslte_cqi_value_tostring(&cqi_report, cqi_str, SRSLTE_CQI_STR_MAX_CHAR); + } - Info("PUCCH: tti_tx=%d, n_pucch=%d, n_prb=%d, ack=%s%s%s%s%s, sr=%s, cfo=%.1f KHz%s\n", + Info("PUCCH: tti_tx=%d, n_pucch=%d, n_prb=%d, ack=%s%s%s%s, sr=%s, cfo=%.1f KHz%s\n", (tti + 4) % 10240, ue_ul.pucch.last_n_pucch, ue_ul.pucch.last_n_prb, uci_data.uci_ack_len > 0 ? (uci_data.uci_ack ? "1" : "0") : "no", uci_data.uci_ack_len > 1 ? (uci_data.uci_ack_2 ? "1" : "0") : "", uci_data.uci_ri_len > 0 ? (uci_data.uci_ri ? ", ri=1" : ", ri=0") : "", - uci_data.uci_cqi_len > 0 ? ", cqi=" : "", - uci_data.uci_cqi_len > 0 ? str_cqi : "", + uci_data.uci_cqi_len > 0 ? cqi_str : "", uci_data.scheduling_request ? "yes" : "no", cfo * 15, timestr); } From ddf7d2b2f782318f29483d9f59b494956b18667b Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 25 Jun 2018 16:13:09 +0200 Subject: [PATCH 36/40] soapy: rework driver init and add option to load config file --- lib/src/phy/rf/rf_soapy_imp.c | 79 +++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 18 deletions(-) diff --git a/lib/src/phy/rf/rf_soapy_imp.c b/lib/src/phy/rf/rf_soapy_imp.c index ef191e119..1e939061d 100644 --- a/lib/src/phy/rf/rf_soapy_imp.c +++ b/lib/src/phy/rf/rf_soapy_imp.c @@ -130,7 +130,13 @@ bool rf_soapy_rx_wait_lo_locked(void *h) void rf_soapy_set_tx_cal(void *h, srslte_rf_cal_t *cal) { - // not supported + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + double actual_bw = SoapySDRDevice_getBandwidth(handler->device, SOAPY_SDR_TX, 0); + char str_buf[25]; + snprintf(str_buf, sizeof(str_buf), "%f", actual_bw); + if (SoapySDRDevice_writeSetting(handler->device, "CALIBRATE_TX", str_buf)) { + printf("Error calibrating Rx\n"); + } } @@ -274,22 +280,22 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) } // list device sensors - size_t sensor_length; - char** sensors; - sensors = SoapySDRDevice_listSensors(handler->device, &sensor_length); + size_t list_length; + char** list; + list = SoapySDRDevice_listSensors(handler->device, &list_length); printf("Available device sensors: \n"); - for(int i = 0; i < sensor_length; i++) { - printf(" - %s\n", sensors[i]); + for(int i = 0; i < list_length; i++) { + printf(" - %s\n", list[i]); } // list channel sensors - sensors = SoapySDRDevice_listChannelSensors(handler->device, SOAPY_SDR_RX, 0, &sensor_length); + list = SoapySDRDevice_listChannelSensors(handler->device, SOAPY_SDR_RX, 0, &list_length); printf("Available sensors for RX channel 0: \n"); - for(int i = 0; i < sensor_length; i++) { - printf(" - %s\n", sensors[i]); + for(int i = 0; i < list_length; i++) { + printf(" - %s\n", list[i]); } - /* Set static radio info */ + // Set static radio info SoapySDRRange tx_range = SoapySDRDevice_getGainRange(handler->device, SOAPY_SDR_TX, 0); SoapySDRRange rx_range = SoapySDRDevice_getGainRange(handler->device, SOAPY_SDR_RX, 0); handler->info.min_tx_gain = tx_range.minimum; @@ -299,6 +305,18 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) // Check device arguments if (args) { + // config file + const char config_arg[] = "config="; + char config_str[64] = {0}; + char *config_ptr = strstr(args, config_arg); + if (config_ptr) { + copy_subdev_string(config_str, config_ptr + strlen(config_arg)); + printf("Loading config file %s\n", config_str); + SoapySDRDevice_writeSetting(handler->device, "LOAD_CONFIG", config_str); + remove_substring(args, config_arg); + remove_substring(args, config_str); + } + // rx antenna const char rx_ant_arg[] = "rxant="; char rx_ant_str[64] = {0}; @@ -328,6 +346,37 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) } } + // receive one subframe to allow for transceiver calibration + if (strstr(devname, "lime")) { + // set default tx gain and leave some time to calibrate tx + rf_soapy_set_tx_gain(handler, 45); + rf_soapy_set_rx_gain(handler, 35); + + cf_t dummy_buffer[1920]; + cf_t *dummy_buffer_array[SRSLTE_MAX_PORTS]; + dummy_buffer_array[0] = dummy_buffer; + rf_soapy_start_rx_stream(handler, true); + rf_soapy_recv_with_time_multi(handler, (void**)dummy_buffer_array, 1920, false, NULL, NULL); + rf_soapy_stop_rx_stream(handler); + + usleep(10000); + //SoapySDR_setLogLevel(SOAPY_SDR_ERROR); + } + + // list gains and AGC mode + bool has_agc = SoapySDRDevice_hasGainMode(handler->device, SOAPY_SDR_RX, 0); + list = SoapySDRDevice_listGains(handler->device, SOAPY_SDR_RX, 0, &list_length); + printf("State of gain elements for Rx channel 0 (AGC %s):\n", has_agc ? "supported":"not supported"); + for(int i = 0; i < list_length; i++) { + printf(" - %s: %.2f dB\n", list[i], SoapySDRDevice_getGainElement(handler->device, SOAPY_SDR_RX, 0, list[i])); + } + + has_agc = SoapySDRDevice_hasGainMode(handler->device, SOAPY_SDR_TX, 0); + printf("State of gain elements for Tx channel 0 (AGC %s):\n", has_agc ? "supported":"not supported"); + for(int i = 0; i < list_length; i++) { + printf(" - %s: %.2f dB\n", list[i], SoapySDRDevice_getGainElement(handler->device, SOAPY_SDR_TX, 0, list[i])); + } + // print actual antenna configuration char *ant = SoapySDRDevice_getAntenna(handler->device, SOAPY_SDR_RX, 0); printf("Rx antenna set to %s\n", ant); @@ -335,12 +384,6 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) ant = SoapySDRDevice_getAntenna(handler->device, SOAPY_SDR_TX, 0); printf("Tx antenna set to %s\n", ant); - // set default tx gain and leave some time to calibrate tx - rf_soapy_set_tx_gain(handler, 35); - usleep(10000); - - SoapySDR_setLogLevel(SOAPY_SDR_ERROR); - return SRSLTE_SUCCESS; } @@ -497,14 +540,14 @@ double rf_soapy_set_tx_gain(void *h, double gain) double rf_soapy_get_rx_gain(void *h) { rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - return SoapySDRDevice_getGain(handler->device,SOAPY_SDR_RX, 0); + return SoapySDRDevice_getGain(handler->device, SOAPY_SDR_RX, 0); } double rf_soapy_get_tx_gain(void *h) { rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - return SoapySDRDevice_getGain(handler->device,SOAPY_SDR_TX, 0); + return SoapySDRDevice_getGain(handler->device, SOAPY_SDR_TX, 0); } From b551c82f7b51bdd8e9009701ddb2d9e1494789db Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 25 Jun 2018 16:45:32 +0200 Subject: [PATCH 37/40] fix bug in packing s1ap --- srsenb/src/upper/s1ap.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srsenb/src/upper/s1ap.cc b/srsenb/src/upper/s1ap.cc index 8e1643a0c..3f9861e11 100644 --- a/srsenb/src/upper/s1ap.cc +++ b/srsenb/src/upper/s1ap.cc @@ -939,7 +939,7 @@ bool s1ap::send_initial_ctxt_setup_failure(uint16_t rnti) fail->Cause.choice.radioNetwork.ext = false; fail->Cause.choice.radioNetwork.e = LIBLTE_S1AP_CAUSERADIONETWORK_UNSPECIFIED; - liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT*)&buf); + liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT*)buf); s1ap_log->info_hex(buf->msg, buf->N_bytes, "Sending InitialContextSetupFailure for RNTI:0x%x", rnti); ssize_t n_sent = sctp_sendmsg(socket_fd, buf->msg, buf->N_bytes, From 064d7bd2dc6468a96ddb46c0d7a07ea7a2ac918d Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 25 Jun 2018 18:19:57 +0200 Subject: [PATCH 38/40] use original UE establishment cause in S1AP initial UE message --- lib/include/srslte/interfaces/enb_interfaces.h | 4 ++-- srsenb/hdr/upper/rrc.h | 2 ++ srsenb/hdr/upper/s1ap.h | 6 +++--- srsenb/src/upper/rrc.cc | 5 +++-- srsenb/src/upper/s1ap.cc | 12 ++++++------ 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index 1b4f0da56..550e6e3ea 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -274,8 +274,8 @@ public: class s1ap_interface_rrc { public: - virtual void initial_ue(uint16_t rnti, srslte::byte_buffer_t *pdu) = 0; - virtual void initial_ue(uint16_t rnti, srslte::byte_buffer_t *pdu, uint32_t m_tmsi, uint8_t mmec) = 0; + virtual void initial_ue(uint16_t rnti, LIBLTE_S1AP_RRC_ESTABLISHMENT_CAUSE_ENUM cause, srslte::byte_buffer_t *pdu) = 0; + virtual void initial_ue(uint16_t rnti, LIBLTE_S1AP_RRC_ESTABLISHMENT_CAUSE_ENUM cause, srslte::byte_buffer_t *pdu, uint32_t m_tmsi, uint8_t mmec) = 0; virtual void write_pdu(uint16_t rnti, srslte::byte_buffer_t *pdu) = 0; virtual bool user_exists(uint16_t rnti) = 0; virtual bool user_release(uint16_t rnti, LIBLTE_S1AP_CAUSERADIONETWORK_ENUM cause_radio) = 0; diff --git a/srsenb/hdr/upper/rrc.h b/srsenb/hdr/upper/rrc.h index 77895facb..69e2b75ce 100644 --- a/srsenb/hdr/upper/rrc.h +++ b/srsenb/hdr/upper/rrc.h @@ -251,6 +251,8 @@ public: struct timeval t_last_activity; + LIBLTE_RRC_CON_REQ_EST_CAUSE_ENUM establishment_cause; + // S-TMSI for this UE bool has_tmsi; uint32_t m_tmsi; diff --git a/srsenb/hdr/upper/s1ap.h b/srsenb/hdr/upper/s1ap.h index 2e355649f..284b67d03 100644 --- a/srsenb/hdr/upper/s1ap.h +++ b/srsenb/hdr/upper/s1ap.h @@ -72,8 +72,8 @@ public: void run_thread(); // RRC interface - void initial_ue(uint16_t rnti, srslte::byte_buffer_t *pdu); - void initial_ue(uint16_t rnti, srslte::byte_buffer_t *pdu, uint32_t m_tmsi, uint8_t mmec); + void initial_ue(uint16_t rnti, LIBLTE_S1AP_RRC_ESTABLISHMENT_CAUSE_ENUM cause, srslte::byte_buffer_t *pdu); + void initial_ue(uint16_t rnti, LIBLTE_S1AP_RRC_ESTABLISHMENT_CAUSE_ENUM cause, srslte::byte_buffer_t *pdu, uint32_t m_tmsi, uint8_t mmec); void write_pdu(uint16_t rnti, srslte::byte_buffer_t *pdu); bool user_exists(uint16_t rnti); bool user_release(uint16_t rnti, LIBLTE_S1AP_CAUSERADIONETWORK_ENUM cause_radio); @@ -128,7 +128,7 @@ private: bool handle_s1setupfailure(LIBLTE_S1AP_MESSAGE_S1SETUPFAILURE_STRUCT *msg); bool handle_erabsetuprequest(LIBLTE_S1AP_MESSAGE_E_RABSETUPREQUEST_STRUCT *msg); - bool send_initialuemessage(uint16_t rnti, srslte::byte_buffer_t *pdu, bool has_tmsi, uint32_t m_tmsi=0, uint8_t mmec=0); + bool send_initialuemessage(uint16_t rnti, LIBLTE_S1AP_RRC_ESTABLISHMENT_CAUSE_ENUM cause, srslte::byte_buffer_t *pdu, bool has_tmsi, uint32_t m_tmsi=0, uint8_t mmec=0); bool send_ulnastransport(uint16_t rnti, srslte::byte_buffer_t *pdu); bool send_uectxtreleaserequest(uint16_t rnti, LIBLTE_S1AP_CAUSE_STRUCT *cause); bool send_uectxtreleasecomplete(uint16_t rnti, uint32_t mme_ue_id, uint32_t enb_ue_id); diff --git a/srsenb/src/upper/rrc.cc b/srsenb/src/upper/rrc.cc index f3d61829f..eccf18f6a 100644 --- a/srsenb/src/upper/rrc.cc +++ b/srsenb/src/upper/rrc.cc @@ -1043,6 +1043,7 @@ void rrc::ue::handle_rrc_con_req(LIBLTE_RRC_CONNECTION_REQUEST_STRUCT *msg) m_tmsi = msg->ue_id.s_tmsi.m_tmsi; has_tmsi = true; } + establishment_cause = msg->cause; send_connection_setup(); state = RRC_STATE_WAIT_FOR_CON_SETUP_COMPLETE; } @@ -1069,9 +1070,9 @@ void rrc::ue::handle_rrc_con_setup_complete(LIBLTE_RRC_CONNECTION_SETUP_COMPLETE parent->mac->phy_config_enabled(rnti, true); if(has_tmsi) { - parent->s1ap->initial_ue(rnti, pdu, m_tmsi, mmec); + parent->s1ap->initial_ue(rnti, (LIBLTE_S1AP_RRC_ESTABLISHMENT_CAUSE_ENUM)establishment_cause, pdu, m_tmsi, mmec); } else { - parent->s1ap->initial_ue(rnti, pdu); + parent->s1ap->initial_ue(rnti, (LIBLTE_S1AP_RRC_ESTABLISHMENT_CAUSE_ENUM)establishment_cause, pdu); } state = RRC_STATE_WAIT_FOR_CON_RECONF_COMPLETE; } diff --git a/srsenb/src/upper/s1ap.cc b/srsenb/src/upper/s1ap.cc index 3f9861e11..da399fe14 100644 --- a/srsenb/src/upper/s1ap.cc +++ b/srsenb/src/upper/s1ap.cc @@ -174,22 +174,22 @@ void s1ap::build_tai_cgi() /******************************************************************************* /* RRC interface ********************************************************************************/ -void s1ap::initial_ue(uint16_t rnti, srslte::byte_buffer_t *pdu) +void s1ap::initial_ue(uint16_t rnti, LIBLTE_S1AP_RRC_ESTABLISHMENT_CAUSE_ENUM cause, srslte::byte_buffer_t *pdu) { ue_ctxt_map[rnti].eNB_UE_S1AP_ID = next_eNB_UE_S1AP_ID++; ue_ctxt_map[rnti].stream_id = 1; ue_ctxt_map[rnti].release_requested = false; enbid_to_rnti_map[ue_ctxt_map[rnti].eNB_UE_S1AP_ID] = rnti; - send_initialuemessage(rnti, pdu, false); + send_initialuemessage(rnti, cause, pdu, false); } -void s1ap::initial_ue(uint16_t rnti, srslte::byte_buffer_t *pdu, uint32_t m_tmsi, uint8_t mmec) +void s1ap::initial_ue(uint16_t rnti, LIBLTE_S1AP_RRC_ESTABLISHMENT_CAUSE_ENUM cause, srslte::byte_buffer_t *pdu, uint32_t m_tmsi, uint8_t mmec) { ue_ctxt_map[rnti].eNB_UE_S1AP_ID = next_eNB_UE_S1AP_ID++; ue_ctxt_map[rnti].stream_id = 1; ue_ctxt_map[rnti].release_requested = false; enbid_to_rnti_map[ue_ctxt_map[rnti].eNB_UE_S1AP_ID] = rnti; - send_initialuemessage(rnti, pdu, true, m_tmsi, mmec); + send_initialuemessage(rnti, cause, pdu, true, m_tmsi, mmec); } void s1ap::write_pdu(uint16_t rnti, srslte::byte_buffer_t *pdu) @@ -609,7 +609,7 @@ bool s1ap::handle_s1setupfailure(LIBLTE_S1AP_MESSAGE_S1SETUPFAILURE_STRUCT *msg) /* S1AP message senders ********************************************************************************/ -bool s1ap::send_initialuemessage(uint16_t rnti, srslte::byte_buffer_t *pdu, bool has_tmsi, uint32_t m_tmsi, uint8_t mmec) +bool s1ap::send_initialuemessage(uint16_t rnti, LIBLTE_S1AP_RRC_ESTABLISHMENT_CAUSE_ENUM cause, srslte::byte_buffer_t *pdu, bool has_tmsi, uint32_t m_tmsi, uint8_t mmec) { if(!mme_connected) { return false; @@ -662,7 +662,7 @@ bool s1ap::send_initialuemessage(uint16_t rnti, srslte::byte_buffer_t *pdu, bool // RRC Establishment Cause initue->RRC_Establishment_Cause.ext = false; - initue->RRC_Establishment_Cause.e = LIBLTE_S1AP_RRC_ESTABLISHMENT_CAUSE_MO_SIGNALLING; + initue->RRC_Establishment_Cause.e = cause; liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT*)&msg); s1ap_log->info_hex(msg.msg, msg.N_bytes, "Sending InitialUEMessage for RNTI:0x%x", rnti); From 9d18349a084a406b74738ba9f3cbbc4950204961 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 26 Jun 2018 10:27:39 +0200 Subject: [PATCH 39/40] Reduced uhd timeout --- lib/src/phy/rf/rf_uhd_imp.c | 6 +++--- srsenb/src/phy/phch_worker.cc | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/phy/rf/rf_uhd_imp.c b/lib/src/phy/rf/rf_uhd_imp.c index a0548347e..f287f5579 100644 --- a/lib/src/phy/rf/rf_uhd_imp.c +++ b/lib/src/phy/rf/rf_uhd_imp.c @@ -807,7 +807,7 @@ int rf_uhd_recv_with_time_multi(void *h, rxd_samples = 0; uhd_error error = uhd_rx_streamer_recv(handler->rx_stream, buffs_ptr, - num_rx_samples, md, 1.0, false, &rxd_samples); + num_rx_samples, md, 0.1, false, &rxd_samples); if (error) { fprintf(stderr, "Error receiving from UHD: %d\n", error); log_rx_error(handler); @@ -917,7 +917,7 @@ int rf_uhd_send_timed_multi(void *h, buffs_ptr[i] = buff; } uhd_error error = uhd_tx_streamer_send(handler->tx_stream, buffs_ptr, - tx_samples, &handler->tx_md, 3.0, &txd_samples); + tx_samples, &handler->tx_md, 0.1, &txd_samples); if (error) { fprintf(stderr, "Error sending to UHD: %d\n", error); goto unlock; @@ -939,7 +939,7 @@ int rf_uhd_send_timed_multi(void *h, uhd_tx_metadata_set_has_time_spec(&handler->tx_md, is_start_of_burst); uhd_tx_metadata_set_start(&handler->tx_md, is_start_of_burst); uhd_tx_metadata_set_end(&handler->tx_md, is_end_of_burst); - uhd_error error = uhd_tx_streamer_send(handler->tx_stream, buffs_ptr, nsamples, &handler->tx_md, 3.0, &txd_samples); + uhd_error error = uhd_tx_streamer_send(handler->tx_stream, buffs_ptr, nsamples, &handler->tx_md, 0.0, &txd_samples); if (error) { fprintf(stderr, "Error sending to UHD: %d\n", error); goto unlock; diff --git a/srsenb/src/phy/phch_worker.cc b/srsenb/src/phy/phch_worker.cc index e368c3b80..4a365f75f 100644 --- a/srsenb/src/phy/phch_worker.cc +++ b/srsenb/src/phy/phch_worker.cc @@ -39,10 +39,10 @@ using namespace std; // Enable this to log SI -//#define LOG_THIS(a) 1 +#define LOG_THIS(a) 1 // Enable this one to skip SI-RNTI -#define LOG_THIS(rnti) (rnti != 0xFFFF) +//#define LOG_THIS(rnti) (rnti != 0xFFFF) /* Define GUI-related things */ From 0fcb27de5386f1f90cd2f2be7f9c779175c5501e Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 26 Jun 2018 11:46:42 +0200 Subject: [PATCH 40/40] soapy: make soapy log level a device param and fix issue in setting tx bandwidth --- lib/src/phy/rf/rf_soapy_imp.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/src/phy/rf/rf_soapy_imp.c b/lib/src/phy/rf/rf_soapy_imp.c index 1e939061d..b6260f21a 100644 --- a/lib/src/phy/rf/rf_soapy_imp.c +++ b/lib/src/phy/rf/rf_soapy_imp.c @@ -344,6 +344,19 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) remove_substring(args, tx_ant_arg); remove_substring(args, tx_ant_str); } + + // log level + const char loglevel_arg[] = "loglevel="; + char loglevel_str[64] = {0}; + char *loglevel_ptr = strstr(args, loglevel_arg); + if (loglevel_ptr) { + copy_subdev_string(loglevel_str, loglevel_ptr + strlen(loglevel_arg)); + if (strcmp(loglevel_str, "error") == 0) { + SoapySDR_setLogLevel(SOAPY_SDR_ERROR); + } + remove_substring(args, loglevel_arg); + remove_substring(args, loglevel_str); + } } // receive one subframe to allow for transceiver calibration @@ -360,7 +373,6 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) rf_soapy_stop_rx_stream(handler); usleep(10000); - //SoapySDR_setLogLevel(SOAPY_SDR_ERROR); } // list gains and AGC mode @@ -457,7 +469,7 @@ double rf_soapy_set_rx_srate(void *h, double rate) // Set bandwidth close to current rate size_t bw_length; SoapySDRRange *bw_range = SoapySDRDevice_getBandwidthRange(handler->device, SOAPY_SDR_RX, 0, &bw_length); - double bw = rate; + double bw = rate * 0.75; bw = MIN(bw, bw_range->maximum); bw = MAX(bw, bw_range->minimum); bw = MAX(bw, 2.5e6); // For the Lime to avoid warnings @@ -493,10 +505,10 @@ double rf_soapy_set_tx_srate(void *h, double rate) #if SET_RF_BW size_t bw_length; SoapySDRRange *bw_range = SoapySDRDevice_getBandwidthRange(handler->device, SOAPY_SDR_TX, 0, &bw_length); - // try to set the BW to the actual sampling rate but make sure to stay within device boundaries - double bw = rate; - bw = MIN(rate, bw_range->maximum); - bw = MAX(rate, bw_range->minimum); + // try to set the BW a bit narrower than sampling rate to prevent aliasing but make sure to stay within device boundaries + double bw = rate * 0.75; + bw = MAX(bw, bw_range->minimum); + bw = MIN(bw, bw_range->maximum); if (SoapySDRDevice_setBandwidth(handler->device, SOAPY_SDR_TX, 0, bw) != 0) { printf("setBandwidth fail: %s\n", SoapySDRDevice_lastError()); return SRSLTE_ERROR;