first time UE connection established

This commit is contained in:
Raymond Knopp
2017-04-25 11:50:15 -07:00
parent ca2c8357c9
commit 63a18b8193
39 changed files with 1267 additions and 1593 deletions
+97 -103
View File
@@ -64,11 +64,11 @@ int eth_socket_init_raw(openair0_device *device) {
local_mac = device->eth_params->my_addr;
remote_mac = malloc(ETH_ALEN);
memset((void*)remote_mac,0,ETH_ALEN);
printf("[%s] local MAC addr %s remote MAC addr %s\n","RRU", local_mac,remote_mac);
printf("[%s] local MAC addr (user) %s remote MAC addr (user) %s\n","RRU", local_mac,remote_mac);
} else {
local_mac = device->eth_params->my_addr;
remote_mac = device->eth_params->remote_addr;
printf("[%s] local MAC addr %s remote MAC addr %s\n","RAU", local_mac,remote_mac);
printf("[%s] local MAC addr (user) %s remote MAC addr (user) %s\n","RAU", local_mac,remote_mac);
}
@@ -76,46 +76,64 @@ int eth_socket_init_raw(openair0_device *device) {
sock_dom=AF_PACKET;
sock_type=SOCK_RAW;
sock_proto=IPPROTO_RAW;
if ((eth->sockfd = socket(sock_dom, sock_type, sock_proto)) == -1) {
perror("ETHERNET: Error opening RAW socket");
if ((eth->sockfdc = socket(sock_dom, sock_type, sock_proto)) == -1) {
perror("ETHERNET: Error opening RAW socket (control)");
exit(0);
}
if ((eth->sockfdd = socket(sock_dom, sock_type, sock_proto)) == -1) {
perror("ETHERNET: Error opening RAW socket (user)");
exit(0);
}
/* initialize destination address */
bzero((void *)&(eth->local_addr_ll), sizeof(struct sockaddr_ll));
bzero((void *)&(eth->local_addrc_ll), sizeof(struct sockaddr_ll));
bzero((void *)&(eth->local_addrd_ll), sizeof(struct sockaddr_ll));
bzero((void *)&(eth->if_index), sizeof(struct ifreq));
/* Get the index of the interface to send on */
strcpy(eth->if_index.ifr_name,eth->if_name);
if (ioctl(eth->sockfd, SIOCGIFINDEX, &(eth->if_index)) < 0)
if (ioctl(eth->sockfdc, SIOCGIFINDEX, &(eth->if_index)) < 0)
perror("SIOCGIFINDEX");
if (ioctl(eth->sockfdd, SIOCGIFINDEX, &(eth->if_index)) < 0)
perror("SIOCGIFINDEX");
eth->local_addr_ll.sll_family = AF_PACKET;
eth->local_addr_ll.sll_ifindex = eth->if_index.ifr_ifindex;
eth->local_addrc_ll.sll_family = AF_PACKET;
eth->local_addrc_ll.sll_ifindex = eth->if_index.ifr_ifindex;
eth->local_addrd_ll.sll_family = AF_PACKET;
eth->local_addrd_ll.sll_ifindex = eth->if_index.ifr_ifindex;
/* hear traffic from specific protocol*/
if (eth->flags == ETH_RAW_IF5_MOBIPASS) {
eth->local_addr_ll.sll_protocol = htons(0xbffe);
eth->local_addrd_ll.sll_protocol = htons(0xbffe);
} else{
eth->local_addr_ll.sll_protocol = htons((short)device->eth_params->my_port);
eth->local_addrc_ll.sll_protocol = htons((short)device->eth_params->my_portc);
eth->local_addrd_ll.sll_protocol = htons((short)device->eth_params->my_portd);
}
eth->local_addr_ll.sll_halen = ETH_ALEN;
eth->local_addr_ll.sll_pkttype = PACKET_OTHERHOST;
eth->local_addrc_ll.sll_halen = ETH_ALEN;
eth->local_addrc_ll.sll_pkttype = PACKET_OTHERHOST;
eth->local_addrd_ll.sll_halen = ETH_ALEN;
eth->local_addrd_ll.sll_pkttype = PACKET_OTHERHOST;
eth->addr_len = sizeof(struct sockaddr_ll);
if (bind(eth->sockfd,(struct sockaddr *)&eth->local_addr_ll,eth->addr_len)<0) {
perror("ETHERNET: Cannot bind to socket");
exit(0);
}
if ((eth->flags != ETH_RAW_IF5_MOBIPASS ) &&
(bind(eth->sockfdc,(struct sockaddr *)&eth->local_addrc_ll,eth->addr_len)<0)) {
perror("ETHERNET: Cannot bind to socket (control)");
exit(0);
}
if (bind(eth->sockfdd,(struct sockaddr *)&eth->local_addrd_ll,eth->addr_len)<0) {
perror("ETHERNET: Cannot bind to socket (user)");
exit(0);
}
/* Construct the Ethernet header */
ether_aton_r(local_mac, (struct ether_addr *)(&(eth->eh.ether_shost)));
ether_aton_r(remote_mac, (struct ether_addr *)(&(eth->eh.ether_dhost)));
ether_aton_r(local_mac, (struct ether_addr *)(&(eth->ehd.ether_shost)));
ether_aton_r(remote_mac, (struct ether_addr *)(&(eth->ehd.ether_dhost)));
if (eth->flags == ETH_RAW_IF5_MOBIPASS) {
eth->eh.ether_type = htons(0xbffe);
eth->ehd.ether_type = htons(0xbffe);
} else {
eth->eh.ether_type = htons((short)device->eth_params->my_port);
eth->ehc.ether_type = htons((short)device->eth_params->my_portc);
eth->ehd.ether_type = htons((short)device->eth_params->my_portd);
}
printf("[%s] binding to hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"),eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5]);
printf("[%s] binding to hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"),eth->ehd.ether_shost[0],eth->ehd.ether_shost[1],eth->ehd.ether_shost[2],eth->ehd.ether_shost[3],eth->ehd.ether_shost[4],eth->ehd.ether_shost[5]);
return 0;
}
@@ -142,7 +160,7 @@ int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, voi
openair0_timestamp temp1 = *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t));
bytes_sent = 0;
memcpy(buff2,(void*)&eth->eh,MAC_HEADER_SIZE_BYTES);
memcpy(buff2,(void*)&eth->ehd,MAC_HEADER_SIZE_BYTES);
*(int16_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int16_t))=1+(i<<1);
*(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)) = timestamp;
@@ -157,10 +175,10 @@ int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, voi
bytes_sent);
#endif
/* Send packet */
bytes_sent += send(eth->sockfd,
buff2,
RAW_PACKET_SIZE_BYTES(nsamps),
sendto_flag);
bytes_sent += send(eth->sockfdd,
buff2,
RAW_PACKET_SIZE_BYTES(nsamps),
sendto_flag);
if ( bytes_sent == -1) {
eth->num_tx_errors++;
perror("ETHERNET WRITE: ");
@@ -212,10 +230,10 @@ int trx_eth_write_raw_IF4p5(openair0_device *device, openair0_timestamp timestam
eth->tx_nsamps = nblocks;
memcpy(buff[0], (void*)&eth->eh, MAC_HEADER_SIZE_BYTES);
memcpy(buff[0], (void*)&eth->ehd, MAC_HEADER_SIZE_BYTES);
bytes_sent = send(eth->sockfd,
bytes_sent = send(eth->sockfdd,
buff[0],
packet_size,
0);
@@ -240,7 +258,8 @@ int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, voi
int i=0;
eth_state_t *eth = (eth_state_t*)device->priv;
int rcvfrom_flag =0;
int ret;
eth->rx_nsamps=nsamps;
for (i=0;i<cc;i++) {
@@ -256,17 +275,17 @@ int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, voi
bytes_received=0;
while(bytes_received < RAW_PACKET_SIZE_BYTES(nsamps)) {
bytes_received +=recv(eth->sockfd,
buff2,
RAW_PACKET_SIZE_BYTES(nsamps),
rcvfrom_flag);
ret = recv(eth->sockfdd,
buff2,
RAW_PACKET_SIZE_BYTES(nsamps),
rcvfrom_flag);
if (bytes_received ==-1) {
if (ret ==-1) {
eth->num_rx_errors++;
perror("ETHERNET IF5 READ: ");
if (errno == EAGAIN) continue;
exit(-1);
return(-1);
} else {
bytes_received += ret;
/* store the timestamp value from packet's header */
*timestamp = *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t));
eth->rx_actual_nsamps=bytes_received>>2;
@@ -303,26 +322,26 @@ 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);
int ret;
#ifdef DEBUG
printf("Reading from device %p, eth %p, sockfd %d\n",device,eth,eth->sockfd);
#endif
bytes_received = recv(eth->sockfd,
bytes_received = recv(eth->sockfdd,
buff[0],
packet_size,
MSG_PEEK);
if (bytes_received ==-1) {
eth->num_rx_errors++;
perror("ETHERNET IF4p5 READ (header): ");
exit(-1);
}
if (bytes_received ==-1) {
eth->num_rx_errors++;
perror("ETHERNET IF4p5 READ (header): ");
#ifdef DEBUG
for (int i=0;i<packet_size;i++)
printf("%2x.",((uint8_t*)buff[0])[i]);
printf("\n");
for (int i=0;i<packet_size;i++)
printf("%2x.",((uint8_t*)buff[0])[i]);
printf("\n");
#endif
return(-1);
}
*timestamp = test_header->sub_type;
if (test_header->sub_type == IF4p5_PDLFFT) {
@@ -335,15 +354,16 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam
while(bytes_received < packet_size) {
bytes_received = recv(eth->sockfd,
buff[0],
packet_size,
0);
if (bytes_received ==-1) {
ret = recv(eth->sockfdd,
buff[0],
packet_size,
0);
if (ret ==-1) {
eth->num_rx_errors++;
perror("ETHERNET IF4p5 READ (payload): ");
exit(-1);
return(-1);
} else {
bytes_received+=ret;
eth->rx_actual_nsamps = bytes_received>>1;
eth->rx_count++;
}
@@ -357,14 +377,14 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam
int trx_eth_read_raw_IF5_mobipass(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) {
// Read nblocks info from packet itself
int nblocks = nsamps;
int bytes_received=0;
eth_state_t *eth = (eth_state_t*)device->priv;
int ret;
ssize_t packet_size = 28; //MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t ;
ssize_t packet_size = 28; //MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t ;
// ssize_t packet_size = MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + 640*sizeof(int16_t);
bytes_received = recv(eth->sockfd,
bytes_received = recv(eth->sockfdd,
buff[0],
packet_size,
MSG_PEEK);
@@ -380,15 +400,16 @@ int trx_eth_read_raw_IF5_mobipass(openair0_device *device, openair0_timestamp *t
packet_size = MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + 640*sizeof(int16_t);
while(bytes_received < packet_size) {
bytes_received = recv(eth->sockfd,
buff[0],
packet_size,
0);
ret = recv(eth->sockfdd,
buff[0],
packet_size,
0);
if (bytes_received ==-1) {
eth->num_rx_errors++;
perror("[MOBIPASS] ETHERNET IF5 READ (payload): ");
exit(-1);
return(-1);
} else {
bytes_received+=ret;
eth->rx_actual_nsamps = bytes_received>>1;
eth->rx_count++;
}
@@ -398,35 +419,8 @@ int trx_eth_read_raw_IF5_mobipass(openair0_device *device, openair0_timestamp *t
return(bytes_received);
/*
if (bytes_received > 0) {
while(bytes_received < packet_size) {
bytes_received = recv(eth->sockfd,
buff[0],
packet_size,
0);
if (bytes_received ==-1) {
eth->num_rx_errors++;
perror("ETHERNET IF5_MOBIPASS READ (payload): ");
exit(-1);
} else {
eth->rx_actual_nsamps = bytes_received>>1;
eth->rx_count++;
}
}
if (bytes_received == packet_size){
IF5_mobipass_header_t *test_header = (IF5_mobipass_header_t*)((uint8_t *)buff[0] + MAC_HEADER_SIZE_BYTES);
*timestamp = test_header->time_stamp;
}
eth->rx_nsamps = nsamps;
}
return(bytes_received);
*/
}
int eth_set_dev_conf_raw(openair0_device *device) {
eth_state_t *eth = (eth_state_t*)device->priv;
@@ -441,13 +435,13 @@ int eth_set_dev_conf_raw(openair0_device *device) {
msg_len = MAC_HEADER_SIZE_BYTES + sizeof(openair0_config_t);
memcpy(msg,(void*)&eth->eh,MAC_HEADER_SIZE_BYTES);
memcpy(msg,(void*)&eth->ehc,MAC_HEADER_SIZE_BYTES);
memcpy((msg+MAC_HEADER_SIZE_BYTES),(void*)device->openair0_cfg,sizeof(openair0_config_t));
if (send(eth->sockfd,
msg,
msg_len,
0)==-1) {
if (send(eth->sockfdc,
msg,
msg_len,
0)==-1) {
perror("ETHERNET: ");
exit(0);
}
@@ -472,13 +466,13 @@ int eth_set_dev_conf_raw_IF4p5(openair0_device *device) {
msg_len = MAC_HEADER_SIZE_BYTES + sizeof(openair0_config_t);
memcpy(msg,(void*)&eth->eh,MAC_HEADER_SIZE_BYTES);
memcpy(msg,(void*)&eth->ehc,MAC_HEADER_SIZE_BYTES);
memcpy((msg+MAC_HEADER_SIZE_BYTES),(void*)device->openair0_cfg,sizeof(openair0_config_t));
if (send(eth->sockfd,
msg,
msg_len,
0)==-1) {
if (send(eth->sockfdc,
msg,
msg_len,
0)==-1) {
perror("ETHERNET: ");
exit(0);
}
@@ -497,7 +491,7 @@ int eth_get_dev_conf_raw(openair0_device *device) {
msg_len = MAC_HEADER_SIZE_BYTES + sizeof(openair0_config_t);
/* RRU receives from RAU openair0_config_t */
if (recv(eth->sockfd,
if (recv(eth->sockfdc,
msg,
msg_len,
0)==-1) {
@@ -506,10 +500,10 @@ int eth_get_dev_conf_raw(openair0_device *device) {
}
/* RRU stores the remote MAC address */
memcpy(eth->eh.ether_dhost,(msg+ETH_ALEN),ETH_ALEN);
memcpy(eth->ehd.ether_dhost,(msg+ETH_ALEN),ETH_ALEN);
//memcpy((void*)&device->openair0_cfg,(msg + MAC_HEADER_SIZE_BYTES), sizeof(openair0_config_t));
device->openair0_cfg=(openair0_config_t *)(msg + MAC_HEADER_SIZE_BYTES);
printf("[%s] binding mod to hardware address %x:%x:%x:%x:%x:%x hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"),eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5],eth->eh.ether_dhost[0],eth->eh.ether_dhost[1],eth->eh.ether_dhost[2],eth->eh.ether_dhost[3],eth->eh.ether_dhost[4],eth->eh.ether_dhost[5]);
printf("[%s] binding mod to hardware address %x:%x:%x:%x:%x:%x hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"),eth->ehd.ether_shost[0],eth->ehd.ether_shost[1],eth->ehd.ether_shost[2],eth->ehd.ether_shost[3],eth->ehd.ether_shost[4],eth->ehd.ether_shost[5],eth->ehd.ether_dhost[0],eth->ehd.ether_dhost[1],eth->ehd.ether_dhost[2],eth->ehd.ether_dhost[3],eth->ehd.ether_dhost[4],eth->ehd.ether_dhost[5]);
return 0;
}
@@ -526,7 +520,7 @@ int eth_get_dev_conf_raw_IF4p5(openair0_device *device) {
msg_len = MAC_HEADER_SIZE_BYTES + sizeof(openair0_config_t);
/* RRU receives from RAU openair0_config_t */
if (recv(eth->sockfd,
if (recv(eth->sockfdc,
msg,
msg_len,
0)==-1) {
@@ -535,10 +529,10 @@ int eth_get_dev_conf_raw_IF4p5(openair0_device *device) {
}
/* RRU stores the remote MAC address */
memcpy(eth->eh.ether_dhost,(msg+ETH_ALEN),ETH_ALEN);
memcpy(eth->ehd.ether_dhost,(msg+ETH_ALEN),ETH_ALEN);
//memcpy((void*)&device->openair0_cfg,(msg + MAC_HEADER_SIZE_BYTES), sizeof(openair0_config_t));
//device->openair0_cfg=(openair0_config_t *)(msg + MAC_HEADER_SIZE_BYTES);
printf("[%s] binding mod to hardware address %x:%x:%x:%x:%x:%x hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"),eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5],eth->eh.ether_dhost[0],eth->eh.ether_dhost[1],eth->eh.ether_dhost[2],eth->eh.ether_dhost[3],eth->eh.ether_dhost[4],eth->eh.ether_dhost[5]);
printf("[%s] binding mod to hardware address %x:%x:%x:%x:%x:%x hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"),eth->ehd.ether_shost[0],eth->ehd.ether_shost[1],eth->ehd.ether_shost[2],eth->ehd.ether_shost[3],eth->ehd.ether_shost[4],eth->ehd.ether_shost[5],eth->ehd.ether_dhost[0],eth->ehd.ether_dhost[1],eth->ehd.ether_dhost[2],eth->ehd.ether_dhost[3],eth->ehd.ether_dhost[4],eth->ehd.ether_dhost[5]);
return 0;
}
+97 -258
View File
@@ -48,11 +48,8 @@
#include "common/ran_context.h"
#define DEBUG 0
//struct sockaddr_in dest_addr[MAX_INST];
//struct sockaddr_in local_addr[MAX_INST];
//int addr_len[MAX_INST];
// These are for IF5 and must be put into the device structure if multiple RUs in the same RAU !!!!!!!!!!!!!!!!!
uint16_t pck_seq_num = 1;
uint16_t pck_seq_num_cur=0;
uint16_t pck_seq_num_prev=0;
@@ -64,25 +61,35 @@ int eth_socket_init_udp(openair0_device *device) {
char str_local[INET_ADDRSTRLEN];
char str_remote[INET_ADDRSTRLEN];
const char *local_ip, *remote_ip;
int local_port=0, remote_port=0;
const char *local_ip, *remote_ipc,*remote_ipd;
int local_portc=0,local_portd=0, remote_portc=0,remote_portd=0;
int sock_dom=0;
int sock_type=0;
int sock_proto=0;
int enable=1;
const char str[2][4] = {"RRU\0","RAU\0"};
int hostind = 0;
local_ip = eth_params->my_addr;
local_portc = eth_params->my_portc;
local_portd = eth_params->my_portd;
if (device->host_type == RRU_HOST ) {
local_ip = eth_params->my_addr;
local_port = eth_params->my_port;
remote_ip = "0.0.0.0";
remote_port = 0;
printf("[%s] local ip addr %s port %d\n", "RRU", local_ip, local_port);
} else {
local_ip = eth_params->my_addr;
local_port = eth_params->my_port;
remote_ip = eth_params->remote_addr;
remote_port = eth_params->remote_port;
printf("[%s] local ip addr %s port %d\n","RAU", local_ip, local_port);
remote_ipc = "0.0.0.0";
remote_ipd = eth_params->remote_addr;
remote_portc = 0;
remote_portd = eth_params->remote_portd;;
printf("[%s] local ip addr %s portc %d portd %d\n", "RRU", local_ip, local_portc, local_portd);
} else {
remote_ipc = eth_params->remote_addr;
remote_ipd = "0.0.0.0";
remote_portc = eth_params->remote_portc;
remote_portd = 0;
hostind = 1;
printf("[%s] local ip addr %s portc %d portd %d\n","RAU", local_ip, local_portc, local_portd);
}
/* Open socket to send on */
@@ -90,43 +97,69 @@ int eth_socket_init_udp(openair0_device *device) {
sock_type=SOCK_DGRAM;
sock_proto=IPPROTO_UDP;
if ((eth->sockfd = socket(sock_dom, sock_type, sock_proto)) == -1) {
perror("ETHERNET: Error opening socket");
if ((eth->sockfdc = socket(sock_dom, sock_type, sock_proto)) == -1) {
perror("ETHERNET: Error opening socket (control)");
exit(0);
}
if ((eth->sockfdd = socket(sock_dom, sock_type, sock_proto)) == -1) {
perror("ETHERNET: Error opening socket (user)");
exit(0);
}
/* initialize addresses */
bzero((void *)&(eth->dest_addr), sizeof(eth->dest_addr));
bzero((void *)&(eth->local_addr), sizeof(eth->local_addr));
bzero((void *)&(eth->dest_addrc), sizeof(eth->dest_addrc));
bzero((void *)&(eth->local_addrc), sizeof(eth->local_addrc));
bzero((void *)&(eth->dest_addrd), sizeof(eth->dest_addrd));
bzero((void *)&(eth->local_addrd), sizeof(eth->local_addrd));
eth->addr_len = sizeof(struct sockaddr_in);
eth->dest_addr.sin_family = AF_INET;
inet_pton(AF_INET,remote_ip,&(eth->dest_addr.sin_addr.s_addr));
eth->dest_addr.sin_port=htons(remote_port);
inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str_remote, INET_ADDRSTRLEN);
eth->dest_addrc.sin_family = AF_INET;
inet_pton(AF_INET,remote_ipc,&(eth->dest_addrc.sin_addr.s_addr));
eth->dest_addrc.sin_port=htons(remote_portc);
inet_ntop(AF_INET, &(eth->dest_addrc.sin_addr), str_remote, INET_ADDRSTRLEN);
eth->dest_addrd.sin_family = AF_INET;
inet_pton(AF_INET,remote_ipd,&(eth->dest_addrd.sin_addr.s_addr));
eth->dest_addrd.sin_port=htons(remote_portd);
eth->local_addrc.sin_family = AF_INET;
inet_pton(AF_INET,local_ip,&(eth->local_addrc.sin_addr.s_addr));
eth->local_addrc.sin_port=htons(local_portc);
inet_ntop(AF_INET, &(eth->local_addrc.sin_addr), str_local, INET_ADDRSTRLEN);
eth->local_addrd.sin_family = AF_INET;
inet_pton(AF_INET,local_ip,&(eth->local_addrd.sin_addr.s_addr));
eth->local_addrd.sin_port=htons(local_portd);
eth->local_addr.sin_family = AF_INET;
inet_pton(AF_INET,local_ip,&(eth->local_addr.sin_addr.s_addr));
eth->local_addr.sin_port=htons(local_port);
inet_ntop(AF_INET, &(eth->local_addr.sin_addr), str_local, INET_ADDRSTRLEN);
/* set reuse address flag */
if (setsockopt(eth->sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) {
perror("ETHERNET: Cannot set SO_REUSEADDR option on socket");
if (setsockopt(eth->sockfdc, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) {
perror("ETHERNET: Cannot set SO_REUSEADDR option on socket (control)");
exit(0);
}
if (setsockopt(eth->sockfdd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) {
perror("ETHERNET: Cannot set SO_REUSEADDR option on socket (user)");
exit(0);
}
/* want to receive -> so bind */
if (bind(eth->sockfd,(struct sockaddr *)&eth->local_addr,eth->addr_len)<0) {
perror("ETHERNET: Cannot bind to socket");
exit(0);
} else {
printf("[%s] binding to %s:%d\n","RAU",str_local,ntohs(eth->local_addr.sin_port));
}
if (bind(eth->sockfdc,(struct sockaddr *)&eth->local_addrc,eth->addr_len)<0) {
perror("ETHERNET: Cannot bind to socket (control)");
exit(0);
} else {
printf("[%s] binding to %s:%d (control)\n",str[hostind],str_local,ntohs(eth->local_addrc.sin_port));
}
if (bind(eth->sockfdd,(struct sockaddr *)&eth->local_addrd,eth->addr_len)<0) {
perror("ETHERNET: Cannot bind to socket (user)");
exit(0);
} else {
printf("[%s] binding to %s:%d (user)\n",str[hostind],str_local,ntohs(eth->local_addrd.sin_port));
}
return 0;
}
@@ -142,39 +175,26 @@ int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestam
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,
bytes_received = recvfrom(eth->sockfdd,
buff[0],
packet_size,
0,
(struct sockaddr *)&eth->dest_addr,
(struct sockaddr *)&eth->dest_addrd,
(socklen_t *)&eth->addr_len);
if (bytes_received ==-1) {
eth->num_rx_errors++;
if (errno == EAGAIN) {
/*
again_cnt++;
usleep(10);
if (again_cnt == 1000) {
perror("ETHERNET IF4p5 READ (EAGAIN): ");
exit(-1);
} else {
printf("AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN AGAIN \n");
goto again;
}
*/
printf("Lost IF4p5 connection with %s\n", inet_ntoa(eth->dest_addr.sin_addr));
exit(-1);
printf("Lost IF4p5 connection with %s\n", inet_ntoa(eth->dest_addrd.sin_addr));
} else if (errno == EWOULDBLOCK) {
block_cnt++;
usleep(10);
if (block_cnt == 1000) {
perror("ETHERNET IF4p5 READ (EWOULDBLOCK): ");
exit(-1);
} else {
printf("BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK \n");
goto again;
@@ -182,7 +202,6 @@ int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestam
} else {
perror("ETHERNET IF4p5 READ");
printf("(%s):\n", strerror(errno));
exit(-1);
}
} else {
*timestamp = test_header->sub_type;
@@ -208,7 +227,7 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam
char str[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str, INET_ADDRSTRLEN);
inet_ntop(AF_INET, &(eth->dest_addrd.sin_addr), str, INET_ADDRSTRLEN);
if (flags == IF4p5_PDLFFT) {
packet_size = UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks);
@@ -224,18 +243,18 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam
}
eth->tx_nsamps = nblocks;
//printf("Sending %d bytes to %s\n",packet_size,str);
// printf("Sending %d bytes to %s:%d\n",packet_size,str,ntohs(eth->local_addrd.sin_port));
bytes_sent = sendto(eth->sockfd,
bytes_sent = sendto(eth->sockfdd,
buff[0],
packet_size,
0,
(struct sockaddr*)&eth->dest_addr,
(struct sockaddr*)&eth->dest_addrd,
eth->addr_len);
if (bytes_sent == -1) {
eth->num_tx_errors++;
perror("ETHERNET WRITE: ");
perror("error writing to remote unit (user) : ");
exit(-1);
} else {
eth->tx_actual_nsamps = bytes_sent>>1;
@@ -284,11 +303,11 @@ int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, voi
bytes_sent);
#endif
/* Send packet */
bytes_sent += sendto(eth->sockfd,
bytes_sent += sendto(eth->sockfdd,
buff2,
UDP_PACKET_SIZE_BYTES(nsamps),
sendto_flag,
(struct sockaddr*)&eth->dest_addr,
(struct sockaddr*)&eth->dest_addrd,
eth->addr_len);
if ( bytes_sent == -1) {
@@ -353,11 +372,11 @@ 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,
bytes_received +=recvfrom(eth->sockfdd,
buff2,
UDP_PACKET_SIZE_BYTES(nsamps),
rcvfrom_flag,
(struct sockaddr *)&eth->dest_addr,
(struct sockaddr *)&eth->dest_addrd,
(socklen_t *)&eth->addr_len);
if (bytes_received ==-1) {
@@ -421,205 +440,25 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi
}
return (bytes_received-APP_HEADER_SIZE_BYTES)>>2;
}
int trx_eth_ctlsend_udp(openair0_device *device, void *msg, ssize_t msg_len) {
int eth_set_dev_conf_udp(openair0_device *device) {
eth_state_t *eth = (eth_state_t*)device->priv;
ssize_t msg_len,len;
RRU_CONFIG_msg_t rru_config_msg;
int received_capabilities=0;
char str[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str, INET_ADDRSTRLEN);
// Wait for capabilities
while (received_capabilities==0) {
rru_config_msg.type = RAU_tick;
rru_config_msg.len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE;
printf("Sending RAU tick to RRU on %s\n",str);
if (sendto(eth->sockfd,&rru_config_msg,rru_config_msg.len,0,(struct sockaddr *)&eth->dest_addr,eth->addr_len)==-1) {
perror("ETHERNET: sendto conf_udp");
printf("addr_len : %d, msg_len %d\n",eth->addr_len,msg_len);
exit(0);
}
msg_len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_capabilities_t);
// wait for answer with timeout
if (len = recvfrom(eth->sockfd,
&rru_config_msg,
msg_len,
0,
(struct sockaddr *)&eth->dest_addr,
(socklen_t *)&eth->addr_len)<0) {
printf("Waiting for RRU on %s\n",str);
}
else if (rru_config_msg.type == RRU_capabilities) {
AssertFatal(rru_config_msg.len==msg_len,"Received capabilities with incorrect length (%d!=%d)\n",rru_config_msg.len,msg_len);
printf("Received capabilities from RRU on %s (len %d/%d, num_bands %d,max_pdschReferenceSignalPower %d, max_rxgain %d, nb_tx %d, nb_rx %d)\n",str,
rru_config_msg.len,msg_len,
((RRU_capabilities_t*)&rru_config_msg.msg[0])->num_bands,
((RRU_capabilities_t*)&rru_config_msg.msg[0])->max_pdschReferenceSignalPower[0],
((RRU_capabilities_t*)&rru_config_msg.msg[0])->max_rxgain[0],
((RRU_capabilities_t*)&rru_config_msg.msg[0])->nb_tx[0],
((RRU_capabilities_t*)&rru_config_msg.msg[0])->nb_rx[0]);
received_capabilities=1;
}
else {
printf("Received incorrect message %d from RRU on %s\n",rru_config_msg.type,str);
}
}
AssertFatal(device->configure_rru!=NULL,"device->configure_rru is null for RRU %d, shouldn't be ...\n",device->Mod_id);
device->configure_rru(device->Mod_id,
(RRU_capabilities_t *)&rru_config_msg.msg[0]);
rru_config_msg.type = RRU_config;
rru_config_msg.len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_config_t);
printf("Sending Configuration to RRU on %s (num_bands %d,band0 %d,txfreq %u,rxfreq %u,att_tx %d,att_rx %d,N_RB_DL %d,N_RB_UL %d,3/4FS %d, prach_FO %d, prach_CI %d)\n",str,
((RRU_config_t *)&rru_config_msg.msg[0])->num_bands,
((RRU_config_t *)&rru_config_msg.msg[0])->band_list[0],
((RRU_config_t *)&rru_config_msg.msg[0])->tx_freq[0],
((RRU_config_t *)&rru_config_msg.msg[0])->rx_freq[0],
((RRU_config_t *)&rru_config_msg.msg[0])->att_tx[0],
((RRU_config_t *)&rru_config_msg.msg[0])->att_rx[0],
((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_DL[0],
((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_UL[0],
((RRU_config_t *)&rru_config_msg.msg[0])->threequarter_fs[0],
((RRU_config_t *)&rru_config_msg.msg[0])->prach_FreqOffset[0],
((RRU_config_t *)&rru_config_msg.msg[0])->prach_ConfigIndex[0]);
if (sendto(eth->sockfd,&rru_config_msg,rru_config_msg.len,0,(struct sockaddr *)&eth->dest_addr,eth->addr_len)==-1) {
perror("ETHERNET: sendto conf_udp");
printf("addr_len : %d, msg_len %d\n",eth->addr_len,msg_len);
exit(0);
}
return 0;
return(sendto(((eth_state_t*)device->priv)->sockfdc,
msg,
msg_len,
0,
(struct sockaddr *)&((eth_state_t*)device->priv)->dest_addrc,
((eth_state_t*)device->priv)->addr_len));
}
extern RAN_CONTEXT_t RC;
int eth_get_dev_conf_udp(openair0_device *device) {
eth_state_t *eth = (eth_state_t*)device->priv;
char str1[INET_ADDRSTRLEN],str[INET_ADDRSTRLEN];
void *msg;
RRU_CONFIG_msg_t rru_config_msg;
ssize_t msg_len;
int tick_received = 0;
int configuration_received = 0;
RRU_capabilities_t *cap;
RU_t *ru = RC.ru[0];
int i;
inet_ntop(AF_INET, &(eth->local_addr.sin_addr), str, INET_ADDRSTRLEN);
inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str1, INET_ADDRSTRLEN);
int trx_eth_ctlrecv_udp(openair0_device *device, void *msg, ssize_t msg_len) {
// wait for RAU_tick
while (tick_received == 0) {
msg_len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE;
if (recvfrom(eth->sockfd,
&rru_config_msg,
msg_len,
0,
(struct sockaddr *)&eth->dest_addr,
(socklen_t *)&eth->addr_len)<0) {
printf("RRU on %s Waiting for RAU on %s\n",str,str1);
}
else {
if (rru_config_msg.type == RAU_tick) {
printf("Tick received from RAU on %s\n",str1);
tick_received = 1;
}
}
}
// send capabilities
rru_config_msg.type = RRU_capabilities;
rru_config_msg.len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_capabilities_t);
cap = (RRU_capabilities_t*)&rru_config_msg.msg[0];
printf("Sending Capabilities (len %d, num_bands %d,max_pdschReferenceSignalPower %d, max_rxgain %d, nb_tx %d, nb_rx %d)\n",
rru_config_msg.len,ru->num_bands,ru->max_pdschReferenceSignalPower,ru->max_rxgain,ru->nb_tx,ru->nb_rx);
switch (ru->function) {
case NGFI_RRU_IF4p5:
cap->FH_fmt = OAI_IF4p5_only;
break;
case NGFI_RRU_IF5:
cap->FH_fmt = OAI_IF5_only;
break;
case MBP_RRU_IF5:
cap->FH_fmt = MBP_IF5;
break;
default:
AssertFatal(1==0,"RU_function is unknown %d\n",RC.ru[0]->function);
break;
}
cap->num_bands = ru->num_bands;
for (i=0;i<ru->num_bands;i++) {
cap->band_list[i] = ru->band[i];
cap->nb_rx[i] = ru->nb_rx;
cap->nb_tx[i] = ru->nb_tx;
cap->max_pdschReferenceSignalPower[i] = ru->max_pdschReferenceSignalPower;
cap->max_rxgain[i] = ru->max_rxgain;
}
if (sendto(eth->sockfd,&rru_config_msg,rru_config_msg.len,0,(struct sockaddr *)&eth->dest_addr,eth->addr_len)==-1) {
perror("ETHERNET: sendto conf_udp");
printf("addr_len : %d, msg_len %d\n",eth->addr_len,msg_len);
exit(0);
}
// wait for configuration
rru_config_msg.len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_config_t);
while (configuration_received == 0) {
if (recvfrom(eth->sockfd,
&rru_config_msg,
rru_config_msg.len,
0,
(struct sockaddr *)&eth->dest_addr,
(socklen_t *)&eth->addr_len)==-1) {
printf("Waiting for configuration from RAU on %s\n",str1);
}
else {
printf("Configuration received from RAU on %s (num_bands %d,band0 %d,txfreq %u,rxfreq %u,att_tx %d,att_rx %d,N_RB_DL %d,N_RB_UL %d,3/4FS %d, prach_FO %d, prach_CI %d)\n",str,
((RRU_config_t *)&rru_config_msg.msg[0])->num_bands,
((RRU_config_t *)&rru_config_msg.msg[0])->band_list[0],
((RRU_config_t *)&rru_config_msg.msg[0])->tx_freq[0],
((RRU_config_t *)&rru_config_msg.msg[0])->rx_freq[0],
((RRU_config_t *)&rru_config_msg.msg[0])->att_tx[0],
((RRU_config_t *)&rru_config_msg.msg[0])->att_rx[0],
((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_DL[0],
((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_UL[0],
((RRU_config_t *)&rru_config_msg.msg[0])->threequarter_fs[0],
((RRU_config_t *)&rru_config_msg.msg[0])->prach_FreqOffset[0],
((RRU_config_t *)&rru_config_msg.msg[0])->prach_ConfigIndex[0]);
AssertFatal(device->configure_rru!=NULL,"device->configure_rru is null for RRU %d\n",device->Mod_id);
device->configure_rru(device->Mod_id,
(void*)&rru_config_msg.msg[0]);
configuration_received = 1;
}
}
// device->openair0_cfg=(openair0_config_t *)msg;
/* get remote ip address and port */
/* inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str1, INET_ADDRSTRLEN); */
/* device->openair0_cfg->remote_port =ntohs(eth->dest_addr.sin_port); */
/* device->openair0_cfg->remote_addr =str1; */
/* /\* restore local ip address and port *\/ */
/* inet_ntop(AF_INET, &(eth->local_addr.sin_addr), str, INET_ADDRSTRLEN); */
/* device->openair0_cfg->my_port =ntohs(eth->local_addr.sin_port); */
/* device->openair0_cfg->my_addr =str; */
/* printf("[RRU] 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;
return (recvfrom(((eth_state_t*)device->priv)->sockfdc,
msg,
msg_len,
0,
(struct sockaddr *)&((eth_state_t*)device->priv)->dest_addrc,
(socklen_t *)&((eth_state_t*)device->priv)->addr_len));
}
@@ -58,11 +58,13 @@ int trx_eth_start(openair0_device *device) {
printf("Setting Timenout to 999999 usecs\n");
if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1;
/*
if (device->host_type == RAU_HOST) {
if(eth_set_dev_conf_raw(device)!=0) return -1;
} else {
if(eth_get_dev_conf_raw(device)!=0) return -1;
}
}*/
/* adjust MTU wrt number of samples per packet */
if(ethernet_tune (device,MTU_SIZE,RAW_PACKET_SIZE_BYTES(device->openair0_cfg->samples_per_packet))!=0) return -1;
if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1;
@@ -74,12 +76,14 @@ int trx_eth_start(openair0_device *device) {
printf("Setting Timenout to 999999 usecs\n");
if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1;
/* RRU gets openair0 device configuration - RAU sets openair0 device configuration*/
/*
if (device->host_type == RAU_HOST) {
if(eth_set_dev_conf_raw_IF4p5(device)!=0) return -1;
} else {
if(eth_get_dev_conf_raw_IF4p5(device)!=0) return -1;
}
*/
/* adjust MTU wrt number of samples per packet */
if(ethernet_tune (device,MTU_SIZE,RAW_IF4p5_PRACH_SIZE_BYTES)!=0) return -1;
if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1;
@@ -87,15 +91,16 @@ int trx_eth_start(openair0_device *device) {
printf("Setting ETHERNET to UDP_IF4p5_MODE\n");
if (eth_socket_init_udp(device)!=0) return -1;
// printf("Setting Timeout to 999999 usecs\n");
// if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1;
printf("Setting Timeout to 999999 usecs\n");
if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1;
/*
if (device->host_type == RAU_HOST) {
if(eth_set_dev_conf_udp(device)!=0) return -1;
} else {
if(eth_get_dev_conf_udp(device)!=0) return -1;
}
*/
/* adjust MTU wrt number of samples per packet */
/*if(ethernet_tune (device,MTU_SIZE,UDP_IF4p5_PRACH_SIZE_BYTES)!=0) return -1;
@@ -111,12 +116,13 @@ int trx_eth_start(openair0_device *device) {
} else {
printf("Setting ETHERNET to UDP_IF5_MODE\n");
if (eth_socket_init_udp(device)!=0) return -1;
/* RRU gets openair0 device configuration - RAU sets openair0 device configuration*/
/*
if (device->host_type == RAU_HOST) {
if(eth_set_dev_conf_udp(device)!=0) return -1;
} else {
if(eth_get_dev_conf_udp(device)!=0) return -1;
}
}*/
/* adjust MTU wrt number of samples per packet */
if(ethernet_tune (device,MTU_SIZE,UDP_IF4p5_PRACH_SIZE_BYTES)!=0) return -1;
@@ -135,7 +141,7 @@ void trx_eth_end(openair0_device *device) {
eth_state_t *eth = (eth_state_t*)device->priv;
/* destroys socket only for the processes that call the eth_end fuction-- shutdown() for beaking the pipe */
if ( close(eth->sockfd) <0 ) {
if ( close(eth->sockfdd) <0 ) {
perror("ETHERNET: Failed to close socket");
exit(0);
} else {
@@ -144,43 +150,6 @@ void trx_eth_end(openair0_device *device) {
}
int trx_eth_request(openair0_device *device, void *msg, ssize_t msg_len) {
eth_state_t *eth = (eth_state_t*)device->priv;
/* RAU sends a message to RRU */
if (sendto(eth->sockfd,msg,msg_len,0,(struct sockaddr *)&eth->dest_addr,eth->addr_len)==-1) {
perror("ETHERNET: ");
exit(0);
}
return 0;
}
int trx_eth_reply(openair0_device *device, void *msg, ssize_t msg_len) {
eth_state_t *eth = (eth_state_t*)device->priv;
/* RRU receives from RAU a message */
if (recvfrom(eth->sockfd,
msg,
msg_len,
0,
(struct sockaddr *)&eth->dest_addr,
(socklen_t *)&eth->addr_len)==-1) {
perror("ETHERNET: recv_from in trx_eth_reply ");
exit(0);
}
return 0;
}
int trx_eth_stop(openair0_device *device) {
return(0);
}
@@ -217,7 +186,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,
if (setsockopt(eth->sockfdd,
SOL_SOCKET,
SO_SNDBUF,
&value,sizeof(value))) {
@@ -228,7 +197,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,
if (setsockopt(eth->sockfdd,
SOL_SOCKET,
SO_RCVBUF,
&value,sizeof(value))) {
@@ -241,7 +210,15 @@ 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,
if (setsockopt(eth->sockfdc,
SOL_SOCKET,
SO_RCVTIMEO,
(char *)&timeout,sizeof(timeout))) {
perror("[ETHERNET] setsockopt()");
} else {
printf( "receive timeout= %u usec\n",(unsigned int)timeout.tv_usec);
}
if (setsockopt(eth->sockfdd,
SOL_SOCKET,
SO_RCVTIMEO,
(char *)&timeout,sizeof(timeout))) {
@@ -254,7 +231,15 @@ 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,
if (setsockopt(eth->sockfdc,
SOL_SOCKET,
SO_SNDTIMEO,
(char *)&timeout,sizeof(timeout))) {
perror("[ETHERNET] setsockopt()");
} else {
printf( "send timeout= %d,%d sec\n",(int)timeout.tv_sec,(int)timeout.tv_usec);
}
if (setsockopt(eth->sockfdd,
SOL_SOCKET,
SO_SNDTIMEO,
(char *)&timeout,sizeof(timeout))) {
@@ -270,7 +255,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, sizeof(ifr.ifr_name));
ifr.ifr_mtu =value;
if (ioctl(eth->sockfd,SIOCSIFMTU,(caddr_t)&ifr) < 0 )
if (ioctl(eth->sockfdd,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,ifr.ifr_mtu);
@@ -280,7 +265,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, sizeof(ifr.ifr_name));
ifr.ifr_qlen =value;
if (ioctl(eth->sockfd,SIOCSIFTXQLEN,(caddr_t)&ifr) < 0 )
if (ioctl(eth->sockfdd,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,ifr.ifr_qlen);
@@ -366,8 +351,6 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, 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;
device->trx_reply_func = trx_eth_reply;
device->trx_get_stats_func = trx_eth_get_stats;
device->trx_reset_stats_func = trx_eth_reset_stats;
device->trx_end_func = trx_eth_end;
@@ -380,13 +363,17 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
device->trx_read_func = trx_eth_read_raw;
} else if (eth->flags == ETH_UDP_MODE) {
device->trx_write_func = trx_eth_write_udp;
device->trx_read_func = trx_eth_read_udp;
device->trx_read_func = trx_eth_read_udp;
device->trx_ctlsend_func = trx_eth_ctlsend_udp;
device->trx_ctlrecv_func = trx_eth_ctlrecv_udp;
} else if (eth->flags == ETH_RAW_IF4p5_MODE) {
device->trx_write_func = trx_eth_write_raw_IF4p5;
device->trx_read_func = trx_eth_read_raw_IF4p5;
} else if (eth->flags == ETH_UDP_IF4p5_MODE) {
device->trx_write_func = trx_eth_write_udp_IF4p5;
device->trx_read_func = trx_eth_read_udp_IF4p5;
device->trx_read_func = trx_eth_read_udp_IF4p5;
device->trx_ctlsend_func = trx_eth_ctlsend_udp;
device->trx_ctlrecv_func = trx_eth_ctlrecv_udp;
} else if (eth->flags == ETH_RAW_IF5_MOBIPASS) {
device->trx_write_func = trx_eth_write_raw_IF4p5;
device->trx_read_func = trx_eth_read_raw_IF5_mobipass;
@@ -399,9 +386,9 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
device->priv = eth;
/* device specific */
openair0_cfg[0].iq_rxrescale = 15;//rescale iqs
openair0_cfg[0].iq_txshift = eth_params->iq_txshift;// shift
openair0_cfg[0].tx_sample_advance = eth_params->tx_sample_advance;
// openair0_cfg[0].iq_rxrescale = 15;//rescale iqs
// openair0_cfg[0].iq_txshift = eth_params->iq_txshift;// shift
// openair0_cfg[0].tx_sample_advance = eth_params->tx_sample_advance;
/* RRU does not have any information to make this configuration atm */
/*
@@ -54,22 +54,32 @@
/*!\brief opaque ethernet data structure */
typedef struct {
/*!\brief socket file desc */
int sockfd;
/*!\brief socket file desc (control)*/
int sockfdc;
/*!\brief socket file desc (user)*/
int sockfdd;
/*!\brief interface name */
char *if_name;
/*!\brief buffer size */
unsigned int buffer_size;
/*!\brief destination address for UDP socket*/
struct sockaddr_in dest_addr;
/*!\brief local address for UDP socket*/
struct sockaddr_in local_addr;
/*!\brief destination address (control) for UDP socket*/
struct sockaddr_in dest_addrc;
/*!\brief local address (control) for UDP socket*/
struct sockaddr_in local_addrc;
/*!\brief destination address (user) for UDP socket*/
struct sockaddr_in dest_addrd;
/*!\brief local address (user) for UDP socket*/
struct sockaddr_in local_addrd;
/*!\brief address length for both UDP and RAW socket*/
int addr_len;
/*!\brief destination address for RAW socket*/
struct sockaddr_ll dest_addr_ll;
/*!\brief local address for RAW socket*/
struct sockaddr_ll local_addr_ll;
/*!\brief destination address (control) for RAW socket*/
struct sockaddr_ll dest_addrc_ll;
/*!\brief local address (control) for RAW socket*/
struct sockaddr_ll local_addrc_ll;
/*!\brief destination address (user) for RAW socket*/
struct sockaddr_ll dest_addrd_ll;
/*!\brief local address (user) for RAW socket*/
struct sockaddr_ll local_addrd_ll;
/*!\brief inteface index for RAW socket*/
struct ifreq if_index;
/*!\brief timeout ms */
@@ -117,9 +127,10 @@ typedef struct {
uint64_t tx_count;
/*!\brief number of packets received */
uint64_t rx_count;
struct ether_header eh;
/*!\brief precomputed ethernet header (control) */
struct ether_header ehc;
/*!\brief precomputed ethernet header (data) */
struct ether_header ehd;
} eth_state_t;
@@ -158,79 +169,6 @@ typedef enum {
MAX_OPT
} eth_opt_t;
#define MAX_RRU_CONFIG_SIZE 1024
typedef enum {
RAU_tick=0,
RRU_capabilities=1,
RRU_config=2,
RRU_MSG_max_num=3
} rru_config_msg_type_t;
typedef struct RRU_CONFIG_msg_s {
rru_config_msg_type_t type;
ssize_t len;
uint8_t msg[MAX_RRU_CONFIG_SIZE];
} RRU_CONFIG_msg_t;
typedef enum {
OAI_IF5_only =0,
OAI_IF4p5_only =1,
OAI_IF5_and_IF4p5 =2,
MBP_IF5 =3,
MAX_FH_FMTs =4
} FH_fmt_options_t;
#define MAX_BANDS_PER_RRU 4
typedef struct RRU_capabilities_s {
/// Fronthaul format
FH_fmt_options_t FH_fmt;
/// number of EUTRA bands (<=4) supported by RRU
uint8_t num_bands;
/// EUTRA band list supported by RRU
uint8_t band_list[MAX_BANDS_PER_RRU];
/// Number of concurrent bands (component carriers)
uint8_t num_concurrent_bands;
/// Maximum TX EPRE of each band
int8_t max_pdschReferenceSignalPower[MAX_BANDS_PER_RRU];
/// Maximum RX gain of each band
uint8_t max_rxgain[MAX_BANDS_PER_RRU];
/// Number of RX ports of each band
uint8_t nb_rx[MAX_BANDS_PER_RRU];
/// Number of TX ports of each band
uint8_t nb_tx[MAX_BANDS_PER_RRU];
/// max DL bandwidth (1,6,15,25,50,75,100)
uint8_t N_RB_DL[MAX_BANDS_PER_RRU];
/// max UL bandwidth (1,6,15,25,50,75,100)
uint8_t N_RB_UL[MAX_BANDS_PER_RRU];
} RRU_capabilities_t;
typedef struct RRU_config_s {
/// Fronthaul format
RU_if_south_t FH_fmt;
/// number of EUTRA bands (<=4) configured in RRU
uint8_t num_bands;
/// EUTRA band list configured in RRU
uint8_t band_list[MAX_BANDS_PER_RRU];
/// TX frequency
uint32_t tx_freq[MAX_BANDS_PER_RRU];
/// RX frequency
uint32_t rx_freq[MAX_BANDS_PER_RRU];
/// TX attenation w.r.t. max
uint8_t att_tx[MAX_BANDS_PER_RRU];
/// RX attenuation w.r.t. max
uint8_t att_rx[MAX_BANDS_PER_RRU];
/// DL bandwidth
uint8_t N_RB_DL[MAX_BANDS_PER_RRU];
/// UL bandwidth
uint8_t N_RB_UL[MAX_BANDS_PER_RRU];
/// 3/4 sampling rate
uint8_t threequarter_fs[MAX_BANDS_PER_RRU];
/// prach_FreqOffset for IF4p5
int prach_FreqOffset[MAX_BANDS_PER_RRU];
/// prach_ConfigIndex for IF4p5
int prach_ConfigIndex[MAX_BANDS_PER_RRU];
} RRU_config_t;
/*
#define SND_BUF_SIZE 1
@@ -286,19 +224,8 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value);
int eth_socket_init_udp(openair0_device *device);
int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags);
int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc);
//int trx_eth_write_udp_IF4(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags);
//int trx_eth_read_udp_IF4(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc);
int eth_get_dev_conf_udp(openair0_device *device);
/*! \fn static int eth_set_dev_conf_udp(openair0_device *device)
* \brief
* \param[in] *device openair device
* \param[out]
* \return 0 on success, otherwise -1
* \note
* @ingroup _oai
*/
int eth_set_dev_conf_udp(openair0_device *device);
int eth_socket_init_raw(openair0_device *device);
int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags);
int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc);
@@ -307,6 +234,9 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam
int trx_eth_read_raw_IF5_mobipass(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc);
int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags);
int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc);
int trx_eth_ctlsend_udp(openair0_device *device, void *msg, ssize_t msg_len);
int trx_eth_ctlrecv_udp(openair0_device *device, void *msg, ssize_t msg_len);
int eth_get_dev_conf_raw(openair0_device *device);
int eth_set_dev_conf_raw(openair0_device *device);
int eth_get_dev_conf_raw_IF4p5(openair0_device *device);