srsran / srsRAN_4G

Open source SDR 4G software suite from Software Radio Systems (SRS) https://docs.srsran.com/projects/4g
https://www.srsran.com
GNU Affero General Public License v3.0
3.49k stars 1.15k forks source link

Trying to use b71 with COTS UE #1054

Open lhms1234 opened 1 year ago

lhms1234 commented 1 year ago

Hello, community.

Issue Description

Aiming to use b71 LTE, I've begun to make some changes in the srsRAN stack from tag "release_22_10" (more specifically changing one line - b71 with correct values - and adding another in the struct lte_bands - adding b72). After some time, I discovered that an open pull request (#973) is making the exactly same implementation I've done.

Setup Details

Expected Behavior

Be able to use b71 LTE in srsRAN with COTS UEs.

Actual Behaviour

During my tests, both COTS UE Moto Edge Plus and Quectel RM500Q-GL failed to detect the RAN in b71 because SIBs weren't created correctly. The enb.log file points me to file .../srsRAN/lib/src/asn1/rrc/si.cc:3150, where the function "pack_integer" is called limiting the "ub" up to 64u. I've tried to change this value to 72u, but then another error appeared in the log: in .../srsRAN/lib/src/asn1/rrc/si.cc:2613 the same "ub" limitation was observed, then, the same strategy was applied, setting a higher value (133471) to the field. After these two modifications, no error or warning was appointed in enb's log, but the UEs don't detect the desired band. Collecting pcaps and configuring Wireshark as described in the documentation (https://docs.srsran.com/en/next/general/source/5_troubleshooting.html#examining-pcaps-with-wireshark), I noticed that Wireshark couldn't decode SIB2 messages when I used b71, as is showed bellow:

LTE RRC DL_SCH    SystemInformation [ SIB2[UNKNOWN PER: too long integer(per_normally_small_nonnegative_whole_number)]

This behavior did not occur in the vanilla version with bands lower than 64 (tested with bands 7, 20, and 28):

LTE RRC DL_SCH  SystemInformation [ SIB2 SIB3 ]

I would like to know if some additional configuration/change should be done to enable the usage of higher LTE bands (even in the vanilla version).

Steps to reproduce the problem

Apply this patch to add the b71 definition in lte_bands:

From b4f6e9aaffb572b170f854a7d67d4b6ea96ec4eb Mon Sep 17 00:00:00 2001
From: Luiz H <lhsilva@cpqd.com.br>
Date: Tue, 6 Dec 2022 10:53:34 -0300
Subject: [PATCH] Add b71 LTE definition in lte_bands

---
 lib/include/srsran/phy/common/phy_common.h | 2 +-
 lib/src/phy/common/phy_common.c            | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/include/srsran/phy/common/phy_common.h b/lib/include/srsran/phy/common/phy_common.h
index f19b2ce87..79761a0b0 100644
--- a/lib/include/srsran/phy/common/phy_common.h
+++ b/lib/include/srsran/phy/common/phy_common.h
@@ -171,7 +171,7 @@ typedef enum { SRSRAN_SF_NORM = 0, SRSRAN_SF_MBSFN } srsran_sf_t;
 #define SRSRAN_FDD_NOF_HARQ (FDD_HARQ_DELAY_DL_MS + FDD_HARQ_DELAY_UL_MS)
 #define SRSRAN_MAX_HARQ_PROC 15

-#define SRSRAN_NOF_LTE_BANDS 58
+#define SRSRAN_NOF_LTE_BANDS 59 //58

 #define SRSRAN_DEFAULT_MAX_FRAMES_PBCH 500
 #define SRSRAN_DEFAULT_MAX_FRAMES_PSS 10
diff --git a/lib/src/phy/common/phy_common.c b/lib/src/phy/common/phy_common.c
index b4838ac53..be0f86de4 100644
--- a/lib/src/phy/common/phy_common.c
+++ b/lib/src/phy/common/phy_common.c
@@ -587,7 +587,8 @@ struct lte_band lte_bands[SRSRAN_NOF_LTE_BANDS] = {
     {68, 753, 67536, 132672, 55, SRSRAN_BAND_GEO_AREA_EMEA},
     {69, 2570, 67836, 0, 0, SRSRAN_BAND_GEO_AREA_EMEA},
     {70, 1995, 68336, 132972, 300, SRSRAN_BAND_GEO_AREA_NAR},
-    {71, 0, 68586, 133122, 0, SRSRAN_BAND_GEO_AREA_NAR} // dummy band to bound band 70 earfcn
+    {71, 617, 68586, 133122, -46, SRSRAN_BAND_GEO_AREA_NAR},
+    {72, 0, 68936, 133472, 0, SRSRAN_BAND_GEO_AREA_EMEA}
 };

 int srsran_str2mimotype(char* mimo_type_str, srsran_tx_scheme_t* type)
-- 
2.17.1

The following .conf files was changed:

# srsenb.conf

[enb]
enb_id = 0x01
mcc = 001
mnc = 01
mme_addr = 192.168.10.44
gtp_bind_addr = 192.168.10.135
s1c_bind_addr = 192.168.10.135
s1c_bind_port = 0
n_prb = 25

[enb_files]
sib_config = /home/oai4/luiz/sib.conf
rr_config  = /home/oai4/luiz/rr.conf
rb_config = /home/oai4/luiz/rb.conf

[rf]
tx_gain = 80
rx_gain = 40

[pcap]
enable = true
filename = /home/oai4/luiz/enb_mac.pcap
s1ap_enable = true
s1ap_filename = /home/oai4/luiz/enb_s1ap.pcap

[log]
all_level = debug
all_hex_limit = 32
filename = /home/oai4/luiz/enb.log
file_max_size = -1

[gui]
enable = false
...
# rr.conf
...
cell_list =
(
  {
    // rf_port = 0;
    cell_id = 0x01;
    //tac = 0x0007;
    tac = 0x0001;
    pci = 1;
    // root_seq_idx = 204;
    dl_earfcn = 66886;
    // B07 (FDD): 3350
    // B20 (FDD): 6340
    // B28 (FDD): 9310  [9210, 9659]
    // B39 (TDD): 38275 -> Não funciona
    // B71 (FDD): 68766 // 68761
    //ul_earfcn = 133147; ////ul_earfcn = 21400;
    ho_active = false;
    //meas_gap_period = 0; // 0 (inactive), 40 or 80
    //meas_gap_offset_subframe = [6, 12, 18, 24, 30];
...

To execute eNB, I used the following command:

sudo srsenb /home/oai4/luiz/enb.conf

Thanks in advance.

WVFmauricio commented 1 year ago

Issue Description

Being guide by the pull request #617 I have tried to make the b66 and b71 works. In my tests the SIB1 is working fine and sending the nonCriticalExtension containing the SystemInformationBlockType1-v8h0-IEs with the right freqBandIndicator-v9e0.

Actual Behaviour

However, I am facing a problem with SIB2 in the msg2. When including the SystemInformationBlockType2-v8h0-IEs, the msg2 got incomplete and some elements cannot be seem in the PCAP using wireshark, such as the SystemInformationBlockType2-v8h0-IEs and other SIBs (SIB3, SIB4 and so on). Follow an image of the problem.

image

Steps to reproduce the problem

Apply this patch to add the b71 definition in lte_bands:

/lib/include/srsran/phy/common/phy_common.h

index f19b2ce87..79761a0b0 100644
--- a/lib/include/srsran/phy/common/phy_common.h
+++ b/lib/include/srsran/phy/common/phy_common.h
@@ -171,7 +171,7 @@ typedef enum { SRSRAN_SF_NORM = 0, SRSRAN_SF_MBSFN } srsran_sf_t;
 #define SRSRAN_FDD_NOF_HARQ (FDD_HARQ_DELAY_DL_MS + FDD_HARQ_DELAY_UL_MS)
 #define SRSRAN_MAX_HARQ_PROC 15

-#define SRSRAN_NOF_LTE_BANDS 58
+#define SRSRAN_NOF_LTE_BANDS 59 //58

 #define SRSRAN_DEFAULT_MAX_FRAMES_PBCH 500
 #define SRSRAN_DEFAULT_MAX_FRAMES_PSS 10

/lib/src/asn1/rrc/si.cc b/lib/src/asn1/rrc/si.cc

diff --git a/lib/src/asn1/rrc/si.cc b/lib/src/asn1/rrc/si.cc
index 80b23294e..045b3e728 100644
--- a/lib/src/asn1/rrc/si.cc
+++ b/lib/src/asn1/rrc/si.cc
@@ -2653,6 +2653,9 @@ SRSASN_CODE sib_type2_s::pack(bit_ref& bref) const
       varlength_field_pack_guard varlen_scope(bref, false);

       HANDLE_CODE(bref.pack(late_non_crit_ext_present, 1));
+      if (late_non_crit_ext_present) {
+        HANDLE_CODE(late_non_crit_ext.pack(bref));
+      }
     }
     if (group_flags[1]) {
       varlength_field_pack_guard varlen_scope(bref, false);
@@ -2798,6 +2801,9 @@ SRSASN_CODE sib_type2_s::unpack(cbit_ref& bref)
       varlength_field_unpack_guard varlen_scope(bref, false);

       HANDLE_CODE(bref.unpack(late_non_crit_ext_present, 1));
+      if (late_non_crit_ext_present) {
+        HANDLE_CODE(late_non_crit_ext.unpack(bref));
+      }
     }
     if (group_flags[1]) {
       varlength_field_unpack_guard varlen_scope(bref, false);   

/lib/src/phy/common/phy_common.c b/lib/src/phy/common/phy_common.c

diff --git a/lib/src/phy/common/phy_common.c b/lib/src/phy/common/phy_common.c
index b4838ac53..be0f86de4 100644
--- a/lib/src/phy/common/phy_common.c
+++ b/lib/src/phy/common/phy_common.c
@@ -587,7 +587,8 @@ struct lte_band lte_bands[SRSRAN_NOF_LTE_BANDS] = {
     {68, 753, 67536, 132672, 55, SRSRAN_BAND_GEO_AREA_EMEA},
     {69, 2570, 67836, 0, 0, SRSRAN_BAND_GEO_AREA_EMEA},
     {70, 1995, 68336, 132972, 300, SRSRAN_BAND_GEO_AREA_NAR},
-    {71, 0, 68586, 133122, 0, SRSRAN_BAND_GEO_AREA_NAR} // dummy band to bound band 70 earfcn
+    {71, 617, 68586, 133122, -46, SRSRAN_BAND_GEO_AREA_NAR},
+    {72, 0, 68936, 133472, 0, SRSRAN_BAND_GEO_AREA_EMEA}
 };

 int srsran_str2mimotype(char* mimo_type_str, srsran_tx_scheme_t* type)

/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc

diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc
index 9d61f1c83..e3661cc72 100644
--- a/srsenb/src/stack/mac/mac.cc
+++ b/srsenb/src/stack/mac/mac.cc
@@ -32,7 +32,7 @@
 #include "srsran/interfaces/enb_rrc_interface_mac.h"
 #include "srsran/srslog/event_trace.h"

-// #define WRITE_SIB_PCAP
+ #define WRITE_SIB_PCAP
 using namespace asn1::rrc;

 namespace srsenb {

/srsenb/src/stack/rrc/rrc_cell_cfg.cc b/srsenb/src/stack/rrc/rrc_cell_cfg.cc

diff --git a/srsenb/src/stack/rrc/rrc_cell_cfg.cc b/srsenb/src/stack/rrc/rrc_cell_cfg.cc
index 21746083e..a661beb79 100644
--- a/srsenb/src/stack/rrc/rrc_cell_cfg.cc
+++ b/srsenb/src/stack/rrc/rrc_cell_cfg.cc
@@ -21,7 +21,7 @@

 #include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h"
 #include "srsran/phy/utils/vector.h"
-
+#include <iostream>
 using namespace asn1::rrc;

 namespace srsenb {
@@ -51,7 +51,31 @@ enb_cell_common_list::enb_cell_common_list(const rrc_cfg_t& cfg_) : cfg(cfg_)
     cell_access->cell_id.from_number((cfg.enb_id << 8u) + new_cell->cell_cfg.cell_id);
     cell_access->tac.from_number(new_cell->cell_cfg.tac);
     // Update DL EARFCN
-    new_cell->sib1.freq_band_ind = (uint8_t)srsran_band_get_band(new_cell->cell_cfg.dl_earfcn);
+    // new_cell->sib1.freq_band_ind = (uint8_t)srsran_band_get_band(new_cell->cell_cfg.dl_earfcn);
+    uint8_t freq_band_ind = (uint8_t)srsran_band_get_band(new_cell->cell_cfg.dl_earfcn);
+    if (freq_band_ind <= 64) {
+        new_cell->sib1.freq_band_ind = freq_band_ind;
+    } else {
+        new_cell->sib1.freq_band_ind = 64;
+        new_cell->sib1.non_crit_ext_present = true;
+        new_cell->sib1.non_crit_ext.late_non_crit_ext_present = true;
+
+        // prepare buffer
+        uint8_t byte_buf1[16];
+        asn1::bit_ref bref_in1(&byte_buf1[0], sizeof(byte_buf1));
+
+        // create extension struct and encode it
+        asn1::rrc::sib_type1_v8h0_ies_s sib1_v8h0_ies;
+        sib1_v8h0_ies.non_crit_ext_present = true;
+        sib1_v8h0_ies.non_crit_ext.freq_band_ind_v9e0_present = true;
+        sib1_v8h0_ies.non_crit_ext.freq_band_ind_v9e0 = freq_band_ind;
+        sib1_v8h0_ies.pack(bref_in1);
+        
+        // copy encoded data to non_crit_ext.late_non_crit_ext octet string
+        new_cell->sib1.non_crit_ext.late_non_crit_ext.resize(bref_in1.distance_bytes());
+        memcpy(new_cell->sib1.non_crit_ext.late_non_crit_ext.data(), byte_buf1, bref_in1.distance_bytes());
+
+    }

     // Set Cell SIB2
     // update PRACH root seq index for this cell
@@ -59,7 +83,39 @@ enb_cell_common_list::enb_cell_common_list(const rrc_cfg_t& cfg_) : cfg(cfg_)
     new_cell->sib2.rr_cfg_common.prach_cfg.root_seq_idx = new_cell->cell_cfg.root_seq_idx;
     // update carrier freq
     if (new_cell->sib2.freq_info.ul_carrier_freq_present) {
-      new_cell->sib2.freq_info.ul_carrier_freq = new_cell->cell_cfg.ul_earfcn;
+//      new_cell->sib2.freq_info.ul_carrier_freq = new_cell->cell_cfg.ul_earfcn;
+        uint32_t ul_earfcn = new_cell->cell_cfg.ul_earfcn;
+        if (ul_earfcn <= 65535) {
+            new_cell->sib2.freq_info.ul_carrier_freq = ul_earfcn;
+
+        } else {
+            new_cell->sib2.freq_info.ul_carrier_freq = 65535;
+            new_cell->sib2.late_non_crit_ext_present = true;
+            new_cell->sib2.ext = true;
+          
+            // prepare buffer
+            uint8_t byte_buf2[16];
+            asn1::bit_ref bref_in2(&byte_buf2[0], sizeof(byte_buf2));
+
+            // create extension struct and encode it
+            asn1::rrc::sib_type2_v8h0_ies_s sib2_v8h0_ies;
+            sib2_v8h0_ies.non_crit_ext_present = true;
+            sib2_v8h0_ies.non_crit_ext.ul_carrier_freq_v9e0_present = true;
+            sib2_v8h0_ies.non_crit_ext.ul_carrier_freq_v9e0 = ul_earfcn;
+            sib2_v8h0_ies.pack(bref_in2);
+            
+            // copy encoded data to late_non_crit_ext octet string
+            new_cell->sib2.late_non_crit_ext.resize(bref_in2.distance_bytes());
+            memcpy(new_cell->sib2.late_non_crit_ext.data(), byte_buf2, bref_in2.distance_bytes());
+
+            /*std::cout << std::endl<< "Byte_buf2: ";
+            for(long unsigned int i=0; i<sizeof(byte_buf2); i++)
+            {
+              printf("%x", byte_buf2[i]);
+            }
+            std::cout << std::endl<< "late_non_crit_ext (later) "<< new_cell->sib2.late_non_crit_ext.to_string() << std::endl;
+            std::cout << std::endl<< "late_non_crit_ext.size() "<< new_cell->sib2.late_non_crit_ext.size()<< std::endl;*/
+        }
     }
   }

The following .conf files was changed:

srsenb.conf

[enb]
enb_id = 0x01
mcc = 001
mnc = 01
mme_addr = 192.168.10.44
gtp_bind_addr = 192.168.10.135
s1c_bind_addr = 192.168.10.135
s1c_bind_port = 0
n_prb = 25

[enb_files]
sib_config = /home/oai4/weskley/sib.conf
rr_config  = /home/oai4/weskley/rr.conf
rb_config = /home/oai4/weskley/rb.conf

[rf]
tx_gain = 80 #80
rx_gain = 40 #40

[pcap]
enable = true #enable = false
filename = /home/oai4/weskley/enb_mac.pcap
s1ap_enable = true
s1ap_filename = /home/oai4/weskley/enb_s1ap.pcap

[log]
all_level = debug
all_hex_limit = 32
filename = /home/oai4/weskley/enb.log
file_max_size = -1

[gui]
enable = false

...

rr.conf

cell_list =
(
  {
    // rf_port = 0;
    cell_id = 0x01;
    //tac = 0x0007;
    tac = 0x0001;
    pci = 1;
    // root_seq_idx = 204;
    dl_earfcn = 66886;
    // B07 (FDD): 3350
    // B20 (FDD): 6340
    // B28 (FDD): 9310  [9210, 9659]
    // B66 (FDD): 66886
    // B71 (FDD): 68766 // 68761
    //ul_earfcn = 133147; ////ul_earfcn = 21400;
    ho_active = false;
    //meas_gap_period = 0; // 0 (inactive), 40 or 80
    //meas_gap_offset_subframe = [6, 12, 18, 24, 30];

...

To execute eNB, I used the following command:

sudo srsenb /home/oai4/weskley/enb.conf

Attached ENB logs

enb.log

I would like to know if someone already have faced the same issue and how to fix it? Did I missed to configure something?

Thanks in advance!!

andrepuschmann commented 1 year ago

Thanks for your detailed report @lhmscpqd and the update on it @WVFmauricio . PR #973 will be included in the next version but we didn't extend/add the changes to the ASN1 packing you suggested. So the issue will still be present. We also have no means to really test b71 I am afraid.