From 443b5fd026917bc57c33c9ba3c37e4486c43bd39 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 11 Jul 2019 15:22:30 +0200 Subject: [PATCH 1/4] T: add -no-bind option to macpdu2wireshark To be used when you send data to another host. On the other host, to avoid ICMP traffic about the port not being open, do: ./nc -l -u -p 9999 > /dev/null You need to restart this command each time you run macpdu2wireshark. You can use any other program that will accept UDP packets on the port 9999 (default port of macpdu2wireshark, change if you use another port of course). --- common/utils/T/tracer/macpdu2wireshark.c | 94 +++++------------------- 1 file changed, 19 insertions(+), 75 deletions(-) diff --git a/common/utils/T/tracer/macpdu2wireshark.c b/common/utils/T/tracer/macpdu2wireshark.c index 8720efd8c0..c391a99786 100644 --- a/common/utils/T/tracer/macpdu2wireshark.c +++ b/common/utils/T/tracer/macpdu2wireshark.c @@ -52,6 +52,7 @@ typedef struct { int max_mib; int max_sib; int live; + int no_bind; /* runtime vars */ int cur_mib; int cur_sib; @@ -264,9 +265,11 @@ void *receiver(void *_d) { abort(); } - if (bind(s, (struct sockaddr *)&d->to, sizeof(struct sockaddr_in)) == -1) { - perror("bind"); - abort(); + if (d->no_bind == 0) { + if (bind(s, (struct sockaddr *)&d->to, sizeof(struct sockaddr_in)) == -1) { + perror("bind"); + abort(); + } } while (1) { @@ -290,6 +293,7 @@ void usage(void) { " -live run live\n" " -live-ip tracee's IP address (default %s)\n" " -live-port tracee's port (default %d)\n" + " -no-bind don't bind to IP address (for remote logging)\n" "-i and -live are mutually exclusive options. One of them must be provided\n" "but not both.\n", DEFAULT_IP, @@ -318,78 +322,18 @@ int main(int n, char **v) { for (i = 1; i < n; i++) { if (!strcmp(v[i], "-h") || !strcmp(v[i], "--help")) usage(); - - if (!strcmp(v[i], "-d")) { - if (i > n-2) usage(); - - database_filename = v[++i]; - continue; - } - - if (!strcmp(v[i], "-i")) { - if (i > n-2) usage(); - - input_filename = v[++i]; - continue; - } - - if (!strcmp(v[i], "-ip")) { - if (i > n-2) usage(); - - ip = v[++i]; - continue; - } - - if (!strcmp(v[i], "-p")) { - if(i>n-2)usage(); - - port=atoi(v[++i]); - continue; - } - - if (!strcmp(v[i], "-no-mib")) { - d.no_mib = 1; - continue; - } - - if (!strcmp(v[i], "-no-sib")) { - d.no_sib = 1; - continue; - } - - if (!strcmp(v[i], "-max-mib")) { - if (i > n-2) usage(); - - d.max_mib = atoi(v[++i]); - continue; - } - - if (!strcmp(v[i], "-max-sib")) { - if (i > n-2) usage(); - - d.max_sib = atoi(v[++i]); - continue; - } - - if (!strcmp(v[i], "-live")) { - live = 1; - continue; - } - - if (!strcmp(v[i], "-live-ip")) { - if (i > n-2) usage(); - - live_ip = v[++i]; - continue; - } - - if (!strcmp(v[i], "-live-port")) { - if (i > n-2) usage(); - - live_port = atoi(v[++i]); - continue; - } - + if (!strcmp(v[i], "-d")) { if(i>n-2)usage(); database_filename = v[++i]; continue; } + if (!strcmp(v[i], "-i")) { if(i>n-2)usage(); input_filename = v[++i]; continue; } + if (!strcmp(v[i], "-ip")) { if(i>n-2)usage(); ip = v[++i]; continue; } + if (!strcmp(v[i], "-p")) { if(i>n-2)usage(); port = atoi(v[++i]); continue; } + if (!strcmp(v[i], "-no-mib")) { d.no_mib = 1; continue; } + if (!strcmp(v[i], "-no-sib")) { d.no_sib = 1; continue; } + if (!strcmp(v[i], "-max-mib")) { if(i>n-2)usage(); d.max_mib = atoi(v[++i]); continue; } + if (!strcmp(v[i], "-max-sib")) { if(i>n-2)usage(); d.max_sib = atoi(v[++i]); continue; } + if (!strcmp(v[i], "-live")) { live = 1; continue; } + if (!strcmp(v[i], "-live-ip")) { if(i>n-2)usage(); live_ip = v[++i]; continue; } + if (!strcmp(v[i], "-live-port")) { if(i>n-2)usage(); live_port = atoi(v[++i]); continue; } + if (!strcmp(v[i], "-no-bind")) { d.no_bind = 1; continue; } usage(); } From 5775d325e0248508417d49ceae5ba6423777b349 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 11 Jul 2019 15:26:00 +0200 Subject: [PATCH 2/4] phy: do not put random bits in unused DCI This used to be done to ease power estimation in the UE, but this is not correct. Let's put no energy in the REs with no DCI data, which is what needs to be done. Plus it consumes a lot of CPU because of calling taus() way too much. --- openair1/PHY/LTE_TRANSPORT/dci.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c index b4b253a297..1913afab2d 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci.c +++ b/openair1/PHY/LTE_TRANSPORT/dci.c @@ -291,24 +291,8 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, y[0] = &yseq0[0]; y[1] = &yseq1[0]; - if (IS_SOFTMODEM_BASICSIM) { - /* this should be the normal case - * but it has to be validated for all the various cases - * so let's just do it for the basic simulator - */ - // memset(e, 2, DCI_BITS_MAX); - } else { - // reset all bits to , here we set elements as 2 - // memset(e, 2, DCI_BITS_MAX); - // here we interpret NIL as a random QPSK sequence. That makes power estimation easier. - for (i=0; i, here we set elements as 2 */ + memset(e, 2, DCI_BITS_MAX); e_ptr = e; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DCI0,1); From 8a8fdd59c2472d1da535badc1a71193bcd053d6d Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 11 Jul 2019 15:28:33 +0200 Subject: [PATCH 3/4] cleanup: no variable definition in header file We declare variables in header files, we don't define them. So we need to use 'extern' in the header file and put the definition in some C file. --- openair2/RRC/LTE/rrc_eNB.c | 4 ++++ openair2/RRC/LTE/rrc_proto.h | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 4543ff3050..5b98991591 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -116,6 +116,10 @@ extern int rrc_eNB_process_security(const protocol_ctxt_t *const ctxt_pP, rrc_eN extern void process_eNB_security_key (const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *const ue_context_pP, uint8_t *security_key_pP); extern int derive_keNB_star(const uint8_t *kenb_32, const uint16_t pci, const uint32_t earfcn_dl, const bool is_rel8_only, uint8_t * kenb_star); +pthread_mutex_t rrc_release_freelist; +RRC_release_list_t rrc_release_info; +pthread_mutex_t lock_ue_freelist; + void openair_rrc_on( const protocol_ctxt_t *const ctxt_pP diff --git a/openair2/RRC/LTE/rrc_proto.h b/openair2/RRC/LTE/rrc_proto.h index e7e5e71d80..a8ee7ecabe 100644 --- a/openair2/RRC/LTE/rrc_proto.h +++ b/openair2/RRC/LTE/rrc_proto.h @@ -667,9 +667,11 @@ void openair_rrc_top_init_ue( uint8_t cba_group_active, uint8_t HO_active ); -pthread_mutex_t rrc_release_freelist; -RRC_release_list_t rrc_release_info; -pthread_mutex_t lock_ue_freelist; + +extern pthread_mutex_t rrc_release_freelist; +extern RRC_release_list_t rrc_release_info; +extern pthread_mutex_t lock_ue_freelist; + void remove_UE_from_freelist(module_id_t mod_id, rnti_t rnti); void put_UE_in_freelist(module_id_t mod_id, rnti_t rnti, boolean_t removeFlag); void release_UE_in_freeList(module_id_t mod_id); From 2421b71d6809d67c6f2a6dd9e4181a6a10e0ef94 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 11 Jul 2019 16:27:40 +0200 Subject: [PATCH 4/4] x2ap/sctp: increase buffer size The 5G phone OPPO has a very big UE capability (> 2KB). We need bigger buffers to transfer this, especially in x2 handover. Also the sctp messages need a bigger buffer. Note: in sctp, we didn't check for partial messages, it's now done. When detected, we exit. To be redone differently if needed. (Look for "if (!(flags & MSG_EOR))".) --- openair2/COMMON/x2ap_messages_types.h | 2 +- openair2/RRC/LTE/rrc_eNB.c | 4 ++-- openair2/X2AP/x2ap_eNB_handler.c | 4 ++-- openair3/SCTP/sctp_default_values.h | 2 +- openair3/SCTP/sctp_eNB_task.c | 5 +++++ 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/openair2/COMMON/x2ap_messages_types.h b/openair2/COMMON/x2ap_messages_types.h index d284f4d0b9..5a35b85fdb 100644 --- a/openair2/COMMON/x2ap_messages_types.h +++ b/openair2/COMMON/x2ap_messages_types.h @@ -205,7 +205,7 @@ typedef struct x2ap_handover_req_s { x2ap_lastvisitedcell_info_t lastvisitedcell_info; - uint8_t rrc_buffer[1024 /* arbitrary, big enough */]; + uint8_t rrc_buffer[8192 /* arbitrary, big enough */]; int rrc_buffer_size; int target_assoc_id; diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 5b98991591..ac22da1b42 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -4614,10 +4614,10 @@ rrc_eNB_generate_HandoverPreparationInformation( uint8_t *buffer, int *_size ) { - memset(buffer, 0, RRC_BUF_SIZE); + memset(buffer, 0, 8192); char *ho_buf = (char *) buffer; int ho_size; - ho_size = do_HandoverPreparation(ho_buf, 1024, ue_context_pP->ue_context.UE_Capability, ue_context_pP->ue_context.UE_Capability_size); + ho_size = do_HandoverPreparation(ho_buf, 8192, ue_context_pP->ue_context.UE_Capability, ue_context_pP->ue_context.UE_Capability_size); *_size = ho_size; } diff --git a/openair2/X2AP/x2ap_eNB_handler.c b/openair2/X2AP/x2ap_eNB_handler.c index 2a44501a33..41d92a695e 100644 --- a/openair2/X2AP/x2ap_eNB_handler.c +++ b/openair2/X2AP/x2ap_eNB_handler.c @@ -730,7 +730,7 @@ int x2ap_eNB_handle_handover_preparation (instance_t instance, X2AP_RRC_Context_t *c = &ie->value.choice.UE_ContextInformation.rRC_Context; - if (c->size > 1024 /* TODO: this is the size of rrc_buffer in struct x2ap_handover_req_ack_s*/) + if (c->size > 8192 /* TODO: this is the size of rrc_buffer in struct x2ap_handover_req_s */) { printf("%s:%d: fatal: buffer too big\n", __FILE__, __LINE__); abort(); } memcpy(X2AP_HANDOVER_REQ(msg).rrc_buffer, c->buf, c->size); @@ -821,7 +821,7 @@ int x2ap_eNB_handle_handover_response (instance_t instance, X2AP_TargeteNBtoSource_eNBTransparentContainer_t *c = &ie->value.choice.TargeteNBtoSource_eNBTransparentContainer; - if (c->size > 1024 /* TODO: this is the size of rrc_buffer in struct x2ap_handover_req_ack_s*/) + if (c->size > 1024 /* TODO: this is the size of rrc_buffer in struct x2ap_handover_req_ack_s */) { printf("%s:%d: fatal: buffer too big\n", __FILE__, __LINE__); abort(); } memcpy(X2AP_HANDOVER_REQ_ACK(msg).rrc_buffer, c->buf, c->size); diff --git a/openair3/SCTP/sctp_default_values.h b/openair3/SCTP/sctp_default_values.h index 5008ea0b72..528ffb5a05 100644 --- a/openair3/SCTP/sctp_default_values.h +++ b/openair3/SCTP/sctp_default_values.h @@ -26,6 +26,6 @@ #define SCTP_IN_STREAMS (16) #define SCTP_MAX_ATTEMPTS (2) #define SCTP_TIMEOUT (5) -#define SCTP_RECV_BUFFER_SIZE (1024) +#define SCTP_RECV_BUFFER_SIZE (8192) #endif /* SCTP_DEFAULT_VALUES_H_ */ diff --git a/openair3/SCTP/sctp_eNB_task.c b/openair3/SCTP/sctp_eNB_task.c index e934888178..3cb64254fc 100644 --- a/openair3/SCTP/sctp_eNB_task.c +++ b/openair3/SCTP/sctp_eNB_task.c @@ -955,6 +955,11 @@ sctp_eNB_read_from_socket( return; } + if (!(flags & MSG_EOR)) { + SCTP_ERROR("fatal: partial SCTP messages are not handled\n"); + exit(1); + } + if (flags & MSG_NOTIFICATION) { union sctp_notification *snp; snp = (union sctp_notification *)buffer;