Commit f55e1d98 authored by Cedric Roux's avatar Cedric Roux

- Added support reliable link for ethernet transport

Note: this new feature is not compiled (and therefore not used) if libpgm-dev is not installed

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4011 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent f0cf6ab6
......@@ -5,4 +5,4 @@ ETHERNET_TRANSPORT_OBJS += $(TOP_DIR)/SIMULATION/ETH_TRANSPORT/multicast_link.o
ETHERNET_TRANSPORT_OBJS += $(TOP_DIR)/SIMULATION/ETH_TRANSPORT/socket.o
ETHERNET_TRANSPORT_OBJS += $(TOP_DIR)/SIMULATION/ETH_TRANSPORT/bypass_session_layer.o
ETHERNET_TRANSPORT_OBJS += $(TOP_DIR)/SIMULATION/ETH_TRANSPORT/emu_transport.o
ETHERNET_TRANSPORT_OBJS += $(TOP_DIR)/SIMULATION/ETH_TRANSPORT/pgm_link.o
......@@ -18,11 +18,12 @@
#include "UTIL/LOG/log.h"
#ifdef USER_MODE
#include "multicast_link.h"
# include "multicast_link.h"
# include "pgm_link.h"
#endif
char rx_bufferP[BYPASS_RX_BUFFER_SIZE];
static unsigned int num_bytesP = 0;
unsigned int num_bytesP = 0;
int N_P = 0, N_R = 0;
char bypass_tx_buffer[BYPASS_TX_BUFFER_SIZE];
static unsigned int byte_tx_count;
......@@ -42,6 +43,7 @@ mapping transport_names[] = {
void init_bypass (void)
{
LOG_I(EMU, "[PHYSIM] INIT BYPASS\n");
#if !defined(ENABLE_NEW_MULTICAST)
pthread_mutex_init (&Tx_mutex, NULL);
pthread_cond_init (&Tx_cond, NULL);
......@@ -49,6 +51,9 @@ void init_bypass (void)
pthread_mutex_init (&emul_low_mutex, NULL);
pthread_cond_init (&emul_low_cond, NULL);
emul_low_mutex_var = 1;
#endif
#if defined(ENABLE_PGM_TRANSPORT)
pgm_oai_init(oai_emulation.info.multicast_ifname);
#endif
bypass_init (emul_tx_handler, emul_rx_handler);
}
......@@ -68,89 +73,21 @@ void bypass_init (tx_handler_t tx_handlerP, rx_handler_t rx_handlerP)
emu_rx_status = WAIT_SYNC_TRANSPORT;
}
int bypass_rx_data(unsigned int frame, unsigned int last_slot,
unsigned int next_slot, uint8_t is_master)
int emu_transport_handle_sync(bypass_msg_header_t *messg)
{
bypass_msg_header_t *messg;
bypass_proto2multicast_header_t *bypass_read_header;
eNB_transport_info_t *eNB_info;
UE_transport_info_t *UE_info;
int ue_info_ix, enb_info_ix;
int bytes_read = 0;
int bytes_data_to_read;
int m_id, n_enb, n_ue, n_dci, total_tbs = 0, total_header = 0;
LOG_D(EMU, "Entering bypass_rx for frame %d next_slot %d is_master %u\n",
frame, next_slot, is_master);
#if defined(ENABLE_NEW_MULTICAST)
if (multicast_link_read_data_from_sock(is_master) == 1) {
/* We got a timeout */
return -1;
}
#else
pthread_mutex_lock(&emul_low_mutex);
if(emul_low_mutex_var) {
pthread_cond_wait(&emul_low_cond, &emul_low_mutex);
}
if(num_bytesP==0) {
pthread_mutex_unlock(&emul_low_mutex);
} else {
#endif
bypass_read_header = (bypass_proto2multicast_header_t *) (
&rx_bufferP[bytes_read]);
bytes_read += sizeof (bypass_proto2multicast_header_t);
bytes_data_to_read = bypass_read_header->size;
if(num_bytesP!=bytes_read+bytes_data_to_read) {
LOG_W(EMU, "WARNINIG BYTES2READ # DELIVERED BYTES!!!\n");
} else {
messg = (bypass_msg_header_t *) (&rx_bufferP[bytes_read]);
bytes_read += sizeof (bypass_msg_header_t);
#if defined(ENABLE_NEW_MULTICAST)
LOG_D(EMU, "Received %d bytes [%s] from master_id %d with seq %"PRIuMAX"\n",
num_bytesP, map_int_to_str(transport_names, messg->Message_type),
messg->master_id,
messg->seq_num);
DevCheck4((messg->frame == frame) && (messg->subframe == (next_slot>>1)),
messg->frame, frame, messg->subframe, next_slot>>1);
#else
if ((messg->frame != frame) || (messg->subframe != next_slot>>1))
LOG_W(EMU,
"Received %s from master %d for (frame %d,subframe %d) "
"currently (frame %d,subframe %d)\n",
map_int_to_str(transport_names,messg->Message_type),
messg->master_id,
messg->frame, messg->subframe,
frame, next_slot>>1);
#endif
//chek if MASTER in my List
// switch(Emulation_status){
switch(messg->Message_type) {
//case WAIT_SYNC_TRANSPORT:
case EMU_TRANSPORT_INFO_WAIT_PM:
if (messg->master_id==0 ) {
Master_list_rx=((Master_list_rx) |(1<< messg->master_id));
}
break;
case EMU_TRANSPORT_INFO_WAIT_SM:
Master_list_rx=((Master_list_rx) |(1<< messg->master_id));
break;
case EMU_TRANSPORT_INFO_SYNC:
int m_id;
// determite the total number of remote enb & ue
oai_emulation.info.nb_enb_remote += messg->nb_enb;
oai_emulation.info.nb_ue_remote += messg->nb_ue;
// determine the index of local enb and ue wrt the remote ones
if ( messg->master_id < oai_emulation.info.master_id ) {
if (messg->master_id < oai_emulation.info.master_id) {
oai_emulation.info.first_enb_local +=messg->nb_enb;
oai_emulation.info.first_ue_local +=messg->nb_ue;
}
// store param for enb per master
if ((oai_emulation.info.master[messg->master_id].nb_enb = messg->nb_enb) > 0 ) {
if ((oai_emulation.info.master[messg->master_id].nb_enb = messg->nb_enb) > 0) {
for (m_id=0; m_id < messg->master_id; m_id++ ) {
oai_emulation.info.master[messg->master_id].first_enb+=oai_emulation.info.master[m_id].nb_enb;
}
......@@ -166,7 +103,7 @@ int bypass_rx_data(unsigned int frame, unsigned int last_slot,
oai_emulation.info.master[messg->master_id].first_ue+=oai_emulation.info.master[m_id].nb_ue;
}
LOG_I(EMU,
"[UE]WAIT_SYNC_TRANSPORT state: for master %d (first ue %d, total ue%d)\n",
"[UE] WAIT_SYNC_TRANSPORT state: for master %d (first ue %d, total ue%d)\n",
messg->master_id,
oai_emulation.info.master[messg->master_id].first_ue,
oai_emulation.info.master[messg->master_id].nb_ue );
......@@ -176,14 +113,38 @@ int bypass_rx_data(unsigned int frame, unsigned int last_slot,
if (Master_list_rx == oai_emulation.info.master_list) {
emu_rx_status = SYNCED_TRANSPORT;
}
LOG_I(EMU,
"WAIT_SYNC_TRANSPORT state: m_id %d total enb remote %d total ue remote %d \n",
messg->master_id,oai_emulation.info.nb_enb_remote,
oai_emulation.info.nb_ue_remote );
break;
return 0;
}
//case WAIT_ENB_TRANSPORT:
case EMU_TRANSPORT_INFO_ENB:
int emu_transport_handle_wait_sm(bypass_msg_header_t *messg)
{
Master_list_rx = ((Master_list_rx) | (1 << messg->master_id));
return 0;
}
int emu_transport_handle_wait_pm(bypass_msg_header_t *messg)
{
if (messg->master_id == 0) {
Master_list_rx = ((Master_list_rx) | (1 << messg->master_id));
}
return 0;
}
static
int emu_transport_handle_enb_info(bypass_msg_header_t *messg,
unsigned int next_slot,
int bytes_read)
{
eNB_transport_info_t *eNB_info;
int total_header = 0, total_tbs = 0;
int n_dci, n_enb;
#ifdef DEBUG_EMU
LOG_D(EMU," RX ENB_TRANSPORT INFO from master %d \n",messg->master_id);
#endif
......@@ -191,37 +152,33 @@ int bypass_rx_data(unsigned int frame, unsigned int last_slot,
oai_emulation.info.nb_enb_remote);
if (oai_emulation.info.master[messg->master_id].nb_enb > 0 ) {
enb_info_ix =0;
total_header=0;
total_header += sizeof(eNB_transport_info_t)-MAX_TRANSPORT_BLOCKS_BUFFER_SIZE;
eNB_info = (eNB_transport_info_t *) (&rx_bufferP[bytes_read]);
for (n_enb = oai_emulation.info.master[messg->master_id].first_enb;
n_enb < oai_emulation.info.master[messg->master_id].first_enb+
oai_emulation.info.master[messg->master_id].nb_enb ;
n_enb ++) {
total_tbs=0;
for (n_dci = 0 ;
n_dci < (eNB_info[enb_info_ix].num_ue_spec_dci+
eNB_info[enb_info_ix].num_common_dci);
n_dci ++) {
total_tbs+=eNB_info[enb_info_ix].tbs[n_dci];
}
enb_info_ix++;
if ( (total_tbs + total_header) > MAX_TRANSPORT_BLOCKS_BUFFER_SIZE ) {
oai_emulation.info.master[messg->master_id].nb_enb;
n_enb ++)
{
for (n_dci = 0; n_dci < (eNB_info->num_ue_spec_dci + eNB_info->num_common_dci); n_dci ++) {
total_tbs += eNB_info->tbs[n_dci];
}
if ((total_tbs + total_header) > MAX_TRANSPORT_BLOCKS_BUFFER_SIZE ) {
LOG_W(EMU,"RX eNB Transport buffer total size %d (header%d,tbs %d) \n",
total_header+total_tbs, total_header,total_tbs);
}
memcpy (&eNB_transport_info[n_enb],eNB_info, total_header+total_tbs);
eNB_info = (eNB_transport_info_t *)((unsigned int)eNB_info + total_header+
total_tbs);
bytes_read+=total_header+total_tbs;
memcpy (&eNB_transport_info[n_enb],eNB_info, total_header + total_tbs);
/* Go to the next eNB info */
eNB_info += (total_header + total_tbs);
bytes_read += (total_header + total_tbs);
}
for (n_enb = oai_emulation.info.master[messg->master_id].first_enb;
n_enb < oai_emulation.info.master[messg->master_id].first_enb+
oai_emulation.info.master[messg->master_id].nb_enb ;
n_enb ++) {
n_enb < oai_emulation.info.master[messg->master_id].first_enb +
oai_emulation.info.master[messg->master_id].nb_enb; n_enb ++) {
fill_phy_enb_vars(n_enb, next_slot);
}
} else {
......@@ -233,54 +190,53 @@ int bypass_rx_data(unsigned int frame, unsigned int last_slot,
if (Master_list_rx == oai_emulation.info.master_list) {
emu_rx_status = SYNCED_TRANSPORT;
}
break;
case EMU_TRANSPORT_INFO_UE:
return 0;
}
static
int emu_transport_handle_ue_info(bypass_msg_header_t *messg,
unsigned int last_slot,
int bytes_read)
{
UE_transport_info_t *UE_info;
int n_ue, n_enb;
int total_tbs = 0, total_header = 0;
#ifdef DEBUG_EMU
LOG_D(EMU," RX UE TRANSPORT INFO from master %d\n",messg->master_id);
#endif
clear_UE_transport_info(oai_emulation.info.nb_ue_local+
oai_emulation.info.nb_ue_remote);
if (oai_emulation.info.master[messg->master_id].nb_ue >
0 ) { //&& oai_emulation.info.nb_enb_local >0 ){
// get the header first
ue_info_ix =0;
total_header=0;
if (oai_emulation.info.master[messg->master_id].nb_ue > 0 ) {
total_header += sizeof(UE_transport_info_t)-MAX_TRANSPORT_BLOCKS_BUFFER_SIZE;
UE_info = (UE_transport_info_t *) (&rx_bufferP[bytes_read]);
// get the total size of the transport blocks
for (n_ue = oai_emulation.info.master[messg->master_id].first_ue;
n_ue < oai_emulation.info.master[messg->master_id].first_ue+
oai_emulation.info.master[messg->master_id].nb_ue ;
n_ue ++) {
total_tbs=0;
for (n_enb = 0; n_enb < UE_info[ue_info_ix].num_eNB; n_enb ++) {
total_tbs+=UE_info[ue_info_ix].tbs[n_enb];
n_ue < oai_emulation.info.master[messg->master_id].first_ue +
oai_emulation.info.master[messg->master_id].nb_ue; n_ue ++) {
total_tbs = 0;
for (n_enb = 0; n_enb < UE_info->num_eNB; n_enb ++) {
total_tbs += UE_info->tbs[n_enb];
}
ue_info_ix++;
if (total_tbs + total_header > MAX_TRANSPORT_BLOCKS_BUFFER_SIZE ) {
LOG_W(EMU,"RX [UE %d] Total size of buffer is %d (header%d,tbs %d) \n",
n_ue, total_header+total_tbs,total_header,total_tbs);
}
memcpy (&UE_transport_info[n_ue], UE_info, total_header+total_tbs);
UE_info = (UE_transport_info_t *)((unsigned int)UE_info + total_header+
total_tbs);
bytes_read+=total_header+total_tbs;
memcpy (&UE_transport_info[n_ue], UE_info, total_header + total_tbs);
/* Go to the next UE info */
UE_info += (total_header + total_tbs);
bytes_read += (total_header + total_tbs);
}
#ifdef DEBUG_EMU
for (n_enb=0; n_enb < UE_info[0].num_eNB; n_enb ++ )
LOG_T(EMU,"dump ue transport info rnti %x enb_id %d, harq_id %d tbs %d\n",
UE_transport_info[0].rnti[n_enb],
UE_transport_info[0].eNB_id[n_enb],
UE_transport_info[0].harq_pid[n_enb],
UE_transport_info[0].tbs[n_enb]);
#endif
for (n_ue = oai_emulation.info.master[messg->master_id].first_ue;
n_ue < oai_emulation.info.master[messg->master_id].first_ue +
oai_emulation.info.master[messg->master_id].nb_ue ;
n_ue ++) {
fill_phy_ue_vars(n_ue,last_slot);
oai_emulation.info.master[messg->master_id].nb_ue; n_ue ++) {
fill_phy_ue_vars(n_ue, last_slot);
}
} else {
LOG_T(EMU,"WAIT_UE_TRANSPORT state: no UE transport info from master %d\n",
......@@ -291,6 +247,85 @@ int bypass_rx_data(unsigned int frame, unsigned int last_slot,
if (Master_list_rx == oai_emulation.info.master_list) {
emu_rx_status = SYNCED_TRANSPORT;
}
return 0;
}
int bypass_rx_data(unsigned int frame, unsigned int last_slot,
unsigned int next_slot, uint8_t is_master)
{
bypass_msg_header_t *messg;
bypass_proto2multicast_header_t *bypass_read_header;
int bytes_read = 0;
LOG_D(EMU, "Entering bypass_rx for frame %d next_slot %d is_master %u\n",
frame, next_slot, is_master);
#if defined(ENABLE_NEW_MULTICAST)
# if defined(ENABLE_PGM_TRANSPORT)
num_bytesP = pgm_recv_msg(oai_emulation.info.multicast_group,
(uint8_t *)&rx_bufferP[0], sizeof(rx_bufferP));
DevCheck(num_bytesP > 0, num_bytesP, 0, 0);
# else
if (multicast_link_read_data_from_sock(is_master) == 1) {
/* We got a timeout */
return -1;
}
# endif
#else
pthread_mutex_lock(&emul_low_mutex);
if(emul_low_mutex_var) {
pthread_cond_wait(&emul_low_cond, &emul_low_mutex);
}
if(num_bytesP==0) {
pthread_mutex_unlock(&emul_low_mutex);
} else {
#endif
bypass_read_header = (bypass_proto2multicast_header_t *) (
&rx_bufferP[bytes_read]);
bytes_read += sizeof (bypass_proto2multicast_header_t);
if (num_bytesP != bytes_read + bypass_read_header->size) {
LOG_W(EMU, "WARNINIG BYTES2READ # DELIVERED BYTES!!! (%d != %d)\n",
num_bytesP, bytes_read + bypass_read_header->size);
exit(EXIT_FAILURE);
} else {
messg = (bypass_msg_header_t *) (&rx_bufferP[bytes_read]);
bytes_read += sizeof (bypass_msg_header_t);
#if defined(ENABLE_NEW_MULTICAST)
LOG_D(EMU, "Received %d bytes [%s] from master_id %d with seq %"PRIuMAX"\n",
num_bytesP, map_int_to_str(transport_names, messg->Message_type),
messg->master_id,
messg->seq_num);
DevCheck4((messg->frame == frame) && (messg->subframe == (next_slot>>1)),
messg->frame, frame, messg->subframe, next_slot>>1);
#else
if ((messg->frame != frame) || (messg->subframe != next_slot>>1))
LOG_W(EMU,
"Received %s from master %d for (frame %d,subframe %d) "
"currently (frame %d,subframe %d)\n",
map_int_to_str(transport_names,messg->Message_type),
messg->master_id,
messg->frame, messg->subframe,
frame, next_slot>>1);
#endif
//chek if MASTER in my List
switch(messg->Message_type) {
case EMU_TRANSPORT_INFO_WAIT_PM:
emu_transport_handle_wait_pm(messg);
break;
case EMU_TRANSPORT_INFO_WAIT_SM:
emu_transport_handle_wait_sm(messg);
break;
case EMU_TRANSPORT_INFO_SYNC:
emu_transport_handle_sync(messg);
break;
case EMU_TRANSPORT_INFO_ENB:
emu_transport_handle_enb_info(messg, next_slot, bytes_read);
break;
case EMU_TRANSPORT_INFO_UE:
emu_transport_handle_ue_info(messg, last_slot, bytes_read);
break;
case EMU_TRANSPORT_INFO_RELEASE :
Master_list_rx = oai_emulation.info.master_list;
......@@ -311,7 +346,7 @@ int bypass_rx_data(unsigned int frame, unsigned int last_slot,
pthread_cond_signal(&emul_low_cond);
pthread_mutex_unlock(&emul_low_mutex);
#endif
bypass_signal_mac_phy(frame,last_slot, next_slot, is_master);
bypass_signal_mac_phy(frame, last_slot, next_slot, is_master);
#if !defined(ENABLE_NEW_MULTICAST)
}
#endif
......@@ -376,14 +411,14 @@ void bypass_signal_mac_phy(unsigned int frame, unsigned int last_slot,
unsigned int next_slot, uint8_t is_master)
{
/******************************************************************************************************/
if(Master_list_rx != oai_emulation.info.master_list) {
if (Master_list_rx != oai_emulation.info.master_list) {
#ifndef USER_MODE
rtf_put(fifo_mac_bypass, &tt, 1);
/* the Rx window is still opened (Re)signal bypass_phy (emulate MAC signal) */
#endif
bypass_rx_data(frame, last_slot, next_slot, is_master);
} else {
Master_list_rx=0;
Master_list_rx = 0;
}
}
......@@ -467,14 +502,13 @@ void bypass_tx_data(emu_transport_info_t Type, unsigned int frame, unsigned int
n_enb<(oai_emulation.info.first_enb_local+oai_emulation.info.nb_enb_local);
n_enb++) {
total_tbs=0;
for (n_dci =0 ;
n_dci < (eNB_transport_info[n_enb].num_ue_spec_dci+
for (n_dci = 0; n_dci < (eNB_transport_info[n_enb].num_ue_spec_dci +
eNB_transport_info[n_enb].num_common_dci);
n_dci++) {
total_tbs +=eNB_transport_info[n_enb].tbs[n_dci];
}
if (total_tbs <= MAX_TRANSPORT_BLOCKS_BUFFER_SIZE) {
total_size = sizeof(eNB_transport_info_t)+total_tbs-
total_size = sizeof(eNB_transport_info_t) + total_tbs -
MAX_TRANSPORT_BLOCKS_BUFFER_SIZE;
} else {
LOG_E(EMU,
......@@ -483,7 +517,7 @@ void bypass_tx_data(emu_transport_info_t Type, unsigned int frame, unsigned int
}
memcpy(&bypass_tx_buffer[byte_tx_count], (char *)&eNB_transport_info[n_enb],
total_size);
byte_tx_count +=total_size;
byte_tx_count += total_size;
}
} else if (Type == UE_TRANSPORT) {
LOG_D(EMU,"[TX_DATA] UE TRANSPORT\n");
......@@ -506,7 +540,7 @@ void bypass_tx_data(emu_transport_info_t Type, unsigned int frame, unsigned int
}
memcpy(&bypass_tx_buffer[byte_tx_count], (char *)&UE_transport_info[n_ue],
total_size);
byte_tx_count +=total_size;
byte_tx_count += total_size;
}
} else if (Type == RELEASE_TRANSPORT) {
messg->Message_type = EMU_TRANSPORT_INFO_RELEASE;
......@@ -517,8 +551,13 @@ void bypass_tx_data(emu_transport_info_t Type, unsigned int frame, unsigned int
((bypass_proto2multicast_header_t *) bypass_tx_buffer)->size = byte_tx_count -
sizeof (bypass_proto2multicast_header_t);
multicast_link_write_sock (oai_emulation.info.multicast_group,
#if defined(ENABLE_PGM_TRANSPORT)
pgm_link_send_msg(oai_emulation.info.multicast_group,
(uint8_t *)bypass_tx_buffer, byte_tx_count);
#else
multicast_link_write_sock(oai_emulation.info.multicast_group,
bypass_tx_buffer, byte_tx_count);
#endif
LOG_D(EMU, "Sent %d bytes [%s] with master_id %d and seq %"PRIuMAX"\n",
byte_tx_count, map_int_to_str(transport_names, Type),
......
......@@ -18,6 +18,8 @@
#include "UTIL/LOG/log.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
#include "pgm_link.h"
extern unsigned int Master_list_rx;
extern unsigned char NB_INST;
......@@ -29,6 +31,29 @@ void emu_transport_sync(void)
LOG_D(EMU, "Entering EMU transport SYNC is primary master %d\n",
oai_emulation.info.is_primary_master);
#if defined(ENABLE_PGM_TRANSPORT)
if (oai_emulation.info.is_primary_master == 0) {
bypass_tx_data(WAIT_SM_TRANSPORT,0,0);
// just wait to recieve the master 0 msg
Master_list_rx = oai_emulation.info.master_list - 1;
bypass_rx_data(0,0,0,1);
} else {
bypass_rx_data(0,0,0,0);
bypass_tx_data(WAIT_PM_TRANSPORT,0,0);
}
if (oai_emulation.info.master_list != 0) {
bypass_tx_data(SYNC_TRANSPORT,0,0);
bypass_rx_data(0,0,0,0);
// i received the sync from all secondary masters
if (emu_rx_status == SYNCED_TRANSPORT) {
emu_tx_status = SYNCED_TRANSPORT;
}
LOG_D(EMU,"TX secondary master SYNC_TRANSPORT state \n");
}
#else
if (oai_emulation.info.is_primary_master == 0) {
retry:
bypass_tx_data(WAIT_SM_TRANSPORT,0,0);
......@@ -58,6 +83,7 @@ retry2:
LOG_D(EMU,"TX secondary master SYNC_TRANSPORT state \n");
}
#endif
LOG_D(EMU, "Leaving EMU transport SYNC is primary master %d\n",
oai_emulation.info.is_primary_master);
}
......@@ -102,26 +128,15 @@ void emu_transport_DL(unsigned int frame, unsigned int last_slot,
{
LOG_D(EMU, "Entering EMU transport DL, is primary master %d\n",
oai_emulation.info.is_primary_master);
if (oai_emulation.info.is_primary_master==0) {
// bypass_rx_data(last_slot);
if (oai_emulation.info.nb_enb_local>0) { // send in DL if
bypass_tx_data(ENB_TRANSPORT,frame, next_slot);
bypass_tx_data(ENB_TRANSPORT, frame, next_slot);
bypass_rx_data(frame, last_slot, next_slot, 1);
} else {
bypass_tx_data(WAIT_SM_TRANSPORT,frame,next_slot);
bypass_rx_data(frame, last_slot, next_slot, 0);
}
} else { // I am the master
// bypass_tx_data(WAIT_TRANSPORT,last_slot);
if (oai_emulation.info.nb_enb_local>0) { // send in DL if
bypass_tx_data(ENB_TRANSPORT,frame, next_slot);
bypass_rx_data(frame,last_slot, next_slot, 1);
} else {
bypass_tx_data(WAIT_SM_TRANSPORT,frame, next_slot);
bypass_rx_data(frame,last_slot, next_slot, 0);
}
}
LOG_D(EMU, "Leaving EMU transport DL, is primary master %d\n",
oai_emulation.info.is_primary_master);
}
......@@ -131,25 +146,15 @@ void emu_transport_UL(unsigned int frame, unsigned int last_slot,
{
LOG_D(EMU, "Entering EMU transport UL, is primary master %d\n",
oai_emulation.info.is_primary_master);
if (oai_emulation.info.is_primary_master==0) {
// bypass_rx_data(last_slot, next_slot);
if (oai_emulation.info.nb_ue_local>0) {
bypass_tx_data(UE_TRANSPORT, frame, next_slot);
bypass_rx_data(frame,last_slot, next_slot, 1);
bypass_rx_data(frame, last_slot, next_slot, 1);
} else {
bypass_tx_data(WAIT_SM_TRANSPORT, frame, next_slot);
bypass_rx_data(frame,last_slot, next_slot, 0);
}
} else {
// bypass_tx_data(WAIT_TRANSPORT,last_slot);
if (oai_emulation.info.nb_ue_local>0) {
bypass_tx_data(UE_TRANSPORT,frame, next_slot);
bypass_rx_data(frame,last_slot, next_slot, 1);
} else {
bypass_tx_data(WAIT_SM_TRANSPORT,frame, next_slot);
bypass_rx_data(frame,last_slot, next_slot, 0);
}
}
LOG_D(EMU, "Leaving EMU transport UL, is primary master %d\n",
oai_emulation.info.is_primary_master);
}
......
......@@ -39,9 +39,7 @@
extern unsigned short Master_id;
#define MULTICAST_LINK_NUM_GROUPS 4
char *multicast_group_list[MULTICAST_LINK_NUM_GROUPS] = {
const char *multicast_group_list[MULTICAST_LINK_NUM_GROUPS] = {
"239.0.0.161",
"239.0.0.162",
"239.0.0.163",
......@@ -63,7 +61,7 @@ static char *multicast_if;
//------------------------------------------------------------------------------
void
multicast_link_init ()
multicast_link_init(void)
{
//------------------------------------------------------------------------------
int group;
......@@ -103,7 +101,7 @@ multicast_link_init ()
}
}
#if !defined(ENABLE_TCP_MULTICAST)
#if !defined(ENABLE_NEW_MULTICAST)
/* Make the socket blocking */
socket_setnonblocking(group_list[group].socket);
#endif
......@@ -211,7 +209,7 @@ multicast_link_read ()
//------------------------------------------------------------------------------
int
multicast_link_write_sock (int groupP, char *dataP, uint32_t sizeP)
multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP)
{
//------------------------------------------------------------------------------
int num;
......@@ -231,7 +229,7 @@ int multicast_link_read_data_from_sock(uint8_t is_master)
int readsocks; /* Number of sockets ready for reading */
timeout.tv_sec = 0;
timeout.tv_usec = 3000;
timeout.tv_usec = 15000;
if (is_master == 0) {
/* UE will block indefinetely if no data is sent from eNB
......@@ -285,8 +283,9 @@ void multicast_link_start(void (*rx_handlerP) (unsigned int, char *),
LOG_I(EMU, "[MULTICAST] LINK START on interface=%s for group=%d: handler=%p\n",
(multicast_if == NULL) ? "not specified" : multicast_if, multicast_group,
rx_handler);
#if !defined(ENABLE_PGM_TRANSPORT)
multicast_link_init ();
#endif
#if ! defined(ENABLE_NEW_MULTICAST)
LOG_D(EMU, "[MULTICAST] multicast link start thread\n");
if (pthread_create (&main_loop_thread, NULL, multicast_link_main_loop,
......
......@@ -26,6 +26,10 @@ private_multicast_link (typedef struct multicast_group_t {
char rx_buffer[40000];
} multicast_group_t;)
#define MULTICAST_LINK_NUM_GROUPS 4
extern const char *multicast_group_list[MULTICAST_LINK_NUM_GROUPS];
private_multicast_link(void multicast_link_init ());
private_multicast_link(void multicast_link_read_data (int groupP));
private_multicast_link(void multicast_link_read ());
......
#include <pthread.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <arpa/inet.h>
#if defined(ENABLE_PGM_TRANSPORT)
#include <pgm/pgm.h>
#include "UTIL/assertions.h"
#include "multicast_link.h"
#include "UTIL/OCG/OCG.h"
#include "UTIL/OCG/OCG_extern.h"
#include "UTIL/LOG/log.h"
typedef struct {
pgm_sock_t *sock;
uint16_t port;
uint8_t rx_buffer[40000];
} pgm_multicast_group_t;
pgm_multicast_group_t pgm_multicast_group[MULTICAST_LINK_NUM_GROUPS];
static
int pgm_create_socket(int index, const char *if_addr);
#if defined(ENABLE_PGM_DEBUG)
static void
log_handler (
const int log_level,
const char* message,
void* closure
)
{
printf("%s\n", message);
}
#endif
int pgm_oai_init(char *if_name)
{
pgm_error_t* pgm_err = NULL;
memset(pgm_multicast_group, 0,
MULTICAST_LINK_NUM_GROUPS * sizeof(pgm_multicast_group_t));
#if defined(ENABLE_PGM_DEBUG)
pgm_messages_init();
pgm_min_log_level = PGM_LOG_LEVEL_DEBUG;
pgm_log_mask = 0xFFF;
pgm_log_set_handler(log_handler, NULL);
#endif
if (!pgm_init(&pgm_err)) {
LOG_E(EMU, "Unable to start PGM engine: %s\n", pgm_err->message);
pgm_error_free (pgm_err);
exit(EXIT_FAILURE);
}
return pgm_create_socket(oai_emulation.info.multicast_group, if_name);
}
int pgm_recv_msg(int group, uint8_t *buffer, uint32_t length)
{
size_t num_bytes = 0;
int status = 0;
pgm_error_t* pgm_err = NULL;
struct pgm_sockaddr_t from;
socklen_t fromlen = sizeof(from);
DevCheck((group <= MULTICAST_LINK_NUM_GROUPS) && (group >= 0),
group, MULTICAST_LINK_NUM_GROUPS, 0);
LOG_I(EMU, "[PGM] Entering recv function for group %d\n", group);
status = pgm_recvfrom(pgm_multicast_group[group].sock,
buffer,
length,
0,
&num_bytes,
&from,
&fromlen,
&pgm_err);
if (PGM_IO_STATUS_NORMAL == status) {
LOG_D(EMU, "[PGM] Received %d bytes for group %d\n", num_bytes, group);
return num_bytes;
} else {
if (pgm_err) {
LOG_E(EMU, "[PGM] recvform failed: %s", pgm_err->message);
pgm_error_free (pgm_err);
pgm_err = NULL;
}
}
return -1;
}
int pgm_link_send_msg(int group, uint8_t *data, uint32_t len)
{
int status;
size_t bytes_written = 0;
status = pgm_send(pgm_multicast_group[group].sock, data, len, &bytes_written);
if (status != PGM_IO_STATUS_NORMAL) {
return -1;
}
return bytes_written;
}
static
int pgm_create_socket(int index, const char *if_addr)
{
struct pgm_addrinfo_t* res = NULL;
pgm_error_t* pgm_err = NULL;
sa_family_t sa_family = AF_INET;
int udp_encap_port = 46014 + index;
int max_tpdu = 1500;
int sqns = 100;
int port;
struct pgm_sockaddr_t addr;
int blocking = 0;
int multicast_loop = 0;
int multicast_hops = 0;
int dscp, i;
port = udp_encap_port;
LOG_D(EMU, "[PGM] Preparing socket for group %d and address %s\n",
index, if_addr);
if (!pgm_getaddrinfo(if_addr, NULL, &res, &pgm_err)) {
LOG_E(EMU, "Parsing network parameter: %s\n", pgm_err->message);
goto err_abort;
}
if (udp_encap_port) {
LOG_I(EMU, "[PGM] Creating PGM/UDP socket for encapsulated port %d\n",
udp_encap_port);
if (!pgm_socket (&pgm_multicast_group[index].sock, sa_family,
SOCK_SEQPACKET, IPPROTO_UDP, &pgm_err)) {
LOG_E(EMU, "[PGM] Socket: %s\n", pgm_err->message);
goto err_abort;
}
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_UDP_ENCAP_UCAST_PORT, &udp_encap_port,
sizeof(udp_encap_port));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_UDP_ENCAP_MCAST_PORT, &udp_encap_port,
sizeof(udp_encap_port));
} else {
LOG_I(EMU, "[PGM] Creating PGM/IP socket\n");
if (!pgm_socket(&pgm_multicast_group[index].sock, sa_family,
SOCK_SEQPACKET, IPPROTO_PGM, &pgm_err)) {
LOG_E(EMU, "Creating PGM/IP socket: %s\n", pgm_err->message);
goto err_abort;
}
}
{
/* Use RFC 2113 tagging for PGM Router Assist */
const int no_router_assist = 0;
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_IP_ROUTER_ALERT, &no_router_assist,
sizeof(no_router_assist));
}
// pgm_drop_superuser();
{
/* set PGM parameters */
const int recv_only = 0,
passive = 0,
peer_expiry = pgm_secs (300),
spmr_expiry = pgm_msecs (250),
nak_bo_ivl = pgm_msecs (50),
nak_rpt_ivl = pgm_secs (2),
nak_rdata_ivl = pgm_secs (2),
nak_data_retries = 50,
nak_ncf_retries = 50,
ambient_spm = pgm_secs(30);
const int heartbeat_spm[] = {
pgm_msecs (100),
pgm_msecs (100),
pgm_msecs (100),
pgm_msecs (100),
pgm_msecs (1300),
pgm_secs (7),
pgm_secs (16),
pgm_secs (25),
pgm_secs (30)
};
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_RECV_ONLY, &recv_only, sizeof(recv_only));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_PASSIVE, &passive, sizeof(passive));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_MTU, &max_tpdu, sizeof(max_tpdu));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_RXW_SQNS, &sqns, sizeof(sqns));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_PEER_EXPIRY, &peer_expiry, sizeof(peer_expiry));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_SPMR_EXPIRY, &spmr_expiry, sizeof(spmr_expiry));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_NAK_BO_IVL, &nak_bo_ivl, sizeof(nak_bo_ivl));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_NAK_RPT_IVL, &nak_rpt_ivl, sizeof(nak_rpt_ivl));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_NAK_RDATA_IVL, &nak_rdata_ivl, sizeof(nak_rdata_ivl));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_NAK_DATA_RETRIES, &nak_data_retries, sizeof(nak_data_retries));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_NAK_NCF_RETRIES, &nak_ncf_retries, sizeof(nak_ncf_retries));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_AMBIENT_SPM, &ambient_spm, sizeof(ambient_spm));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_HEARTBEAT_SPM, &heartbeat_spm, sizeof(heartbeat_spm));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_TXW_SQNS, &sqns, sizeof(sqns));
}
/* create global session identifier */
memset (&addr, 0, sizeof(addr));
/* sa_port should be in host byte order */
addr.sa_port = port;
addr.sa_addr.sport = DEFAULT_DATA_SOURCE_PORT + index;
if (!pgm_gsi_create_from_hostname(&addr.sa_addr.gsi, &pgm_err)) {
LOG_E(EMU, "[PGM] Creating GSI: %s\n", pgm_err->message);
goto err_abort;
}
LOG_D(EMU, "[PGM] Created GSI %s\n", pgm_tsi_print(&addr.sa_addr));
/* assign socket to specified address */
{
struct pgm_interface_req_t if_req;
memset (&if_req, 0, sizeof(if_req));
if_req.ir_interface = res->ai_recv_addrs[0].gsr_interface;
if_req.ir_scope_id = 0;
if (AF_INET6 == sa_family) {
struct sockaddr_in6 sa6;
memcpy (&sa6, &res->ai_recv_addrs[0].gsr_group, sizeof(sa6));
if_req.ir_scope_id = sa6.sin6_scope_id;
}
if (!pgm_bind3(pgm_multicast_group[index].sock, &addr, sizeof(addr),
&if_req, sizeof(if_req), /* tx interface */
&if_req, sizeof(if_req), /* rx interface */
&pgm_err))
{
LOG_E(EMU, "[PGM] Error: %s\n", pgm_err->message);
goto err_abort;
}
}
/* join IP multicast groups */
{
struct group_req req;
struct sockaddr_in addr_in;
memset(&req, 0, sizeof(req));
/* Interface index */
req.gr_interface = res->ai_recv_addrs[0].gsr_interface;
addr_in.sin_family = AF_INET;
addr_in.sin_port = htons(port);
for (i = 0; i < MULTICAST_LINK_NUM_GROUPS; i++) {
addr_in.sin_addr.s_addr = inet_addr(multicast_group_list[i]);
memcpy(&req.gr_group, &addr_in, sizeof(addr_in));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_JOIN_GROUP, &req,
sizeof(struct group_req));
}
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_SEND_GROUP, &req,
sizeof(struct group_req));
}
/* set IP parameters */
multicast_hops = 64;
dscp = 0x2e << 2; /* Expedited Forwarding PHB for network elements, no ECN. */
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_MULTICAST_LOOP, &multicast_loop, sizeof(multicast_loop));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
PGM_MULTICAST_HOPS, &multicast_hops, sizeof(multicast_hops));
if (AF_INET6 != sa_family)
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, PGM_TOS,
&dscp, sizeof(dscp));
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, PGM_NOBLOCK,
&blocking, sizeof(blocking));
if (!pgm_connect(pgm_multicast_group[index].sock, &pgm_err)) {
LOG_E(EMU, "[PGM] Connecting socket: %s\n", pgm_err->message);
goto err_abort;
}
return 0;
err_abort:
if (NULL != pgm_multicast_group[index].sock) {
pgm_close(pgm_multicast_group[index].sock, FALSE);
pgm_multicast_group[index].sock = NULL;
}
if (NULL != res) {
pgm_freeaddrinfo (res);
res = NULL;
}
if (NULL != pgm_err) {
pgm_error_free (pgm_err);
pgm_err = NULL;
}
exit(EXIT_FAILURE);
}
#endif
#ifndef PGM_LINK_H_
#define PGM_LINK_H_
/* Define prototypes only if enabled */
#if defined(ENABLE_PGM_TRANSPORT)
int pgm_oai_init(char *if_name);
int pgm_recv_msg(int group, uint8_t *buffer, uint32_t length);
int pgm_link_send_msg(int group, uint8_t *data, uint32_t len);
#endif
#endif /* PGM_LINK_H_ */
......@@ -14,7 +14,8 @@
void init_bypass (void);
void bypass_init ( unsigned int (*tx_handlerP) (unsigned char,char*, unsigned int*, unsigned int*),unsigned int (*rx_handlerP) (unsigned char,char*,unsigned int));
int bypass_rx_data (unsigned int frame, unsigned int last_slot, unsigned int next_slot, uint8_t is_master);
int bypass_rx_data(unsigned int frame, unsigned int last_slot,
unsigned int next_slot, uint8_t is_master);
void bypass_signal_mac_phy(unsigned int frame, unsigned int last_slot,
unsigned int next_slot, uint8_t is_master);
#ifndef USER_MODE
......
......@@ -46,7 +46,7 @@ do { \
#define DevCheck4(cOND, vALUE1, vALUE2, vALUE3, vALUE4) \
do { \
if (!(cOND)) { \
fprintf(stderr, "%s:%d:%s Assertion `"#cOND"` failed.\n", \
fprintf(stderr, "%s:%d:%s\nAssertion `"#cOND"` failed.\n", \
__FILE__, __LINE__, __FUNCTION__); \
fprintf(stderr, #vALUE1": %d\n"#vALUE2": %d\n"#vALUE3": %d\n" \
#vALUE4": %d\n", \
......
......@@ -3,14 +3,15 @@ all: oaisim naslite_netlink_ether
userclean: clean oaisim naslite_netlink_ether
oaisim:
(cd $(OPENAIR_TARGETS)/SIMU/USER && make NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 Rel10=1 -j8)
(cd $(OPENAIR_TARGETS)/SIMU/USER && $(MAKE) NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1)
naslite_netlink_ether:
(cd $(OPENAIR2_DIR) && make naslite_netlink_ether.ko)
(cd $(OPENAIR2_DIR)/NAS/DRIVER/LITE/RB_TOOL/ && make)
(cd $(OPENAIR2_DIR) && $(MAKE) naslite_netlink_ether.ko)
(cd $(OPENAIR2_DIR)/NAS/DRIVER/LITE/RB_TOOL/ && $(MAKE))
clean:
(cd $(OPENAIR2_DIR)/NAS/DRIVER/LITE && make clean)
(cd $(OPENAIR_TARGETS)/SIMU/USER && $(MAKE) clean)
(cd $(OPENAIR2_DIR)/NAS/DRIVER/LITE && $(MAKE) clean)
(cd $(OPENAIR_TARGETS)/SIMU/USER && make clean)
(cd $(OPENAIR_TARGETS)/SIMU/USER && make cleanasn1)
......@@ -221,6 +221,14 @@ CFLAGS += -DENABLE_VCD_FIFO
CFLAGS += -DENABLE_NEW_MULTICAST
# CFLAGS += -DENABLE_LOG_FIFO
# Check if libpgm is installed and use it if found instead of the unreliable
# multicast
ENABLE_PGM = $(shell if pkg-config --exists openpgm-5.1; then echo "1" ; else echo "0"; fi)
ifeq ($(ENABLE_PGM), 1)
CFLAGS += `pkg-config --cflags openpgm-5.1` -DENABLE_PGM_TRANSPORT
PGM_LDFLAGS = `pkg-config --libs openpgm-5.1`
endif
OBJ = $(PHY_OBJS) $(SIMULATION_OBJS) $(ETHERNET_TRANSPORT_OBJS) $(TOOLS_OBJS) $(SCHED_OBJS) $(STATS_OBJS) $(OAISIM_OBJS) $(NAS_OBJS) $(INT_OBJS) $(UTIL_OBJ)
ifeq ($(OPENAIR2),1)
OBJ += $(L2_OBJS)
......@@ -243,7 +251,9 @@ printvars:
@echo L2 objs are $(L2_OBJS)
@echo eNB_flag is $(eNB_flag)
@echo UE_flag is $(UE_flag)
@echo $(S1AP_BUILT_OBJS)
@echo S1AP objs: $(S1AP_BUILT_OBJS)
@echo CFLAGS: $(CFLAGS)
@echo Enable PGM: $(ENABLE_PGM)
ASN1RELDIR=R9.8
ifeq ($(USE_MME), R8)
......@@ -299,7 +309,7 @@ oaisim : $(ASN1_MSG_OBJS1) $(OBJ) oaisim.c $(LFDS_DIR)/bin/liblfds611.a
endif
@echo "Compiling oaisim.c ..."
@$(CC) -I$(TOP_DIR) $(L2_incl) $(UTIL_incl) -I$(ASN1_MSG_INC) $(S1AP_Incl) -o oaisim $(CFLAGS) $(EXTRA_CFLAGS) $^ \
-lm -lblas -lpthread -llapack_atlas -lforms -lxml2 -lX11 -lXpm -lrt $(LFDS_DIR)/bin/liblfds611.a
-lm -lblas -lpthread -llapack_atlas -lforms -lxml2 -lX11 -lXpm -lrt $(LFDS_DIR)/bin/liblfds611.a $(PGM_LDFLAGS)
ifeq ($(rrc_cellular_eNB),1)
mv oaisim oaisim_eNB
......
......@@ -415,9 +415,10 @@ int olg_config() {
oai_emulation.info.g_log_level,
oai_emulation.info.g_log_verbosity,
oai_emulation.emulation_config.log_emu.interval);
// if perf eval then reset the otg log level
set_comp_log(PHY, LOG_NONE, 0x15,1);
set_comp_log(EMU, LOG_NONE, 0x15,1);
set_comp_log(EMU, LOG_FULL, 0x15,1);
set_comp_log(OCG, LOG_NONE, 0x15,1);
set_comp_log(OCM, LOG_NONE, 0x15,1);
set_comp_log(OTG, LOG_NONE, 0x15,1);
......
......@@ -98,7 +98,7 @@ void get_simulation_options(int argc, char *argv[]) {
{NULL, 0, NULL, 0}
};
while ((c = getopt_long (argc, argv, "aA:b:B:c:C:d:eE:f:FGg:hi:IJ:k:l:m:M:n:N:O:p:P:rR:s:S:t:T:u:U:vVx:y:w:W:X:z:Z:", long_options, &option_index)) != -1) {
while ((c = getopt_long (argc, argv, "aA:b:B:c:C:D:d:eE:f:FGg:hi:IJ:k:l:m:M:n:N:O:p:P:rR:s:S:t:T:u:U:vVx:y:w:W:X:z:Z:", long_options, &option_index)) != -1) {
switch (c) {
case 0:
......@@ -248,8 +248,7 @@ void get_simulation_options(int argc, char *argv[]) {
oai_emulation.info.multicast_group = atoi (optarg);
break;
case 'D':
oai_emulation.info.multicast_ifname = malloc (strlen(optarg) + 1);
strcpy(oai_emulation.info.multicast_ifname, optarg);
oai_emulation.info.multicast_ifname = strdup(optarg);
break;
case 'B':
oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option = optarg;
......
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