From 591e0e1f36060c8bdcac9b7aee944eb6462c5512 Mon Sep 17 00:00:00 2001 From: "Deokseong \"David\" Kim" Date: Wed, 16 Jun 2021 16:06:38 -0700 Subject: [PATCH] Adjusted UDP port ids for multiple UE connection with proxy --- executables/nr-ue.c | 5 +++-- executables/nr-uesoftmodem.c | 21 ++++++++++++++++--- executables/softmodem-common.h | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 2 +- openair2/RRC/LTE/rrc_UE.c | 7 ++++--- openair2/RRC/NR_UE/rrc_UE.c | 10 ++++----- targets/RT/USER/lte-ue.c | 4 ++-- 7 files changed, 34 insertions(+), 17 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index d3519ae883..c73a8fba8e 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -129,8 +129,8 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue, void init_nrUE_standalone_thread(int ue_idx) { const char *standalone_addr = "127.0.0.1"; - int standalone_tx_port = 3611 + (ue_idx)*2; - int standalone_rx_port = 3612 + (ue_idx)*2; + int standalone_tx_port = 3611 + ue_idx * 2; + int standalone_rx_port = 3612 + ue_idx * 2; nrue_init_standalone_socket(standalone_addr, standalone_tx_port, standalone_rx_port); pthread_t thread; @@ -252,6 +252,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) } } } + return NULL; } diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 8f270defa1..b04498f6f7 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -456,7 +456,7 @@ void init_openair0(void) { } } -void init_pdcp(void) { +void init_pdcp(int ue_id) { uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); /*if (IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF)) { @@ -471,7 +471,7 @@ void init_pdcp(void) { } pdcp_layer_init(); nr_DRB_preconfiguration();*/ - nr_pdcp_module_init(pdcp_initmask, 0); + nr_pdcp_module_init(pdcp_initmask, ue_id); pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); LOG_I(PDCP, "Before getting out from init_pdcp() \n"); @@ -525,8 +525,23 @@ int main( int argc, char **argv ) { LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); init_NR_UE(1,rrc_config_path); + + int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 0; + int node_number = get_softmodem_params()->node_number; + ue_id_g = (node_number == 0) ? 0 : node_number - 2; + AssertFatal(ue_id_g >= 0, "UE id is expected to be nonnegative.\n"); + if(IS_SOFTMODEM_NOS1) - init_pdcp(); + { + if(node_number == 0) + { + init_pdcp(0); + } + else + { + init_pdcp(mode_offset + node_number - 1); + } + } NB_UE_INST=1; NB_INST=1; diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index 56a7372b36..003636c379 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -148,7 +148,7 @@ extern "C" {"use-256qam-table", CONFIG_HLP_256QAM, PARAMFLAG_BOOL, iptr:&USE_256QAM_TABLE, defintval:0, TYPE_INT, 0}, \ {"nfapi", CONFIG_HLP_NFAPI, 0, u8ptr:&nfapi_mode, defintval:0, TYPE_UINT8, 0}, \ {"nsa", CONFIG_HLP_NSA, PARAMFLAG_BOOL, iptr:&NSA, defintval:0, TYPE_INT, 0}, \ - {"node-number", NULL, 0, u16ptr:&NODE_NUMBER, defuintval:2, TYPE_UINT16, 0}, \ + {"node-number", NULL, 0, u16ptr:&NODE_NUMBER, defuintval:0, TYPE_UINT16, 0}, \ } #define CONFIG_HLP_NSA "Enable NSA mode \n" diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index eb58a9c0a3..08b4fcca80 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -530,7 +530,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, if(ra->cfra) { - LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) CFRA procedure succeeded!\n", UE_id, ra->rnti); + LOG_A(NR_MAC, "(ue %i, rnti 0x%04x) CFRA procedure succeeded!\n", UE_id, ra->rnti); //nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP); UE_info->active[UE_id] = true; diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index fa612cb29c..c45afbf6c8 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -98,6 +98,7 @@ static int from_nr_ue_fd = -1; static int to_nr_ue_fd = -1; int slrb_id; int send_ue_information = 0; +extern int ue_id_g; // for malloc_clear #include "PHY/defs_UE.h" @@ -6515,7 +6516,7 @@ void nsa_sendmsg_to_nrue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg struct sockaddr_in sa = { .sin_family = AF_INET, - .sin_port = htons(6008), + .sin_port = htons(6008 + ue_id_g * 2), }; int sent = sendto(to_nr_ue_fd, &n_msg, to_send, 0, (struct sockaddr *)&sa, sizeof(sa)); @@ -6532,12 +6533,12 @@ void nsa_sendmsg_to_nrue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg LOG_I(RRC, "Sent a %d message to the nrUE (%d bytes) \n", msg_type, sent); } -void init_connections_with_nr_ue(void) +void init_connections_with_nr_ue() { struct sockaddr_in sa = { .sin_family = AF_INET, - .sin_port = htons(6007), + .sin_port = htons(6007 + ue_id_g * 2), }; AssertFatal(from_nr_ue_fd == -1, "from_nr_ue_fd was assigned already"); from_nr_ue_fd = socket(AF_INET, SOCK_DGRAM, 0); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index fc8511d50e..391ed7981f 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -133,7 +133,7 @@ uint8_t first_rrcreconfigurationcomplete = 0; static const char nsa_ipaddr[] = "127.0.0.1"; static int from_lte_ue_fd = -1; static int to_lte_ue_fd = -1; -uint16_t ue_id_g; +extern uint16_t ue_id_g; static Rrc_State_NR_t nr_rrc_get_state (module_id_t ue_mod_idP) { return NR_UE_rrc_inst[ue_mod_idP].nrRrcState; @@ -2909,7 +2909,7 @@ void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, MessagesIds msg_ struct sockaddr_in sa = { .sin_family = AF_INET, - .sin_port = htons(6007), + .sin_port = htons(6007 + ue_id_g * 2), }; int sent = sendto(from_lte_ue_fd, &n_msg, to_send, 0, (struct sockaddr *)&sa, sizeof(sa)); @@ -2931,7 +2931,7 @@ void init_connections_with_lte_ue(void) struct sockaddr_in sa = { .sin_family = AF_INET, - .sin_port = htons(6008), + .sin_port = htons(6008 + ue_id_g * 2), }; AssertFatal(from_lte_ue_fd == -1, "from_lte_ue_fd was assigned already"); from_lte_ue_fd = socket(AF_INET, SOCK_DGRAM, 0); @@ -2973,9 +2973,9 @@ static void start_oai_nrue_threads() LOG_E(MAC, "sem_init() error\n"); abort(); } - int node_num = get_softmodem_params()->node_number; - ue_id_g = (node_num == 0)? 0 : node_num-2; + init_nrUE_standalone_thread(ue_id_g); + } static void nsa_rrc_ue_process_ueCapabilityEnquiry(void) diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 47b6ea2d6e..0ae03ee537 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -421,8 +421,8 @@ void init_UE_stub_single_thread(int nb_inst, void init_UE_standalone_thread(int ue_idx) { const char *standalone_addr = "127.0.0.1"; // these two lines go into init - int standalone_tx_port = 3211 + ue_idx*2; - int standalone_rx_port = 3212 + ue_idx*2; + int standalone_tx_port = 3211 + ue_idx * 2; + int standalone_rx_port = 3212 + ue_idx * 2; ue_init_standalone_socket(standalone_addr, standalone_tx_port, standalone_rx_port); pthread_t thread;