int loop = 0; if (ra->rnti == 0) { // This condition allows for the usage of a preconfigured rnti for the CFRA do { // 3GPP TS 38.321 version 15.13.0 Section 7.1 Table 7.1-1: RNTI values ra->rnti = (taus() % 0xffef) + 1; loop++; } while (loop != 100 && !((find_nr_UE(&nr_mac->UE_info, ra->rnti) == NULL) && (find_nr_RA_id(module_idP, CC_id, ra->rnti) == -1) && ra->rnti >= 0x1 && ra->rnti <= 0xffef)); if (loop == 100) { LOG_E(NR_MAC, "[RAPROC] initialisation random access aborted\n"); abort(); } }
开发环境配置
首先硬件设备就不多说了,因为我在四楼工作,所以我干脆把整套系统都放到一台机子上运行。怎么All in One进行开发研究请见之前的文章。另外一个需要配置的就是VSCode里面的GDB:首先在VSCode中配置GDB(就是按下Ctrl+Shift+D,然后新建launch.json文件)。写入以下内容:
voidextract_imsi(uint8_t *pdu_buf, uint32_t pdu_len, rrc_eNB_ue_context_t *ue_context_pP) { /* Process NAS message locally to get the IMSI */ nas_message_t nas_msg; memset(&nas_msg, 0, sizeof(nas_message_t)); int size = 0; nas_message_security_header_t *header = &nas_msg.header; /* Decode the first octet of the header (security header type or EPS * bearer identity, and protocol discriminator) */ DECODE_U8((char *) pdu_buf, *(uint8_t *) (header), size);
/* Decode NAS message only if decodable*/ if (!(header->security_header_type <= SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED && header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE && pdu_len > NAS_MESSAGE_SECURITY_HEADER_SIZE)) return;
// ...... }
但是这个解码好像不对。经过和OAI 团队的沟通发现,IMSI确实不能在gNB侧解,我服了…所以我又绕回来了,其实可以通过接入时的CU/DU id 对用户进行区分。那么思路就是找到CU_ID 和 DU_ID的映射关系,显然这个关系应该要用Hash表实现。
在函数的phy_procedures_gNB_TX(processingData_L1tx_t *msgTx,int frame, int slot,int do_meas)这个函数中,相关的逻辑代码是放在这样的结构下运行的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
for (int i = 0; i < gNB->max_nb_srs; i++) { if (srs) { if ((srs->active == 1) && (srs->frame == frame_rx) && (srs->slot == slot_rx)) { for (int uI = 0; uI < nr_srs_channel_iq_matrix.num_ue_srs_ports; uI++) { for (int gI = 0; gI < nr_srs_channel_iq_matrix.num_gnb_antenna_elements; gI++) { for (int pI = 0; pI < nr_srs_channel_iq_matrix.num_prgs; pI++) { channel_matrix[i][uI][gI][pI].r = xxx.r; channel_matrix[i][uI][gI][pI].i = xxx.i; }// for (int pI = 0; pI < nr_srs_channel_iq_matrix.num_prgs; pI++) }// for (int gI = 0; gI < nr_srs_channel_iq_matrix.num_gnb_antenna_elements; gI++) }// for (int uI = 0; uI < nr_srs_channel_iq_matrix.num_ue_srs_ports; uI++) }// if ((srs->active == 1) && (srs->frame == frame_rx) && (srs->slot == slot_rx)) }// if (srs) }// for (int i = 0; i < gNB->max_nb_srs; i++)
git clone https://github.com/EttusResearch/uhd.git ~/uhd cd ~/uhd git checkout v4.6.0.0 cd host mkdir build cd build cmake ../ make -j $(nproc) make test# This step is optional sudo make install sudo ldconfig sudo uhd_images_downloader