Commit e625d73b authored by Nick Ho's avatar Nick Ho

add the primitives between MAC and RRC, and decode the MSG3 PDU at RRC successfully

parent d2261be4
......@@ -220,7 +220,7 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
int ul_total_buffer = 0;
//mac_NB_IoT_t *mac_inst;
UE_TEMPLATE_NB_IoT *UE_info;
LOG_I(MAC,"RX_SDU_IN\n");
//mac_inst = get_mac_inst(module_id);
// note: if lcid < 25 this is sdu, otherwise this is CE
......@@ -257,13 +257,18 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
// MSG3 content: |R|R|PHR|PHR|DVI|DVI|DVI|DVI|CCCH payload
PHR = ((payload_ptr[0] >> 5) & 0x01)*2+((payload_ptr[0]>>4) & 0x01);
DVI_index = (payload_ptr[0] >>3 & 0x01)*8+ (payload_ptr[0] >>2 & 0x01)*4 + (payload_ptr[0] >>1 & 0x01)*2 +(payload_ptr[0] >>0 & 0x01);
//LOG_D(MAC,"DVI_index= %d\n",DVI_index);
ul_total_buffer = DV_table[DVI_index];
LOG_D(MAC,"PHR = %d, ul_total_buffer = %d\n",PHR,ul_total_buffer);
LOG_I(MAC,"PHR = %d, ul_total_buffer = %d\n",PHR,ul_total_buffer);
// go to payload
payload_ptr+=1;
// Note that the first 6 byte (48 bits) of this CCCH SDU should be encoded in the MSG4 for contention resolution
printf("CCCH SDU content: ");
for(int a = 0; a<9;a++)
printf("%02x ",payload_ptr[a]);
printf("\n");
rx_lengths[i]-=1;
LOG_D(MAC,"rx_lengths : %d\n", rx_lengths[i]);
LOG_I(MAC,"rx_lengths : %d\n", rx_lengths[i]);
mac_rrc_msg3_ind_NB_IoT(payload_ptr,rnti);
//NB_IoT_mac_rrc_data_ind(payload_ptr,mac_inst,rnti);
//NB_IoT_receive_msg3(mac_inst,rnti,PHR,ul_total_buffer);
break;
......
......@@ -2,7 +2,7 @@
#include "LAYER2/MAC/proto_NB_IoT.h"
#include "LAYER2/MAC/extern_NB_IoT.h"
int tmp =0;
int tmp = 0;
void simulate_preamble(UL_IND_NB_IoT_t *UL_INFO, int CE, int sc)
{
......@@ -37,6 +37,41 @@ void enable_preamble_simulation(UL_IND_NB_IoT_t *UL_INFO,int i)
}
}
void simulate_msg3(UL_IND_NB_IoT_t *UL_INFO)
{
uint8_t *msg3 = NULL;
msg3 = (uint8_t *) malloc (11*sizeof(uint8_t));
msg3[0] = 0;
msg3[1] = 58;
msg3[2] = 42; // 2A
msg3[3] = 179; // B3
msg3[4] = 84; // 54
msg3[5] = 141; // 8D
msg3[6] = 43; // 2B
msg3[7] = 52; // 34
msg3[8] = 64; // 40
msg3[9] = 0;
msg3[10] = 0;
UL_INFO->RX_NPUSCH.number_of_pdus = 1;
UL_INFO->module_id = 0;
UL_INFO->CC_id = 0;
UL_INFO->frame = 521;
UL_INFO->subframe = 1;
UL_INFO->RX_NPUSCH.rx_pdu_list = (nfapi_rx_indication_pdu_t * )malloc(sizeof(nfapi_rx_indication_pdu_t));
UL_INFO->RX_NPUSCH.rx_pdu_list->rx_ue_information.rnti = 0x0101;
UL_INFO->RX_NPUSCH.rx_pdu_list->data = msg3;
UL_INFO->RX_NPUSCH.rx_pdu_list->rx_indication_rel8.length = 11;
}
void enable_msg3_simulation(UL_IND_NB_IoT_t *UL_INFO, int i)
{
if(i==1)
{
if(UL_INFO->frame==521 && UL_INFO->subframe==1)
{
simulate_msg3(UL_INFO);
}
}
}
// Sched_INFO as a input for the scheduler
void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
{
......@@ -47,6 +82,7 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
enable_preamble_simulation(UL_INFO,0);
enable_msg3_simulation(UL_INFO,0);
//if(preamble_trigger==0)
//{
//If there is a preamble, do the initiate RA procedure
......@@ -93,6 +129,7 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
}
}
*/
//If there is a Uplink SDU which needs to send to MAC
if(UL_INFO->RX_NPUSCH.number_of_pdus>0)
......@@ -112,8 +149,7 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
}
}
*/
UL_INFO->RX_NPUSCH.number_of_pdus = 0;
if(UL_INFO->hypersfn==1 && UL_INFO->frame==0)
{
......
......@@ -37,6 +37,8 @@
#include "LAYER2/MAC/defs_NB_IoT.h"
/*NOTE: no static function should be declared in this header file (e.g. init_SI_NB)*/
void mac_rrc_msg3_ind_NB_IoT(uint8_t *payload_ptr,uint16_t rnti);
uint8_t *get_NB_IoT_MIB(
rrc_eNB_carrier_data_NB_IoT_t *carrier,
uint16_t N_RB_DL,//may not needed--> for NB_IoT only 1 PRB is used
......
......@@ -39,6 +39,8 @@
#include "extern_NB_IoT.h"
#include "LAYER2/MAC/proto_NB_IoT.h"
#include "RRC/LITE/MESSAGES/asn1_msg_NB_IoT.h"
#include "RRCConnectionRequest-NB.h"
#include "UL-CCCH-Message-NB.h"
// NB-IoT end
#include "assertions.h"
#include "asn1_conversions.h"
......@@ -119,6 +121,47 @@ extern uint16_t two_tier_hexagonal_cellIds[7];
mui_t rrc_eNB_mui = 0;
void mac_rrc_msg3_ind_NB_IoT(uint8_t *payload_ptr, uint16_t rnti)
{
LOG_I(RRC,"recieve MSG3 CCCH SDU from MAC\n");
asn_dec_rval_t dec_rval;
RRCConnectionRequest_NB_r13_IEs_t* rrcConnectionRequest_NB = NULL;
UL_CCCH_Message_NB_t* ul_ccch_msg_NB = NULL;
dec_rval = uper_decode(
NULL,
&asn_DEF_UL_CCCH_Message_NB,
(void**)&ul_ccch_msg_NB,
payload_ptr,
100,
0,
0);
if (ul_ccch_msg_NB->message.choice.c1.present==UL_CCCH_MessageType_NB__c1_PR_rrcConnectionRequest_r13)
{
LOG_I(RRC,"The decode CCH MSG is RRC connection Request NB\n");
rrcConnectionRequest_NB = &ul_ccch_msg_NB->message.choice.c1.choice.rrcConnectionRequest_r13.criticalExtensions.choice.rrcConnectionRequest_r13;
if (rrcConnectionRequest_NB->ue_Identity_r13.present == InitialUE_Identity_PR_randomValue)
{
uint8_t *da = rrcConnectionRequest_NB->ue_Identity_r13.choice.randomValue.buf; /* BIT STRING body */
int length = rrcConnectionRequest_NB->ue_Identity_r13.choice.randomValue.size; /* Size of the above buffer */
printf("Random Value: ");
for(int a = 0; a<length;a++)
printf("%02x ",da[a]);
printf("\n");
}else if (rrcConnectionRequest_NB->ue_Identity_r13.present == InitialUE_Identity_PR_s_TMSI)
{
uint8_t *da = rrcConnectionRequest_NB->ue_Identity_r13.choice.s_TMSI.m_TMSI.buf; /* BIT STRING body */
int length = rrcConnectionRequest_NB->ue_Identity_r13.choice.s_TMSI.m_TMSI.size; /* Size of the above buffer */
printf("TMSI: ");
for(int a = 0; a<length;a++)
printf("%02x ",da[a]);
printf("\n");
}else
LOG_E(RRC,"unknown TMSI or Random Value format in RRC connection request NB\n");
}else
LOG_E(RRC,"unknown MSG3 format for NB-IoT for current test\n");
}
uint8_t *get_NB_IoT_MIB(
rrc_eNB_carrier_data_NB_IoT_t *carrier,
uint16_t N_RB_DL,//may not needed--> for NB_IoT only 1 PRB is used
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment