Commit eb363157 authored by knopp's avatar knopp
Browse files

moved simulation target into lte-uesoftmodem with --simL1 option

parent 4b943d4b
......@@ -621,9 +621,7 @@ add_boolean_option(RRC_DEFAULT_RAB_IS_AM False "set the RLC mode to AM for the d
add_boolean_option(OAI_NW_DRIVER_TYPE_ETHERNET False "????")
add_boolean_option(DEADLINE_SCHEDULER True "Use the Linux scheduler SCHED_DEADLINE: kernel >= 3.14")
add_boolean_option(CPU_AFFINITY False "Enable CPU Affinity of threads (only valid without deadline scheduler). It is enabled only with >2 CPUs")
add_boolean_option(NAS_ADDRESS_FIX False "specific to oaisim: for nasmesh driver")
add_boolean_option(NAS_NETLINK False "useless ??? Must be True to compile nasmesh driver without rtai ????")
add_boolean_option(OAISIM False "specific to oaisim")
add_boolean_option(OAI_NW_DRIVER_USE_NETLINK True "????")
add_boolean_option(USE_MME False "this flag is used only one time in lte-softmodem.c")
......@@ -652,9 +650,7 @@ add_boolean_option(OPENAIR_LTE True "Seems legacy: keep it to true")
# PHY options
##########################
add_boolean_option(DRIVER2013 True "only relevant for EXMIMO")
add_boolean_option(ENABLE_NEW_MULTICAST False "specific to oaisim")
add_boolean_option(EXMIMO_IOT True "????")
add_boolean_option(LARGE_SCALE False "specific to oaisim: defines max eNB=2 and max UE=120")
add_boolean_option(LOCALIZATION False "???")
add_integer_option(MAX_NUM_CCs 1 "????")
add_boolean_option(MU_RECEIVER False "????")
......@@ -677,7 +673,6 @@ add_boolean_option(NAS_UE True "NAS UE INSTANCE (<> NAS_MME)")
##########################
# ACCESS STRATUM LAYER2 OPTIONS
##########################
add_boolean_option(MAC_CONTEXT True "specific to oaisim")
add_boolean_option(JUMBO_FRAME True "ENABLE LARGE SDU in ACCESS STRATUM (larger than common MTU)")
##########################
......@@ -1720,12 +1715,14 @@ ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
${OPENAIR1_DIR}/SIMULATION/TOOLS/multipath_channel.c
${OPENAIR1_DIR}/SIMULATION/TOOLS/multipath_tv_channel.c
${OPENAIR1_DIR}/SIMULATION/TOOLS/abstraction.c
${OPENAIR1_DIR}/SIMULATION/TOOLS/channel_sim.c
${OPENAIR1_DIR}/SIMULATION/RF/rf.c
${OPENAIR1_DIR}/SIMULATION/RF/dac.c
${OPENAIR1_DIR}/SIMULATION/RF/adc.c
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
)
add_library(SIMU_ETH
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c
......@@ -1982,6 +1979,8 @@ add_executable(lte-uesoftmodem
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_TARGETS}/RT/USER/lte-ue.c
${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c
${OPENAIR_TARGETS}/RT/USER/lte-ru.c
${OPENAIR_TARGETS}/RT/USER/rfsim.c
${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
......@@ -2000,13 +1999,13 @@ add_executable(lte-uesoftmodem
target_link_libraries (lte-uesoftmodem
-Wl,--start-group
RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE
RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE SIMU
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
-Wl,--end-group z dl)
target_link_libraries (lte-uesoftmodem ${LIBXML2_LIBRARIES})
target_link_libraries (lte-uesoftmodem pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES})
target_link_libraries (lte-uesoftmodem pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (lte-uesoftmodem ${LIB_LMS_LIBRARIES})
target_link_libraries (lte-uesoftmodem ${T_LIB})
......@@ -2019,6 +2018,8 @@ add_executable(lte-uesoftmodem-nos1
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_TARGETS}/RT/USER/lte-ue.c
${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c
${OPENAIR_TARGETS}/RT/USER/lte-ru.c
${OPENAIR_TARGETS}/RT/USER/rfsim.c
${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
......@@ -2038,13 +2039,13 @@ add_executable(lte-uesoftmodem-nos1
target_link_libraries (lte-uesoftmodem-nos1
-Wl,--start-group
RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB}
RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE SIMU ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB}
${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
-Wl,--end-group z dl )
target_link_libraries (lte-uesoftmodem-nos1 ${LIBXML2_LIBRARIES})
target_link_libraries (lte-uesoftmodem-nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES})
target_link_libraries (lte-uesoftmodem-nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (lte-uesoftmodem-nos1 ${LIB_LMS_LIBRARIES})
target_link_libraries (lte-uesoftmodem-nos1 ${T_LIB})
......@@ -2075,96 +2076,6 @@ target_link_libraries (lte-uesoftmodem-nos1 ${T_LIB})
# Addexecutables for tests
####################################
# A all in one network simulator
################
add_executable(oaisim
${rrc_h}
${s1ap_h}
${x2ap_h}
${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR_TARGETS}/RT/USER/lte-ue.c
${OPENAIR_TARGETS}/RT/USER/lte-ru.c
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_TARGETS}/SIMU/USER/channel_sim.c
# ${OPENAIR_TARGETS}/SIMU/USER/oaisim_config.c
${OPENAIR_TARGETS}/SIMU/USER/sinr_sim.c
${OPENAIR_TARGETS}/SIMU/USER/cor_SF_sim.c
${OPENAIR_TARGETS}/SIMU/USER/oaisim_functions.c
${OPENAIR_TARGETS}/SIMU/USER/event_handler.c
${OPENAIR_TARGETS}/SIMU/USER/oaisim.c
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
${OPENAIR2_DIR}/RRC/NAS/rb_config.c
${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c
${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c
${XFORMS_SOURCE}
${T_SOURCE}
${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES}
)
target_include_directories(oaisim PUBLIC ${OPENAIR_TARGETS}/SIMU/USER)
target_link_libraries (oaisim
-Wl,-ldl,--start-group
RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE ${MSC_LIB} LIB_NAS_UE SIMU SECU_OSA ${ITTI_LIB} ${MIH_LIB}
${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7
-Wl,--end-group z dl)
target_link_libraries (oaisim ${LIBXML2_LIBRARIES} ${LAPACK_LIBRARIES})
target_link_libraries (oaisim pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp z
${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${OPENPGM_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES})
#Force link with forms, regardless XFORMS option
target_link_libraries (oaisim forms)
target_link_libraries (oaisim ${T_LIB})
# A all in one network simulator
################
add_executable(oaisim_nos1
${rrc_h}
${s1ap_h}
${x2ap_h}
${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR_TARGETS}/RT/USER/lte-ue.c
${OPENAIR_TARGETS}/RT/USER/lte-ru.c
${OPENAIR1_DIR}/SCHED/prach_procedures.c
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_TARGETS}/SIMU/USER/channel_sim.c
# ${OPENAIR_TARGETS}/SIMU/USER/oaisim_config.c
${OPENAIR_TARGETS}/SIMU/USER/sinr_sim.c
${OPENAIR_TARGETS}/SIMU/USER/cor_SF_sim.c
${OPENAIR_TARGETS}/SIMU/USER/oaisim_functions.c
${OPENAIR_TARGETS}/SIMU/USER/event_handler.c
${OPENAIR_TARGETS}/SIMU/USER/oaisim.c
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
${OPENAIR2_DIR}/RRC/NAS/rb_config.c
${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c
${OPENAIR_DIR}/common/utils/system.c
${XFORMS_SOURCE}
${T_SOURCE}
${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES}
)
target_include_directories(oaisim_nos1 PUBLIC ${OPENAIR_TARGETS}/SIMU/USER)
target_link_libraries (oaisim_nos1
-Wl,--start-group
RRC_LIB X2AP_LIB SECU_CN UTIL HASHTABLE SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS ${MSC_LIB} ${ITTI_LIB} SIMU L2_UE ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7
-Wl,--end-group z dl )
target_link_libraries (oaisim_nos1 ${LIBXML2_LIBRARIES} ${LAPACK_LIBRARIES})
target_link_libraries (oaisim_nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES}
${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${OPENPGM_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES})
#Force link with forms, regardless XFORMS option
target_link_libraries (oaisim_nos1 forms)
#message("protobuflib is ${PROTOBUF_LIB}")
target_link_libraries (oaisim_nos1 ${T_LIB})
# Unitary tests for each piece of L1: example, mbmssim is MBMS L1 simulator
#####################################
......@@ -2262,7 +2173,7 @@ endforeach(myExe)
if (${T_TRACER})
foreach(i
#all "add_executable" definitions (except tests, rb_tool, updatefw)
lte-softmodem lte-softmodem-nos1 oaisim oaisim_nos1
lte-softmodem lte-softmodem-nos1
dlsim_tm4 dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim
pdcchsim pucchsim prachsim syncsim
#all "add_library" definitions
......
......@@ -42,8 +42,8 @@
#include "log.h"
#if defined (LOG_D) && defined (LOG_E)
# define SIG_DEBUG(x, args...) LOG_D(EMU, x, ##args)
# define SIG_ERROR(x, args...) LOG_E(EMU, x, ##args)
# define SIG_DEBUG(x, args...) LOG_D(SIM, x, ##args)
# define SIG_ERROR(x, args...) LOG_E(SIM, x, ##args)
#endif
#ifndef SIG_DEBUG
......
......@@ -70,7 +70,6 @@ extern char mode_string[4][20];
extern unsigned char NB_RU;
#ifndef OPENAIR2
extern unsigned char NB_eNB_INST;
......
......@@ -65,7 +65,6 @@ extern int flagMag;
extern char mode_string[4][20];
extern unsigned char NB_RU;
#ifndef OPENAIR2
extern unsigned char NB_eNB_INST;
......
......@@ -67,7 +67,6 @@ char mode_string[4][20] = {"NOT SYNCHED","PRACH","RAR","PUSCH"};
#include "SIMULATION/ETH_TRANSPORT/vars.h"
unsigned char NB_RU=0;
#ifndef OPENAIR2
unsigned char NB_eNB_INST=0;
......
......@@ -61,7 +61,6 @@ char mode_string[4][20] = {"NOT SYNCHED","PRACH","RAR","PUSCH"};
#include "SIMULATION/ETH_TRANSPORT/vars.h"
unsigned char NB_RU=0;
#ifndef OPENAIR2
unsigned char NB_eNB_INST=0;
......
......@@ -99,7 +99,7 @@ multicast_link_init(void)
SOCK_DGRAM,
&group_list[group].port, &sin);
LOG_D(EMU, "multicast_link_init(): Created socket %d for group %d, port %d\n",
LOG_D(SIM, "multicast_link_init(): Created socket %d for group %d, port %d\n",
group_list[group].socket,group,group_list[group].port);
/* Used so we can re-bind to our port while a previous connection is still
......@@ -107,17 +107,17 @@ multicast_link_init(void)
*/
if (setsockopt(group_list[group].socket, SOL_SOCKET, SO_REUSEADDR,
&reuse_addr, sizeof (reuse_addr)) < 0) {
LOG_E(EMU, "[MULTICAST] ERROR : setsockopt:SO_REUSEADDR, exiting ...");
LOG_E(SIM, "[MULTICAST] ERROR : setsockopt:SO_REUSEADDR, exiting ...");
exit (EXIT_FAILURE);
}
if (multicast_if != NULL) {
if (setsockopt(group_list[group].socket, SOL_SOCKET,SO_BINDTODEVICE,
multicast_if, strlen(multicast_if)) < 0) {
LOG_E(EMU,
LOG_E(SIM,
"[MULTICAST] ERROR : setsockopt:SO_BINDTODEVICE on interface %s, exiting ...\n",
multicast_if);
LOG_E(EMU,
LOG_E(SIM,
"[MULTICAST] make sure that you have a root privilage or run with sudo -E \n");
exit (EXIT_FAILURE);
}
......@@ -132,7 +132,7 @@ multicast_link_init(void)
if (setsockopt (group_list[group].socket, IPPROTO_IP, IP_MULTICAST_LOOP,
&multicast_loop, sizeof (multicast_loop)) < 0) {
LOG_E(EMU,
LOG_E(SIM,
"[MULTICAST] ERROR: %s line %d multicast_link_main_loop() IP_MULTICAST_LOOP %m",
__FILE__, __LINE__);
exit (EXIT_FAILURE);
......@@ -143,13 +143,13 @@ multicast_link_init(void)
command.imr_interface.s_addr = htonl (INADDR_ANY);
if (command.imr_multiaddr.s_addr == -1) {
LOG_E(EMU, "[MULTICAST] ERROR: %s line %d NO MULTICAST", __FILE__, __LINE__);
LOG_E(SIM, "[MULTICAST] ERROR: %s line %d NO MULTICAST", __FILE__, __LINE__);
exit (EXIT_FAILURE);
}
if (setsockopt (group_list[group].socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&command, sizeof (command)) < 0) {
LOG_E(EMU, "[MULTICAST] ERROR: %s line %d IP_ADD_MEMBERSHIP %m", __FILE__,
LOG_E(SIM, "[MULTICAST] ERROR: %s line %d IP_ADD_MEMBERSHIP %m", __FILE__,
__LINE__);
exit (EXIT_FAILURE);
}
......@@ -202,13 +202,13 @@ multicast_link_read_data (int groupP)
if ((groupP < MULTICAST_LINK_NUM_GROUPS) && (groupP >= 0)) {
if ((num_bytes = recvfrom (group_list[groupP].socket,
group_list[groupP].rx_buffer, 40000, 0, 0, 0)) < 0) {
LOG_E(EMU, "[MULTICAST] recvfrom has failed (%d:%s)\n (%s:%d)\n",
LOG_E(SIM, "[MULTICAST] recvfrom has failed (%d:%s)\n (%s:%d)\n",
errno, strerror(errno), __FILE__, __LINE__);
} else {
rx_handler(num_bytes,group_list[groupP].rx_buffer);
}
} else {
LOG_E(EMU, "[MULTICAST] ERROR: groupP out of bounds %d\n", groupP);
LOG_E(SIM, "[MULTICAST] ERROR: groupP out of bounds %d\n", groupP);
}
}
......@@ -242,7 +242,7 @@ multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP)
if ((num = sendto (group_list[groupP].socket, dataP, sizeP, 0,
(struct sockaddr *) &group_list[groupP].sock_remote_addr,
sizeof (group_list[groupP].sock_remote_addr))) < 0) {
LOG_E(EMU, "[MULTICAST] sendto has failed (%d:%s)\n (%s:%d)\n",
LOG_E(SIM, "[MULTICAST] sendto has failed (%d:%s)\n (%s:%d)\n",
errno, strerror(errno),
__FILE__, __LINE__);
}
......@@ -274,22 +274,22 @@ int multicast_link_read_data_from_sock(uint8_t is_master)
multicast_link_build_select_list ();
LOG_D(EMU, "Stuck on select with timeout %s\n",
LOG_D(SIM, "Stuck on select with timeout %s\n",
timeout_p == NULL ? "infinite" : "15000 usecs");
readsocks = select(highsock + 1, &socks, (fd_set *) 0, (fd_set *) 0, timeout_p);
if (readsocks < 0) {
LOG_E(EMU, "Multicast select failed (%d:%s)\n", errno, strerror(errno));
LOG_E(SIM, "Multicast select failed (%d:%s)\n", errno, strerror(errno));
exit(EXIT_FAILURE);
} else if (readsocks > 0) {
#ifdef DEBUG_EMU
LOG_D(EMU, "Multicast Normal read\n");
#ifdef DEBUG_SIM
LOG_D(SIM, "Multicast Normal read\n");
#endif
multicast_link_read();
} else {
/* Timeout */
LOG_I(EMU, "Multicast select time-out\n");
LOG_I(SIM, "Multicast select time-out\n");
return 1;
}
......@@ -311,21 +311,21 @@ void multicast_link_start(void (*rx_handlerP) (unsigned int, char *),
rx_handler = rx_handlerP;
multicast_group = _multicast_group;
multicast_if = multicast_ifname;
LOG_I(EMU, "[MULTICAST] LINK START on interface=%s for group=%d: handler=%p\n",
LOG_I(SIM, "[MULTICAST] LINK START on interface=%s for group=%d: handler=%p\n",
(multicast_if == NULL) ? "not specified" : multicast_if, multicast_group,
rx_handler);
multicast_link_init ();
#if ! defined(ENABLE_NEW_MULTICAST)
LOG_D(EMU, "[MULTICAST] multicast link start thread\n");
LOG_D(SIM, "[MULTICAST] multicast link start thread\n");
if (pthread_create (&main_loop_thread, NULL, multicast_link_main_loop,
NULL) != 0) {
LOG_E(EMU, "[MULTICAST LINK] Error in pthread_create (%d:%s)\n",
LOG_E(SIM, "[MULTICAST LINK] Error in pthread_create (%d:%s)\n",
errno, strerror(errno));
exit(EXIT_FAILURE);
} else {
pthread_detach(main_loop_thread); // disassociate from parent
LOG_I(EMU, "[MULTICAST LINK] Thread detached\n");
LOG_I(SIM, "[MULTICAST LINK] Thread detached\n");
}
#endif
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <string.h>
#include <math.h>
#include <unistd.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include "SIMULATION/TOOLS/sim.h"
#include "SIMULATION/RF/rf.h"
#include "PHY/types.h"
#include "PHY/defs_eNB.h"
#include "PHY/phy_extern.h"
#include "PHY/phy_extern_ue.h"
#include "LAYER2/MAC/mac.h"
#include "LAYER2/MAC/mac_extern.h"
#include "UTIL/LOG/log_if.h"
#include "UTIL/LOG/log_extern.h"
#include "RRC/LTE/rrc_extern.h"
#include "PHY_INTERFACE/phy_interface_extern.h"
#include "UTIL/OCG/OCG.h"
#include "UTIL/OPT/opt.h" // to test OPT
#include "UTIL/FIFO/types.h"
#define RF
#define DEBUG_SIM
/*
#undef LOG_D
#define LOG_D(A,B,C...) printf(B,C)
*/
int number_rb_ul;
int first_rbUL ;
extern Signal_buffers_t *signal_buffers_g;
double r_re_DL[NUMBER_OF_UE_MAX][2][30720];
double r_im_DL[NUMBER_OF_UE_MAX][2][30720];
double r_re_UL[NUMBER_OF_eNB_MAX][2][30720];
double r_im_UL[NUMBER_OF_eNB_MAX][2][30720];
int RU_output_mask[NUMBER_OF_UE_MAX];
int UE_output_mask[NUMBER_OF_RU_MAX];
pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX];
pthread_mutex_t UE_output_mutex[NUMBER_OF_RU_MAX];
double ru_amp[NUMBER_OF_RU_MAX];
void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs],
uint16_t subframe,
uint32_t offset,
uint32_t length,
uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *ue_frame_parms,
uint8_t UE_id,
int CC_id)
{
int32_t att_eNB_id=-1;
int32_t **txdata,**rxdata;
uint32_t eNB_id,ru_id=0;
double tx_pwr;
double rx_pwr;
int32_t rx_pwr2;
uint32_t i,aa;
uint32_t sf_offset;
double min_path_loss=-200;
uint8_t hold_channel=0;
uint8_t nb_antennas_rx = RU2UE[0][0][CC_id]->nb_rx; // number of rx antennas at UE
uint8_t nb_antennas_tx = RU2UE[0][0][CC_id]->nb_tx; // number of tx antennas at eNB
double s_re0[30720];
double s_re1[30720];
double *s_re[2];
double s_im0[30720];
double s_im1[30720];
double *s_im[2];
double r_re00[30720];
double r_re01[30720];
double *r_re0[2];
double r_im00[30720];
double r_im01[30720];
double *r_im0[2];
LTE_DL_FRAME_PARMS *frame_parms;
s_re[0] = s_re0;
s_im[0] = s_im0;
s_re[1] = s_re1;
s_im[1] = s_im1;
r_re0[0] = r_re00;
r_im0[0] = r_im00;
r_re0[1] = r_re01;
r_im0[1] = r_im01;
if (subframe==0)
hold_channel = 0;
else
hold_channel = 1;
pthread_mutex_lock(&RU_output_mutex[UE_id]);
if (RU_output_mask[UE_id] == 0) { // This is the first eNodeB for this UE, clear the buffer
for (aa=0; aa<nb_antennas_rx; aa++) {
memset((void*)r_re_DL[UE_id][aa],0,(RC.ru[0]->frame_parms.samples_per_tti)*sizeof(double));
memset((void*)r_im_DL[UE_id][aa],0,(RC.ru[0]->frame_parms.samples_per_tti)*sizeof(double));
}
}
pthread_mutex_unlock(&RU_output_mutex[UE_id]);
for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
txdata = RC.ru[ru_id]->common.txdata;
frame_parms = &RC.ru[ru_id]->frame_parms;
sf_offset = (subframe*frame_parms->samples_per_tti) + offset;
LOG_D(SIM,">>>>>>>>>>>>>>>>>TXPATH: RU %d : DL_sig reading TX for subframe %d (sf_offset %d, length %d) from %p\n",ru_id,subframe,sf_offset,length,txdata[0]+sf_offset);
int length_meas = frame_parms->ofdm_symbol_size;
if (sf_offset+length <= frame_parms->samples_per_tti*10) {
tx_pwr = dac_fixed_gain(s_re,
s_im,
txdata,
sf_offset,
nb_antennas_tx,
length,
sf_offset,
length_meas,
14,
frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE
0,
&ru_amp[ru_id],
frame_parms->N_RB_DL*12);
}
else {
tx_pwr = dac_fixed_gain(s_re,
s_im,
txdata,
sf_offset,
nb_antennas_tx,
(frame_parms->samples_per_tti*10)-sf_offset,
sf_offset,
length_meas,
14,
frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE
0,
&ru_amp[ru_id],
frame_parms->N_RB_DL*12);
tx_pwr = dac_fixed_gain(s_re,
s_im,
txdata,
sf_offset,
nb_antennas_tx,
length+sf_offset-(frame_parms->samples_per_tti*10),
sf_offset,
length_meas,
14,
frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE
0,
&ru_amp[ru_id],
frame_parms->N_RB_DL*12);
}
#ifdef DEBUG_SIM
LOG_D(PHY,"[SIM][DL] subframe %d: txp (time) %d dB\n",
subframe,dB_fixed(signal_energy(&txdata[0][sf_offset],length_meas)));
LOG_D(OCM,"[SIM][DL] RU %d (CCid %d): tx_pwr %.1f dBm/RE (target %d dBm/RE), for subframe %d\n",
ru_id,CC_id,
10*log10(tx_pwr),
frame_parms->pdsch_config_common.referenceSignalPower,
subframe);
#endif
tx_pwr = signal_energy_fp(s_re,s_im,nb_antennas_tx,
length<length_meas?length:length_meas,
0)/(12.0*frame_parms->N_RB_DL);
//RU2UE[eNB_id][UE_id]->path_loss_dB = 0;
multipath_channel(RU2UE[ru_id][UE_id][CC_id],s_re,s_im,r_re0,r_im0,
length,hold_channel);
#ifdef DEBUG_SIM
rx_pwr = signal_energy_fp2(RU2UE[ru_id][UE_id][CC_id]->ch[0],
RU2UE[ru_id][UE_id][CC_id]->channel_length)*RU2UE[ru_id][UE_id][CC_id]->channel_length;
LOG_D(OCM,"[SIM][DL] Channel RU %d => UE %d (CCid %d): Channel gain %f dB (%f)\n",ru_id,UE_id,CC_id,10*log10(rx_pwr),rx_pwr);
#endif
#ifdef DEBUG_SIM
for (i=0; i<RU2UE[ru_id][UE_id][CC_id]->channel_length; i++)
LOG_D(OCM,"channel(%d,%d)[%d] : (%f,%f)\n",ru_id,UE_id,i,RU2UE[ru_id][UE_id][CC_id]->ch[0][i].x,RU2UE[ru_id][UE_id][CC_id]->ch[0][i].y);
#endif
LOG_D(OCM,"[SIM][DL] Channel RU %d => UE %d (CCid %d): tx_power %.1f dBm/RE, path_loss %1.f dB\n",
ru_id,UE_id,CC_id,
(double)frame_parms->pdsch_config_common.referenceSignalPower,
RU2UE[ru_id][UE_id][CC_id]->path_loss_dB);
#ifdef DEBUG_SIM
rx_pwr = signal_energy_fp(r_re0,r_im0,nb_antennas_rx,
length<length_meas?length:length_meas,
0)/(12.0*frame_parms->N_RB_DL);
LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr %f dBm/RE (%f dBm RSSI,tx %f dB)for subframe %d (length %d)\n",UE_id,
10*log10(rx_pwr),
10*log10(rx_pwr*(double)frame_parms->N_RB_DL*12),
10*log10(tx_pwr),subframe,
length<length_meas?length:length_meas);