Commit 25ab1c35 authored by luhan wang's avatar luhan wang

modifications for if4p5 UDP

parent 9b9a7e50
...@@ -142,54 +142,59 @@ int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestam ...@@ -142,54 +142,59 @@ int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestam
// Read nblocks info from packet itself // Read nblocks info from packet itself
int nblocks = nsamps; int nblocks = nsamps;
int bytes_received=0; int bytes_received=-1;
eth_state_t *eth = (eth_state_t*)device->priv; eth_state_t *eth = (eth_state_t*)device->priv;
int Mod_id = device->Mod_id; int Mod_id = device->Mod_id;
ssize_t packet_size = sizeof_IF4p5_header_t; ssize_t packet_size = sizeof_IF4p5_header_t;
IF4p5_header_t *test_header = (IF4p5_header_t*)(buff[0]); IF4p5_header_t *test_header = (IF4p5_header_t*)(buff[0]);
int block_cnt=0;
int again_cnt=0;
packet_size = max(UDP_IF4p5_PRACH_SIZE_BYTES, max(UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks), UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks)));
while(bytes_received == -1) {
again:
bytes_received = recvfrom(eth->sockfd[Mod_id], bytes_received = recvfrom(eth->sockfd[Mod_id],
buff[0], buff[0],
packet_size, packet_size,
0, 0,
(struct sockaddr *)&dest_addr[Mod_id], (struct sockaddr *)&dest_addr[Mod_id],
(socklen_t *)&addr_len[Mod_id]); (socklen_t *)&addr_len[Mod_id]);
if (bytes_received ==-1) { if (bytes_received ==-1) {
eth->num_rx_errors++; eth->num_rx_errors++;
perror("ETHERNET IF4p5 READ (header): "); if (errno == EAGAIN) {
again_cnt++;
usleep(10);
if (again_cnt == 1000) {
perror("ETHERNET IF4p5 READ (EAGAIN): ");
exit(-1); exit(-1);
} else {
printf("AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN \n");
goto again;
} }
} else if (errno == EWOULDBLOCK) {
*timestamp = test_header->sub_type; block_cnt++;
usleep(10);
if (test_header->sub_type == IF4p5_PDLFFT) { if (block_cnt == 1000) {
packet_size = UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks); perror("ETHERNET IF4p5 READ (EWOULDBLOCK): ");
} else if (test_header->sub_type == IF4p5_PULFFT) { exit(-1);
packet_size = UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks);
} else { } else {
packet_size = UDP_IF4p5_PRACH_SIZE_BYTES; printf("BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK \n");
goto again;
} }
} else {
perror("ETHERNET IF4p5 READ");
while(bytes_received < packet_size) { printf("(%s):\n", strerror(errno));
bytes_received = recvfrom(eth->sockfd[Mod_id],
buff[0],
packet_size,
0,
(struct sockaddr *)&dest_addr[Mod_id],
(socklen_t *)&addr_len[Mod_id]);
if (bytes_received ==-1) {
eth->num_rx_errors++;
perror("ETHERNET IF4p5 READ (payload): ");
exit(-1); exit(-1);
}
} else { } else {
*timestamp = test_header->sub_type;
eth->rx_actual_nsamps = bytes_received>>1; eth->rx_actual_nsamps = bytes_received>>1;
eth->rx_count++; eth->rx_count++;
} }
} }
//printf("size of third %d subtype %d frame %d subframe %d symbol %d \n", bytes_received, test_header->sub_type, ((test_header->frame_status)>>6)&0xffff, ((test_header->frame_status)>>22)&0x000f, ((test_header->frame_status)>>26)&0x000f) ;
eth->rx_nsamps = nsamps; eth->rx_nsamps = nsamps;
return(bytes_received); return(bytes_received);
...@@ -298,7 +303,7 @@ int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, voi ...@@ -298,7 +303,7 @@ int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, voi
eth->tx_actual_nsamps=bytes_sent>>2; eth->tx_actual_nsamps=bytes_sent>>2;
eth->tx_count++; eth->tx_count++;
pck_seq_num++; pck_seq_num++;
if ( pck_seq_num > MAX_PACKET_SEQ_NUM(nsamps,76800) ) pck_seq_num = 1; if ( pck_seq_num > MAX_PACKET_SEQ_NUM(nsamps,device->openair0_cfg->samples_per_frame) ) pck_seq_num = 1;
} }
} }
/* tx buffer values restored */ /* tx buffer values restored */
...@@ -396,7 +401,7 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi ...@@ -396,7 +401,7 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi
/* get the packet sequence number from packet's header */ /* get the packet sequence number from packet's header */
pck_seq_num_cur = *(uint16_t *)buff2; pck_seq_num_cur = *(uint16_t *)buff2;
//printf("cur=%d prev=%d buff=%d\n",pck_seq_num_cur,pck_seq_num_prev,*(uint16_t *)(buff2)); //printf("cur=%d prev=%d buff=%d\n",pck_seq_num_cur,pck_seq_num_prev,*(uint16_t *)(buff2));
if ( ( pck_seq_num_cur != (pck_seq_num_prev + 1) ) && !((pck_seq_num_prev==75) && (pck_seq_num_cur==1 ))){ if ( ( pck_seq_num_cur != (pck_seq_num_prev + 1) ) && !((pck_seq_num_prev==MAX_PACKET_SEQ_NUM(nsamps,device->openair0_cfg->samples_per_frame)) && (pck_seq_num_cur==1 )) && !((pck_seq_num_prev==1) && (pck_seq_num_cur==1))) {
printf("out of order packet received1! %d|%d|%d\n",pck_seq_num_cur,pck_seq_num_prev,(int)*timestamp); printf("out of order packet received1! %d|%d|%d\n",pck_seq_num_cur,pck_seq_num_prev,(int)*timestamp);
} }
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RX_SEQ_NUM,pck_seq_num_cur); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RX_SEQ_NUM,pck_seq_num_cur);
......
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