Sei sulla pagina 1di 3

5/21/2020 [srslte-users] unpack sib1 in examples/cell_measurement.

[srslte-users] unpack sib1 in


examples/cell_measurement.c
Saverio Mercurio smercurio at prescientwireless.com
Tue Apr 9 20:33:18 UTC 2019

Previous message: [srslte-users] unpack sib1 in examples/cell_measurement.c


Next message: [srslte-users] unpack sib1 in examples/cell_measurement.c
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

I don't know if there is an easier way to do this, but the functions to


unpack and decode are in the asn1 library (lib\src\asn1). I had to do
the same thing with the pdsch_ue example. Since it's C++ code I made a
copy of the file with a .cc extension to make sure it would compile as
C++. The pdsch_ue wasn't actually doing the SIB capture correctly. It
looks like it was a copy and paste from cell_measurement.c, and chopped
in the middle of it. For cell_measurement there is an actual DECODE_SIB
state. In that state, right after the line
"srslte_vec_fprint_byte(stdout, data[0], n/8)" you could add (this is
the code I have in the modified pdsch_ue example):

srslte_vec_fprint_byte(stdout, data[0], n/8);;


asn1::rrc::bcch_dl_sch_msg_s dlsch_msg;

asn1::bit_ref bref(data[0], n / 8);


asn1::SRSASN_CODE unpackResult =
dlsch_msg.unpack(bref);
// printf("unpackResult = %d\n", unpackResult);

if (unpackResult == asn1::SRSASN_SUCCESS)
{
int msgTypeValue =
dlsch_msg.msg.type().value;
// printf("dlsch_msg.msg.type().value=%d\n", msgTypeValue);
if (msgTypeValue == 0)
{
if (dlsch_msg.msg.c1().type().value
== asn1::rrc::bcch_dl_sch_msg_type_c::c1_c_::types::sib_type1)
{
// printf("Accessing
dlsch_msg.msg.c1().sib_type1()\n");
asn1::rrc::sib_type1_s *sib1 = &dlsch_msg.msg.c1().sib_type1();
// printf("Accessing
sib1->cell_access_related_info.plmn_id_list[0].plmn_id\n");
asn1::rrc::plmn_id_s plmn =
sib1->cell_access_related_info.plmn_id_list[0].plmn_id;

std::string plmn_string =
srslte::plmn_id_to_string(plmn);
uint16_t mcc;
uint16_t mnc;
// If we were using C++11 we
could just use stoi
mcc =
atoi(plmn_string.substr(0, 3).c_str());
mnc =
atoi(plmn_string.substr(3, plmn_string.length() - 3).c_str());
// srslte::bytes_to_mcc(&plmn.mcc[0], &mcc);
// srslte::bytes_to_mnc(&plmn.mnc[0], &mnc, plmn.mnc.size());
www.softwareradiosystems.com/pipermail/srslte-users/2019-April/002465.html 1/3
5/21/2020 [srslte-users] unpack sib1 in examples/cell_measurement.c
printf("MCC=%d, MNC=%d\n", mcc,
mnc);
if ((mnc != 0) && (mcc != 0))
{
// go_exit = true;
state = MEASURE;
}
}
}
}
//state = MEASURE;

In my case I wanted the MCC and MNC codes. The string conversion is
clumsy, and as you can see by the commented lines, I had tried to use
the bytes_to_mcc() functions directly, but that didn't work, and I don't
know why. I tried to debug the code in Eclipse, and while I could debug
it and see the class/structure data, I still didn't understand why those
functions didn't work. I had way bigger fish to fry, so I left the code
alone since at least it worked. You should be able to extend it to get
the other elements contained in SIB1.

Note: You will need to add these two #include lines:


#include "srslte/asn1/rrc_asn1.h"
#include "srslte/common/bcd_helpers.h"

On 4/9/2019 2:02 PM, Cooper Quintin wrote:


> Bumping this back up. Is there a function in the API that I can use to
> unpack the raw SIB1 data? Failing that does anyone have any hints as to
> how to go about writing that function? Is there a chart anywhere that
> describes the parts of the binary sib1 packet?
>
> Cooper Quintin
> Senior Staff Technologist | EFF
> PGP: 75FB 9347 FA4B 22A0 5068 080B D0EA 7B6F F0AF E2CA
> Twitter: @cooperq
>
> On 3/28/19 8:16 PM, Cooper Quintin wrote:
>> In lib/examples/cell_measurement.c:333 we decode the SIB1 block like so:
>> ` n = srslte_ue_dl_decode(&ue_dl, data, 0,
>> sfn*10+srslte_ue_sync_get_sfidx(&ue_sync), acks);
>> `
>> and then print it once decoding is successful (i.e. n > 0).
>>
>> I am interested in unpacking the SIB block after that, extracting things
>> such as the mcc, mnc, cell_id, tac, etc.
>>
>> Is there a function that will allow me to unpack the binary sib block
>> stored in data[0] and access these things? If not do you have any
>> pointers on how I would start to go about that?
>>
>> Thanks,
>>
> _______________________________________________
> srslte-users mailing list
> srslte-users at lists.softwareradiosystems.com
> http://www.softwareradiosystems.com/mailman/listinfo/srslte-users

Previous message: [srslte-users] unpack sib1 in examples/cell_measurement.c


Next message: [srslte-users] unpack sib1 in examples/cell_measurement.c
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

www.softwareradiosystems.com/pipermail/srslte-users/2019-April/002465.html 2/3
5/21/2020 [srslte-users] unpack sib1 in examples/cell_measurement.c

More information about the srslte-users mailing list

www.softwareradiosystems.com/pipermail/srslte-users/2019-April/002465.html 3/3

Potrebbero piacerti anche