Commit 181ae665 authored by Michael Cook's avatar Michael Cook

Merge branch 'episys/mel/pdcp_socket_update' into 'episys/master'

Episys/mel/pdcp socket update

See merge request aburger/openairinterface5g!25
parents b68479aa 9fa09f53
......@@ -59,7 +59,8 @@ void nfapi_trace_dbg(nfapi_trace_level_t level, const char *format, ...)
if (num_chars > TRACE_HEADER_LENGTH)
{
printf("trace_dbg: Error, num_chars is too large: %d", num_chars);
printf("trace_dbg: Error, num_chars is too large: %d\n", num_chars);
fflush(stdout);
return;
}
......@@ -73,4 +74,5 @@ void nfapi_trace_dbg(nfapi_trace_level_t level, const char *format, ...)
printf("%s", trace_buff);
}
va_end(p_args);
fflush(stdout);
}
......@@ -25,7 +25,7 @@
#include "nfapi_pnf_interface.h"
#define NFAPI_MAX_PACKED_MESSAGE_SIZE 8192
#define NFAPI_MAX_PACKED_MESSAGE_SIZE 4096
typedef struct {
uint16_t dl_conf_ontime;
......
......@@ -1701,12 +1701,19 @@ void pnf_nfapi_p7_read_dispatch_message(pnf_p7_t* pnf_p7, uint32_t now_hr_time)
}
// read the segment
recvfrom_result = recvfrom(pnf_p7->p7_sock, pnf_p7->rx_message_buffer, header.message_length, MSG_DONTWAIT, (struct sockaddr*)&remote_addr, &remote_addr_size);
recvfrom_result = recvfrom(pnf_p7->p7_sock, pnf_p7->rx_message_buffer, pnf_p7->rx_message_buffer_size,
MSG_DONTWAIT | MSG_TRUNC, (struct sockaddr*)&remote_addr, &remote_addr_size);
now_hr_time = pnf_get_current_time_hr(); //DJP - moved to here - get closer timestamp???
if(recvfrom_result > 0)
{
if (recvfrom_result != header.message_length)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(%d). Received unexpected number of bytes. %d != %d",
__FUNCTION__, __LINE__, recvfrom_result, header.message_length);
break;
}
pnf_handle_p7_message(pnf_p7->rx_message_buffer, recvfrom_result, pnf_p7, now_hr_time);
}
}
......
......@@ -1537,9 +1537,9 @@ int vnf_p7_read_dispatch_message(vnf_p7_t* vnf_p7)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "recvfrom returned 0\n");
}
else if(recvfrom_result != header.message_length)
else if(recvfrom_result != -1 && recvfrom_result != header.message_length)
{
NFAPI_TRACE(NFAPI_TRACE_NOTE, "did not receive the entire message %d %d\n", recvfrom_result, header.message_length);
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Received unexpected number of bytes %d %d\n", recvfrom_result, header.message_length);
recvfrom_result += recvfrom(vnf_p7->socket, &vnf_p7->rx_message_buffer[recvfrom_result], header.message_length - recvfrom_result, MSG_WAITALL, (struct sockaddr*)&remote_addr, &remote_addr_size);
......
......@@ -91,7 +91,7 @@ const double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812,
};
//int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27};
const int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28};
const int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 27};
//for SNR to MI conversion 7 th order Polynomial coeff
const double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639};
......
......@@ -91,7 +91,7 @@ const double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812,
};
//int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27};
const int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28};
const int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 27};
//for SNR to MI conversion 7 th order Polynomial coeff
const double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639};
......
......@@ -84,7 +84,7 @@ const double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812,
};
//int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27};
const int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28};
const int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 27};
//for SNR to MI conversion 7 th order Polynomial coeff
const double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639};
......
......@@ -48,7 +48,7 @@
#include "LTE_SRB-ToAddModList.h"
#include "LTE_MBMS-SessionInfoList-r9.h"
#include "LTE_PMCH-InfoList-r9.h"
#include "common/utils/ocp_itti/intertask_interface.h"
typedef rlc_op_status_t (*send_rlc_data_req_func_t)(const protocol_ctxt_t *const,
const srb_flag_t, const MBMS_flag_t,
......@@ -59,8 +59,9 @@ typedef boolean_t (*pdcp_data_ind_func_t)( const protocol_ctxt_t *, const srb_fl
mem_block_t *,const uint32_t *const, const uint32_t *const);
/* maximum number of tun interfaces that will be created to emulates UEs */
/* UEs beyond that will be multiplexed on the same tun */
#define MAX_NUMBER_NETIF 16
/* If running in nfapi_pnf_standlone mode, we only need one tunnel interface */
#define MAX_NUMBER_NETIF 1 //16
#define ENB_NAS_USE_TUN_W_MBMS_BIT (1<< 10)
#define PDCP_USE_NETLINK_BIT (1<< 11)
#define LINK_ENB_PDCP_TO_IP_DRIVER_BIT (1<< 13)
......
......@@ -235,21 +235,46 @@ int pdcp_fifo_read_input_sdus_fromtun (const protocol_ctxt_t *const ctxt_pP) {
pdcp_t *pdcp_p = NULL;
int len;
rb_id_t rab_id = DEFAULT_RAB_ID;
int sockd;
do {
if (UE_NAS_USE_TUN) {
if (ue_id_g == 0) {
sockd = nas_sock_fd[ctxt_pP->module_id];
}
else {
sockd = nas_sock_fd[ue_id_g];
}
}
else {
sockd = nas_sock_fd[0];
}
for (;;) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 );
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 );
if (ue_id_g == 0)
{
len = read(UE_NAS_USE_TUN?nas_sock_fd[ctxt_pP->module_id]:nas_sock_fd[0], &nl_rx_buf, NL_MAX_PAYLOAD);
len = read(sockd, &nl_rx_buf, NL_MAX_PAYLOAD);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 );
if (len == -1) {
if (errno == EAGAIN) {
LOG_D(PDCP, "Error reading NAS socket: %s\n", strerror(errno));
}
else {
LOG_E(PDCP, "Error reading NAS socket: %s\n", strerror(errno));
}
break;
}
else
/* Check for message truncation. Strictly speaking if the packet is exactly sizeof(nl_rx_buf) bytes
that would not be an error. But we cannot distinguish that from a packet > sizeof(nl_rx_buf) */
if (len == sizeof(nl_rx_buf))
{
len = read(UE_NAS_USE_TUN?nas_sock_fd[ue_id_g]:nas_sock_fd[0], &nl_rx_buf, NL_MAX_PAYLOAD);
LOG_E(PDCP, "%s(%d). Message truncated %d\n", __FUNCTION__, __LINE__, len);
break;
}
if (len == 0) {
LOG_E(PDCP, "EOF Reading NAS socket\n");
break;
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 );
if (len<=0) continue;
if (UE_NAS_USE_TUN) {
key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
......@@ -291,7 +316,7 @@ int pdcp_fifo_read_input_sdus_fromtun (const protocol_ctxt_t *const ctxt_pP) {
ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id,
ctxt.rnti, rab_id, key);
}
} while (len > 0);
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 );
return len;
......@@ -664,9 +689,20 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP)
//TTN for D2D (PC5S)
// receive a message from ProSe App
memset(receive_buf, 0, BUFSIZE);
bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, 0,
bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, MSG_TRUNC,
(struct sockaddr *) &prose_pdcp_addr, (socklen_t *)&prose_addr_len);
if (bytes_received == -1){
LOG_E(PDCP, "%s(%d). recvfrom failed. %s\n", __FUNCTION__, __LINE__, strerror(errno));
return;
}
if (bytes_received == 0){
LOG_E(PDCP, "%s(%d). EOF pdcp_pc5_sockfd.\n", __FUNCTION__, __LINE__);
}
if (bytes_received > BUFSIZE) {
LOG_E(PDCP, "%s(%d). Message truncated. %d\n", __FUNCTION__, __LINE__, bytes_received);
return;
}
if (bytes_received > 0) {
pc5s_header = calloc(1, sizeof(pc5s_header_t));
memcpy((void *)pc5s_header, (void *)receive_buf, sizeof(pc5s_header_t));
......
......@@ -1273,7 +1273,7 @@ void *ue_standalone_pnf_task(void *context)
{
struct sockaddr_in server_address;
socklen_t addr_len = sizeof(server_address);
char buffer[1024];
char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE];
int sd = ue_rx_sock_descriptor;
assert(sd > 0);
......@@ -1283,12 +1283,17 @@ void *ue_standalone_pnf_task(void *context)
bool dl_config_req_valid = false;
while (true)
{
ssize_t len = recvfrom(sd, buffer, sizeof(buffer), 0, (struct sockaddr *)&server_address, &addr_len);
ssize_t len = recvfrom(sd, buffer, sizeof(buffer), MSG_TRUNC, (struct sockaddr *)&server_address, &addr_len);
if (len == -1)
{
LOG_E(MAC, "reading from standalone pnf sctp socket failed \n");
continue;
}
if (len > sizeof(buffer))
{
LOG_E(MAC, "%s(%d). Message truncated. %zd\n", __FUNCTION__, __LINE__, len);
continue;
}
if (len == sizeof(uint16_t))
{
......@@ -1660,7 +1665,7 @@ static void print_rx_ind(nfapi_rx_indication_t *p)
void send_standalone_msg(UL_IND_t *UL, nfapi_message_id_e msg_type)
{
int encoded_size = -1;
char buffer[1024];
char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE];
switch (msg_type)
{
......
......@@ -19,6 +19,7 @@
//#include "openair1/PHY/LTE_TRANSPORT/defs.h"
//#include "openair1/PHY/defs.h"
//#include "openair1/PHY/LTE_TRANSPORT/defs.h"
#include "nfapi/open-nFAPI/pnf/inc/pnf_p7.h"
#include "queue.h"
#define NUM_MCS 28
......
......@@ -5129,13 +5129,20 @@ void *rrc_control_socket_thread_fct(void *arg) {
LOG_I(RRC,"Listening to incoming connection from ProSe App \n");
// receive a message from ProSe App
memset(receive_buf, 0, BUFSIZE);
n = recvfrom(ctrl_sock_fd, receive_buf, BUFSIZE, 0,
n = recvfrom(ctrl_sock_fd, receive_buf, BUFSIZE, MSG_TRUNC,
(struct sockaddr *) &prose_app_addr, (socklen_t *)&prose_addr_len);
if (n < 0) {
LOG_E(RRC, "ERROR: Failed to receive from ProSe App\n");
exit(EXIT_FAILURE);
}
if (n == 0) {
LOG_E(RRC, "%s(%d). EOF for ctrl_sock_fd\n", __FUNCTION__, __LINE__);
}
if (n > BUFSIZE) {
LOG_E(RRC, "%s(%d). Message truncated. %d\n", __FUNCTION__, __LINE__, n);
exit(EXIT_FAILURE);
}
//TODO: should store the address of ProSeApp [UE_rrc_inst] to be able to send UE state notification to the App
//sl_ctrl_msg_recv = (struct sidelink_ctrl_element *) receive_buf;
......
......@@ -409,10 +409,14 @@ static int socket_udp_receive(int socket_fd, void *buf, int size)
socklen_t slen = sizeof(client);
int l;
l = recvfrom(socket_fd, buf, size, 0, (struct sockaddr *) &client, &slen);
l = recvfrom(socket_fd, buf, size, MSG_TRUNC, (struct sockaddr *) &client, &slen);
//getsockname(socket_fd, (struct sockaddr *)&client, &slen);
if (l == -1) goto error;
if (l == 0) goto socket_closed;
if (l > size) {
LOG_E(MAC, "%s(%d). Message truncated. %d\n", __FUNCTION__, __LINE__, l);
return -1;
}
return l;
......
......@@ -221,7 +221,7 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req(
* - END-MARKER
*/
case NW_GTPV1U_ULP_API_RECV_TPDU: {
uint8_t buffer[4096];
uint8_t buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE];
uint32_t buffer_len;
struct rrc_eNB_ue_context_s *ue_context_p;
uint16_t msgType = NW_GTP_GPDU;
......
......@@ -29,6 +29,7 @@
#include "hashtable.h"
#include "LTE_asn_constant.h"
#include "nfapi/open-nFAPI/pnf/inc/pnf_p7.h"
#ifndef GTPV1U_ENB_DEFS_H_
#define GTPV1U_ENB_DEFS_H_
......
......@@ -235,7 +235,7 @@ udp_eNB_send_to(
void udp_eNB_receiver(struct udp_socket_desc_s *udp_sock_pP)
{
uint8_t l_buffer[2048];
uint8_t l_buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE];
int n;
socklen_t from_len;
struct sockaddr_in addr;
......@@ -246,10 +246,13 @@ void udp_eNB_receiver(struct udp_socket_desc_s *udp_sock_pP)
if (1) {
from_len = (socklen_t)sizeof(struct sockaddr_in);
if ((n = recvfrom(udp_sock_pP->sd, l_buffer, sizeof(l_buffer), 0,
if ((n = recvfrom(udp_sock_pP->sd, l_buffer, sizeof(l_buffer), MSG_TRUNC,
(struct sockaddr *)&addr, &from_len)) < 0) {
LOG_E(UDP_, "Recvfrom failed %s\n", strerror(errno));
return;
} else if (n > sizeof(l_buffer)) {
LOG_E(UDP_, "%s(%d). Message truncated. %d\n", __FUNCTION__, __LINE__, n);
return;
} else if (n == 0) {
LOG_W(UDP_, "Recvfrom returned 0\n");
return;
......
......@@ -31,6 +31,7 @@
#ifndef UDP_ENB_TASK_H_
#define UDP_ENB_TASK_H_
#include "enb_config.h"
#include "nfapi/open-nFAPI/pnf/inc/pnf_p7.h"
/** \brief UDP recv callback prototype. Will be called every time a payload is
......
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