[srslte-users] Unstable SIB detection

Nedelin Rusev nedelin.rusev at gmail.com
Thu Jul 16 09:36:30 UTC 2020


Hi,

I am trying to capture the ENB broadcast signal and read all sent SIBs.
But I am facing an "instability" and I hope you could give me a hint about
it.

Here are details:
-1- I have based my work on
Commit:c892ae56be5302eaee5ca00e270efc7a5ce6fbb2, release_20_04_1 from
2020-05-09, master branch
-2- I am using LimeSDR board
-3- I based my work on pdsch_ue.c. I wanted to keep it all as simple as
possible, so I removed anything I found irrelevant (like measurement
calculations, input file support, graphics, etc)
-4- I extended the code to look for SIBs 2,3,4,5,6,7. And that part seems
to be more or less fine, because if I run ZeroMQ based ENB and ZeroMQ based
pdsch_ue.c, I am able to read all SIBs.
-5- The problem happens when I try to read the actual broadcast signal from
provider's ENB. Then I face issues like the following, which seem to have
random behaviour:
-5.1- the cell is selected, MIB is received, but SIB1 is never detected
-5.2- the cell is selected, MIB is received, SIB1 is received, but SIB2 and
the rest are not detected
-5.3- the cell is selected, MIB is received, SIB1,SIB2,SIB3 are received,
but SIB5 and SIB6 are never received. This is the case which bothers me
most. Below you can find the log: "POINT -5.3- LOG"
When I get to SIB5 detection and I reach the calculated SI Window start
TTI, function srslte_ue_dl_find_and_decode() starts returning errors or
reports packet errors with the "acks" array.

I hope you can give me some clues on the following questions:
Q1: What could be causing the random behaviour described in point5 above? I
would guess it is RF issue, but I don't know how to handle it. Any
suggestions?
Q2: What could be causing the errors in srslte_ue_dl_find_and_decode()?

Below I have placed a log text describing point 5.3 and below it is the
relevant part of the code I use.

Thank you in advance,
Greetings, Nedelin.

PS:
How do I detect SIBs:
- When I get SIB1, I read the SIB1 schedule list and calculate the SI
window for SIB2.
- Start counting TTIs till the SIB2 SI window start value is reached.
- When I get SIB2, I read the SIB1 schedule list and calculate the SI
window for SIB3.
- Start counting TTIs till the SIB3 SI window start value is reached.
- When I get SIB3, I read the SIB1 schedule list and calculate the SI
window for SIB4.
- so on ...

========== POINT -5.3- LOG ==========
Opening RF device with 1 RX antennas...
Soapy has found device #0: addr=1d50:6108, driver=lime, label=LimeSDR-USB
[USB 2.0] 9081C05C1361B, media=USB 2.0, module=FX3, name=LimeSDR-USB,
serial=0009081C05C1361B,
Selecting Soapy device: 0
CGEN: Freq=80 MHz, VCO=2.4 GHz, INT=77, FRAC=131072, DIV_OUTCH_CGEN=14
CGEN: Freq=80 MHz, VCO=2.4 GHz, INT=77, FRAC=131072, DIV_OUTCH_CGEN=14
CGEN: Freq=61.44 MHz, VCO=2.33472 GHz, INT=75, FRAC=0, DIV_OUTCH_CGEN=18
CGEN: Freq=61.44 MHz, VCO=2.33472 GHz, INT=75, FRAC=0, DIV_OUTCH_CGEN=18
Setting up Rx stream with 1 channel(s)
Setting up Tx stream with 1 channel(s)
CGEN: Freq=245.76 MHz, VCO=1.96608 GHz, INT=63, FRAC=0, DIV_OUTCH_CGEN=3
CGEN: Freq=245.76 MHz, VCO=1.96608 GHz, INT=63, FRAC=0, DIV_OUTCH_CGEN=3
MCU programming :   64/16384
...
MCU programming : 16384/16384
MCU Programming finished, 1120 ms
CGEN: Freq=245.76 MHz, VCO=1.96608 GHz, INT=63, FRAC=0, DIV_OUTCH_CGEN=3
CGEN: Freq=245.76 MHz, VCO=1.96608 GHz, INT=63, FRAC=0, DIV_OUTCH_CGEN=3
CGEN: Freq=61.44 MHz, VCO=2.33472 GHz, INT=75, FRAC=0, DIV_OUTCH_CGEN=18
Available device sensors:
 - clock_locked
 - lms7_temp
Available sensors for Rx channel 0:
 - lo_locked
State of gain elements for Rx channel 0 (AGC not supported):
 - TIA: 9.00 dB
 - LNA: 30.00 dB
 - PGA: -4.00 dB
State of gain elements for Tx channel 0 (AGC not supported):
 - PAD: 45.00 dB
 - IAMP: 0.00 dB
Rx antenna set to LNAL
Tx antenna set to BAND1
Starting AGC thread...
Tunning receiver to 2135.000 MHz
Searching for cell...
CGEN: Freq=245.76 MHz, VCO=1.96608 GHz, INT=63, FRAC=0, DIV_OUTCH_CGEN=3
CGEN: Freq=245.76 MHz, VCO=1.96608 GHz, INT=63, FRAC=0, DIV_OUTCH_CGEN=3
*Found Cell_id: 477 FDD, CP: Normal  , DetectRatio=100% PSR=3.56,
Power=-68.9 dBm
 Found Cell_id:   0 FDD, CP: Normal  , DetectRatio= 0% PSR=0.00, Power=-inf
dBm
 Found Cell_id:   0 FDD, CP: Normal  , DetectRatio= 0% PSR=0.00, Power=-inf
dBm
Decoding PBCH for cell 477 (N_id_2=0)
CGEN: Freq=245.76 MHz, VCO=1.96608 GHz, INT=63, FRAC=0, DIV_OUTCH_CGEN=3
CGEN: Freq=245.76 MHz, VCO=1.96608 GHz, INT=63, FRAC=0, DIV_OUTCH_CGEN=3
Setting sampling rate 11.52 MHz
CGEN: Freq=368.64 MHz, VCO=2.21184 GHz, INT=71, FRAC=0, DIV_OUTCH_CGEN=2
CGEN: Freq=368.64 MHz, VCO=2.21184 GHz, INT=71, FRAC=0, DIV_OUTCH_CGEN=2
 - Type:            FDD
 - PCI:             477
 - Nof ports:       2
 - CP:              Normal
 - PRB:             50
 - PHICH Length:    Normal
 - PHICH Resources: 1/6
 - SFN:             236
main(),806: STATE DECODE_SIB1 sfn=238 sf_idx=5 tti=2385 SI_Window {Start:0
Len:0}
SIB1:{
  "cellAccessRelatedInfo": {
    "plmn-IdentityList": [
      {
        "plmn-Identity": {
          "mcc": [
            2,
            8,
            4
          ],
          "mnc": [
            0,
            1
          ]
        },
        "cellReservedForOperatorUse": "notReserved"
      }
    ],
    "trackingAreaCode": "0000010001001101",
    "cellIdentity": "0000100000010010111000000100",
    "cellBarred": "notBarred",
    "intraFreqReselection": "allowed",
    "csg-Indication": false
  },
  "cellSelectionInfo": {
    "q-RxLevMin": -65
  },
  "p-Max": 23,
  "freqBandIndicator": 1,
  "schedulingInfoList": [
    {
      "si-Periodicity": "rf64",
      "sib-MappingInfo": [
      ]
    },
    {
      "si-Periodicity": "rf32",
      "sib-MappingInfo": [
        "sibType3"
      ]
    },
    {
      "si-Periodicity": "rf64",
      "sib-MappingInfo": [
        "sibType5"
      ]
    },
    {
      "si-Periodicity": "rf64",
      "sib-MappingInfo": [
        "sibType6"
      ]
    }
  ],
  "si-WindowLength": "ms10",
  "systemInfoValueTag": 24
}
main(),825: sfn=238 sf_idx=5; Next SIB2 wth SI Window {Start=2560;
Length=10}!
handle_sib(),483: STATE DECODE_SIB2 sfn=256 sf_idx=0 tti=2560 SI_Window
{Start:2560 Len:10}
SIB2:{
  "radioResourceConfigCommon": {
    "rach-ConfigCommon": {
      "preambleInfo": {
        "numberOfRA-Preambles": "n40",
        "preamblesGroupAConfig": {
          "sizeOfRA-PreamblesGroupA": "n32",
          "messageSizeGroupA": "b144",
          "messagePowerOffsetGroupB": "dB10"
        }
      },
      "powerRampingParameters": {
        "powerRampingStep": "dB4",
        "preambleInitialReceivedTargetPower": "dBm-102"
      },
      "ra-SupervisionInfo": {
        "preambleTransMax": "n10",
        "ra-ResponseWindowSize": "sf10",
        "mac-ContentionResolutionTimer": "sf64"
      },
      "maxHARQ-Msg3Tx": 6
    },
    "bcch-Config": {
      "modificationPeriodCoeff": "n2"
    },
    "pcch-Config": {
      "defaultPagingCycle": "rf128",
      "nB": "quarterT"
    },
    "prach-Config": {
      "rootSequenceIndex": 570,
      "prach-ConfigInfo": {
        "prach-ConfigIndex": 3,
        "highSpeedFlag": false,
        "zeroCorrelationZoneConfig": 12,
        "prach-FreqOffset": 3
      }
    },
    "pdsch-ConfigCommon": {
      "referenceSignalPower": 17,
      "p-b": 1
    },
    "pusch-ConfigCommon": {
      "pusch-ConfigBasic": {
        "n-SB": 1,
        "hoppingMode": "interSubFrame",
        "pusch-HoppingOffset": 6,
        "enable64QAM": true
      },
      "ul-ReferenceSignalsPUSCH": {
        "groupHoppingEnabled": false,
        "groupAssignmentPUSCH": 0,
        "sequenceHoppingEnabled": false,
        "cyclicShift": 0
      }
    },
    "pucch-ConfigCommon": {
      "deltaPUCCH-Shift": "ds1",
      "nRB-CQI": 3,
      "nCS-AN": 0,
      "n1PUCCH-AN": 10
    },
    "soundingRS-UL-ConfigCommon": {
    },
    "uplinkPowerControlCommon": {
      "p0-NominalPUSCH": -100,
      "alpha": "al1",
      "p0-NominalPUCCH": -116,
      "deltaFList-PUCCH": {
        "deltaF-PUCCH-Format1": "deltaF0",
        "deltaF-PUCCH-Format1b": "deltaF1",
        "deltaF-PUCCH-Format2": "deltaF0",
        "deltaF-PUCCH-Format2a": "deltaF0",
        "deltaF-PUCCH-Format2b": "deltaF0"
      },
      "deltaPreambleMsg3": 1
    },
    "ul-CyclicPrefixLength": "len1",
    "pusch-ConfigCommon-v1270": {
      "enable64QAM-v1270": "true"
    }
  },
  "ue-TimersAndConstants": {
    "t300": "ms400",
    "t301": "ms400",
    "t310": "ms2000",
    "n310": "n10",
    "t311": "ms5000",
    "n311": "n1"
  },
  "freqInfo": {
    "ul-CarrierFreq": 18250,
    "ul-Bandwidth": "n50",
    "additionalSpectrumEmission": 1
  },
  "timeAlignmentTimerCommon": "sf10240"
}
main(),847: sfn=256 sf_idx=0; Next SIB3 wth SI Window {Start=2890;
Length=10}!
handle_sib(),483: STATE DECODE_SIB3 sfn=289 sf_idx=0 tti=2890 SI_Window
{Start:2890 Len:10}
operator()(),499: ERROR: Unable to get SI Window for SIB4!
SIB3:{
  "cellReselectionInfoCommon": {
    "q-Hyst": "dB2"
  },
  "cellReselectionServingFreqInfo": {
    "s-NonIntraSearch": 15,
    "threshServingLow": 8,
    "cellReselectionPriority": 6
  },
  "intraFreqCellReselectionInfo": {
    "q-RxLevMin": -65,
    "p-Max": 23,
    "s-IntraSearch": 31,
    "presenceAntennaPort1": true,
    "neighCellConfig": "00",
    "t-ReselectionEUTRA": 1
  }
}
main(),847: sfn=289 sf_idx=0; Next SIB5 wth SI Window {Start=3220;
Length=10}!
handle_sib(),483: STATE DECODE_SIB5 sfn=322 sf_idx=0 tti=3220 SI_Window
{Start:3220 Len:10}
find_and_decode(),432: ERROR: pkt_errors=1 pmch_pkt_errors=0
handle_sib(),483: STATE DECODE_SIB5 sfn=322 sf_idx=1 tti=3221 SI_Window
{Start:3220 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=322 sf_idx=2 tti=3222 SI_Window
{Start:3220 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=322 sf_idx=3 tti=3223 SI_Window
{Start:3220 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=322 sf_idx=4 tti=3224 SI_Window
{Start:3220 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=322 sf_idx=5 tti=3225 SI_Window
{Start:3220 Len:10}
operator()(),492: SIB1 detected! Do not print!
handle_sib(),483: STATE DECODE_SIB5 sfn=322 sf_idx=6 tti=3226 SI_Window
{Start:3220 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=322 sf_idx=7 tti=3227 SI_Window
{Start:3220 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=322 sf_idx=8 tti=3228 SI_Window
{Start:3220 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=322 sf_idx=9 tti=3229 SI_Window
{Start:3220 Len:10}
handle_sib(),511: Recalculated SIB5 window {Start=3860, Length=10}!
handle_sib(),483: STATE DECODE_SIB5 sfn=386 sf_idx=0 tti=3860 SI_Window
{Start:3860 Len:10}
find_and_decode(),432: ERROR: pkt_errors=1 pmch_pkt_errors=0
handle_sib(),483: STATE DECODE_SIB5 sfn=386 sf_idx=1 tti=3861 SI_Window
{Start:3860 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=386 sf_idx=2 tti=3862 SI_Window
{Start:3860 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=386 sf_idx=3 tti=3863 SI_Window
{Start:3860 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=386 sf_idx=4 tti=3864 SI_Window
{Start:3860 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=386 sf_idx=5 tti=3865 SI_Window
{Start:3860 Len:10}
operator()(),492: SIB1 detected! Do not print!
handle_sib(),483: STATE DECODE_SIB5 sfn=386 sf_idx=6 tti=3866 SI_Window
{Start:3860 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=386 sf_idx=7 tti=3867 SI_Window
{Start:3860 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=386 sf_idx=8 tti=3868 SI_Window
{Start:3860 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=386 sf_idx=9 tti=3869 SI_Window
{Start:3860 Len:10}
handle_sib(),511: Recalculated SIB5 window {Start=4500, Length=10}!
handle_sib(),483: STATE DECODE_SIB5 sfn=450 sf_idx=0 tti=4500 SI_Window
{Start:4500 Len:10}
find_and_decode(),432: ERROR: pkt_errors=1 pmch_pkt_errors=0
handle_sib(),483: STATE DECODE_SIB5 sfn=450 sf_idx=1 tti=4501 SI_Window
{Start:4500 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=450 sf_idx=2 tti=4502 SI_Window
{Start:4500 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=450 sf_idx=3 tti=4503 SI_Window
{Start:4500 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=450 sf_idx=4 tti=4504 SI_Window
{Start:4500 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=450 sf_idx=5 tti=4505 SI_Window
{Start:4500 Len:10}
operator()(),492: SIB1 detected! Do not print!
handle_sib(),483: STATE DECODE_SIB5 sfn=450 sf_idx=6 tti=4506 SI_Window
{Start:4500 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=450 sf_idx=7 tti=4507 SI_Window
{Start:4500 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=450 sf_idx=8 tti=4508 SI_Window
{Start:4500 Len:10}
handle_sib(),483: STATE DECODE_SIB5 sfn=450 sf_idx=9 tti=4509 SI_Window
{Start:4500 Len:10}
handle_sib(),511: Recalculated SIB5 window {Start=5140, Length=10}!
... repeats till the end

===================== CODE =======================

/***********************************************************
*******************************************************/
/**************************************** COPY FROM rrc_procedures.cc
*********************************************/
/***********************************************************
*******************************************************/
// Helper functions
const uint32_t sib1_periodicity = 20;

/**
 * compute "T" (aka si-Periodicity) and "n" (order of entry in
schedulingInfoList).
 * @param sib_index SI index of interest
 * @param sib1 configuration of SIB1
 * @return {T, n} if successful, {0, -1} if sib_index was not found
 */
std::pair<uint32_t, int32_t> compute_si_periodicity_and_idx(uint32_t
sib_index, const asn1::rrc::sib_type1_s* sib1)
{
  if (sib_index == 1) {
    return {sib1_periodicity, sib_index};
  }
  if (sib_index == 2) {
    // SIB2 scheduling
      return {sib1->sched_info_list[0].si_periodicity.to_number(), 0};
  }
  // SIB3+ scheduling Section 5.2.3
  for (uint32_t i = 0; i < sib1->sched_info_list.size(); ++i) {
    for (uint32_t j = 0; j < sib1->sched_info_list[i].sib_map_info.size();
++j) {
      if (sib1->sched_info_list[i].sib_map_info[j].to_number() ==
sib_index) {
          return {sib1->sched_info_list[i].si_periodicity.to_number(), i};
      }
    }
  }
  return {0, -1};
}

/**
 * Determine the start TTI of SI-window (see TS 36.331 Sec 5.2.3)
 * @param tti    current TTI
 * @param T      Parameter "T" representing a SIB si-Periodicity
 * @param offset frame offset for the start of SI-window
 * @param a      subframe when SI-window starts
 * @return       next TTI when SI-window starts
 */
uint32_t sib_start_tti(uint32_t tti, uint32_t T, uint32_t offset, uint32_t
a)
{
  return (T * 10 * (1 + tti / (T * 10)) + (offset * 10) + a) % 10240; //
the 1 means next opportunity
}

/**
 * Determine SI-window [start, length] (see TS 36.331 Sec 5.2.3)
 * @param sib_index index of SI-message of interest
 * @return
 */
std::pair<uint32_t, uint32_t> compute_si_window(uint32_t tti, uint32_t
sib_index, uint32_t n, uint32_t T, const asn1::rrc::sib_type1_s* sib1)
{
  uint32_t si_win_start;
  uint32_t si_win_len; // si-WindowLength or "w"
  if (sib_index == 1) {
    si_win_len   = 1;
    si_win_start = sib_start_tti(tti, 2, 0, 5);
  } else {
    si_win_len      = sib1->si_win_len.to_number();
    uint32_t x      = n * si_win_len;
    uint32_t a      = x % 10; // subframe #a when the SI-window starts
    uint32_t offset = x / 10; // frame offset
    si_win_start    = sib_start_tti(tti, T, offset, a);
  }
  return {si_win_start, si_win_len};
}

template<typename Func>
bool find_and_decode(Func&& fcn)
{
    bool    res                         = true;
    bool    acks[SRSLTE_MAX_CODEWORDS]  = {false};
    int32_t n                           = 0;

    for (uint32_t tm = 0; tm < 4 && !n; tm++)
    {
        ue_dl_cfg.cfg.tm = (srslte_tm_t)tm;

        if ((ue_dl_cfg.cfg.tm == SRSLTE_TM1 && cell.nof_ports == 1) || (
ue_dl_cfg.cfg.tm > SRSLTE_TM1 && cell.nof_ports > 1))
        {
            n = srslte_ue_dl_find_and_decode(&ue_dl, &dl_sf, &ue_dl_cfg,
&pdsch_cfg, data, acks);

            if (0 < n)
            {
                int32_t pkt_errors=0, pmch_pkt_errors=0;
                for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) {
                  if (pdsch_cfg.grant.tb[tb].enabled) {
                    if (!acks[tb]) {
                      if (dl_sf.sf_type == SRSLTE_SF_NORM) {
                        pkt_errors++;
                      } else {
                        pmch_pkt_errors++;
                      }
                    }
                  }
                }
                if (!pkt_errors && !pmch_pkt_errors)
                {
                    asn1::rrc::bcch_dl_sch_msg_s    dlsch_msg;
                    asn1::cbit_ref                  dlsch_bref(data[0],
max_sib_size);
                    asn1::SRSASN_CODE err =
dlsch_msg.unpack(dlsch_bref);

                    if (err != asn1::SRSASN_SUCCESS or
dlsch_msg.msg.type().value != asn1::rrc::bcch_dl_sch_msg_
type_c::types_opts::c1)
                    {
                        printf("%s(),%d: Could not unpack BCCH DL-SCH
message! err=%d dlsch_msg.msg.type().value=%d[expected %d]\n",
                            __FUNCTION__, __LINE__, err,
dlsch_msg.msg.type().value, asn1::rrc::bcch_dl_sch_msg_
type_c::types_opts::c1);
                        res = false;
                    }
                    else
                    {
                        if ( fcn(dlsch_msg) )
                            print_sibs(dlsch_msg);
                    }
                }
                else
                {
                    printf("%s(),%d: ERROR: pkt_errors=%d
pmch_pkt_errors=%d\n", __FUNCTION__, __LINE__, pkt_errors, pmch_pkt_errors);
                }
            } //n = srslte_ue_dl_find_and_decode(&ue_dl, &dl_sf,
&ue_dl_cfg, &pdsch_cfg, data, acks);
            else
            {
                //printf("%s(),%d: >>> ERROR: srslte_ue_dl_find_and_decode
failed!\n", __FUNCTION__, __LINE__);
                res = false;
            }
        } //if (((ue_dl_cfg.cfg.tm == SRSLTE_TM1 && cell.nof_ports == 1) ||
(ue_dl_cfg.cfg.tm > SRSLTE_TM1 && cell.nof_ports > 1))
    } //for (uint32_t tm = 0; tm < 4 && !n; tm++)
    return res;
}

bool get_next_si_window(const asn1::rrc::sib_type1_s& sib1, uint32_t tti,
std::pair<uint32_t, int32_t>& window, uint32_t&& next_sib)
{
    bool found = (2 == next_sib) ? true : false;

    //check if the next_sib is among the listed SIBs and is not SIB2 (it
should always be present)
    for(uint32_t i = 0; i < sib1.sched_info_list.size() && !found; i++)
        for (uint32_t j = 0; j < sib1.sched_info_list[i].sib_map_info.size()
&& !found; ++j)
            found = (next_sib == sib1.sched_info_list[i].sib_
map_info[j].to_number());

    if (!found) //no such SIB in the list
        return found;

    window = compute_si_periodicity_and_idx(next_sib, &sib1);
    if (window.second >= 0)
        window = compute_si_window(tti, next_sib, window.second,
window.first, &sib1);
    else
    {
        printf("%s(),%d: ERROR: Wrong SIB%d description {periodicity=%d,
index=%d}!\n", __FUNCTION__, __LINE__, next_sib, window.first,
window.second);
        found = false;
    }
    return found;
}

void pre_find_and_decode(const uint8_t mch_table[10], const
srslte_chest_dl_cfg_t& chest_pdsch_cfg, const srslte_chest_dl_cfg_t&
chest_mbsfn_cfg, uint32_t sfn, uint32_t sf_idx)
{
    srslte_sf_t sf_type = (mch_table[sf_idx] == 0 ||
prog_args.mbsfn_area_id < 0) ? SRSLTE_SF_NORM : SRSLTE_SF_MBSFN; // Not an
MBSFN subframe
    ue_dl_cfg.chest_cfg = (mch_table[sf_idx] == 0 ||
prog_args.mbsfn_area_id < 0) ? chest_pdsch_cfg : chest_mbsfn_cfg; // Set
MBSFN channel estimation

    dl_sf.tti                             = sfn * 10 + sf_idx;
    dl_sf.sf_type                         = sf_type;
    ue_dl_cfg.cfg.pdsch.use_tbs_index_alt = prog_args.enable_256qam;
}

void handle_sib(uint32_t sfn, uint32_t sf_idx, const
asn1::rrc::sib_type1_s& sib1, std::pair<uint32_t, int32_t>& window,
int32_t& state)
{
    uint32_t tti = sfn * 10 + sf_idx;
    if (window.first <= tti && tti < (window.first + window.second))
    {
        printf("%s(),%d: STATE DECODE_SIB%d sfn=%d sf_idx=%d tti=%d
SI_Window {Start:%d Len:%d}\n", __FUNCTION__, __LINE__, state, sfn, sf_idx,
tti, window.first, window.second);

        int32_t old_state = state;

        bool res = find_and_decode([&](asn1::rrc::bcch_dl_sch_msg_s&
dlsch_msg) -> bool
                {
                    bool res = true;
                    if (dlsch_msg.msg.c1().type() ==
asn1::rrc::bcch_dl_sch_msg_type_c::c1_c_::types::sib_type1)
                    {
                        printf("%s(),%d: SIB1 detected! Do not print!\n",
__FUNCTION__, __LINE__);
                        res = false;
                    }
                    else
                    {
                        //get the next state and check if it is present in
SIB schedule list
                        while (++state < DECODE_LAST &&
!get_next_si_window(sib1, tti, window, state))
                            printf("%s(),%d: ERROR: Unable to get SI Window
for SIB%d!\n", __FUNCTION__, __LINE__, state);
                    }
                    return res;
                });

        if (!res && ((window.first + window.second - tti) == 1))
//recalculate this window, if the sib is not found in the current one
        {
            tti = sfn * 10 + 0;
            window = compute_si_periodicity_and_idx(old_state, &sib1);
            if (window.second >= 0)
            {
                window = compute_si_window(tti, old_state, window.second,
window.first, &sib1);
                printf("%s(),%d: Recalculated SIB%d window {Start=%d,
Length=%d}!\n", __FUNCTION__, __LINE__, old_state, window.first,
window.second);
            }
            else
            {
                printf("%s(),%d: ERROR: Wrong SIB%d description
{periodicity=%d, index=%d}!\n", __FUNCTION__, __LINE__, old_state,
window.first, window.second);
            }
        }
    }
}

int main(int argc, char** argv)
{
 ...
    srslte_rf_start_rx_stream(&rf, false);
...
    ue_sync.cfo_correct_enable_track = !prog_args.disable_cfo;
    srslte_pbch_decode_reset(&ue_mib.pbch);

    INFO("\nEntering main loop...\n\n");

    /* Main loop */
    uint64_t sf_cnt = 0;
    uint32_t sfn    = 0, sf_idx = 0;
    asn1::rrc::sib_type1_s sib1;
    std::pair<uint32_t, int32_t> window {0, 0}; //{periodicity, index in
schedule list}
    int32_t state = DECODE_MIB;

    while (!go_exit && (sf_cnt < (uint64_t)prog_args.nof_subframes ||
prog_args.nof_subframes == -1))
    {
        cf_t* buffers[SRSLTE_MAX_CHANNELS] = {};
        for (int p = 0; p < SRSLTE_MAX_PORTS; p++)
            buffers[p] = sf_buffer[p];

        ret = srslte_ue_sync_zerocopy(&ue_sync, buffers, max_num_samples);
        if (ret < 0)
            printf("%s(),%d: Error calling srslte_ue_sync_work()\n",
__FUNCTION__, __LINE__);

        /* srslte_ue_sync_get_buffer returns 1 if successfully read 1
aligned subframe */
        if (ret == 1)
        {
            sf_idx = srslte_ue_sync_get_sfidx(&ue_sync);

            if(state != DECODE_MIB)
                pre_find_and_decode(mch_table, chest_pdsch_cfg,
chest_mbsfn_cfg, sfn, sf_idx);

            switch (state)
            {
                case DECODE_MIB:
                {
                    if (sf_idx == 0)
                    {
                        uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN];
                        int     sfn_offset;
                        int32_t n = srslte_ue_mib_decode(&ue_mib,
bch_payload, NULL, &sfn_offset);
                        if (n < 0)
                        {
                            printf("%s(),%d: Error decoding UE
MIB\n",__FUNCTION__, __LINE__);
                            exit(-1);
                        }
                        else if (n == SRSLTE_UE_MIB_FOUND)
                        {
                            srslte_pbch_mib_unpack(bch_payload, &cell,
&sfn);
                            srslte_cell_fprint(stdout, &cell, sfn);
                            sfn = (sfn + sfn_offset) % 1024;
                            state = DECODE_SIB1;
                        }
                    }
                } //case DECODE_MIB:
                break;

                case DECODE_SIB1:
                {
                    uint32_t tti = sfn * 10 + sf_idx;

                    if (5 == sf_idx && (sfn % 2) == 0)
                    {
                        printf("%s(),%d: STATE DECODE_SIB%d sfn=%d
sf_idx=%d tti=%d SI_Window {Start:%d Len:%d}\n", __FUNCTION__, __LINE__,
state, sfn, sf_idx, tti, window.first, window.second);

                        find_and_decode([&](asn1::rrc::bcch_dl_sch_msg_s&
dlsch_msg) -> bool
                                {
                                    bool res = false;
                                    if (dlsch_msg.msg.c1().type() ==
asn1::rrc::bcch_dl_sch_msg_type_c::c1_c_::types::sib_type1)
                                    {
                                        sib1 =
dlsch_msg.msg.c1().sib_type1();

                                        //get the next state and check if
it is present in SIB schedule list
                                        while (++state < DECODE_LAST &&
!get_next_si_window(sib1, tti, window, state))
                                            printf("%s(),%d: ERROR: Unable
to get SI Window for SIB%d!\n", __FUNCTION__, __LINE__, state);

                                        res = true;
                                    }
                                    return res;
                                });

                        if(state != DECODE_SIB1)
                            printf("%s(),%d: sfn=%d sf_idx=%d; Next SIB%d
wth SI Window {Start=%d; Length=%d}!\n", __FUNCTION__, __LINE__, sfn,
sf_idx, state, window.first, window.second);

                        // Feed-back ue_sync with chest_dl CFO estimation
                        if (sf_idx == 5 && prog_args.enable_cfo_ref) {
                            srslte_ue_sync_set_cfo_ref(&ue_sync,
ue_dl.chest_res.cfo);
                        }
                    }
                } //case DECODE_SIB1:
                break;

                case DECODE_SIB2:
                case DECODE_SIB3:
                case DECODE_SIB4:
                case DECODE_SIB5:
                case DECODE_SIB6:
                case DECODE_SIB7:
                {
                    int32_t old_state = state;

                    handle_sib(sfn, sf_idx, sib1, window, state);

                    if(state != old_state)
                        printf("%s(),%d: sfn=%d sf_idx=%d; Next SIB%d wth
SI Window {Start=%d; Length=%d}!\n", __FUNCTION__, __LINE__, sfn, sf_idx,
state, window.first, window.second);
                }
                break;

                default:
                    break;
            }

            if (sf_idx == 9) {
                sfn++;
                if (sfn == 1024) {
                    sfn = 0;
                    printf("%s(),%d: RESET sfn=%d\n", __FUNCTION__,
__LINE__, sfn);
                }
            }
            fflush(stdout);
        }
        sf_cnt++;
    } // Main loop
...
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.srsran.com/pipermail/srsran-users/attachments/20200716/6d8f647c/attachment.htm>


More information about the srsran-users mailing list