From bdc72c65c451eec5763c34b10e9df2e5dfcd9f55 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 20 Feb 2018 18:54:41 +0000 Subject: [PATCH] Adding print to debug TPC issue. --- srsepc/hdr/spgw/spgw.h | 4 ++++ srsepc/src/spgw/spgw.cc | 23 +++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/srsepc/hdr/spgw/spgw.h b/srsepc/hdr/spgw/spgw.h index 095b4d9b0..f39674ba7 100644 --- a/srsepc/hdr/spgw/spgw.h +++ b/srsepc/hdr/spgw/spgw.h @@ -117,6 +117,10 @@ private: uint32_t m_h_next_ue_ip; + /*Time*/ + struct timeval m_t_last_dl; + struct timeval m_t_last_ul; + /*Logs*/ srslte::log_filter *m_spgw_log; diff --git a/srsepc/src/spgw/spgw.cc b/srsepc/src/spgw/spgw.cc index add16b2c4..55f19818d 100644 --- a/srsepc/src/spgw/spgw.cc +++ b/srsepc/src/spgw/spgw.cc @@ -224,6 +224,9 @@ spgw::init_sgi_if(spgw_args_t *args) return srslte::ERROR_CANT_START; } + //Set initial time of setup + gettimeofday(&m_t_last_dl, NULL); + m_sgi_up = true; return(srslte::ERROR_NONE); } @@ -297,15 +300,11 @@ spgw::run_thread() if (FD_ISSET(m_s1u, &set)) { msg->N_bytes = recvfrom(m_s1u, msg->msg, SRSLTE_MAX_BUFFER_SIZE_BYTES, 0, &src_addr, &addrlen ); - //m_spgw_log->console("Received PDU from S1-U. Bytes %d\n", msg->N_bytes); - //m_spgw_log->debug("Received PDU from S1-U. Bytes %d\n", msg->N_bytes); handle_s1u_pdu(msg); } if (FD_ISSET(m_sgi_if, &set)) { msg->N_bytes = read(sgi, msg->msg, SRSLTE_MAX_BUFFER_SIZE_BYTES); - //m_spgw_log->console("Received PDU from SGi. Bytes %d\n", msg->N_bytes); - //m_spgw_log->debug("Received PDU from SGi. Bytes %d\n", msg->N_bytes); handle_sgi_pdu(msg); } } @@ -328,6 +327,8 @@ spgw::handle_sgi_pdu(srslte::byte_buffer_t *msg) bool ip_found = false; srslte::gtpc_f_teid_ie enb_fteid; + struct timeval t_now, t_delta; + version = msg->msg[0]>>4; ((uint8_t*)&dest_ip)[0] = msg->msg[16]; ((uint8_t*)&dest_ip)[1] = msg->msg[17]; @@ -380,8 +381,18 @@ spgw::handle_sgi_pdu(srslte::byte_buffer_t *msg) m_spgw_log->error("Error sending packet to eNB\n"); return; } - //m_spgw_log->console("Sent packet to %s:%d. Bytes=%d/%d\n",inet_ntoa(enb_addr.sin_addr), GTPU_RX_PORT,n,msg->N_bytes); - + else if((unsigned int) n!=msg->N_bytes) + { + m_spgw_log->error("Mis-match between packet bytes and sent bytes: Sent: %d, Packet: %d \n",n,msg->N_bytes); + } + t_delta.tv_sec = t_now.tv_sec - m_t_last_dl.tv_sec; + t_delta.tv_usec = t_now.tv_sec - m_t_last_dl.tv_usec; + gettimeofday(&t_now, NULL); + if(t_delta.tv_sec>=5) + { + m_t_last_dl = t_now; + m_spgw_log->console("Sent %d bytes DL over the last %d.%d seconds. Bitrate = \n",msg->N_bytes, t_delta.tv_sec, t_delta.tv_usec/1000); + } return; }