Commit aae1ac05 authored by Nick Ho's avatar Nick Ho

Recovery attach complete & Can receive one ping

parent 584bad45
......@@ -1569,18 +1569,30 @@ break;
}
}
unsigned char sample_security[10] = {0x3d, 0x03, 0x00, 0xa0, 0x01, 0x30, 0x0b, 0x07, 0x53, 0x08};
unsigned char auth_rsp[10] = {0x3d, 0x03, 0x00, 0xa0, 0x01, 0x30, 0x0b, 0x07, 0x53, 0x08};
unsigned char attach_complete[8] = {0x01, 0x07, 0x43, 0x00, 0x03, 0x52, 0x00, 0xc2};
int cnt = 0;
int correct_bit = 0;
int correct_bit_attach = 0;
for (cnt=0; cnt <10; cnt++)
{
if(sample_security[cnt] == decoded_bytes[cnt])
if(auth_rsp[cnt] == decoded_bytes[cnt])
{
//printf("correct_bit++\n");
correct_bit++;
}
}
for (cnt=10; cnt <18; cnt++)
{
if(attach_complete[cnt-10] == decoded_bytes[cnt])
{
//printf("correct_bit_attach++\n");
correct_bit_attach++;
}
}
// check status on output
if (iteration_cnt>1) {
oldcrc= *((unsigned int *)(&decoded_bytes[(n>>3)-crc_len]));
......@@ -1588,7 +1600,7 @@ break;
switch (crc_type) {
case CRC24_A:
if (correct_bit<10)
if ((correct_bit<10) && (correct_bit_attach<8))
{
oldcrc&=0x00ffffff;
crc = crc24a(&decoded_bytes[F>>3],
......@@ -1597,7 +1609,7 @@ break;
((uint8_t *)&crc)[2] = ((uint8_t *)&crc)[0];
((uint8_t *)&crc)[0] = temp;
break;
}else
}else if(correct_bit==10)
{
printf("Try to recovery authentication response\n");
......@@ -1755,6 +1767,42 @@ break;
decoded_bytes[11] = decoded_bytes[11] - 0x08;
decoded_bytes[17] = decoded_bytes[17] - 0x08;
break;
}else if(correct_bit_attach==8)
{
printf("Try to recovery attach complete\n");
// the first case, didn't change anything
oldcrc&=0x00ffffff;
crc = 0;
crc = crc24a(&decoded_bytes[F>>3],
n-24-F)>>8;
temp=((uint8_t *)&crc)[2];
((uint8_t *)&crc)[2] = ((uint8_t *)&crc)[0];
((uint8_t *)&crc)[0] = temp;
//printf("oldcrc %x, crc %x\n",oldcrc,crc);
if (crc == oldcrc)
{
return iteration_cnt;
}
// Add 1st byte for 00001000 (0x08)
decoded_bytes[7] = decoded_bytes[7] + 0x08;
//oldcrc&=0x00ffffff;
crc = 0;
crc = crc24a(&decoded_bytes[F>>3],
n-24-F)>>8;
temp=((uint8_t *)&crc)[2];
((uint8_t *)&crc)[2] = ((uint8_t *)&crc)[0];
((uint8_t *)&crc)[0] = temp;
//printf("oldcrc %x, crc %x\n",oldcrc,crc);
if (crc == oldcrc)
{
return iteration_cnt;
}
decoded_bytes[7] = decoded_bytes[7] - 0x08;
break;
}
case CRC24_B:
oldcrc&=0x00ffffff;
......
......@@ -1682,7 +1682,7 @@ uint32_t turbo_decoding_NB_IoT(PHY_VARS_eNB *eNB,
if (ulsch_harq->b[14] == 0x00 && ulsch_harq->b[15] == 0x07 && ulsch_harq->b[16] == 0x5e)
{
printf("try to recovery Security mode complete, show the 11 th byte : %02x \n",ulsch_harq->b[11]);
printf("Try to recovery Security mode complete, show the 11 th byte : %02x \n",ulsch_harq->b[11]);
//ulsch_harq->b[11] = ulsch_harq->b[11] + 0x08;
ulsch_harq->b[17] = 0x00;
fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1); // indicate ACK to MAC
......
......@@ -103,7 +103,8 @@ typedef enum rach_state_e
{
initial_access = 0,
rach_for_auth_rsp,
rach_for_next,
rach_for_TAU,
rach_for_next
}rach_state_t;
......
......@@ -100,10 +100,7 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
mcs = mapped_mcs[UE_info->CE_level][mappedMcsIndex];
if ((UE_state_machine == rach_for_next) && (UE_info->ul_total_buffer==22))
{
mcs = 6;
}
//mcs = 2;
while((TBS<UE_info->ul_total_buffer)&&(Iru<=7))
......@@ -159,7 +156,7 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
UE_sched_ctrl_info->NPUSCH_sf_start=NPUSCH_info->sf_start;
//UE_sched_ctrl_info->resent_flag = 1;
LOG_N(MAC,"Key resent \n");
UE_sched_ctrl_info->dci_n0_index_ndi=1;
UE_sched_ctrl_info->dci_n0_index_ndi=0;
}else
{
......@@ -260,7 +257,7 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
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);
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
......@@ -310,7 +307,7 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
//UE_info->direction = 1; //1 for DL scheduler
LOG_I(MAC,"After receive Msg5, change the UE scheduling direction to DL\n");
}
}else if (UE_state_machine == rach_for_auth_rsp)
}else if (UE_state_machine == rach_for_auth_rsp || UE_state_machine == rach_for_TAU)
{
LOG_N(MAC,"Here we are for the DCI N0 generating \n");
if (UE_info != NULL)
......
......@@ -5,6 +5,7 @@
int tmp = 0;
//int block_rach = 0;
int first_msg4 = 0;
int rach_count = 0;
void simulate_preamble(UL_IND_NB_IoT_t *UL_INFO, int CE, int sc)
{
......@@ -118,6 +119,22 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
);
//block_rach = 2;
}else if (UE_state_machine == rach_for_next || UE_state_machine == rach_for_TAU)
{
rach_count++;
if (rach_count == 4)
{
LOG_N(MAC,"It is the third time that this UE try to rach\n");
init_RA_NB_IoT(mac_inst,
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc,
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.nrach_ce_level,
UL_INFO->frame,
//timing_offset = Timing_advance * 16
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance*16
);
UE_state_machine = rach_for_TAU;
}
}
}
}
......
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