Commit 26ac2a13 authored by Nick Ho's avatar Nick Ho

Add compiler option for the NB-IoT CRC Recovery

parent a59ccb36
...@@ -571,6 +571,7 @@ add_boolean_option(FLEXRAN_AGENT_SB_IF False "enable FlexRAN ...@@ -571,6 +571,7 @@ add_boolean_option(FLEXRAN_AGENT_SB_IF False "enable FlexRAN
# NB-IOT # NB-IOT
################################################################ ################################################################
add_boolean_option(NB_IOT True "Enabling NB-IoT code") add_boolean_option(NB_IOT True "Enabling NB-IoT code")
add_boolean_option(NB_IOT_CRC_REVOVERY True "Enabling NB-IoT CRC Recovery for some specific data")
######################## ########################
......
...@@ -1569,12 +1569,16 @@ break; ...@@ -1569,12 +1569,16 @@ break;
} }
} }
#ifdef NB_IOT_CRC_REVOVERY
unsigned char auth_rsp[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}; unsigned char attach_complete[8] = {0x01, 0x07, 0x43, 0x00, 0x03, 0x52, 0x00, 0xc2};
unsigned char security_complte[3] = {0x00, 0x07, 0x5e};
int cnt = 0; int cnt = 0;
int correct_bit = 0; int correct_bit = 0;
int correct_bit_attach = 0; int correct_bit_attach = 0;
int correct_bit_security = 0;
//unsigned char padding = 0x00;
for (cnt=0; cnt <10; cnt++) for (cnt=0; cnt <10; cnt++)
{ {
...@@ -1592,7 +1596,15 @@ break; ...@@ -1592,7 +1596,15 @@ break;
correct_bit_attach++; correct_bit_attach++;
} }
} }
for (cnt=0; cnt <3; cnt++)
{
if(security_complte[cnt] == decoded_bytes[cnt+14])
{
//printf("correct_bit_security++\n");
correct_bit_security++;
}
}
#endif
// check status on output // check status on output
if (iteration_cnt>1) { if (iteration_cnt>1) {
oldcrc= *((unsigned int *)(&decoded_bytes[(n>>3)-crc_len])); oldcrc= *((unsigned int *)(&decoded_bytes[(n>>3)-crc_len]));
...@@ -1600,7 +1612,8 @@ break; ...@@ -1600,7 +1612,8 @@ break;
switch (crc_type) { switch (crc_type) {
case CRC24_A: case CRC24_A:
if ((correct_bit<10) && (correct_bit_attach<8)) #ifdef NB_IOT_CRC_REVOVERY
if ((correct_bit<10) && (correct_bit_attach<8)&&(correct_bit_security<3))
{ {
oldcrc&=0x00ffffff; oldcrc&=0x00ffffff;
crc = crc24a(&decoded_bytes[F>>3], crc = crc24a(&decoded_bytes[F>>3],
...@@ -1767,6 +1780,7 @@ break; ...@@ -1767,6 +1780,7 @@ break;
decoded_bytes[11] = decoded_bytes[11] - 0x08; decoded_bytes[11] = decoded_bytes[11] - 0x08;
decoded_bytes[17] = decoded_bytes[17] - 0x08; decoded_bytes[17] = decoded_bytes[17] - 0x08;
break; break;
}else if(correct_bit_attach==8) }else if(correct_bit_attach==8)
{ {
printf("Try to recovery attach complete\n"); printf("Try to recovery attach complete\n");
...@@ -1803,7 +1817,96 @@ break; ...@@ -1803,7 +1817,96 @@ break;
} }
decoded_bytes[7] = decoded_bytes[7] - 0x08; decoded_bytes[7] = decoded_bytes[7] - 0x08;
break; break;
}else if (correct_bit_security == 3)
{
printf("Try to recovery security 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)
{
decoded_bytes[17] = 0x00;
return iteration_cnt;
}
// Add 1st byte for 00001000 (0x08)
decoded_bytes[11] = decoded_bytes[11] + 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)
{
decoded_bytes[17] = 0x00;
return iteration_cnt;
}
decoded_bytes[11] = decoded_bytes[11] - 0x08;
// Add 1st byte for 00001000 (0x08)
//padding = decoded_bytes[17];
decoded_bytes[17] = decoded_bytes[17] + 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)
{
decoded_bytes[17] = 0x00;
return iteration_cnt;
}
decoded_bytes[17] = decoded_bytes[17] - 0x08;
// Add 1st byte for 00001000 (0x08)
decoded_bytes[11] = decoded_bytes[11] + 0x08;
decoded_bytes[17] = decoded_bytes[17] + 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)
{
//decoded_bytes[17] = 0x00;
return iteration_cnt;
}
decoded_bytes[17] = decoded_bytes[17] - 0x08;
decoded_bytes[11] = decoded_bytes[11] - 0x08;
} }
break;
#else
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;
break;
#endif
case CRC24_B: case CRC24_B:
oldcrc&=0x00ffffff; oldcrc&=0x00ffffff;
crc = crc24b(decoded_bytes, crc = crc24b(decoded_bytes,
......
...@@ -183,9 +183,9 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -183,9 +183,9 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
ndlcch->rnti[ncce_index] = rnti; //we store the RNTI (e.g. for RNTI will be used later) ndlcch->rnti[ncce_index] = rnti; //we store the RNTI (e.g. for RNTI will be used later)
ndlcch->active[ncce_index] = 1; //will be activated by the corresponding NDSLCH pdu ndlcch->active[ncce_index] = 1; //will be activated by the corresponding NDSLCH pdu
ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,16); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
printf("dci_repetitions: %d, A = %d\n",ndlcch->dci_repetitions[ncce_index],ndlcch->A[ncce_index]); //printf("dci_repetitions: %d, A = %d\n",ndlcch->dci_repetitions[ncce_index],ndlcch->A[ncce_index]);
DCI_flip = (uint8_t*)malloc(3*sizeof(uint8_t)); DCI_flip = (uint8_t*)malloc(3*sizeof(uint8_t));
...@@ -209,7 +209,7 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -209,7 +209,7 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
* ISF = ResAssign * ISF = ResAssign
*/ */
ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,16); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
LOG_I(PHY,"DCI packing for N0 done \n"); LOG_I(PHY,"DCI packing for N0 done \n");
...@@ -319,7 +319,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -319,7 +319,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
DCI_flip[i] = 0x0; DCI_flip[i] = 0x0;
} }
DCI_flip[0] = (type << 7) | (orderIndicator << 6) | (Sched_delay<<2) | ResAssign ; DCI_flip[0] = (type << 7) | (orderIndicator << 6) | (Sched_delay<<3) | ResAssign ;
DCI_flip[1] = (mcs << 4) | RepNum; DCI_flip[1] = (mcs << 4) | RepNum;
DCI_flip[2] = (ndi << 7) | (HARQackRes << 3) | (DCIRep <<1); DCI_flip[2] = (ndi << 7) | (HARQackRes << 3) | (DCIRep <<1);
......
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