Commit 727cdb4a authored by luhan wang's avatar luhan wang

updates for udp IF4p5

parent 3c7ec4e4
......@@ -664,7 +664,7 @@ add_boolean_option(ENABLE_NEW_MULTICAST False "specific to oaisim")
add_boolean_option(EXMIMO_IOT True "????")
add_boolean_option(LARGE_SCALE False "specific to oaisim: defines max eNB=2 and max UE=120")
add_boolean_option(LOCALIZATION False "???")
add_integer_option(MAX_NUM_CCs 1 "????")
add_integer_option(MAX_NUM_CCs 2 "????")
add_boolean_option(MU_RECEIVER False "????")
add_boolean_option(NEW_FFT True "????")
add_boolean_option(OPENAIR1 True "????")
......
......@@ -222,10 +222,14 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t
data_block = (uint16_t*) (rx_buffer+sizeof_IF4p5_header_t);
}
*frame = ((packet_header->frame_status)>>6)&0xffff;
*subframe = ((packet_header->frame_status)>>22)&0x000f;
*packet_type = packet_header->sub_type;
printf("CC_id %d : frame %d, subframe %d\n",eNB->CC_id,*frame,*subframe);
if (*packet_type == IF4p5_PDLFFT) {
*symbol_number = ((packet_header->frame_status)>>26)&0x000f;
......
......@@ -311,6 +311,9 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam
ssize_t packet_size = MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t;
IF4p5_header_t *test_header = (IF4p5_header_t*)(buff[0] + MAC_HEADER_SIZE_BYTES);
#ifdef DEBUG
printf("Reading from device %p, eth %p, sockfd %d\n",device,eth,eth->sockfd[Mod_id]);
#endif
bytes_received = recv(eth->sockfd[Mod_id],
buff[0],
......@@ -321,6 +324,11 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam
perror("ETHERNET IF4p5 READ (header): ");
exit(-1);
}
#ifdef DEBUG
for (int i=0;i<packet_size;i++)
printf("%2x.",((uint8_t*)buff[0])[i]);
printf("\n");
#endif
*timestamp = test_header->sub_type;
......
......@@ -54,9 +54,9 @@
#include "ethernet_lib.h"
#define DEBUG 0
struct sockaddr_in dest_addr[MAX_INST];
struct sockaddr_in local_addr[MAX_INST];
int addr_len[MAX_INST];
//struct sockaddr_in dest_addr[MAX_INST];
//struct sockaddr_in local_addr[MAX_INST];
//int addr_len[MAX_INST];
uint16_t pck_seq_num = 1;
......@@ -96,7 +96,7 @@ int eth_socket_init_udp(openair0_device *device) {
sock_type=SOCK_DGRAM;
sock_proto=IPPROTO_UDP;
if ((eth->sockfd[Mod_id] = socket(sock_dom, sock_type, sock_proto)) == -1) {
if ((eth->sockfd = socket(sock_dom, sock_type, sock_proto)) == -1) {
perror("ETHERNET: Error opening socket");
exit(0);
}
......@@ -107,32 +107,32 @@ int eth_socket_init_udp(openair0_device *device) {
bzero((void *)&(local_addr[i]), sizeof(local_addr[i]));
}
addr_len[Mod_id] = sizeof(struct sockaddr_in);
eth->udp.addr_len = sizeof(struct sockaddr_in);
dest_addr[Mod_id].sin_family = AF_INET;
inet_pton(AF_INET,remote_ip,&(dest_addr[Mod_id].sin_addr.s_addr));
dest_addr[Mod_id].sin_port=htons(remote_port);
inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str_remote, INET_ADDRSTRLEN);
eth->udp.dest_addr.sin_family = AF_INET;
inet_pton(AF_INET,remote_ip,&(dest_addr.sin_addr.s_addr));
eth->udp.dest_addr.sin_port=htons(remote_port);
inet_ntop(AF_INET, &(eth->udp.dest_addr.sin_addr), str_remote, INET_ADDRSTRLEN);
local_addr[Mod_id].sin_family = AF_INET;
inet_pton(AF_INET,local_ip,&(local_addr[Mod_id].sin_addr.s_addr));
local_addr[Mod_id].sin_port=htons(local_port);
inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str_local, INET_ADDRSTRLEN);
device->local_addr.sin_family = AF_INET;
inet_pton(AF_INET,local_ip,&(device->local_addr.sin_addr.s_addr));
device->local_addr.sin_port=htons(local_port);
inet_ntop(AF_INET, &(device->local_addr.sin_addr), str_local, INET_ADDRSTRLEN);
/* set reuse address flag */
if (setsockopt(eth->sockfd[Mod_id], SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) {
if (setsockopt(eth->sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) {
perror("ETHERNET: Cannot set SO_REUSEADDR option on socket");
exit(0);
}
/* want to receive -> so bind */
if (bind(eth->sockfd[Mod_id],(struct sockaddr *)&local_addr[Mod_id],addr_len[Mod_id])<0) {
if (bind(eth->sockfd,(struct sockaddr *)&eth->udp.local_addr,addr_len[Mod_id])<0) {
perror("ETHERNET: Cannot bind to socket");
exit(0);
} else {
printf("[%s] binding mod_%d to %s:%d\n","RRH",Mod_id,str_local,ntohs(local_addr[Mod_id].sin_port));
printf("[%s] binding mod_%d to %s:%d\n","RRH",Mod_id,str_local,ntohs(eth->udp.local_addr.sin_port));
}
return 0;
......@@ -155,11 +155,11 @@ int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestam
while(bytes_received == -1) {
again:
bytes_received = recvfrom(eth->sockfd[Mod_id],
bytes_received = recvfrom(eth->sockfd,
buff[0],
packet_size,
0,
(struct sockaddr *)&dest_addr[Mod_id],
(struct sockaddr *)&eth->udp.dest_addr,
(socklen_t *)&addr_len[Mod_id]);
if (bytes_received ==-1) {
eth->num_rx_errors++;
......@@ -223,11 +223,11 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam
eth->tx_nsamps = nblocks;
bytes_sent = sendto(eth->sockfd[Mod_id],
bytes_sent = sendto(eth->sockfd,
buff[0],
packet_size,
0,
(struct sockaddr*)&dest_addr[Mod_id],
(struct sockaddr*)&eth->udp.dest_addr,
addr_len[Mod_id]);
if (bytes_sent == -1) {
......@@ -280,11 +280,11 @@ int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, voi
bytes_sent);
#endif
/* Send packet */
bytes_sent += sendto(eth->sockfd[Mod_id],
bytes_sent += sendto(eth->sockfd,
buff2,
UDP_PACKET_SIZE_BYTES(nsamps),
sendto_flag,
(struct sockaddr*)&dest_addr[Mod_id],
(struct sockaddr*)&eth->udp.dest_addr,
addr_len[Mod_id]);
if ( bytes_sent == -1) {
......@@ -350,12 +350,12 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi
UDP_PACKET_SIZE_BYTES(nsamps) - bytes_received,
bytes_received);
#endif
bytes_received +=recvfrom(eth->sockfd[Mod_id],
bytes_received +=recvfrom(eth->sockfd,
buff2,
UDP_PACKET_SIZE_BYTES(nsamps),
rcvfrom_flag,
(struct sockaddr *)&dest_addr[Mod_id],
(socklen_t *)&addr_len[Mod_id]);
(struct sockaddr *)&eth->udp.dest_addr,
(socklen_t *)&device->udp.addr_len);
if (bytes_received ==-1) {
eth->num_rx_errors++;
......@@ -438,8 +438,12 @@ int eth_set_dev_conf_udp(openair0_device *device) {
msg_len=sizeof(openair0_config_t);
memcpy(msg,(void*)device->openair0_cfg,msg_len);
if (sendto(eth->sockfd[Mod_id],msg,msg_len,0,(struct sockaddr *)&dest_addr[Mod_id],addr_len[Mod_id])==-1) {
printf("Sending configuration to device %p (%d.%d.%d.%d)\n",device,
eth->udp.dest_addr[3],eth->udp.dest_addr[2],eth->udp.dest_addr[1],eth->udp.dest_addr[0],msg_len);
if (sendto(eth->sockfd,msg,msg_len,0,(struct sockaddr *)&eth->udp.dest_addr,device->udp.addr_len)==-1) {
perror("ETHERNET: ");
printf("addr_len[%d] : %d, msg_len %d\n",Mod_id,device->udp.addr_len,msg_len);
exit(0);
}
......@@ -457,15 +461,15 @@ int eth_get_dev_conf_udp(openair0_device *device) {
msg=malloc(sizeof(openair0_config_t));
msg_len=sizeof(openair0_config_t);
inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str, INET_ADDRSTRLEN);
inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str1, INET_ADDRSTRLEN);
inet_ntop(AF_INET, &(eth->udp.local_addr.sin_addr), str, INET_ADDRSTRLEN);
inet_ntop(AF_INET, &(eth->udp.dest_addr.sin_addr), str1, INET_ADDRSTRLEN);
/* RRH receives from BBU openair0_config_t */
if (recvfrom(eth->sockfd[Mod_id],
if (recvfrom(eth->sockfd,
msg,
msg_len,
0,
(struct sockaddr *)&dest_addr[Mod_id],
(struct sockaddr *)&eth->udp.dest_addr,
(socklen_t *)&addr_len[Mod_id])==-1) {
perror("ETHERNET: ");
exit(0);
......@@ -473,15 +477,15 @@ int eth_get_dev_conf_udp(openair0_device *device) {
device->openair0_cfg=(openair0_config_t *)msg;
/* get remote ip address and port */
/* inet_ntop(AF_INET, &(dest_addr[Mod_id].sin_addr), str1, INET_ADDRSTRLEN); */
/* device->openair0_cfg->remote_port =ntohs(dest_addr[Mod_id].sin_port); */
/* inet_ntop(AF_INET, &(eth->udp.dest_addr.sin_addr), str1, INET_ADDRSTRLEN); */
/* device->openair0_cfg->remote_port =ntohs(eth->udp.dest_addr.sin_port); */
/* device->openair0_cfg->remote_addr =str1; */
/* /\* restore local ip address and port *\/ */
/* inet_ntop(AF_INET, &(local_addr[Mod_id].sin_addr), str, INET_ADDRSTRLEN); */
/* device->openair0_cfg->my_port =ntohs(local_addr[Mod_id].sin_port); */
/* inet_ntop(AF_INET, &(eth->udp.local_addr.sin_addr), str, INET_ADDRSTRLEN); */
/* device->openair0_cfg->my_port =ntohs(eth->udp.local_addr.sin_port); */
/* device->openair0_cfg->my_addr =str; */
/* printf("[RRH] mod_%d socket %d connected to BBU %s:%d %s:%d\n", Mod_id, eth->sockfd[Mod_id],str1, device->openair0_cfg->remote_port, str, device->openair0_cfg->my_port); */
/* printf("[RRH] mod_%d socket %d connected to BBU %s:%d %s:%d\n", Mod_id, eth->sockfd,str1, device->openair0_cfg->remote_port, str, device->openair0_cfg->my_port); */
return 0;
}
......@@ -52,9 +52,9 @@
#include "common_lib.h"
#include "ethernet_lib.h"
int num_devices_eth = 0;
struct sockaddr_in dest_addr[MAX_INST];
int dest_addr_len[MAX_INST];
//int num_devices_eth = 0;
//struct sockaddr_in dest_addr[MAX_INST];
//int dest_addr_len[MAX_INST];
int trx_eth_start(openair0_device *device) {
......@@ -121,7 +121,7 @@ void trx_eth_end(openair0_device *device) {
eth_state_t *eth = (eth_state_t*)device->priv;
int Mod_id = device->Mod_id;
/* destroys socket only for the processes that call the eth_end fuction-- shutdown() for beaking the pipe */
if ( close(eth->sockfd[Mod_id]) <0 ) {
if ( close(eth->sockfd) <0 ) {
perror("ETHERNET: Failed to close socket");
exit(0);
} else {
......@@ -137,7 +137,14 @@ int trx_eth_request(openair0_device *device, void *msg, ssize_t msg_len) {
eth_state_t *eth = (eth_state_t*)device->priv;
/* BBU sends a message to RRH */
if (sendto(eth->sockfd[Mod_id],msg,msg_len,0,(struct sockaddr *)&dest_addr[Mod_id],dest_addr_len[Mod_id])==-1) {
if ((eth->flags == ETH_RAW_MODE) || (eth->flags == ETH_RAW_IF4p5_MODE))
if (sendto(eth->sockfd,msg,msg_len,0,(struct sockaddr *)&eth->raw.dest_addr,eth->raw.dest_addr_len)==-1) {
perror("ETHERNET: ");
exit(0);
}
else
if (sendto(eth->sockfd,msg,msg_len,0,(struct sockaddr *)&eth->udp.dest_addr,eth->udp.dest_addr_len)==-1) {
perror("ETHERNET: ");
exit(0);
}
......@@ -152,15 +159,32 @@ int trx_eth_reply(openair0_device *device, void *msg, ssize_t msg_len) {
int Mod_id = device->Mod_id;
/* RRH receives from BBU a message */
if (recvfrom(eth->sockfd[Mod_id],
if ((eth->flags == ETH_RAW_MODE) || (eth->flags == ETH_RAW_IF4p5_MODE)) {
if (recvfrom(eth->sockfd,
msg,
msg_len,
0,
(struct sockaddr *)&dest_addr[Mod_id],
(socklen_t *)&dest_addr_len[Mod_id])==-1) {
(struct sockaddr *)&eth->raw.dest_addr,
(socklen_t *)&eth->raw.dest_addr_len)==-1) {
perror("ETHERNET: ");
exit(0);
}
}
else {
if (recvfrom(eth->sockfd,
msg,
msg_len,
0,
(struct sockaddr *)&eth->udp.dest_addr,
(socklen_t *)&eth->udp.dest_addr_len)==-1) {
perror("ETHERNET: ");
exit(0);
}
}
return 0;
}
......@@ -204,7 +228,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
/****************** socket level options ************************/
switch(option) {
case SND_BUF_SIZE: /* transmit socket buffer size */
if (setsockopt(eth->sockfd[Mod_id],
if (setsockopt(eth->sockfd,
SOL_SOCKET,
SO_SNDBUF,
&value,sizeof(value))) {
......@@ -215,7 +239,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
break;
case RCV_BUF_SIZE: /* receive socket buffer size */
if (setsockopt(eth->sockfd[Mod_id],
if (setsockopt(eth->sockfd,
SOL_SOCKET,
SO_RCVBUF,
&value,sizeof(value))) {
......@@ -228,7 +252,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
case RCV_TIMEOUT:
timeout.tv_sec = value/1000000;
timeout.tv_usec = value%1000000;//less than rt_period?
if (setsockopt(eth->sockfd[Mod_id],
if (setsockopt(eth->sockfd,
SOL_SOCKET,
SO_RCVTIMEO,
(char *)&timeout,sizeof(timeout))) {
......@@ -241,7 +265,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
case SND_TIMEOUT:
timeout.tv_sec = value/1000000000;
timeout.tv_usec = value%1000000000;//less than rt_period?
if (setsockopt(eth->sockfd[Mod_id],
if (setsockopt(eth->sockfd,
SOL_SOCKET,
SO_SNDTIMEO,
(char *)&timeout,sizeof(timeout))) {
......@@ -257,7 +281,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
ifr.ifr_addr.sa_family = AF_INET;
strncpy(ifr.ifr_name,eth->if_name[Mod_id], sizeof(ifr.ifr_name));
ifr.ifr_mtu =value;
if (ioctl(eth->sockfd[Mod_id],SIOCSIFMTU,(caddr_t)&ifr) < 0 )
if (ioctl(eth->sockfd,SIOCSIFMTU,(caddr_t)&ifr) < 0 )
perror ("[ETHERNET] Can't set the MTU");
else
printf("[ETHERNET] %s MTU size has changed to %d\n",eth->if_name[Mod_id],ifr.ifr_mtu);
......@@ -267,7 +291,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
ifr.ifr_addr.sa_family = AF_INET;
strncpy(ifr.ifr_name,eth->if_name[Mod_id], sizeof(ifr.ifr_name));
ifr.ifr_qlen =value;
if (ioctl(eth->sockfd[Mod_id],SIOCSIFTXQLEN,(caddr_t)&ifr) < 0 )
if (ioctl(eth->sockfd,SIOCSIFTXQLEN,(caddr_t)&ifr) < 0 )
perror ("[ETHERNET] Can't set the txqueuelen");
else
printf("[ETHERNET] %s txqueuelen size has changed to %d\n",eth->if_name[Mod_id],ifr.ifr_qlen);
......@@ -351,7 +375,7 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
}
printf("[ETHERNET]: Initializing openair0_device for %s ...\n", ((device->host_type == BBU_HOST) ? "BBU": "RRH"));
device->Mod_id = num_devices_eth++;
device->Mod_id = 0;//num_devices_eth++;
device->transp_type = ETHERNET_TP;
device->trx_start_func = trx_eth_start;
device->trx_request_func = trx_eth_request;
......
......@@ -36,6 +36,7 @@ eNBs =
Nid_cell = 0;
N_RB_DL = 50;
Nid_cell_mbsfn = 0;
nb_antenna_ports = 1;
nb_antennas_tx = 1;
nb_antennas_rx = 1;
tx_gain = 90;
......@@ -67,7 +68,7 @@ eNBs =
srs_ackNackST =;
srs_MaxUpPts =;*/
pusch_p0_Nominal = -102;
pusch_p0_Nominal = -96;
pusch_alpha = "AL1";
pucch_p0_Nominal = -104;
msg3_delta_Preamble = 6;
......@@ -100,6 +101,7 @@ eNBs =
ue_TimersAndConstants_t311 = 10000;
ue_TimersAndConstants_n310 = 20;
ue_TimersAndConstants_n311 = 1;
ue_TransmissionMode = 1;
}
);
......
......@@ -981,11 +981,11 @@ void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) {
if (proc->first_rx == 0) {
if (proc->subframe_rx != *subframe){
LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,*subframe);
LOG_E(PHY,"Received Timestamp (IF4p5) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d,CCid %d)\n",proc->subframe_rx,*subframe,eNB->CC_id);
exit_fun("Exiting");
}
if (proc->frame_rx != *frame) {
LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,*frame);
LOG_E(PHY,"Received Timestamp (IF4p5) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d,CCid %d)\n",proc->frame_rx,*frame,eNB->CC_id);
exit_fun("Exiting");
}
} else {
......@@ -1276,7 +1276,8 @@ static void* eNB_thread_single( void* param ) {
subframe++;
}
LOG_D(PHY,"eNB Fronthaul thread, frame %d, subframe %d\n",frame,subframe);
LOG_D(PHY,"eNB thread single %p (proc %p, CC_id %d), frame %d (%p), subframe %d (%p)\n",
pthread_self(), proc, eNB->CC_id, frame,&frame,subframe,&subframe);
// synchronization on FH interface, acquire signals/data and block
if (eNB->rx_fh) eNB->rx_fh(eNB,&frame,&subframe);
......@@ -1400,6 +1401,7 @@ void init_eNB_proc(int inst) {
}
//for multiple CCs: setup master and slaves
/*
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
eNB = PHY_vars_eNB_g[inst][CC_id];
......@@ -1412,7 +1414,7 @@ void init_eNB_proc(int inst) {
if (i >= CC_id) eNB->proc.slave_proc[i] = &(PHY_vars_eNB_g[inst][i+1]->proc);
}
}
}
}*/
/* setup PHY proc TX sync mechanism */
......@@ -1614,6 +1616,8 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst
eNB->node_timing = node_timing[CC_id];
eNB->abstraction_flag = 0;
eNB->single_thread_flag = single_thread_flag;
eNB->iframe_offset = -1;
eNB->isubframe_offset = -1;
LOG_I(PHY,"Initializing eNB %d CC_id %d : (%s,%s)\n",inst,CC_id,eNB_functions[node_function[CC_id]],eNB_timing[node_timing[CC_id]]);
switch (node_function[CC_id]) {
......
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