void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) { unsigned char *otg_pkt=NULL; module_id_t dst_id; // dst for otg rb_id_t rb_id; unsigned int pkt_size=0; #if defined(USER_MODE) && defined(OAI_EMU) module_id_t src_id; static unsigned int pkt_cnt_enb=0, pkt_cnt_ue=0; Packet_otg_elt_t *otg_pkt_info=NULL; int result; uint8_t pdcp_mode, is_ue=0; #endif protocol_ctxt_t ctxt; // we need to add conditions to avoid transmitting data when the UE is not RRC connected. #if defined(USER_MODE) && defined(OAI_EMU) if (oai_emulation.info.otg_enabled ==1 ) { // module_id is source id while ((otg_pkt_info = pkt_list_remove_head(&(otg_pdcp_buffer[ctxt_pP->instance]))) != NULL) { LOG_I(OTG,"Mod_id %d Frame %d Got a packet (%p), HEAD of otg_pdcp_buffer[%d] is %p and Nb elements is %d\n", ctxt_pP->module_id, ctxt_pP->frame, otg_pkt_info, ctxt_pP->instance, pkt_list_get_head(&(otg_pdcp_buffer[ctxt_pP->instance])), otg_pdcp_buffer[ctxt_pP->instance].nb_elements); //otg_pkt_info = pkt_list_remove_head(&(otg_pdcp_buffer[module_id])); dst_id = (otg_pkt_info->otg_pkt).dst_id; // type is module_id_t src_id = (otg_pkt_info->otg_pkt).module_id; // type is module_id_t rb_id = (otg_pkt_info->otg_pkt).rb_id; is_ue = (otg_pkt_info->otg_pkt).is_ue; pdcp_mode = (otg_pkt_info->otg_pkt).mode; // LOG_I(PDCP,"pdcp_fifo, pdcp mode is= %d\n",pdcp_mode); // generate traffic if the ue is rrc reconfigured state // if (mac_get_rrc_status(module_id, ctxt_pP->enb_flag, dst_id ) > 2 /*RRC_CONNECTED*/) { // not needed: this test is already done in update_otg_enb otg_pkt = (unsigned char*) (otg_pkt_info->otg_pkt).sdu_buffer; pkt_size = (otg_pkt_info->otg_pkt).sdu_buffer_size; if (otg_pkt != NULL) { if (is_ue == 0 ) { PROTOCOL_CTXT_SET_BY_MODULE_ID( &ctxt, src_id, ENB_FLAG_YES, oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id], ctxt_pP->frame, ctxt_pP->subframe, src_id); LOG_D(OTG,"[eNB %d] Frame %d sending packet %d from module %d on rab id %d (src %d, dst %d/%x) pkt size %d for pdcp mode %d\n", ctxt.module_id, ctxt.frame, pkt_cnt_enb++, src_id, rb_id, src_id, dst_id, oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id], pkt_size, pdcp_mode); result = pdcp_data_req(&ctxt, SRB_FLAG_NO, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, pkt_size, otg_pkt, pdcp_mode); if (result != TRUE) { LOG_W(OTG,"PDCP data request failed!\n"); } } else { //rb_id= eNB_index * MAX_NUM_RB + DTCH; LOG_D(OTG,"[UE %d] Frame %d: sending packet %d from module %d on rab id %d (src %d/%x, dst %d) pkt size %d\n", ctxt_pP->module_id, ctxt_pP->frame, pkt_cnt_ue++, ctxt_pP->module_id, rb_id, src_id, pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id], // [src_id] dst_id, pkt_size); PROTOCOL_CTXT_SET_BY_MODULE_ID( &ctxt, ctxt_pP->module_id, //src_id, ENB_FLAG_NO, pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id],// [src_id] ctxt_pP->frame, ctxt_pP->subframe, dst_id); result = pdcp_data_req( &ctxt, SRB_FLAG_NO, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, pkt_size, otg_pkt, PDCP_TRANSMISSION_MODE_DATA); if (result != TRUE) { LOG_W(OTG,"PDCP data request failed!\n"); } } free(otg_pkt); otg_pkt = NULL; } // } //else LOG_D(OTG,"ctxt_pP->frame %d enb %d-> ue %d link not yet established state %d \n", ctxt_pP->frame, eNB_index,dst_id - NB_eNB_INST, mac_get_rrc_status(module_id, ctxt_pP->enb_flag, dst_id - NB_eNB_INST)); } } #else if ((otg_enabled==1) && (ctxt_pP->enb_flag == ENB_FLAG_YES)) { // generate DL traffic unsigned int ctime=0; ctime = ctxt_pP->frame * 100; /*if ((mac_get_rrc_status(eNB_index, ctxt_pP->enb_flag, 0 ) > 2) && (mac_get_rrc_status(eNB_index, ctxt_pP->enb_flag, 1 ) > 2)) { */ PROTOCOL_CTXT_SET_BY_MODULE_ID( &ctxt, ctxt_pP->module_id, ctxt_pP->enb_flag, NOT_A_RNTI, ctxt_pP->frame, ctxt_pP->subframe, ctxt_pP->module_id); for (dst_id = 0; dst_id<NUMBER_OF_UE_MAX; dst_id++) { ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id]; if (ctxt.rnti != NOT_A_RNTI) { if (mac_eNB_get_rrc_status(ctxt.module_id, ctxt.rnti ) > 2 /*RRC_SI_RECEIVED*/) { unsigned int temp = 0; otg_pkt=packet_gen( ENB_MODULE_ID_TO_INSTANCE(ctxt.module_id), UE_MODULE_ID_TO_INSTANCE(dst_id), 0, ctime, &temp); pkt_size = temp; if (otg_pkt != NULL) { rb_id = dst_id * maxDRB + DTCH; pdcp_data_req(&ctxt, SRB_FLAG_NO, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, pkt_size, otg_pkt, PDCP_TRANSMISSION_MODE_DATA); LOG_I(OTG, "send packet from module %d on rab id %d (src %d, dst %d) pkt size %d\n", ctxt_pP->module_id, rb_id, ctxt_pP->module_id, dst_id, pkt_size); free(otg_pkt); } } } } } #endif }
int main_below_ip() { int i, j, k, l, rtt_owd ,rx_otg=0, simu_time=0, ctime=0, nb_round=0; float p; char *packet; int rx_packet_out; int pkt_size; printf(" max enb %d, max ue %d \n", NUMBER_OF_eNB_MAX, NUMBER_OF_UE_MAX); do { nb_round=nb_round+1; // for (stime=0; stime < SIMU_TIME; stime++) // discrete event generation : tick, stime generate the ctime for (i=0; i<(NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX); i++) { for (j=0; j<(NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX); j++) { for (k=0; k<MAX_NUM_TRAFFIC_STATE; k++) { LOG_I(OTG,"OTG emulation src=%d, dst=%d, state=%d \n", i, j, k); ctime=0; // set the ctime to 0 do { if (simu_time> SIMU_TIME) { otg_info->ctime=SIMU_TIME; return(0); } LOG_I(OTG,"val :: ctime=%d\n", ctime); char *packet=NULL; /*packet=packet_gen(i, j, k, ctime);*/ packet=packet_gen(i, j, ctime, &pkt_size); if (packet!=NULL) { if ((ceil(g_otg->duration[i]*uniform_rng()))==ctime) { printf("DROP PACKET (i=%d,j=%d) seq num=%d\n",i, j, otg_info->seq_num[i][j]); } else { printf("SEND PACKET (i=%d,j=%d) seq num=%d\n",i, j, otg_info->seq_num[i][j]); rtt_owd=ceil(uniform_rng()*8.56); LOG_I(OTG,"one way delay= %d , (src=%d, dst=%d, state=%d)\n", rtt_owd, i, j, k); ctime+=rtt_owd; otg_info->rx_pkt_owd[i][j]=rtt_owd; simu_time+=rtt_owd; //rx_packet_out=check_packet(i, j, ctime, packet); rx_packet_out=otg_rx_pkt(i,j, ctime, packet, pkt_size); //if (rx_packet_out==NULL) // LOG_I(OTG,"PKTS INFO:: DROPED\n"); //else{ // if (rx_packet_out!=NULL){ // rx_packet_out=NULL; free(packet); // } //} //Do not increase the ctime and simu_time with the one way delay. ctime-=rtt_owd; simu_time-=rtt_owd; LOG_I(OTG,"PKTS INFO:: (src=%d, dst=%d, state=%d),NB PKTS=%d ,sequence NB=%d, RTT (one way)ms= %d \n ",i, j, k, otg_info->tx_num_pkt[i][j], otg_info->seq_num[i][j], otg_info->rx_pkt_owd[i][j]); } } else printf("Node (i=%d,j=%d) seq num=%d, ctime %d, prb %lf\n",i, j, otg_info->seq_num[i][j], ctime,(ceil(g_otg->duration[i]*uniform_rng()))); LOG_I(OTG,"Time:: ctime=%d, duration=%d, simu_time=%d, max=%d, (src=%d, dst=%d, state=%d) \n", ctime, g_otg->duration[i],simu_time, SIMU_TIME, i, j,k); ctime+=1; simu_time+=1; } while (ctime<=g_otg->duration[i]) ; } if (otg_info->tx_num_pkt[i][j]>otg_info->rx_num_pkt[i][j]) LOG_I(OTG,"STAT: (LOSS):: (src=%d, dst=%d) NB packet TX= %d, NB packet RX = %d, seq NUM=%d\n ",i, j, otg_info->tx_num_pkt[i][j], otg_info->rx_num_pkt[i][j],otg_info->seq_num[i][j] ); else LOG_I(OTG,"STAT: :: (src=%d, dst=%d) NB packet TX= %d, NB packet RX= %d, seq NUM=%d \n ",i, j, otg_info->tx_num_pkt[i][j], otg_info->rx_num_pkt[i][j], otg_info->seq_num[i][j]); } } } while (simu_time<=SIMU_TIME); }