Merge remote-tracking branch 'origin/develop' into develop-entv

This commit is contained in:
Javier Morgade
2019-05-17 18:11:55 +02:00
596 changed files with 85160 additions and 52024 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ typedef struct {
#define VCD_NUM_FUNCTIONS 195
/* number of VCD variables (to be kept up to date! see in T_messages.txt) */
#define VCD_NUM_VARIABLES 128
#define VCD_NUM_VARIABLES 136
/* first VCD function (to be kept up to date! see in T_messages.txt) */
#define VCD_FIRST_FUNCTION ((uintptr_t)T_VCD_FUNCTION_RT_SLEEP)
+134 -17
View File
@@ -629,7 +629,7 @@ ID = LEGACY_OCM_DEBUG
FORMAT = string,log
ID = LEGACY_OCM_TRACE
DESC = OCM legacy logs - trace level
GROUP = ALL:LEGACY_OCM:LEGACY_GROUP_TRACE:LEGACY
OGROUP = ALL:LEGACY_OCM:LEGACY_GROUP_TRACE:LEGACY
FORMAT = string,log
ID = LEGACY_OIP_INFO
@@ -800,6 +800,47 @@ ID = LEGACY_SIM_TRACE
GROUP = ALL:LEGACY_SIM:LEGACY_GROUP_TRACE:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_VNF_INFO
DESC = NFAPI_VNF legacy logs - info level
GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_INFO:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_VNF_ERROR
DESC = NFAPI_VNF legacy logs - error level
GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_ERROR:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_VNF_WARNING
DESC = NFAPI_VNF legacy logs - warning level
GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_WARNING:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_VNF_DEBUG
DESC = NFAPI_VNF legacy logs - debug level
GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_DEBUG:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_VNF_TRACE
DESC = NFAPI_VNF legacy logs - trace level
GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_TRACE:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_PNF_INFO
DESC = NFAPI_PNF legacy logs - info level
GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_INFO:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_PNF_ERROR
DESC = NFAPI_PNF legacy logs - error level
GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_ERROR:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_PNF_WARNING
DESC = NFAPI_PNF legacy logs - warning level
GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_WARNING:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_PNF_DEBUG
DESC = NFAPI_PNF legacy logs - debug level
GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_DEBUG:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_PNF_TRACE
DESC = NFAPI_PNF legacy logs - trace level
GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_TRACE:LEGACY
FORMAT = string,log
# this is a bad hack but I won't fix (function util_print_hex_octets
# in openairinterface5g/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c
# does funky things with the LOG_x macros but we work on the C pre-processor
@@ -845,26 +886,62 @@ ID = LEGACY_componentP_TRACE
GROUP = ALL:LEGACY_componentP:LEGACY_GROUP_TRACE:LEGACY
FORMAT = string,log
#needed?
ID = LEGACY_CLI_INFO
DESC = CLI legacy logs - info level
GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_INFO:LEGACY
ID = LEGACY_PROTO_AGENT_DEBUG
DESC = PROTO AGENT DEBUG LEVEL
GROUP = ALL:LEGACY_PROTO:LEGACY_GROUP_DEBUG:LEGACY
FORMAT = string,log
ID = LEGACY_CLI_ERROR
DESC = CLI legacy logs - error level
GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_ERROR:LEGACY
ID = LEGACY_PROTO_AGENT_INFO
DESC = PROTO AGENT INFO LEVEL
GROUP = ALL:LEGACY_PROTO:LEGACY_GROUP_INFO:LEGACY
FORMAT = string,log
ID = LEGACY_CLI_WARNING
DESC = CLI legacy logs - warning level
GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_WARNING:LEGACY
ID = LEGACY_PROTO_AGENT_WARNING
DESC = PROTO AGENT WARNING LEVEL
GROUP = ALL:LEGACY_PROTO:LEGACY_GROUP_WARNING:LEGACY
FORMAT = string,log
ID = LEGACY_CLI_DEBUG
DESC = CLI legacy logs - debug level
GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_DEBUG:LEGACY
ID = LEGACY_PROTO_AGENT_ERROR
DESC = PROTO AGENT ERROR LEVEL
GROUP = ALL:LEGACY_PROTO:LEGACY_GROUP_ERROR:LEGACY
FORMAT = string,log
ID = LEGACY_CLI_TRACE
DESC = CLI legacy logs - trace level
GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_TRACE:LEGACY
ID = LEGACY_F1U_DEBUG
DESC = F1U DEBUG LEVEL
GROUP = ALL:LEGACY_F1U:LEGACY_GROUP_DEBUG:LEGACY
FORMAT = string,log
ID = LEGACY_F1U_INFO
DESC = F1U INFO LEVEL
GROUP = ALL:LEGACY_F1U:LEGACY_GROUP_INFO:LEGACY
FORMAT = string,log
ID = LEGACY_F1U_ERROR
DESC = F1U ERROR LEVEL
GROUP = ALL:LEGACY_F1U:LEGACY_GROUP_ERROR:LEGACY
FORMAT = string,log
ID = LEGACY_F1AP_TRACE
DESC = F1AP TRACE LEVEL
GROUP = ALL:LEGACY_F1AP:LEGACY_GROUP_TRACE:LEGACY
FORMAT = string,log
ID = LEGACY_F1AP_DEBUG
DESC = F1AP DEBUG LEVEL
GROUP = ALL:LEGACY_F1AP:LEGACY_GROUP_DEBUG:LEGACY
FORMAT = string,log
ID = LEGACY_F1AP_INFO
DESC = F1AP INFO LEVEL
GROUP = ALL:LEGACY_F1AP:LEGACY_GROUP_INFO:LEGACY
FORMAT = string,log
ID = LEGACY_F1AP_WARNING
DESC = F1AP WARNING LEVEL
GROUP = ALL:LEGACY_F1AP:LEGACY_GROUP_WARNING:LEGACY
FORMAT = string,log
ID = LEGACY_F1AP_ERROR
DESC = F1AP ERROR LEVEL
GROUP = ALL:LEGACY_F1AP:LEGACY_GROUP_ERROR:LEGACY
FORMAT = string,log
#################
@@ -1599,6 +1676,46 @@ ID = VCD_VARIABLE_CPUID_RU_THREAD_TX
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
VCD_NAME = ru_thread_tx_CPUID
ID = VCD_VARIABLE_ON_DURATION_TIMER
DESC = VCD variable ON_DURATION_TIMER
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
VCD_NAME = ue0_on_duration_timer
ID = VCD_VARIABLE_DRX_INACTIVITY
DESC = VCD variable DRX_INACTIVITY
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
VCD_NAME = ue0_drx_inactivity
ID = VCD_VARIABLE_DRX_SHORT_CYCLE
DESC = VCD variable DRX_SHORT_CYCLE
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
VCD_NAME = ue0_drx_short_cycle
ID = VCD_VARIABLE_SHORT_DRX_CYCLE_NUMBER
DESC = VCD variable SHORT_DRX_CYCLE_NUMBER
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
VCD_NAME = ue0_short_drx_cycle_number
ID = VCD_VARIABLE_DRX_LONG_CYCLE
DESC = VCD variable DRX_LONG_CYCLE
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
VCD_NAME = ue0_drx_long_cycle
ID = VCD_VARIABLE_DRX_RETRANSMISSION_HARQ0
DESC = VCD variable DRX_RETRANSMISSION_HARQ0
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
VCD_NAME = ue0_drx_retransmission_harq0
ID = VCD_VARIABLE_DRX_ACTIVE_TIME
DESC = VCD variable DRX_ACTIVE_TIME
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
VCD_NAME = ue0_drx_active_time
ID = VCD_VARIABLE_DRX_ACTIVE_TIME_CONDITION
DESC = VCD variable DRX_ACTIVE_TIME_CONDITION
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
VCD_NAME = ue0_drx_active_time_condition
#functions
+154 -94
View File
@@ -31,7 +31,7 @@ typedef struct {
int remote_port;
pthread_mutex_t lock;
pthread_cond_t cond;
databuf * volatile head, *tail;
databuf *volatile head, *tail;
uint64_t memusage;
uint64_t last_warning_memusage;
} forward_data;
@@ -40,80 +40,115 @@ typedef struct {
/* utility functions */
/****************************************************************************/
static void new_thread(void *(*f)(void *), void *data)
{
static void new_thread(void *(*f)(void *), void *data) {
pthread_t t;
pthread_attr_t att;
if (pthread_attr_init(&att))
{ fprintf(stderr, "pthread_attr_init err\n"); exit(1); }
if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED))
{ fprintf(stderr, "pthread_attr_setdetachstate err\n"); exit(1); }
if (pthread_attr_setstacksize(&att, 10000000))
{ fprintf(stderr, "pthread_attr_setstacksize err\n"); exit(1); }
if (pthread_create(&t, &att, f, data))
{ fprintf(stderr, "pthread_create err\n"); exit(1); }
if (pthread_attr_destroy(&att))
{ fprintf(stderr, "pthread_attr_destroy err\n"); exit(1); }
if (pthread_attr_init(&att)) {
fprintf(stderr, "pthread_attr_init err\n");
exit(1);
}
if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) {
fprintf(stderr, "pthread_attr_setdetachstate err\n");
exit(1);
}
if (pthread_attr_setstacksize(&att, 10000000)) {
fprintf(stderr, "pthread_attr_setstacksize err\n");
exit(1);
}
if (pthread_create(&t, &att, f, data)) {
fprintf(stderr, "pthread_create err\n");
exit(1);
}
if (pthread_attr_destroy(&att)) {
fprintf(stderr, "pthread_attr_destroy err\n");
exit(1);
}
}
static int get_connection(char *addr, int port)
{
static int get_connection(char *addr, int port) {
struct sockaddr_in a;
socklen_t alen;
int s, t;
printf("T tracer: waiting for connection on %s:%d\n", addr, port);
s = socket(AF_INET, SOCK_STREAM, 0);
if (s == -1) { perror("socket"); exit(1); }
if (s == -1) {
perror("socket");
exit(1);
}
t = 1;
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &t, sizeof(int)))
{ perror("setsockopt"); exit(1); }
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &t, sizeof(int))) {
perror("setsockopt");
exit(1);
}
a.sin_family = AF_INET;
a.sin_port = htons(port);
a.sin_addr.s_addr = inet_addr(addr);
if (bind(s, (struct sockaddr *)&a, sizeof(a))) { perror("bind"); exit(1); }
if (listen(s, 5)) { perror("bind"); exit(1); }
if (bind(s, (struct sockaddr *)&a, sizeof(a))) {
perror("bind");
exit(1);
}
if (listen(s, 5)) {
perror("bind");
exit(1);
}
alen = sizeof(a);
t = accept(s, (struct sockaddr *)&a, &alen);
if (t == -1) { perror("accept"); exit(1); }
if (t == -1) {
perror("accept");
exit(1);
}
close(s);
printf("T tracer: connected\n");
return t;
}
static void forward(void *_forwarder, char *buf, int size);
void send_T_messages_txt(void *forwarder)
{
void send_T_messages_txt(void *forwarder) {
char buf[T_BUFFER_MAX];
char *T_LOCAL_buf = buf;
int T_LOCAL_size;
unsigned char *src;
int src_len;
/* trace T_message.txt
* Send several messages -1 with content followed by message -2.
*/
src = T_messages_txt;
src_len = T_messages_txt_len;
while (src_len) {
int send_size = src_len;
if (send_size > T_PAYLOAD_MAXSIZE - sizeof(int))
send_size = T_PAYLOAD_MAXSIZE - sizeof(int);
/* TODO: be careful, we use internal T stuff, to rewrite? */
T_LOCAL_size = 0;
T_HEADER(T_ID(-1));
T_PUT_buffer(1, ((T_buffer){addr:(src), length:(send_size)}));
T_PUT_buffer(1, ((T_buffer) {
addr:
(src), length:
(send_size)
}));
forward(forwarder, buf, T_LOCAL_size);
src += send_size;
src_len -= send_size;
}
T_LOCAL_size = 0;
T_HEADER(T_ID(-2));
forward(forwarder, buf, T_LOCAL_size);
@@ -123,49 +158,54 @@ void send_T_messages_txt(void *forwarder)
/* forward functions */
/****************************************************************************/
static void *data_sender(void *_f)
{
static void *data_sender(void *_f) {
forward_data *f = _f;
databuf *cur;
char *buf, *b;
int size;
wait:
if (pthread_mutex_lock(&f->lock)) abort();
while (f->head == NULL)
if (pthread_cond_wait(&f->cond, &f->lock)) abort();
cur = f->head;
buf = cur->d;
size = cur->l;
f->head = cur->next;
f->memusage -= size;
if (f->head == NULL) f->tail = NULL;
if (pthread_mutex_unlock(&f->lock)) abort();
free(cur);
goto process;
process:
b = buf;
if (f->socket_remote != -1)
while (size) {
int l = write(f->socket_remote, b, size);
if (l <= 0) {
printf("T tracer: forward error\n");
close(f->socket_remote);
f->socket_remote = -1;
break;
while (size) {
int l = write(f->socket_remote, b, size);
if (l <= 0) {
printf("T tracer: forward error\n");
close(f->socket_remote);
f->socket_remote = -1;
break;
}
size -= l;
b += l;
}
size -= l;
b += l;
}
free(buf);
goto wait;
}
static void *forward_remote_messages(void *_f)
{
static void *forward_remote_messages(void *_f) {
#define PUT(x) do { \
if (bufsize == bufmaxsize) { \
bufmaxsize += 4096; \
@@ -180,7 +220,6 @@ static void *forward_remote_messages(void *_f)
int len = l; \
while (len) { PUT(*zz); zz++; len--; } \
} while (0)
forward_data *f = _f;
int from;
int to;
@@ -190,43 +229,53 @@ static void *forward_remote_messages(void *_f)
int bufsize = 0;
int bufmaxsize = 0;
char t;
again:
while (1) {
from = f->socket_remote;
to = f->socket_local;
bufsize = 0;
/* let's read and process messages */
len = read(from, &t, 1); if (len <= 0) goto dead;
len = read(from, &t, 1);
if (len <= 0) goto dead;
PUT(t);
switch (t) {
case 0:
case 1:
/* message 0 and 1: get a length and then 'length' numbers */
if (read(from, &len, sizeof(int)) != sizeof(int)) goto dead;
PUT_BUF(&len, 4);
while (len) {
if (read(from, &l, sizeof(int)) != sizeof(int)) goto dead;
PUT_BUF(&l, 4);
len--;
}
break;
case 0:
case 1:
case 2: break;
default:
printf("%s:%d:%s: unhandled message type %d\n",
__FILE__, __LINE__, __FUNCTION__, t);
abort();
/* message 0 and 1: get a length and then 'length' numbers */
if (read(from, &len, sizeof(int)) != sizeof(int)) goto dead;
PUT_BUF(&len, 4);
while (len) {
if (read(from, &l, sizeof(int)) != sizeof(int)) goto dead;
PUT_BUF(&l, 4);
len--;
}
break;
case 2:
break;
default:
printf("%s:%d:%s: unhandled message type %d\n",
__FILE__, __LINE__, __FUNCTION__, t);
abort();
}
b = buf;
while (bufsize) {
l = write(to, b, bufsize);
if (l <= 0) abort();
bufsize -= l;
b += l;
}
@@ -236,71 +285,80 @@ dead:
/* socket died, let's stop all traces and wait for another tracer */
/* TODO: be careful with those write, they might write less than wanted */
buf[0] = 1;
if (write(to, buf, 1) != 1) abort();
len = T_NUMBER_OF_IDS;
if (write(to, &len, sizeof(int)) != sizeof(int)) abort();
l = 0;
while (len) {
if (write(to, &l, sizeof(int)) != sizeof(int)) abort();
len--;
};
close(f->socket_remote);
f->socket_remote = get_connection("0.0.0.0", f->remote_port);
send_T_messages_txt(f);
goto again;
return NULL;
}
static void *forwarder(int port, int s)
{
static void *forwarder(int port, int s) {
forward_data *f;
f = malloc(sizeof(*f));
f = malloc(sizeof(*f)); if (f == NULL) abort();
if (f == NULL) abort();
pthread_mutex_init(&f->lock, NULL);
pthread_cond_init(&f->cond, NULL);
f->socket_local = s;
f->head = f->tail = NULL;
f->memusage = 0;
f->last_warning_memusage = 0;
printf("T tracer: waiting for remote tracer on port %d\n", port);
f->remote_port = port;
f->socket_remote = get_connection("0.0.0.0", port);
send_T_messages_txt(f);
new_thread(data_sender, f);
new_thread(forward_remote_messages, f);
return f;
}
static void forward(void *_forwarder, char *buf, int size)
{
static void forward(void *_forwarder, char *buf, int size) {
forward_data *f = _forwarder;
int32_t ssize = size;
databuf *new;
new = malloc(sizeof(*new));
new = malloc(sizeof(*new)); if (new == NULL) abort();
if (new == NULL) abort();
if (pthread_mutex_lock(&f->lock)) abort();
new->d = malloc(size + 4); if (new->d == NULL) abort();
new->d = malloc(size + 4);
if (new->d == NULL) abort();
/* put the size of the message at the head */
memcpy(new->d, &ssize, 4);
memcpy(new->d+4, buf, size);
new->l = size+4;
new->next = NULL;
if (f->head == NULL) f->head = new;
if (f->tail != NULL) f->tail->next = new;
f->tail = new;
if (f->head == NULL) f->head = new;
if (f->tail != NULL) f->tail->next = new;
f->tail = new;
#if BASIC_SIMULATOR
/* When runnng the basic simulator, the tracer may be too slow.
* Let's not take too much memory in the tracee and
* wait if there is too much data to send. 200MB is
@@ -308,26 +366,30 @@ static void forward(void *_forwarder, char *buf, int size)
*/
while (f->memusage > 200 * 1024 * 1024) {
if (pthread_cond_signal(&f->cond)) abort();
if (pthread_mutex_unlock(&f->lock)) abort();
usleep(1000);
if (pthread_mutex_lock(&f->lock)) abort();
}
#endif /* BASIC_SIMULATOR */
#endif /* BASIC_SIMULATOR */
f->memusage += size+4;
/* warn every 100MB */
if (f->memusage > f->last_warning_memusage &&
f->memusage - f->last_warning_memusage > 100000000) {
f->last_warning_memusage += 100000000;
printf("T tracer: WARNING: memory usage is over %"PRIu64"MB\n",
f->last_warning_memusage / 1000000);
} else
if (f->memusage < f->last_warning_memusage &&
f->last_warning_memusage - f->memusage > 100000000) {
} else if (f->memusage < f->last_warning_memusage &&
f->last_warning_memusage - f->memusage > 100000000) {
f->last_warning_memusage = (f->memusage/100000000) * 100000000;
}
if (pthread_cond_signal(&f->cond)) abort();
if (pthread_mutex_unlock(&f->lock)) abort();
}
@@ -335,14 +397,12 @@ static void forward(void *_forwarder, char *buf, int size)
/* local functions */
/****************************************************************************/
static void wait_message(void)
{
static void wait_message(void) {
while ((T_local_cache[T_busylist_head].busy & 0x02) == 0) usleep(1000);
}
void T_local_tracer_main(int remote_port, int wait_for_tracer,
int local_socket, void *shm_array)
{
int local_socket, void *shm_array) {
int s;
int port = remote_port;
int dont_wait = wait_for_tracer ? 0 : 1;
@@ -350,16 +410,16 @@ void T_local_tracer_main(int remote_port, int wait_for_tracer,
/* write on a socket fails if the other end is closed and we get SIGPIPE */
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
printf("local tracer received SIGPIPE\n");
abort();
printf("local tracer received SIGPIPE\n");
abort();
}
T_local_cache = shm_array;
s = local_socket;
if (dont_wait) {
char t = 2;
if (write(s, &t, 1) != 1) abort();
}
+16 -23
View File
@@ -5,62 +5,56 @@
#include <string.h>
unsigned long register_notifier(gui *_g, char *notification, widget *w,
notifier handler, void *private)
{
notifier handler, void *private) {
struct gui *g = _g;
unsigned long ret;
glock(g);
if (g->next_notifier_id == 2UL * 1024 * 1024 * 1024)
ERR("%s:%d: report a bug\n", __FILE__, __LINE__);
g->notifiers = realloc(g->notifiers,
(g->notifiers_count+1) * sizeof(struct notifier));
(g->notifiers_count+1) * sizeof(struct notifier));
if (g->notifiers == NULL) abort();
ret = g->next_notifier_id;
g->notifiers[g->notifiers_count].handler = handler;
g->notifiers[g->notifiers_count].id = g->next_notifier_id;
g->next_notifier_id++;
g->notifiers[g->notifiers_count].notification = strdup(notification);
if (g->notifiers[g->notifiers_count].notification == NULL) abort();
g->notifiers[g->notifiers_count].w = w;
g->notifiers[g->notifiers_count].private = private;
/* initialize done to 1 so as not to call the handler if it's created
* by the call of another one that is in progress
*/
g->notifiers[g->notifiers_count].done = 1;
g->notifiers_count++;
gunlock(g);
return ret;
}
void unregister_notifier(gui *_g, unsigned long notifier_id)
{
void unregister_notifier(gui *_g, unsigned long notifier_id) {
struct gui *g = _g;
int i;
glock(g);
for (i = 0; i < g->notifiers_count; i++)
if (g->notifiers[i].id == notifier_id) break;
if (i == g->notifiers_count)
ERR("%s:%d: notifier_id %ld not found\n", __FILE__,__LINE__,notifier_id);
ERR("%s:%d: notifier_id %lu not found\n", __FILE__,__LINE__,notifier_id);
free(g->notifiers[i].notification);
memmove(g->notifiers + i, g->notifiers + i + 1,
(g->notifiers_count-1 - i) * sizeof(struct notifier));
(g->notifiers_count-1 - i) * sizeof(struct notifier));
g->notifiers_count--;
g->notifiers = realloc(g->notifiers,
g->notifiers_count * sizeof(struct notifier));
g->notifiers_count * sizeof(struct notifier));
if (g->notifiers == NULL) abort();
gunlock(g);
@@ -68,19 +62,19 @@ void unregister_notifier(gui *_g, unsigned long notifier_id)
/* called with lock ON */
void gui_notify(struct gui *g, char *notification, widget *w,
void *notification_data)
{
void *notification_data) {
void *private;
notifier handler;
int i;
/* this function is not re-entrant, for the moment keep as is
* and if the need is there, we'll make a new thread to handle
* notifications (or something)
* for now let's crash in case of recursive call
*/
static int inside = 0;
if (inside) ERR("%s:%d: BUG! contact the authors\n", __FILE__, __LINE__);
inside = 1;
/* clear all handlers */
@@ -91,26 +85,25 @@ void gui_notify(struct gui *g, char *notification, widget *w,
* need to be careful here
*/
loop:
for (i = 0; i < g->notifiers_count; i++) {
if (g->notifiers[i].done == 1 ||
g->notifiers[i].w != w ||
strcmp(g->notifiers[i].notification, notification) != 0)
continue;
break;
}
if (i == g->notifiers_count) goto done;
g->notifiers[i].done = 1;
handler = g->notifiers[i].handler;
private = g->notifiers[i].private;
gunlock(g);
handler(private, g, notification, w, notification_data);
glock(g);
goto loop;
done:
inside = 0;
}
+5 -1
View File
@@ -130,9 +130,13 @@ static void paint(gui *_gui, widget *_this)
this->common.y + FLIP(y),
this->common.x + this->vrule_width + 5,
this->common.y + FLIP(y));
/* do not print out of the widget (take care of top) */
y = FLIP(y)-this->label_height/2+this->label_baseline;
if (y - this->label_baseline < 0)
y = this->label_baseline;
x_draw_string(g->x, g->xwin, DEFAULT_FONT, FOREGROUND_COLOR,
this->common.x + this->vrule_width - vwidth - 2,
this->common.y + FLIP(y)-this->label_height/2+this->label_baseline,
this->common.y + y,
v);
}
break;
+4 -1
View File
@@ -3,7 +3,7 @@ CFLAGS=-Wall -g -pthread -DT_TRACER -I. -I..
LIBS=-lX11 -lm -lpng -lXft
all: dump_nack_signal time_meas timeplot
all: dump_nack_signal time_meas timeplot multi-rru-clean
dump_nack_signal: ../utils.o ../database.o ../config.o ../event.o \
dump_nack_signal.o
@@ -16,6 +16,9 @@ time_meas: ../utils.o ../database.o ../config.o ../event.o \
timplot: timeplot.o
$(CC) $(CFLAGS) -o timeplot $^ $(LIBS)
multi-rru-clean: ../utils.o ../database.o ../event.o ../config.o multi-rru-clean.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
.PHONY: all
%.o: %.c
+68 -32
View File
@@ -7,21 +7,19 @@
#include "config.h"
#include "../T_defs.h"
void usage(void)
{
void usage(void) {
printf(
"options:\n"
" -d <database file> this option is mandatory\n"
" -ip <host> connect to given IP address (default %s)\n"
" -p <port> connect to given port (default %d)\n",
DEFAULT_REMOTE_IP,
DEFAULT_REMOTE_PORT
"options:\n"
" -d <database file> this option is mandatory\n"
" -ip <host> connect to given IP address (default %s)\n"
" -p <port> connect to given port (default %d)\n",
DEFAULT_REMOTE_IP,
DEFAULT_REMOTE_PORT
);
exit(1);
}
int main(int n, char **v)
{
int main(int n, char **v) {
char *database_filename = NULL;
void *database;
char *ip = DEFAULT_REMOTE_IP;
@@ -36,11 +34,28 @@ 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], "-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], "-d")) {
if (i > n-2) usage();
database_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;
}
usage();
}
@@ -50,71 +65,92 @@ int main(int n, char **v)
}
database = parse_database(database_filename);
load_config_file(database_filename);
number_of_events = number_of_ids(database);
is_on = calloc(number_of_events, sizeof(int));
if (is_on == NULL) abort();
on_off(database, "ENB_PHY_INPUT_SIGNAL", is_on, 1);
on_off(database, "ENB_PHY_ULSCH_UE_NACK", is_on, 1);
on_off(database, "ENB_PHY_ULSCH_UE_ACK", is_on, 1);
ev_input = event_id_from_name(database, "ENB_PHY_INPUT_SIGNAL");
ev_nack = event_id_from_name(database, "ENB_PHY_ULSCH_UE_NACK");
ev_ack = event_id_from_name(database, "ENB_PHY_ULSCH_UE_ACK");
socket = connect_to(ip, port);
t = 1;
if (socket_send(socket, &t, 1) == -1 ||
socket_send(socket, &number_of_events, sizeof(int)) == -1 ||
socket_send(socket, is_on, number_of_events * sizeof(int)) == -1)
abort();
OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL };
char dump[10][T_BUFFER_MAX];
event dump_ev[10];
FILE *z = fopen("/tmp/dd", "w"); if (z == NULL) abort();
FILE *z = fopen("/tmp/dd", "w");
if (z == NULL) abort();
while (1) {
char *v;
event e;
e = get_event(socket, &ebuf, database);
v = ebuf.obuf;
if (e.type == -1) break;
if (e.type == ev_input) {
int sf = e.e[2].i;
if (ebuf.osize > T_BUFFER_MAX)
{ printf("event size too big\n"); exit(1); }
if (ebuf.osize > T_BUFFER_MAX) {
printf("event size too big\n");
exit(1);
}
memcpy(dump[sf], ebuf.obuf, ebuf.osize);
dump_ev[sf] = e;
printf("input %d/%d\n", e.e[1].i, sf);
if (fwrite(dump_ev[sf].e[4].b, dump_ev[sf].e[4].bsize, 1, z) != 1) abort();
fflush(z);
if (fwrite(dump_ev[sf].e[4].b, dump_ev[sf].e[4].bsize, 1, z) != 1) abort();
fflush(z);
}
if (e.type == ev_nack) {
int sf = e.e[2].i;
printf("nack %d/%d\n", e.e[1].i, sf);
FILE *f = fopen("/tmp/dump.raw", "w"); if (f == NULL) abort();
FILE *f = fopen("/tmp/dump.raw", "w");
if (f == NULL) abort();
if (fwrite(dump[sf] + ((char *)dump_ev[sf].e[4].b - v),
dump_ev[sf].e[4].bsize, 1, f) != 1) abort();
dump_ev[sf].e[4].bsize, 1, f) != 1) abort();
if (fclose(f)) abort();
printf("dumped... press enter (delta %d)\n", (int)((char *)dump_ev[sf].e[4].b - v));
// getchar();
// getchar();
}
if (e.type == ev_ack) {
int sf = e.e[2].i;
printf("ack %d/%d\n", e.e[1].i, sf);
FILE *f = fopen("/tmp/dump.raw", "w"); if (f == NULL) abort();
FILE *f = fopen("/tmp/dump.raw", "w");
if (f == NULL) abort();
if (fwrite(dump[sf] + ((char *)dump_ev[sf].e[4].b - v),
dump_ev[sf].e[4].bsize, 1, f) != 1) abort();
dump_ev[sf].e[4].bsize, 1, f) != 1) abort();
if (fclose(f)) abort();
printf("dumped... press enter (delta %d)\n", (int)((char *)dump_ev[sf].e[4].b - v));
// getchar();
// getchar();
}
}
if (z)
fclose(z);
return 0;
}
@@ -0,0 +1,230 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "database.h"
#include "utils.h"
#include "event.h"
#include "../T_defs.h"
void usage(void)
{
printf(
"usage: <number of tags> <input record file> <output curated record file>\n"
"options:\n"
" -d <database file> this option is mandatory\n"
);
exit(1);
}
#define ERR printf("ERROR: read file %s failed\n", input_filename)
typedef struct {
OBUF b;
struct timespec t;
int filled;
int error;
} cache_t;
void clear_cache(int n, cache_t *c)
{
int i;
for (i = 0; i < n; i++) {
c[i].filled = 0;
c[i].error = 0;
c[i].b.osize = 0;
}
}
void store_in_cache(cache_t *c, int pos, OBUF *b)
{
int i;
for (i = 0; i < b->osize; i++)
PUTC(&c[pos].b, b->obuf[i]);
}
int get_field(database_event_format *f, char *field, char *type)
{
int i;
for (i = 0; i < f->count; i++)
if (!strcmp(f->name[i], field)) {
if (strcmp(f->type[i], type)) break;
return i;
}
printf("bad field %s, check that it exists and has type '%s'\n",field,type);
exit(1);
}
void process_cache(FILE *out, cache_t *c, int n, int frame, int subframe)
{
int i;
struct tm *t;
for (i = 0; i < n; i++)
if (c[i].filled == 0 || c[i].error == 1)
goto error;
for (i = 0; i < n; i++)
fwrite(c[i].b.obuf, c[i].b.osize, 1, out);
clear_cache(n, c);
return;
error:
printf("ERROR: incorrect data at frame %d subframe %d", frame, subframe);
for (i = 0; i < n; i++) if (c[i].filled) {
t = localtime(&c[i].t.tv_sec);
printf(" [tag %d time %2.2d:%2.2d:%2.2d.%9.9ld]", i,
t->tm_hour, t->tm_min, t->tm_sec, c[i].t.tv_nsec);
}
printf("\n");
clear_cache(n, c);
}
int main(int n, char **v)
{
char *database_filename = NULL;
void *database;
int channel_estimate_id;
int number_of_tags = -1;
char *input_filename = NULL;
char *output_filename = NULL;
int i;
FILE *in;
FILE *out;
database_event_format f;
int frame_arg;
int subframe_arg;
int tag_arg;
cache_t *cache;
int cur_frame = -1;
int cur_subframe = -1;
int frame;
int subframe;
int tag;
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 (number_of_tags == -1) { number_of_tags = atoi(v[i]);
if (number_of_tags <= 0) {usage();} continue; }
if (input_filename == NULL) { input_filename = v[i]; continue; }
if (output_filename == NULL) { output_filename = v[i]; continue; }
usage();
}
if (database_filename == NULL) {
printf("ERROR: provide a database file (-d)\n");
exit(1);
}
if (output_filename == NULL || input_filename == NULL || number_of_tags == -1)
usage();
database = parse_database(database_filename);
channel_estimate_id = event_id_from_name(database, "CALIBRATION_CHANNEL_ESTIMATES");
f = get_format(database, channel_estimate_id);
frame_arg = get_field(&f, "frame", "int");
subframe_arg = get_field(&f, "subframe", "int");
tag_arg = get_field(&f, "tag", "int");
in = fopen(input_filename, "r");
if (in == NULL) { perror(input_filename); abort(); }
out = fopen(output_filename, "w");
if (out == NULL) { perror(output_filename); abort(); }
cache = calloc(number_of_tags, sizeof(cache_t));
if (cache == NULL) { perror("malloc"); exit(1); }
clear_cache(number_of_tags, cache);
OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL };
while (1) {
int type;
int32_t length;
char *v;
int vpos = 0;
struct timespec t;
char *buf;
/* read event from file */
if (fread(&length, 4, 1, in) != 1) break;
if (ebuf.omaxsize < length) {
ebuf.omaxsize = (length + 65535) & ~65535;
ebuf.obuf = realloc(ebuf.obuf, ebuf.omaxsize);
if (ebuf.obuf == NULL) { printf("out of memory\n"); exit(1); }
}
v = ebuf.obuf;
memcpy(v+vpos, &length, 4);
vpos += 4;
#ifdef T_SEND_TIME
if (length < sizeof(struct timespec)) { ERR; break; }
if (fread(&t, sizeof(struct timespec), 1, in) != 1) { ERR; break; }
memcpy(v+vpos, &t, sizeof(struct timespec));
vpos += sizeof(struct timespec);
length -= sizeof(struct timespec);
#endif
if (length < sizeof(int)) { ERR; break; }
if (fread(&type, sizeof(int), 1, in) != 1) { ERR; break; }
memcpy(v+vpos, &type, sizeof(int));
vpos += sizeof(int);
length -= sizeof(int);
if (length) if (fread(v+vpos, length, 1, in) != 1) { ERR; break; }
buf = v + vpos;
vpos += length;
ebuf.osize = vpos;
if (type != channel_estimate_id) continue;
event e;
#ifdef T_SEND_TIME
e = new_event(t, type, length, buf, database);
#else
e = new_event(type, length, buf, database);
#endif
frame = e.e[frame_arg].i;
subframe = e.e[subframe_arg].i;
tag = e.e[tag_arg].i;
if (tag < 0 || tag >= number_of_tags) {
struct tm *tt;
tt = localtime(&t.tv_sec);
printf("ERROR: invalid tag (%d), skipping event for frame %d subframe %d (time %2.2d:%2.2d:%2.2d.%9.9ld)\n",
tag, frame, subframe,
tt->tm_hour, tt->tm_min, tt->tm_sec, t.tv_nsec);
continue;
}
if (cur_frame != frame || cur_subframe != subframe)
if (cur_frame != -1)
process_cache(out, cache, number_of_tags, cur_frame, cur_subframe);
cur_frame = frame;
cur_subframe = subframe;
if (cache[tag].filled) {
struct tm *tt;
tt = localtime(&t.tv_sec);
printf("ERROR: tag %d present twice at frame %d subframe %d (time %2.2d:%2.2d:%2.2d.%9.9ld)\n",
tag, frame, subframe,
tt->tm_hour, tt->tm_min, tt->tm_sec, t.tv_nsec);
cache[tag].error = 1;
continue;
}
store_in_cache(cache, tag, &ebuf);
cache[tag].filled = 1;
cache[tag].t = t;
}
if (fclose(in)) perror(input_filename);
if (fclose(out)) perror(output_filename);
free(cache);
return 0;
}
+149 -83
View File
@@ -58,14 +58,11 @@ typedef struct {
} ev_data;
void trace(ev_data *d, int direction, int rnti_type, int rnti,
int frame, int subframe, void *buf, int bufsize, int preamble)
{
int frame, int subframe, void *buf, int bufsize, int preamble) {
ssize_t ret;
int fsf;
int i;
d->buf.osize = 0;
PUTS(&d->buf, MAC_LTE_START_STRING);
PUTC(&d->buf, FDD_RADIO);
PUTC(&d->buf, direction);
@@ -92,16 +89,17 @@ void trace(ev_data *d, int direction, int rnti_type, int rnti,
}
PUTC(&d->buf, MAC_LTE_PAYLOAD_TAG);
for (i = 0; i < bufsize; i++)
PUTC(&d->buf, ((char*)buf)[i]);
PUTC(&d->buf, ((char *)buf)[i]);
ret = sendto(d->socket, d->buf.obuf, d->buf.osize, 0,
(struct sockaddr *)&d->to, sizeof(struct sockaddr_in));
(struct sockaddr *)&d->to, sizeof(struct sockaddr_in));
if (ret != d->buf.osize) abort();
}
void ul(void *_d, event e)
{
void ul(void *_d, event e) {
ev_data *d = _d;
trace(d, DIRECTION_UPLINK, C_RNTI, e.e[d->ul_rnti].i,
e.e[d->ul_frame].i, e.e[d->ul_subframe].i,
@@ -109,13 +107,14 @@ void ul(void *_d, event e)
NO_PREAMBLE);
}
void dl(void *_d, event e)
{
void dl(void *_d, event e) {
ev_data *d = _d;
if (e.e[d->dl_rnti].i == 0xffff) {
if (d->no_sib) return;
if (d->max_sib && d->cur_sib == d->max_sib) return;
d->cur_sib++;
}
@@ -126,22 +125,21 @@ void dl(void *_d, event e)
NO_PREAMBLE);
}
void mib(void *_d, event e)
{
void mib(void *_d, event e) {
ev_data *d = _d;
if (d->no_mib) return;
if (d->max_mib && d->cur_mib == d->max_mib) return;
d->cur_mib++;
if (d->max_mib && d->cur_mib == d->max_mib) return;
d->cur_mib++;
trace(d, DIRECTION_DOWNLINK, NO_RNTI, 0,
e.e[d->mib_frame].i, e.e[d->mib_subframe].i,
e.e[d->mib_data].b, e.e[d->mib_data].bsize,
NO_PREAMBLE);
}
void preamble(void *_d, event e)
{
void preamble(void *_d, event e) {
ev_data *d = _d;
trace(d, DIRECTION_UPLINK, NO_RNTI, 0,
e.e[d->preamble_frame].i, e.e[d->preamble_subframe].i,
@@ -149,8 +147,7 @@ void preamble(void *_d, event e)
e.e[d->preamble_preamble].i);
}
void rar(void *_d, event e)
{
void rar(void *_d, event e) {
ev_data *d = _d;
trace(d, DIRECTION_DOWNLINK, RA_RNTI, e.e[d->rar_rnti].i,
e.e[d->rar_frame].i, e.e[d->rar_subframe].i,
@@ -159,114 +156,118 @@ void rar(void *_d, event e)
}
void setup_data(ev_data *d, void *database, int ul_id, int dl_id, int mib_id,
int preamble_id, int rar_id)
{
int preamble_id, int rar_id) {
database_event_format f;
int i;
d->ul_rnti = -1;
d->ul_frame = -1;
d->ul_subframe = -1;
d->ul_data = -1;
d->dl_rnti = -1;
d->dl_frame = -1;
d->dl_subframe = -1;
d->dl_data = -1;
d->mib_frame = -1;
d->mib_subframe = -1;
d->mib_data = -1;
d->preamble_frame = -1;
d->preamble_subframe = -1;
d->preamble_preamble = -1;
d->rar_rnti = -1;
d->rar_frame = -1;
d->rar_subframe = -1;
d->rar_data = -1;
#define G(var_name, var_type, var) \
if (!strcmp(f.name[i], var_name)) { \
if (strcmp(f.type[i], var_type)) goto error; \
var = i; \
continue; \
}
/* ul: rnti, frame, subframe, data */
f = get_format(database, ul_id);
for (i = 0; i < f.count; i++) {
G("rnti", "int", d->ul_rnti);
G("frame", "int", d->ul_frame);
G("subframe", "int", d->ul_subframe);
G("data", "buffer", d->ul_data);
}
if (d->ul_rnti == -1 || d->ul_frame == -1 || d->ul_subframe == -1 ||
d->ul_data == -1) goto error;
/* dl: rnti, frame, subframe, data */
f = get_format(database, dl_id);
for (i = 0; i < f.count; i++) {
G("rnti", "int", d->dl_rnti);
G("frame", "int", d->dl_frame);
G("subframe", "int", d->dl_subframe);
G("data", "buffer", d->dl_data);
}
if (d->dl_rnti == -1 || d->dl_frame == -1 || d->dl_subframe == -1 ||
d->dl_data == -1) goto error;
/* MIB: frame, subframe, data */
f = get_format(database, mib_id);
for (i = 0; i < f.count; i++) {
G("frame", "int", d->mib_frame);
G("subframe", "int", d->mib_subframe);
G("data", "buffer", d->mib_data);
}
if (d->mib_frame == -1 || d->mib_subframe == -1 || d->mib_data == -1)
goto error;
/* preamble: frame, subframe, preamble */
f = get_format(database, preamble_id);
for (i = 0; i < f.count; i++) {
G("frame", "int", d->preamble_frame);
G("subframe", "int", d->preamble_subframe);
G("preamble", "int", d->preamble_preamble);
}
if (d->preamble_frame == -1 || d->preamble_subframe == -1 ||
d->preamble_preamble == -1) goto error;
/* rar: rnti, frame, subframe, data */
f = get_format(database, rar_id);
for (i = 0; i < f.count; i++) {
G("rnti", "int", d->rar_rnti);
G("frame", "int", d->rar_frame);
G("subframe", "int", d->rar_subframe);
G("data", "buffer", d->rar_data);
}
if (d->rar_rnti == -1 || d->rar_frame == -1 || d->rar_subframe == -1 ||
d->rar_data == -1) goto error;
#undef G
return;
error:
printf("bad T_messages.txt\n");
abort();
}
void *receiver(void *_d)
{
void *receiver(void *_d) {
ev_data *d = _d;
int s;
char buf[100000];
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s == -1) { perror("socket"); abort(); }
if (bind(s, (struct sockaddr *)&d->to, sizeof(struct sockaddr_in)) == -1)
{ perror("bind"); abort(); }
if (s == -1) {
perror("socket");
abort();
}
if (bind(s, (struct sockaddr *)&d->to, sizeof(struct sockaddr_in)) == -1) {
perror("bind");
abort();
}
while (1) {
if (recv(s, buf, 100000, 0) <= 0) abort();
@@ -275,33 +276,31 @@ void *receiver(void *_d)
return 0;
}
void usage(void)
{
void usage(void) {
printf(
"options:\n"
" -d <database file> this option is mandatory\n"
" -i <dump file> read events from this dump file\n"
" -ip <IP address> send packets to this IP address (default %s)\n"
" -p <port> send packets to this port (default %d)\n"
" -no-mib do not report MIB\n"
" -no-sib do not report SIBs\n"
" -max-mib <n> report at maximum n MIB\n"
" -max-sib <n> report at maximum n SIBs\n"
" -live run live\n"
" -live-ip <IP address> tracee's IP address (default %p)\n"
" -live-port <por> tracee's port (default %d)\n"
"-i and -live are mutually exclusive options. One of them must be provided\n"
"but not both.\n",
DEFAULT_IP,
DEFAULT_PORT,
DEFAULT_LIVE_IP,
DEFAULT_LIVE_PORT
"options:\n"
" -d <database file> this option is mandatory\n"
" -i <dump file> read events from this dump file\n"
" -ip <IP address> send packets to this IP address (default %s)\n"
" -p <port> send packets to this port (default %d)\n"
" -no-mib do not report MIB\n"
" -no-sib do not report SIBs\n"
" -max-mib <n> report at maximum n MIB\n"
" -max-sib <n> report at maximum n SIBs\n"
" -live run live\n"
" -live-ip <IP address> tracee's IP address (default %s)\n"
" -live-port <port> tracee's port (default %d)\n"
"-i and -live are mutually exclusive options. One of them must be provided\n"
"but not both.\n",
DEFAULT_IP,
DEFAULT_PORT,
DEFAULT_LIVE_IP,
DEFAULT_LIVE_PORT
);
exit(1);
}
int main(int n, char **v)
{
int main(int n, char **v) {
char *database_filename = NULL;
char *input_filename = NULL;
void *database;
@@ -315,28 +314,82 @@ int main(int n, char **v)
char *live_ip = DEFAULT_LIVE_IP;
int live_port = DEFAULT_LIVE_PORT;
int live = 0;
memset(&d, 0, sizeof(ev_data));
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;
}
usage();
}
@@ -357,25 +410,34 @@ int main(int n, char **v)
if (live == 0) {
in = open(input_filename, O_RDONLY);
if (in == -1) { perror(input_filename); return 1; }
if (in == -1) {
perror(input_filename);
return 1;
}
} else
in = connect_to(live_ip, live_port);
database = parse_database(database_filename);
load_config_file(database_filename);
h = new_handler(database);
if (live) {
char mt = 1;
int number_of_events = number_of_ids(database);
int *is_on = calloc(number_of_events, sizeof(int));
if (is_on == NULL) { printf("ERROR: out of memory\n"); exit(1); }
if (is_on == NULL) {
printf("ERROR: out of memory\n");
exit(1);
}
on_off(database, "ENB_MAC_UE_UL_PDU_WITH_DATA", is_on, 1);
on_off(database, "ENB_MAC_UE_DL_PDU_WITH_DATA", is_on, 1);
on_off(database, "ENB_PHY_MIB", is_on, 1);
on_off(database, "ENB_PHY_INITIATE_RA_PROCEDURE", is_on, 1);
on_off(database, "ENB_MAC_UE_DL_RAR_PDU_WITH_DATA", is_on, 1);
/* activate selected traces */
if (socket_send(in, &mt, 1) == -1 ||
socket_send(in, &number_of_events, sizeof(int)) == -1 ||
@@ -383,6 +445,7 @@ int main(int n, char **v)
printf("ERROR: socket_send failed\n");
exit(1);
}
free(is_on);
}
@@ -392,31 +455,34 @@ int main(int n, char **v)
preamble_id = event_id_from_name(database, "ENB_PHY_INITIATE_RA_PROCEDURE");
rar_id = event_id_from_name(database, "ENB_MAC_UE_DL_RAR_PDU_WITH_DATA");
setup_data(&d, database, ul_id, dl_id, mib_id, preamble_id, rar_id);
register_handler_function(h, ul_id, ul, &d);
register_handler_function(h, dl_id, dl, &d);
register_handler_function(h, mib_id, mib, &d);
register_handler_function(h, preamble_id, preamble, &d);
register_handler_function(h, rar_id, rar, &d);
d.socket = socket(AF_INET, SOCK_DGRAM, 0);
if (d.socket == -1) { perror("socket"); exit(1); }
if (d.socket == -1) {
perror("socket");
exit(1);
}
d.to.sin_family = AF_INET;
d.to.sin_port = htons(port);
d.to.sin_addr.s_addr = inet_addr(ip);
new_thread(receiver, &d);
OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL };
/* read messages */
while (1) {
event e;
e = get_event(in, &ebuf, database);
if (e.type == -1) break;
if (!(e.type == ul_id || e.type == dl_id || e.type == mib_id ||
e.type == preamble_id || e.type == rar_id)) continue;
handle_event(h, e);
}
+3
View File
@@ -195,5 +195,8 @@ int main(int n, char **v)
handle_event(h, e);
}
free(on_off_name);
free(on_off_action);
return 0;
}
+102 -197
View File
@@ -23,9 +23,6 @@ typedef struct {
view *pdcpview;
view *rrcview;
view *legacy;
widget *current_ue_label;
widget *prev_ue_button;
widget *next_ue_button;
widget *pdsch_iq_ue_xy_plot;
widget *dl_estimate_ue_xy_plot;
widget *pdcch_energy_ue_xy_plot;
@@ -121,15 +118,14 @@ static void *gui_thread(void *_g)
return NULL;
}
static filter *ticktime_filter(void *database, char *event, int i, int ue)
static filter *ticktime_filter(void *database, char *event, int i)
{
/* filter is "harq_pid == i && UE_id == 0 && eNB_id == 0" */
/* filter is "harq_pid == i and eNB_id == 0" */
return
filter_and(
filter_eq(filter_evarg(database, event, "harq_pid"), filter_int(i)),
filter_and(
filter_eq(filter_evarg(database, event, "UE_id"), filter_int(ue)),
filter_eq(filter_evarg(database, event, "eNB_ID"), filter_int(0))));
filter_eq(filter_evarg(database, event, "eNB_ID"), filter_int(0)));
}
static void set_current_ue(gui *g, ue_data *e, int ue)
@@ -137,8 +133,6 @@ static void set_current_ue(gui *g, ue_data *e, int ue)
int i;
char s[256];
sprintf(s, "[UE %d] ", ue);
label_set_text(g, e->e->current_ue_label, s);
sprintf(s, "PDSCH IQ [UE %d]", ue);
xy_plot_set_title(g, e->e->pdsch_iq_ue_xy_plot, s);
sprintf(s, "DL estimated channel [UE %d]", ue);
@@ -161,97 +155,24 @@ static void set_current_ue(gui *g, ue_data *e, int ue)
xy_plot_set_title(g, e->e->pucch_power_xy_plot, s);
sprintf(s, "PHY Measurements [UE %d]", ue);
xy_plot_set_title(g, e->e->phy_meas_xy_plot, s);
logger_set_filter(e->e->pdsch_iq_ue_logger,
filter_eq(
filter_evarg(e->database, "UE_PHY_PDSCH_IQ", "UE_ID"),
filter_int(ue)));
logger_set_filter(e->e->dl_estimate_ue_logger,
filter_eq(
filter_evarg(e->database, "UE_PHY_DL_CHANNEL_ESTIMATE", "UE_ID"),
filter_int(ue)));
logger_set_filter(e->e->pdcch_energy_logger,
filter_eq(
filter_evarg(e->database, "UE_PHY_PDCCH_ENERGY", "UE_ID"),
filter_int(ue)));
logger_set_filter(e->e->pdsch_energy_logger,
filter_eq(
filter_evarg(e->database, "UE_PHY_PDSCH_ENERGY", "UE_ID"),
filter_int(ue)));
logger_set_filter(e->e->phy_meas_logger,
filter_eq(
filter_evarg(e->database, "UE_PHY_MEAS", "UE_ID"),
filter_int(ue)));
/*logger_set_filter(e->pucch1_energy_ue_energy_logger,
filter_eq(
filter_evarg(e->database, "ENB_PHY_PUCCH_1_ENERGY", "UE_ID"),
filter_int(ue)));*/
/*logger_set_filter(e->e->pdcch_iq_ue_logger,
filter_eq(
filter_evarg(e->database, "UE_PHY_PDCCH_IQ", "UE_ID"),
filter_int(ue)));*/
for (i = 0; i < 8; i++) {
logger_set_filter(e->e->dl_dci_logger[i],
ticktime_filter(e->database, "UE_PHY_DLSCH_UE_DCI", i, ue));
ticktime_filter(e->database, "UE_PHY_DLSCH_UE_DCI", i));
logger_set_filter(e->e->dl_ack_logger[i],
ticktime_filter(e->database, "UE_PHY_DLSCH_UE_ACK", i, ue));
ticktime_filter(e->database, "UE_PHY_DLSCH_UE_ACK", i));
logger_set_filter(e->e->dl_nack_logger[i],
ticktime_filter(e->database, "UE_PHY_DLSCH_UE_NACK", i, ue));
ticktime_filter(e->database, "UE_PHY_DLSCH_UE_NACK", i));
logger_set_filter(e->e->ul_dci_logger[i],
ticktime_filter(e->database, "UE_PHY_ULSCH_UE_DCI", i, ue));
ticktime_filter(e->database, "UE_PHY_ULSCH_UE_DCI", i));
/*logger_set_filter(e->ul_dci_retransmission_logger[i],
ticktime_filter(e->database,
"ENB_PHY_ULSCH_UE_NO_DCI_RETRANSMISSION", i, ue));*/
"ENB_PHY_ULSCH_UE_NO_DCI_RETRANSMISSION", i));*/
logger_set_filter(e->e->ul_ack_logger[i],
ticktime_filter(e->database, "UE_PHY_ULSCH_UE_ACK", i, ue));
ticktime_filter(e->database, "UE_PHY_ULSCH_UE_ACK", i));
logger_set_filter(e->e->ul_nack_logger[i],
ticktime_filter(e->database, "UE_PHY_ULSCH_UE_NACK", i, ue));
ticktime_filter(e->database, "UE_PHY_ULSCH_UE_NACK", i));
}
logger_set_filter(e->e->dl_mcs_logger,
filter_eq(
filter_evarg(e->database, "UE_PHY_DLSCH_UE_DCI", "UE_id"),
filter_int(ue)));
logger_set_filter(e->e->ul_mcs_logger,
filter_eq(
filter_evarg(e->database, "UE_PHY_ULSCH_UE_DCI", "UE_id"),
filter_int(ue)));
logger_set_filter(e->e->pusch_power_logger,
filter_eq(
filter_evarg(e->database, "UE_PHY_PUSCH_TX_POWER", "UE_id"),
filter_int(ue)));
logger_set_filter(e->e->pusch_ampl_logger,
filter_eq(
filter_evarg(e->database, "UE_PHY_PUSCH_TX_POWER", "UE_id"),
filter_int(ue)));
logger_set_filter(e->e->pucch_power_logger,
filter_eq(
filter_evarg(e->database, "UE_PHY_PUCCH_TX_POWER", "UE_id"),
filter_int(ue)));
logger_set_filter(e->e->pucch_ampl_logger,
filter_eq(
filter_evarg(e->database, "UE_PHY_PUCCH_TX_POWER", "UE_id"),
filter_int(ue)));
}
static void click(void *private, gui *g,
char *notification, widget *w, void *notification_data)
{
int *d = notification_data;
int button = d[0];
ue_data *ed = private;
ue_gui *e = ed->e;
int ue = ed->ue;
if (button != 1) return;
if (w == e->prev_ue_button) { ue--; if (ue < 0) ue = 0; }
if (w == e->next_ue_button) ue++;
if (pthread_mutex_lock(&ed->lock)) abort();
if (ue != ed->ue) {
set_current_ue(g, ed, ue);
ed->ue = ue;
}
if (pthread_mutex_unlock(&ed->lock)) abort();
}
static void ue_main_gui(ue_gui *e, gui *g, event_handler *h, void *database,
@@ -271,7 +192,7 @@ static void ue_main_gui(ue_gui *e, gui *g, event_handler *h, void *database,
widget *text;
view *textview;
int i;
widget *w, *w2;
widget *w;
view *v;
logger *l;
@@ -283,24 +204,8 @@ static void ue_main_gui(ue_gui *e, gui *g, event_handler *h, void *database,
widget_add_child(g, top_container, line, -1);
logo = new_image(g, openair_logo_png, openair_logo_png_len);
/* logo + prev/next UE buttons */
col = new_container(g, VERTICAL);
widget_add_child(g, col, logo, -1);
w = new_container(g, HORIZONTAL);
widget_add_child(g, col, w, -1);
w2 = new_label(g, "");
widget_add_child(g, w, w2, -1);
e->current_ue_label = w2;
/* TODO: use button widget, not label widget */
w2 = new_label(g, " [prev UE] ");
widget_add_child(g, w, w2, -1);
label_set_clickable(g, w2, 1);
e->prev_ue_button = w2;
w2 = new_label(g, " [next UE] ");
widget_add_child(g, w, w2, -1);
label_set_clickable(g, w2, 1);
e->next_ue_button = w2;
widget_add_child(g, line, col, -1);
/* logo */
widget_add_child(g, line, logo, -1);
input_signal_plot = new_xy_plot(g, 256, 55, "input signal", 20);
widget_add_child(g, line, input_signal_plot, -1);
@@ -356,80 +261,13 @@ static void ue_main_gui(ue_gui *e, gui *g, event_handler *h, void *database,
v = new_view_tti(10, g, w, new_color(g, "#0c720c"));
logger_add_view(l, v);
e->phy_meas_logger = l;
/* UE x PDSCH energy */
w = new_xy_plot(g, 128, 55, "", 50);
e->pdsch_energy_ue_xy_plot = w;
/* a bit of space */
line = new_container(g, HORIZONTAL);
widget_add_child(g, top_container, line, -1);
w = new_space(g, 1, 10);
widget_add_child(g, line, w, -1);
xy_plot_set_range(g, w, 0, 1024*10, -10, 80);
l = new_ttilog(h, database,
"UE_PHY_PDSCH_ENERGY", "frame", "subframe", "pdsch_ch_level00", 1);
v = new_view_tti(10, g, w, new_color(g, "#ff0000"));
logger_add_view(l, v);
e->pdsch_energy_logger = l;
l = new_ttilog(h, database,
"UE_PHY_PDSCH_ENERGY", "frame", "subframe", "pdsch_ch_level01", 1);
v = new_view_tti(10, g, w, new_color(g, "#00ff00"));
logger_add_view(l, v);
e->pdsch_energy_logger = l;
l = new_ttilog(h, database,
"UE_PHY_PDSCH_ENERGY", "frame", "subframe", "pdsch_ch_level10", 1);
v = new_view_tti(10, g, w, new_color(g, "#0f0f0f"));
logger_add_view(l, v);
e->pdsch_energy_logger = l;
l = new_ttilog(h, database,
"UE_PHY_PDSCH_ENERGY", "frame", "subframe", "pdsch_ch_level11", 1);
v = new_view_tti(10, g, w, new_color(g, "#0000ff"));
logger_add_view(l, v);
e->pdsch_energy_logger = l;
/* UE x PDCCH energy */
w = new_xy_plot(g, 128, 55, "", 50);
e->pdcch_energy_ue_xy_plot = w;
widget_add_child(g, line, w, -1);
xy_plot_set_range(g, w, 0, 1024*10, -10, 80);
l = new_ttilog(h, database,
"UE_PHY_PDCCH_ENERGY", "frame", "subframe", "pdcch_ch_level00", 1);
v = new_view_tti(10, g, w, new_color(g, "#ff0000"));
logger_add_view(l, v);
e->pdcch_energy_logger = l;
l = new_ttilog(h, database,
"UE_PHY_PDCCH_ENERGY", "frame", "subframe", "pdcch_ch_level01", 1);
v = new_view_tti(10, g, w, new_color(g, "#00ff00"));
logger_add_view(l, v);
e->pdcch_energy_logger = l;
l = new_ttilog(h, database,
"UE_PHY_PDCCH_ENERGY", "frame", "subframe", "pdcch_ch_level10", 1);
v = new_view_tti(10, g, w, new_color(g, "#0f0f0f"));
logger_add_view(l, v);
e->pdcch_energy_logger = l;
l = new_ttilog(h, database,
"UE_PHY_PDCCH_ENERGY", "frame", "subframe", "pdcch_ch_level11", 1);
v = new_view_tti(10, g, w, new_color(g, "#0000ff"));
logger_add_view(l, v);
e->pdcch_energy_logger = l;
/* UE x PDCCH IQ data */
w = new_xy_plot(g, 55, 55, "", 50);
e->pdcch_iq_ue_xy_plot = w;
widget_add_child(g, line, w, -1);
xy_plot_set_range(g, w, -100, 100, -100, 100);
l = new_iqlog(h, database, "UE_PHY_PDCCH_IQ", "nb_rb",
"NB_RB_DL", "symbols_per_tti", "rxdataF_comp");
v = new_view_xy(100*12*14,10,g,w,new_color(g,"#000"),XY_FORCED_MODE);
logger_add_view(l, v);
e->pdcch_iq_ue_logger = l;
/* UE x PDCCH IQ data */
/*w = new_xy_plot(g, 55, 55, "", 50);
e->pdcch_iq_ue_xy_plot = w;
widget_add_child(g, line, w, -1);
xy_plot_set_range(g, w, -2000, 2000, -2000, 2000);
l = new_iqdotlog(h, database, "UE_PHY_PDCCH_IQ", "I", "Q");
v = new_view_xy(500, 10, g, w, new_color(g,"#000"), XY_LOOP_MODE);
logger_add_view(l, v);
e->pdcch_iq_ue_logger = l;*/
/* UE x DL mcs */
line = new_container(g, HORIZONTAL);
widget_add_child(g, top_container, line, -1);
@@ -448,7 +286,7 @@ static void ue_main_gui(ue_gui *e, gui *g, event_handler *h, void *database,
xy_plot_set_range(g, w, 0, 1024*10, -2, 30);
e->ul_mcs_xy_plot = w;
widget_add_child(g, line, w, -1);
l = new_ticked_ttilog(h, database, "UE_PHY_UL_TICK", "frame", "subframe",
l = new_ticked_ttilog(h, database, "UE_PHY_DL_TICK", "frame", "subframe",
"UE_PHY_ULSCH_UE_DCI", "mcs", 0, -1);
v = new_view_tti(10, g, w, new_color(g, "#0c0c72"));
logger_add_view(l, v);
@@ -471,7 +309,7 @@ static void ue_main_gui(ue_gui *e, gui *g, event_handler *h, void *database,
v = new_view_tti(10, g, w, new_color(g, "#720c0c"));
logger_add_view(l, v);
e->pusch_ampl_logger = l;
/* UE x PUCCH TX Power */
// line = new_container(g, HORIZONTAL);
// widget_add_child(g, top_container, line, -1);
@@ -489,8 +327,81 @@ static void ue_main_gui(ue_gui *e, gui *g, event_handler *h, void *database,
v = new_view_tti(10, g, w, new_color(g, "#720c0c"));
logger_add_view(l, v);
e->pucch_ampl_logger = l;
/* UE x PDSCH energy */
w = new_xy_plot(g, 128, 55, "", 50);
e->pdsch_energy_ue_xy_plot = w;
widget_add_child(g, line, w, -1);
xy_plot_set_range(g, w, 0, 1024*10, -10, 80);
l = new_ttilog(h, database,
"UE_PHY_PDSCH_ENERGY", "frame", "subframe", "pdsch_ch_level00", 1);
v = new_view_tti(10, g, w, new_color(g, "#ff0000"));
logger_add_view(l, v);
e->pdsch_energy_logger = l;
l = new_ttilog(h, database,
"UE_PHY_PDSCH_ENERGY", "frame", "subframe", "pdsch_ch_level01", 1);
v = new_view_tti(10, g, w, new_color(g, "#00ff00"));
logger_add_view(l, v);
e->pdsch_energy_logger = l;
l = new_ttilog(h, database,
"UE_PHY_PDSCH_ENERGY", "frame", "subframe", "pdsch_ch_level10", 1);
v = new_view_tti(10, g, w, new_color(g, "#0f0f0f"));
logger_add_view(l, v);
e->pdsch_energy_logger = l;
l = new_ttilog(h, database,
"UE_PHY_PDSCH_ENERGY", "frame", "subframe", "pdsch_ch_level11", 1);
v = new_view_tti(10, g, w, new_color(g, "#0000ff"));
logger_add_view(l, v);
e->pdsch_energy_logger = l;
/* UE x PDCCH energy */
w = new_xy_plot(g, 128, 55, "", 50);
e->pdcch_energy_ue_xy_plot = w;
widget_add_child(g, line, w, -1);
xy_plot_set_range(g, w, 0, 1024*10, -10, 80);
l = new_ttilog(h, database,
"UE_PHY_PDCCH_ENERGY", "frame", "subframe", "pdcch_ch_level00", 1);
v = new_view_tti(10, g, w, new_color(g, "#ff0000"));
logger_add_view(l, v);
e->pdcch_energy_logger = l;
l = new_ttilog(h, database,
"UE_PHY_PDCCH_ENERGY", "frame", "subframe", "pdcch_ch_level01", 1);
v = new_view_tti(10, g, w, new_color(g, "#00ff00"));
logger_add_view(l, v);
e->pdcch_energy_logger = l;
l = new_ttilog(h, database,
"UE_PHY_PDCCH_ENERGY", "frame", "subframe", "pdcch_ch_level10", 1);
v = new_view_tti(10, g, w, new_color(g, "#0f0f0f"));
logger_add_view(l, v);
e->pdcch_energy_logger = l;
l = new_ttilog(h, database,
"UE_PHY_PDCCH_ENERGY", "frame", "subframe", "pdcch_ch_level11", 1);
v = new_view_tti(10, g, w, new_color(g, "#0000ff"));
logger_add_view(l, v);
e->pdcch_energy_logger = l;
/* UE x PDCCH IQ data */
w = new_xy_plot(g, 55, 55, "", 50);
e->pdcch_iq_ue_xy_plot = w;
widget_add_child(g, line, w, -1);
xy_plot_set_range(g, w, -100, 100, -100, 100);
l = new_iqlog(h, database, "UE_PHY_PDCCH_IQ", "nb_rb",
"NB_RB_DL", "symbols_per_tti", "rxdataF_comp");
v = new_view_xy(100*12*14,10,g,w,new_color(g,"#000"),XY_FORCED_MODE);
logger_add_view(l, v);
e->pdcch_iq_ue_logger = l;
/* UE x PDCCH IQ data */
/*w = new_xy_plot(g, 55, 55, "", 50);
e->pdcch_iq_ue_xy_plot = w;
widget_add_child(g, line, w, -1);
xy_plot_set_range(g, w, -2000, 2000, -2000, 2000);
l = new_iqdotlog(h, database, "UE_PHY_PDCCH_IQ", "I", "Q");
v = new_view_xy(500, 10, g, w, new_color(g,"#000"), XY_LOOP_MODE);
logger_add_view(l, v);
e->pdcch_iq_ue_logger = l;*/
/* downlink/uplink UE DCIs */
widget_add_child(g, top_container,
new_label(g,"DL/UL TICK/DCI/ACK/NACK [all UEs]"), -1);
@@ -600,14 +511,14 @@ static void ue_main_gui(ue_gui *e, gui *g, event_handler *h, void *database,
logger_add_view(timelog, subview);
e->ul_dci_logger[i] = timelog;
/* retransmission */
timelog = new_ticklog(h, database,
"ENB_PHY_ULSCH_UE_NO_DCI_RETRANSMISSION", "frame", "subframe");
subview = new_subview_ticktime(timeview, i+9+1,
new_color(g,"#99f"), 3600*1000);
logger_add_view(timelog, subview);
e->ul_dci_retransmission_logger[i] = timelog;
}
/* UL ACK */
@@ -707,8 +618,6 @@ static void ue_main_gui(ue_gui *e, gui *g, event_handler *h, void *database,
#endif
set_current_ue(g, ed, 0);
register_notifier(g, "click", e->prev_ue_button, click, ed);
register_notifier(g, "click", e->next_ue_button, click, ed);
}
void view_add_log(view *v, char *log, event_handler *h, void *database,
@@ -824,13 +733,11 @@ int main(int n, char **v)
on_off(database, "UE_PHY_PUSCH_TX_POWER", is_on, 1);
on_off(database, "UE_PHY_PUCCH_TX_POWER", is_on, 1);
on_off(database, "UE_PHY_MEAS", is_on, 1);
on_off(database, "LEGACY_GROUP_INFO", is_on, 1);
on_off(database, "LEGACY_GROUP_ERROR", is_on, 1);
on_off(database, "LEGACY_GROUP_WARNING", is_on, 1);
view_add_log(eg.phyview, "UE_PHY_UL_TICK", h, database, is_on);
view_add_log(eg.phyview, "UE_PHY_DL_TICK", h, database, is_on);
view_add_log(eg.phyview, "UE_PHY_DLSCH_UE_DCI", h, database, is_on);
view_add_log(eg.phyview, "UE_PHY_DLSCH_UE_ACK", h, database, is_on);
view_add_log(eg.phyview, "UE_PHY_DLSCH_UE_NACK",h, database, is_on);
@@ -838,8 +745,6 @@ int main(int n, char **v)
view_add_log(eg.phyview, "UE_PHY_ULSCH_UE_ACK", h, database, is_on);
view_add_log(eg.phyview, "UE_PHY_ULSCH_UE_NACK", h, database, is_on);
/* deactivate those two by default, they are a bit heavy */
//on_off(database, "ENB_MAC_UE_UL_SDU_WITH_DATA", is_on, 0);
//on_off(database, "ENB_MAC_UE_UL_PDU_WITH_DATA", is_on, 0);
+100 -67
View File
@@ -9,27 +9,38 @@
#include <arpa/inet.h>
#include <math.h>
void new_thread(void *(*f)(void *), void *data)
{
void new_thread(void *(*f)(void *), void *data) {
pthread_t t;
pthread_attr_t att;
if (pthread_attr_init(&att))
{ fprintf(stderr, "pthread_attr_init err\n"); exit(1); }
if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED))
{ fprintf(stderr, "pthread_attr_setdetachstate err\n"); exit(1); }
if (pthread_attr_setstacksize(&att, 10000000))
{ fprintf(stderr, "pthread_attr_setstacksize err\n"); exit(1); }
if (pthread_create(&t, &att, f, data))
{ fprintf(stderr, "pthread_create err\n"); exit(1); }
if (pthread_attr_destroy(&att))
{ fprintf(stderr, "pthread_attr_destroy err\n"); exit(1); }
if (pthread_attr_init(&att)) {
fprintf(stderr, "pthread_attr_init err\n");
exit(1);
}
if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) {
fprintf(stderr, "pthread_attr_setdetachstate err\n");
exit(1);
}
if (pthread_attr_setstacksize(&att, 10000000)) {
fprintf(stderr, "pthread_attr_setstacksize err\n");
exit(1);
}
if (pthread_create(&t, &att, f, data)) {
fprintf(stderr, "pthread_create err\n");
exit(1);
}
if (pthread_attr_destroy(&att)) {
fprintf(stderr, "pthread_attr_destroy err\n");
exit(1);
}
}
void sleepms(int ms)
{
void sleepms(int ms) {
struct timespec t;
t.tv_sec = ms / 1000;
t.tv_nsec = (ms % 1000) * 1000000L;
@@ -37,12 +48,15 @@ void sleepms(int ms)
if (nanosleep(&t, NULL)) abort();
}
void bps(char *out, float v, char *suffix)
{
void bps(char *out, float v, char *suffix) {
static char *bps_unit[4] = { "", "k", "M", "G" };
int flog;
if (v < 1000) flog = 0; else flog = floor(floor(log10(v)) / 3);
if (v < 1000) flog = 0;
else flog = floor(floor(log10(v)) / 3);
if (flog > 3) flog = 3;
v /= pow(10, flog*3);
sprintf(out, "%g%s%s", round(v*100)/100, bps_unit[flog], suffix);
}
@@ -51,25 +65,31 @@ void bps(char *out, float v, char *suffix)
/* list */
/****************************************************************************/
list *list_remove_head(list *l)
{
list *list_remove_head(list *l) {
list *ret;
if (l == NULL) return NULL;
ret = l->next;
if (ret != NULL) ret->last = l->last;
free(l);
return ret;
}
list *list_append(list *l, void *data)
{
list *list_append(list *l, void *data) {
list *new = calloc(1, sizeof(list));
if (new == NULL) abort();
new->data = data;
if (l == NULL) {
new->last = new;
return new;
}
l->last->next = new;
l->last = new;
return l;
@@ -79,88 +99,107 @@ list *list_append(list *l, void *data)
/* socket */
/****************************************************************************/
int create_listen_socket(char *addr, int port)
{
int create_listen_socket(char *addr, int port) {
struct sockaddr_in a;
int s;
int v;
s = socket(AF_INET, SOCK_STREAM, 0);
if (s == -1) { perror("socket"); exit(1); }
if (s == -1) {
perror("socket");
exit(1);
}
v = 1;
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &v, sizeof(int)))
{ perror("setsockopt"); exit(1); }
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &v, sizeof(int))) {
perror("setsockopt");
exit(1);
}
a.sin_family = AF_INET;
a.sin_port = htons(port);
a.sin_addr.s_addr = inet_addr(addr);
if (bind(s, (struct sockaddr *)&a, sizeof(a))) { perror("bind"); exit(1); }
if (listen(s, 5)) { perror("listen"); exit(1); }
if (bind(s, (struct sockaddr *)&a, sizeof(a))) {
perror("bind");
exit(1);
}
if (listen(s, 5)) {
perror("listen");
exit(1);
}
return s;
}
int socket_accept(int s)
{
int socket_accept(int s) {
struct sockaddr_in a;
socklen_t alen;
alen = sizeof(a);
return accept(s, (struct sockaddr *)&a, &alen);
}
int socket_send(int socket, void *buffer, int size)
{
int socket_send(int socket, void *buffer, int size) {
char *x = buffer;
int ret;
while (size) {
ret = write(socket, x, size);
if (ret <= 0) return -1;
size -= ret;
x += ret;
}
return 0;
}
int get_connection(char *addr, int port)
{
int get_connection(char *addr, int port) {
int s, t;
printf("waiting for connection on %s:%d\n", addr, port);
s = create_listen_socket(addr, port);
t = socket_accept(s);
if (t == -1) { perror("accept"); exit(1); }
if (t == -1) {
perror("accept");
exit(1);
}
close(s);
printf("connected\n");
return t;
}
int fullread(int fd, void *_buf, int count)
{
int fullread(int fd, void *_buf, int count) {
char *buf = _buf;
int ret = 0;
int l;
while (count) {
l = read(fd, buf, count);
if (l <= 0) return -1;
count -= l;
buf += l;
ret += l;
}
return ret;
}
int try_connect_to(char *addr, int port)
{
int try_connect_to(char *addr, int port) {
int s;
struct sockaddr_in a;
s = socket(AF_INET, SOCK_STREAM, 0);
if (s == -1) { perror("socket"); exit(1); }
if (s == -1) {
perror("socket");
exit(1);
}
a.sin_family = AF_INET;
a.sin_port = htons(port);
@@ -175,14 +214,12 @@ int try_connect_to(char *addr, int port)
return s;
}
int connect_to(char *addr, int port)
{
int connect_to(char *addr, int port) {
int s;
printf("connecting to %s:%d\n", addr, port);
again:
s = try_connect_to(addr, port);
if (s == -1) {
printf("trying again in 1s\n");
sleep(1);
@@ -196,50 +233,46 @@ again:
/* buffer */
/****************************************************************************/
void PUTC(OBUF *o, char c)
{
void PUTC(OBUF *o, char c) {
if (o->osize == o->omaxsize) {
o->omaxsize += 512;
o->obuf = realloc(o->obuf, o->omaxsize);
if (o->obuf == NULL) abort();
}
o->obuf[o->osize] = c;
o->osize++;
}
void PUTS(OBUF *o, char *s)
{
void PUTS(OBUF *o, char *s) {
while (*s) PUTC(o, *s++);
}
static int clean(char c)
{
static int clean(char c) {
if (!isprint(c)) c = ' ';
return c;
}
void PUTS_CLEAN(OBUF *o, char *s)
{
void PUTS_CLEAN(OBUF *o, char *s) {
while (*s) PUTC(o, clean(*s++));
}
void PUTI(OBUF *o, int i)
{
void PUTI(OBUF *o, int i) {
char s[64];
sprintf(s, "%d", i);
PUTS(o, s);
}
void PUTX2(OBUF *o, int i)
{
void PUTX2(OBUF *o, int i) {
char s[64];
sprintf(s, "%2.2x", i);
PUTS(o, s);
}
void PUTUL(OBUF *o, unsigned long l)
{
void PUTUL(OBUF *o, unsigned long l) {
char s[128];
sprintf(s, "%ld", l);
sprintf(s, "%lu", l);
PUTS(o, s);
}