Commit ac71394e authored by Nick Ho's avatar Nick Ho

Fix the part with the same sim card

parent 51017595
......@@ -1571,7 +1571,8 @@ 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[5] = {0x30, 0x0b, 0x07, 0x53, 0x08};
unsigned char attach_complete[8] = {0x01, 0x07, 0x43, 0x00, 0x03, 0x52, 0x00, 0xc2};
unsigned char security_complte[3] = {0x00, 0x07, 0x5e};
int cnt = 0;
......@@ -1580,9 +1581,9 @@ break;
int correct_bit_security = 0;
//unsigned char padding = 0x00;
for (cnt=0; cnt <10; cnt++)
for (cnt=0; cnt <5; cnt++)
{
if(auth_rsp[cnt] == decoded_bytes[cnt])
if(auth_rsp[cnt] == decoded_bytes[cnt+5])
{
//printf("correct_bit++\n");
correct_bit++;
......@@ -1613,7 +1614,7 @@ break;
case CRC24_A:
#ifdef NB_IOT_CRC_REVOVERY
if ((correct_bit<10) && (correct_bit_attach<8)&&(correct_bit_security<3))
if ((correct_bit<5) && (correct_bit_attach<8)&&(correct_bit_security<3))
{
oldcrc&=0x00ffffff;
crc = crc24a(&decoded_bytes[F>>3],
......@@ -1622,7 +1623,7 @@ break;
((uint8_t *)&crc)[2] = ((uint8_t *)&crc)[0];
((uint8_t *)&crc)[0] = temp;
break;
}else if(correct_bit==10)
}else if(correct_bit==5)
{
printf("Try to recovery authentication response\n");
......
......@@ -1687,6 +1687,18 @@ uint32_t turbo_decoding_NB_IoT(PHY_VARS_eNB *eNB,
ulsch_harq->b[17] = 0x00;
fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1); // indicate ACK to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,1);
}else if (ulsch_harq->b[7] == 0x30 && ulsch_harq->b[8] == 0x03 && ulsch_harq->b[9] == 0x07 && ulsch_harq->b[10] == 0x5f)
{
printf("Try to recovery Security mode reject, show the 11 th byte : %02x \n",ulsch_harq->b[11]);
ulsch_harq->b[11] = ulsch_harq->b[11] + 0x08;
ulsch_harq->b[12] = 0x00;
ulsch_harq->b[13] = 0x00;
ulsch_harq->b[14] = 0x00;
ulsch_harq->b[15] = 0x00;
ulsch_harq->b[16] = 0x00;
ulsch_harq->b[17] = 0x00;
fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1); // indicate ACK to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,1);
}else
{
fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,0); // indicate NAK to MAC
......
......@@ -129,7 +129,7 @@ typedef enum{
DL
}message_direction_t;
#define MAX_NUMBER_OF_UE_MAX_NB_IoT 20
#define MAX_NUMBER_OF_UE_MAX_NB_IoT 50
#define SCH_PAYLOAD_SIZE_MAX_NB_IoT 320
#define MAX_NUMBER_OF_SIBs_NB_IoT 16
......@@ -184,7 +184,7 @@ typedef struct {
DLSCH_PDU_NB_IoT Security_pdu;
DLSCH_PDU_NB_IoT Attach_pdu;
DLSCH_PDU_NB_IoT Attach2_pdu;
/// DLSCH pdu
DLSCH_PDU_NB_IoT DLSCH_pdu;
// PDU size
......
......@@ -33,6 +33,7 @@
int Security_flag = 0;
int Attach_flag = 0;
int Attach_flag2 = 0;
uint8_t from_R_dl_to_idx(uint8_t R)
......@@ -113,7 +114,7 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
#if 1
if(UE_info->HARQ_round==0)
{
if (Security_flag == 0 & Attach_flag == 0 )
if (Security_flag == 0 & Attach_flag == 0 && Attach_flag2 == 0)
{
//Get RLC status
rlc_status = mac_rlc_status_ind(
......@@ -255,6 +256,30 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
printf("%02x ",UE_info->DLSCH_pdu.payload[y]);
}
printf("\n");
}else if (Attach_flag2 == 1)
{
memcpy(UE_info->DLSCH_pdu.payload,UE_info->Attach2_pdu.payload,UE_info->Attach2_pdu.pdu_size);
UE_info->DLSCH_pdu_size= UE_info->Attach2_pdu.pdu_size;
data_size = UE_info->DLSCH_pdu_size;
if(data_size == 0)
{
LOG_D(MAC,"[%04d][DLSchedulerUSS][Fail] No data in DCCH0_NB_IoT\n", mac_inst->current_subframe);
return -1;
}
if(TBS >= data_size) // control and data
{
TBS = get_tbs(data_size, I_tbs, &I_sf);
LOG_I(MAC,"[%04d][DLSchedulerUSS] TBS change to %d because data size is smaller than previous TBS\n", mac_inst->current_subframe, TBS);
}
printf("print the MAC DATA PDU including length payload, we have header %d byte \n",data_size);
//int y;
for (y=0;y<TBS;y++)
{
//for (y=0;y<payload_offset+mac_sdu_size2;y++){
printf("%02x ",UE_info->DLSCH_pdu.payload[y]);
}
printf("\n");
}
if (rlc_data_pdu_size == 20 && Security_flag == 0)
......@@ -273,6 +298,14 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
return -1;
}
if (rlc_data_pdu_size == 41 && Attach_flag2 == 0)
{
memcpy(UE_info->Attach2_pdu.payload,UE_info->DLSCH_pdu.payload,TBS);
UE_info->Attach2_pdu.pdu_size = TBS;
Attach_flag2 = 1;
return -1;
}
}
/*Retransmission*/
......@@ -394,6 +427,8 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
Security_flag = 0;
if (Attach_flag == 1)
Attach_flag = 0;
if (Attach_flag2 == 1)
Attach_flag2 = 0;
LOG_I(MAC,"[%04d][DLSchedulerUSS][%d][Success] Complete scheduling with data size %d\n", mac_inst->current_subframe, UE_info->rnti, data_size);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] RNTI %d\n", mac_inst->current_subframe, UE_info->rnti);
LOG_I(MAC,"[%04d][DLSchedulerUSS][%d][Success] Allocate NPDCCH subframe %d to subframe %d candidate index %d\n", mac_inst->current_subframe, UE_info->rnti, NPDCCH_info->sf_start, NPDCCH_info->sf_end, cdd_num);
......
......@@ -295,6 +295,12 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
if((UE_state_machine == initial_access)||(UE_state_machine == rach_for_next))
{
block_RLC = 0;
int x = 0;
LOG_N(MAC,"Length: %d\n",rx_lengths[i]);
for (x=0;x<rx_lengths[i];x++)
printf("%02x ",payload_ptr[x]);
printf("\n");
mac_rlc_data_ind(
module_id,
rnti,
......@@ -309,6 +315,26 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
1,
NULL);//(unsigned int*)crc_status);
// trigger DL scheduler
if (RLC_RECEIVE_MSG5_FAILED == 1)
{
payload_ptr = payload_ptr+20;
LOG_N(MAC,"RLC Decoded data discard because of SN wrong\n");
//int x = 0;
for (x=0;x<49;x++)
printf("%02x ",payload_ptr[x]);
printf("\n");
protocol_ctxt_t ctxt;
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_id, 1, rnti, frame, 0, module_id);
rrc_data_ind(
&ctxt,
rx_lcids[i],
49,
(char *)payload_ptr);
RLC_RECEIVE_MSG5_FAILED = 0;
}
if (UE_info != NULL)
{
//UE_info->direction = 1; //1 for DL scheduler
......
......@@ -123,4 +123,5 @@ extern const int si_repetition_pattern[4];
extern int waiting_flag_from_RLC;
extern int block_RLC;
extern int Valid_msg3;
extern int RLC_RECEIVE_MSG5_FAILED;
#endif //DEF_H
......@@ -147,6 +147,7 @@ const int si_repetition_pattern[4] = {20, 40, 80, 160};
int waiting_flag_from_RLC = 0;
int block_RLC = 0;
int Valid_msg3 = 1;
int RLC_RECEIVE_MSG5_FAILED = 0;
#endif
......
......@@ -30,7 +30,7 @@
#include "list.h"
#include "LAYER2/MAC/extern.h"
#include "UTIL/LOG/log.h"
#include "LAYER2/MAC/extern_NB_IoT.h"
//-----------------------------------------------------------------------------
signed int
......@@ -447,6 +447,7 @@ rlc_am_receive_process_data_pdu (
rlc_pP->stat_rx_data_pdu_out_of_window += 1;
rlc_pP->stat_rx_data_bytes_out_of_window += tb_size_in_bytesP;
pdu_status = RLC_AM_DATA_PDU_STATUS_SN_OUTSIDE_WINDOW;
RLC_RECEIVE_MSG5_FAILED = 1;
LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] PDU OUT OF RX WINDOW, DISCARDED, SN=%d\n",
PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_info_p->sn);
}
......
......@@ -582,11 +582,13 @@ void rlc_data_ind (
T(T_ENB_RLC_UL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_sizeP));
#endif
LOG_N(RLC,"sdu_size: %d\n",sdu_sizeP);
/*************************For SRB1bis (RLC->RRC)*****************************/
rrc_data_ind(
ctxt_pP,
rb_idP,
51,
sdu_sizeP,
(uint8_t*)&sdu_pP->data[0]);
/***************************************************************************/
......
......@@ -121,9 +121,9 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
}else if (UE_state_machine == rach_for_next || UE_state_machine == rach_for_TAU)
{
rach_count++;
if (rach_count == 4)
{
//rach_count++;
//if (rach_count%3==0)
//{
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,
......@@ -134,7 +134,7 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
);
UE_state_machine = rach_for_TAU;
}
//}
}
}
}
......@@ -195,6 +195,14 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
{
for(i=0;i<UL_INFO->RX_NPUSCH.number_of_pdus;i++)
{
printf("The Receive MAC PDU:");
int x = 0;
for (x = 0; x < (UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_indication_rel8.length; x ++)
{
printf("%02x ", (UL_INFO->RX_NPUSCH.rx_pdu_list+i)->data[x]);
}
printf("\n");
//For MSG3, Normal Uplink Data, NAK
rx_sdu_NB_IoT(UL_INFO->module_id,
UL_INFO->CC_id,
......
......@@ -5070,14 +5070,14 @@ int rrc_eNB_decode_dcch_NB_IoT(
&asn_DEF_UL_DCCH_Message_NB,
(void**)&ul_dcch_msg_NB_IoT,
Rx_sdu,
sdu_sizeP,
100,
0,
0);
/*
printf("....after uper_decode....\n");
printf("Rx_sdu : %d\n",Rx_sdu);
printf("sdu_sizeP : %d\n", sdu_sizeP);
*/
//printf("....after uper_decode....\n");
//printf("Rx_sdu : %d\n",Rx_sdu);
//printf("sdu_sizeP : %d\n", sdu_sizeP);
//#if defined(ENABLE_ITTI)
//# if defined(DISABLE_ITTI_XER_PRINT)
......
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