Commit d915c208 authored by Cedric Roux's avatar Cedric Roux

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

Summary of changes:
- fix a bug with Timing Advance.
  This should improve the stability of the connection
  (for now, only the scenario with one connected UE works).
- use RRC Release 14.3
- add some T tracers, minor fixes for T
parents d413de0a 047b54da
......@@ -291,7 +291,7 @@ elseif (${RRC_ASN1_VERSION} STREQUAL "CBA")
elseif (${RRC_ASN1_VERSION} STREQUAL "Rel10")
set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn)
else()
set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1c/ASN1_files/RRC-e10.asn)
set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn)
endif (${RRC_ASN1_VERSION} STREQUAL "Rel8")
set (RRC_FULL_DIR ${asn1_generated_dir}/${RRC_ASN1_VERSION})
......
......@@ -4,7 +4,7 @@
# <file> <sha1sum of file (without line 4 which changes depending on the location of the files)> <patch to apply to file>
RRC_Rel14=(
"SystemInformation-r8-IEs.h" 562e3c3aeb7c6d76d722f31bf24488a26e627f33 "fix_asn1.data/RRC.rel14/SystemInformation-r8-IEs.h.diff"
"SystemInformation-r8-IEs.h" 4df485c5ddf2540eca271876cdc512caa19b0890 "fix_asn1.data/RRC.rel14/SystemInformation-r8-IEs.h.diff"
)
RRC_Rel10=(
......
......@@ -10,4 +10,9 @@ tracer/replay
tracer/textlog
tracer/vcd
tracer/macpdu2wireshark
tracer/ue
tracer/to_vcd
tracer/extract_input_subframe
tracer/extract_output_subframe
tracer/extract
tracee/tracee
......@@ -29,10 +29,10 @@ typedef struct {
#define T_SHM_FILENAME "/T_shm_segment"
/* number of VCD functions (to be kept up to date! see in T_messages.txt) */
#define VCD_NUM_FUNCTIONS 172
#define VCD_NUM_FUNCTIONS 178
/* number of VCD variables (to be kept up to date! see in T_messages.txt) */
#define VCD_NUM_VARIABLES 118
#define VCD_NUM_VARIABLES 128
/* 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)
......
......@@ -958,6 +958,38 @@ ID = VCD_VARIABLE_SUBFRAME_NUMBER_RX1_ENB
DESC = VCD variable SUBFRAME_NUMBER_RX1_ENB
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
ID = VCD_VARIABLE_FRAME_NUMBER_TX0_RU
DESC = VCD variable FRAME_NUMBER_TX0_RU
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
ID = VCD_VARIABLE_FRAME_NUMBER_TX1_RU
DESC = VCD variable FRAME_NUMBER_TX1_RU
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
ID = VCD_VARIABLE_FRAME_NUMBER_RX0_RU
DESC = VCD variable FRAME_NUMBER_RX0_RU
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
ID = VCD_VARIABLE_FRAME_NUMBER_RX1_RU
DESC = VCD variable FRAME_NUMBER_RX1_RU
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
ID = VCD_VARIABLE_SUBFRAME_NUMBER_TX0_RU
DESC = VCD variable SUBFRAME_NUMBER_TX0_RU
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
ID = VCD_VARIABLE_SUBFRAME_NUMBER_TX1_RU
DESC = VCD variable SUBFRAME_NUMBER_TX1_RU
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
ID = VCD_VARIABLE_SUBFRAME_NUMBER_RX0_RU
DESC = VCD variable SUBFRAME_NUMBER_RX0_RU
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
ID = VCD_VARIABLE_SUBFRAME_NUMBER_RX1_RU
DESC = VCD variable SUBFRAME_NUMBER_RX1_RU
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
ID = VCD_VARIABLE_RUNTIME_TX_ENB
DESC = VCD variable RUNTIME_TX_ENB
GROUP = ALL:VCD:ENB:VCD_VARIABLE
......@@ -1050,6 +1082,14 @@ ID = VCD_VARIABLE_TRX_TST
DESC = VCD variable TRX_TST
GROUP = ALL:VCD:ENB:VCD_VARIABLE
FORMAT = ulong,value
ID = VCD_VARIABLE_TRX_TS_UE
DESC = VCD variable TRX_TS_UE
GROUP = ALL:VCD:UE:VCD_VARIABLE
FORMAT = ulong,value
ID = VCD_VARIABLE_TRX_TST_UE
DESC = VCD variable TRX_TST_UE
GROUP = ALL:VCD:UE:VCD_VARIABLE
FORMAT = ulong,value
ID = VCD_VARIABLE_TRX_WRITE_FLAGS
DESC = VCD variable TRX_WRITE_FLAGS
GROUP = ALL:VCD:ENB:VCD_VARIABLE
......@@ -1413,6 +1453,14 @@ ID = VCD_FUNCTION_TRX_WRITE
DESC = VCD function TRX_WRITE
GROUP = ALL:VCD:ENB:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_TRX_READ_UE
DESC = VCD function TRX_READ_UE
GROUP = ALL:VCD:UE:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_TRX_WRITE_UE
DESC = VCD function TRX_WRITE_UE
GROUP = ALL:VCD:UE:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_TRX_READ_IF
DESC = VCD function TRX_READ_IF
GROUP = ALL:VCD:ENB:VCD_FUNCTION
......@@ -1565,12 +1613,28 @@ ID = VCD_FUNCTION_PHY_PROCEDURES_ENB_TX1
DESC = VCD function PHY_PROCEDURES_ENB_TX1
GROUP = ALL:VCD:ENB:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_PHY_PROCEDURES_ENB_RX_COMMON
DESC = VCD function PHY_PROCEDURES_ENB_RX_COMMON
ID = VCD_FUNCTION_PHY_PROCEDURES_RU_FEPRX
DESC = VCD function PHY_PROCEDURES_RU_FEPRX
GROUP = ALL:VCD:ENB:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_PHY_PROCEDURES_RU_FEPRX1
DESC = VCD function PHY_PROCEDURES_RU_FEPRX1
GROUP = ALL:VCD:ENB:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_PHY_PROCEDURES_RU_FEPTX_OFDM
DESC = VCD function PHY_PROCEDURES_RU_FEPTX_OFDM
GROUP = ALL:VCD:ENB:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_PHY_PROCEDURES_RU_FEPTX_OFDM1
DESC = VCD function PHY_PROCEDURES_RU_FEPTX_OFDM1
GROUP = ALL:VCD:ENB:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_PHY_PROCEDURES_RU_FEPTX_PREC
DESC = VCD function PHY_PROCEDURES_RU_FEPTX_PREC
GROUP = ALL:VCD:ENB:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_PHY_PROCEDURES_ENB_RX_COMMON1
DESC = VCD function PHY_PROCEDURES_ENB_RX_COMMON1
ID = VCD_FUNCTION_PHY_PROCEDURES_RU_FEPTX_PREC1
DESC = VCD function PHY_PROCEDURES_RU_FEPTX_PREC1
GROUP = ALL:VCD:ENB:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_PHY_PROCEDURES_ENB_RX_UESPEC
......@@ -1581,10 +1645,6 @@ ID = VCD_FUNCTION_PHY_PROCEDURES_ENB_RX_UESPEC1
DESC = VCD function PHY_PROCEDURES_ENB_RX_UESPEC1
GROUP = ALL:VCD:ENB:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_ENB_SLOT_FEP
DESC = VCD function ENB_SLOT_FEP
GROUP = ALL:VCD:ENB:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_PHY_PROCEDURES_UE_TX
DESC = VCD function PHY_PROCEDURES_UE_TX
GROUP = ALL:VCD:UE:VCD_FUNCTION
......@@ -1781,6 +1841,10 @@ ID = VCD_FUNCTION_PHY_ENB_PRACH_RX
DESC = VCD function PHY_ENB_PRACH_RX
GROUP = ALL:VCD:ENB:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_PHY_RU_PRACH_RX
DESC = VCD function PHY_RU_PRACH_RX
GROUP = ALL:VCD:ENB:VCD_FUNCTION
FORMAT = int,value
ID = VCD_FUNCTION_PHY_ENB_PDCCH_TX
DESC = VCD function PHY_ENB_PDCCH_TX
GROUP = ALL:VCD:ENB:VCD_FUNCTION
......
......@@ -3,10 +3,11 @@ CFLAGS=-Wall -g -pthread -DT_TRACER -I.
#CFLAGS += -O3 -ffast-math -fomit-frame-pointer
LIBS=-lX11 -lm -lpng -lXft
LIBS=-lm
XLIBS=-lX11 -lpng -lXft
all: record replay extract_config textlog enb ue vcd macpdu2wireshark \
extract_input_subframe
extract_input_subframe extract_output_subframe to_vcd extract
record: utils.o record.o database.o config.o
$(CC) $(CFLAGS) -o record $^ $(LIBS)
......@@ -21,25 +22,36 @@ extract_input_subframe: extract_input_subframe.o database.o event.o utils.o \
config.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
extract_output_subframe: extract_output_subframe.o database.o event.o utils.o \
config.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
extract: extract.o database.o event.o utils.o config.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
textlog: utils.o textlog.o database.o event.o handler.o config.o \
event_selector.o view/view.a gui/gui.a logger/logger.a \
filter/filter.a
$(CC) $(CFLAGS) -o textlog $^ $(LIBS)
$(CC) $(CFLAGS) -o textlog $^ $(LIBS) $(XLIBS)
enb: utils.o enb.o database.o event.o handler.o config.o \
event_selector.o view/view.a gui/gui.a logger/logger.a \
filter/filter.a
$(CC) $(CFLAGS) -o enb $^ $(LIBS)
$(CC) $(CFLAGS) -o enb $^ $(LIBS) $(XLIBS)
ue: utils.o ue.o database.o event.o handler.o config.o \
event_selector.o view/view.a gui/gui.a logger/logger.a \
filter/filter.a
$(CC) $(CFLAGS) -o ue $^ $(LIBS)
$(CC) $(CFLAGS) -o ue $^ $(LIBS) $(XLIBS)
vcd: utils.o vcd.o database.o event.o handler.o config.o \
event_selector.o view/view.a gui/gui.a logger/logger.a \
filter/filter.a
$(CC) $(CFLAGS) -o vcd $^ $(LIBS)
$(CC) $(CFLAGS) -o vcd $^ $(LIBS) $(XLIBS)
to_vcd: to_vcd.o database.o event.o handler.o utils.o config.o \
logger/logger.a filter/filter.a
$(CC) $(CFLAGS) -o to_vcd $^ $(LIBS)
macpdu2wireshark: macpdu2wireshark.o database.o utils.o handler.o event.o \
config.o
......@@ -65,6 +77,7 @@ filter/filter.a:
clean:
rm -f *.o core tracer_remote textlog enb ue vcd record replay
rm -f extract_config macpdu2wireshark extract_input_subframe
rm -f extract_output_subframe to_vcd extract
cd gui && make clean
cd view && make clean
cd logger && make clean
......
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include "database.h"
#include "event.h"
#include "config.h"
void usage(void)
{
printf(
"usage: [options] <file> <event> <buffer name>\n"
"options:\n"
" -d <database file> this option is mandatory\n"
" -o <output file> this option is mandatory\n"
" -f <name> <value> field 'name' of 'event' has to match 'value'\n"
" type of 'name' must be int\n"
" (you can use several -f options)\n"
);
exit(1);
}
int get_filter_arg(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);
}
int main(int n, char **v)
{
char *database_filename = NULL;
void *database;
int i;
int input_event_id;
database_event_format f;
char *file = NULL;
char *output_file = NULL;
FILE *out;
int fd;
char *event_name = NULL;
char *buffer_name = NULL;
char *filter[n];
int filter_arg[n];
int filter_value[n];
int filter_count = 0;
int buffer_arg;
int found;
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], "-o"))
{ if (i > n-2) usage(); output_file = v[++i]; continue; }
if (!strcmp(v[i], "-f")) { if (i>n-3) usage();
filter[filter_count] = v[++i];
filter_value[filter_count++] = atoi(v[++i]);
continue;
}
if (file == NULL) { file = v[i]; continue; }
if (event_name == NULL) { event_name = v[i]; continue; }
if (buffer_name == NULL) { buffer_name = v[i]; continue; }
usage();
}
if (file == NULL || event_name == NULL || buffer_name == NULL) usage();
if (database_filename == NULL) {
printf("ERROR: provide a database file (-d)\n");
exit(1);
}
if (output_file == NULL) {
printf("gimme -o <output file>, thanks\n");
exit(1);
}
out = fopen(output_file, "w"); if(out==NULL){perror(output_file);exit(1);}
database = parse_database(database_filename);
load_config_file(database_filename);
input_event_id = event_id_from_name(database, event_name);
f = get_format(database, input_event_id);
buffer_arg = get_filter_arg(&f, buffer_name, "buffer");
for (i = 0; i < filter_count; i++)
filter_arg[i] = get_filter_arg(&f, filter[i], "int");
fd = open(file, O_RDONLY);
if (fd == -1) { perror(file); exit(1); }
found = 0;
while (1) {
char v[T_BUFFER_MAX];
event e;
e = get_event(fd, v, database);
if (e.type == -1) break;
if (e.type != input_event_id) continue;
for (i = 0; i < filter_count; i++)
if (filter_value[i] != e.e[filter_arg[i]].i)
break;
if (i != filter_count)
continue;
if (fwrite(e.e[buffer_arg].b, e.e[buffer_arg].bsize, 1, out) != 1)
{ perror(output_file); exit(1); }
found = 1;
break;
}
if (found == 0) printf("ERROR: event not found\n");
fclose(out);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include "database.h"
#include "event.h"
#include "config.h"
void usage(void)
{
printf(
"usage: [options] <file> <frame> <subframe> <number of subframes>\n"
" the program dumps 'number of subframes' subframes starting\n"
" at 'frame:suubframe'\n"
"options:\n"
" -d <database file> this option is mandatory\n"
" -o <output file> output to file (default: stdout)\n"
" -v verbose\n"
);
exit(1);
}
int main(int n, char **v)
{
char *database_filename = NULL;
void *database;
int i;
int output_event_id;
database_event_format f;
char *file = NULL;
int fd;
int frame = -1, subframe = -1;
int number_of_subframes = -1;
int frame_arg, subframe_arg, buffer_arg;
int verbose = 0;
char *out_filename = NULL;
FILE *out;
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], "-o"))
{ if (i > n-2) usage(); out_filename = v[++i]; continue; }
if (!strcmp(v[i], "-v")) { verbose = 1; continue; }
if (file == NULL) { file = v[i]; continue; }
if (frame == -1) { frame = atoi(v[i]); continue; }
if (subframe == -1) { subframe = atoi(v[i]); continue; }
if (number_of_subframes == -1) {number_of_subframes=atoi(v[i]);continue;}
usage();
}
if (file == NULL || frame == -1 || subframe == -1 ||
number_of_subframes == -1) usage();
if (database_filename == NULL) {
printf("ERROR: provide a database file (-d)\n");
exit(1);
}
if (out_filename == NULL) out = stdout;
else {
out = fopen(out_filename, "w");
if (out == NULL) { perror(out_filename); exit(1); }
}
database = parse_database(database_filename);
load_config_file(database_filename);
output_event_id = event_id_from_name(database, "ENB_PHY_OUTPUT_SIGNAL");
f = get_format(database, output_event_id);
frame_arg = subframe_arg = buffer_arg = -1;
for (i = 0; i < f.count; i++) {
if (!strcmp(f.name[i], "frame")) {
if (frame_arg != -1) goto err;
if (strcmp(f.type[i], "int")) goto err;
frame_arg = i;
}
if (!strcmp(f.name[i], "subframe")) {
if (subframe_arg != -1) goto err;
if (strcmp(f.type[i], "int")) goto err;
subframe_arg = i;
}
if (!strcmp(f.name[i], "txdata")) {
if (buffer_arg != -1) goto err;
if (strcmp(f.type[i], "buffer")) goto err;
buffer_arg = i;
}
continue;
err:
printf("cannot deal with ENB_PHY_OUTPUT_SIGNAL from database file\n");
exit(1);
}
if (frame_arg == -1 || subframe_arg == -1 || buffer_arg == -1) goto err;
fd = open(file, O_RDONLY);
if (fd == -1) { perror(file); exit(1); }
int last_frame = -1;
int last_subframe = -1;
int subframe_written = 0;
while (1) {
char v[T_BUFFER_MAX];
event e;
e = get_event(fd, v, database);
if (e.type == -1) break;
if (e.type != output_event_id) continue;
if (verbose)
printf("found output frame %d subframe %d size %d\n",
e.e[frame_arg].i, e.e[subframe_arg].i, e.e[buffer_arg].bsize);
if (!(last_frame != -1 ||
(frame == e.e[frame_arg].i && subframe == e.e[subframe_arg].i)))
continue;
frame = e.e[frame_arg].i;
subframe = e.e[subframe_arg].i;
if (last_frame != -1) {
if (frame*10+subframe != (last_frame*10+last_subframe + 1) % 10240) {
printf("error: discontinuity, not what you want...\n");
exit(1);
}
}
last_frame = frame;
last_subframe = subframe;
#if 0
for (i = 0; i < e.e[buffer_arg].bsize/2; i++) {
short *x = e.e[buffer_arg].b;
x[i] *= 14;
}
#endif
if (verbose)
printf("save output frame %d subframe %d size %d\n",
e.e[frame_arg].i, e.e[subframe_arg].i, e.e[buffer_arg].bsize);
if (fwrite(e.e[buffer_arg].b, e.e[buffer_arg].bsize, 1, out) != 1) {
perror(out_filename);
exit(1);
}
subframe_written++;
if (subframe_written != number_of_subframes)
continue;
/* done */
fflush(out);
if (out_filename != NULL) {
if (fclose(out)) perror(out_filename);
}
if (verbose)
printf("%d subframes written\n", subframe_written);
return 0;
}
printf("error with input file, %d subframe written\n", subframe_written);
fflush(out);
if (out_filename != NULL) {
if (fclose(out)) perror(out_filename);
}
return 1;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>
#include <signal.h>
#include <unistd.h>
#include "database.h"
#include "utils.h"
#include "handler.h"
#include "config.h"
#include "logger/logger.h"
#include "view/view.h"
typedef struct {
char *event;
char *arg;
char *vcd_name;
int boolean;
} vcd_vars;
/****************************************************************************/
/* VCD file handling begin */
/****************************************************************************/
FILE *out;
uint64_t start_time;
int start_time_inited;
void vcd_init(char *file)
{
out = fopen(file, "w"); if (out == NULL) { perror(file); exit(1); }
}
void vcd_write_header(vcd_vars *v, int n)
{
int i;
if (fprintf(out,
"$date\n"
" January, 1, 1970.\n"
"$end\n"
"$version\n"
" to_vcd\n"
"$end\n"
"$timescale 1ns $end\n"
"$scope module logic $end\n") <= 0) abort();
for (i = 0; i < n; i++)
if (fprintf(out, "$var wire %d %s %s $end\n",
v[i].boolean ? 1 : 64,
v[i].vcd_name, v[i].vcd_name) <= 0) abort();
if (fprintf(out,
"$upscope $end\n"
"$enddefinitions $end\n"
"$dumpvars\n") <= 0) abort();
for (i = 0; i < n; i++)
if (v[i].boolean) {
if (fprintf(out, "0%s\n", v[i].vcd_name) <= 0) abort();
} else {
if (fprintf(out, "b0 %s\n", v[i].vcd_name) <= 0) abort();
}
if (fprintf(out,
"$end\n") <= 0) abort();
}
void vcd_end(void)
{
if (fclose(out)) { perror("error closing VCD file"); exit(1); }
}
char *b64(uint64_t val)
{
static char v[65];
char *s = &v[64];
*s = 0;
if (val == 0) { s--; *s = '0'; return s; }
while (val) {
s--;
*s = val&1 ? '1' : '0';
val >>= 1;
}
return s;
}
void vcd_dump(char *v)
{
uint64_t h, m, s, ns;
char t;
uint64_t val;
uint64_t time;
char var[256];
if (sscanf(v, "%"SCNu64":%"SCNu64":%"SCNu64".%"SCNu64": %c %"SCNu64" %s",
&h, &m, &s, &ns, &t, &val, var) != 7)
goto err;
time = h*60*60*1000000000 +
m*60*1000000000 +
s*1000000000 +
ns;
if (!start_time_inited) {
start_time = time;
start_time_inited = 1;
}
if (fprintf(out, "#%"PRIu64"\n", time - start_time) <= 0) abort();
switch (t) {
case 'b': if (fprintf(out, "%d%s\n", val!=0, var) <= 0) abort(); break;
case 'l': if (fprintf(out, "b%s %s\n", b64(val), var) <= 0) abort(); break;
default: goto err;
}
return;
err:
printf("bad vcd_dump line '%s'\n", v);
exit(1);
}
/****************************************************************************/
/* VCD file handling end */
/****************************************************************************/
/****************************************************************************/
/* vcd view start */
/****************************************************************************/
struct vcd_view {
view common;
};
static void vcd_view_clear(view *this)
{
/* nothing */
}
static void vcd_view_append(view *_this, char *s)
{
vcd_dump(s);
}
static view *new_view_vcd(void)
{
struct vcd_view *ret = calloc(1, sizeof(struct vcd_view));
if (ret == NULL) abort();
ret->common.clear = vcd_view_clear;
ret->common.append = (void (*)(view *, ...))vcd_view_append;
return (view *)ret;
}
/****************************************************************************/
/* vcd view end */
/****************************************************************************/
void activate_traces(int socket, int number_of_events, int *is_on)
{
char 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();
}
void usage(void)
{
printf(
"options:\n"
" -d <database file> this option is mandatory\n"
" -o <output 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"
" -b <event> <arg> <vcd name> trace as binary (0 off, anything else on)\n"
" -l <event> <arg> <vcd name> trace as uint64_t\n",
DEFAULT_REMOTE_IP,
DEFAULT_REMOTE_PORT
);
exit(1);
}
int run = 1;
static int socket = -1;
void force_stop(int x)
{
printf("\ngently quit...\n");
close(socket);
socket = -1;
run = 0;
}
int main(int n, char **v)
{
char *output_filename = NULL;
char *database_filename = NULL;
void *database;
char *ip = DEFAULT_REMOTE_IP;
int port = DEFAULT_REMOTE_PORT;
int *is_on;
int number_of_events;
int i;
vcd_vars vars[n];
int nvars = 0;
view *vcd_view;
event_handler *h;
logger *textlog;
/* write on a socket fails if the other end is closed and we get SIGPIPE */
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort();
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], "-o"))
{ if (i > n-2) usage(); output_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], "-b")) { if(i>n-4)usage();
vars[nvars].event = v[++i];
vars[nvars].arg = v[++i];
vars[nvars].vcd_name = v[++i];
vars[nvars++].boolean = 1;
continue;
}
if (!strcmp(v[i], "-l")) { if(i>n-4)usage();
vars[nvars].event = v[++i];
vars[nvars].arg = v[++i];
vars[nvars].vcd_name = v[++i];
vars[nvars++].boolean = 0;
continue;
}
usage();
}
if (output_filename == NULL) {
printf("ERROR; provide an output file (-o)\n");
exit(1);
}
if (database_filename == NULL) {
printf("ERROR: provide a database file (-d)\n");
exit(1);
}
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();
h = new_handler(database);
/* create the view */
vcd_view = new_view_vcd();
/* setup traces */
for (i = 0; i < nvars; i++) {
char format[256];
if (strlen(vars[i].arg) > 256-3) abort();
if (strlen(vars[i].vcd_name) > 256-1) abort();
sprintf(format, "%c [%s] %s",
vars[i].boolean ? 'b' : 'l',
vars[i].arg,
vars[i].vcd_name);
textlog = new_textlog(h, database, vars[i].event, format);
logger_add_view(textlog, vcd_view);
on_off(database, vars[i].event, is_on, 1);
}
socket = connect_to(ip, port);
/* activate selected traces */
activate_traces(socket, number_of_events, is_on);
vcd_init(output_filename);
vcd_write_header(vars, nvars);
/* exit on ctrl+c and ctrl+z */
if (signal(SIGQUIT, force_stop) == SIG_ERR) abort();
if (signal(SIGINT, force_stop) == SIG_ERR) abort();
if (signal(SIGTSTP, force_stop) == SIG_ERR) abort();
/* read messages */
while (run) {
char v[T_BUFFER_MAX];
event e;
e = get_event(socket, v, database);
if (e.type == -1) { printf("disconnected? let's quit gently\n"); break; }
handle_event(h, e);
}
vcd_end();
return 0;
}
......@@ -227,11 +227,8 @@ int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms,
int lte_est_timing_advance_pusch(PHY_VARS_eNB* eNB,uint8_t UE_id)
{
static int first_run=1;
static int max_pos_fil2=0;
int temp, i, aa, max_pos=0, max_val=0;
short Re,Im,coef=24576;
short ncoef = 32768 - coef;
short Re,Im;
LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
LTE_eNB_PUSCH *eNB_pusch_vars = eNB->pusch_vars[UE_id];
......@@ -260,16 +257,9 @@ int lte_est_timing_advance_pusch(PHY_VARS_eNB* eNB,uint8_t UE_id)
if (max_pos>frame_parms->ofdm_symbol_size/2)
max_pos = max_pos-frame_parms->ofdm_symbol_size;
// filter position to reduce jitter
if (first_run == 1) {
first_run=0;
max_pos_fil2 = max_pos;
} else
max_pos_fil2 = ((max_pos_fil2 * coef) + (max_pos * ncoef)) >> 15;
//#ifdef DEBUG_PHY
LOG_D(PHY,"frame %d: max_pos = %d, max_pos_fil = %d, sync_pos=%d\n",eNB->proc.frame_rx,max_pos,max_pos_fil2,sync_pos);
LOG_D(PHY,"frame %d: max_pos = %d, sync_pos=%d\n",eNB->proc.frame_rx,max_pos,sync_pos);
//#endif //DEBUG_PHY
return(max_pos_fil2-sync_pos);
return max_pos - sync_pos;
}
......@@ -663,7 +663,7 @@ void prach_procedures(PHY_VARS_eNB *eNB,
{
if ((eNB->prach_energy_counter == 100) &&
(max_preamble_energy[0] > eNB->measurements.prach_I0+200)) {
(max_preamble_energy[0] > eNB->measurements.prach_I0+100)) {
LOG_D(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure with preamble %d, energy %d.%d dB, delay %d\n",
eNB->Mod_id,
......@@ -1524,7 +1524,7 @@ void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe)
pdu->data = eNB->ulsch[UE_id]->harq_processes[harq_pid]->b;
// estimate timing advance for MAC
sync_pos = lte_est_timing_advance_pusch(eNB,UE_id);
timing_advance_update = sync_pos - eNB->frame_parms.nb_prefix_samples/4; //to check
timing_advance_update = sync_pos; // - eNB->frame_parms.nb_prefix_samples/4; //to check
// if (timing_advance_update > 10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);}
// if (timing_advance_update < -10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);}
......
......@@ -113,9 +113,13 @@ void rx_sdu(const module_id_t enb_mod_idP,
UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer = 0;
UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0;
UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1<<harq_pid));
/* don't take into account TA if timer is running */
if (UE_list->UE_sched_ctrl[UE_id].ta_timer == 0)
UE_list->UE_sched_ctrl[UE_id].ta_update = timing_advance;
/* Update with smoothing: 3/4 of old value and 1/4 of new.
* This is the logic that was done in the function
* lte_est_timing_advance_pusch, maybe it's not necessary?
* maybe it's even not correct at all?
*/
UE_list->UE_sched_ctrl[UE_id].ta_update =
(UE_list->UE_sched_ctrl[UE_id].ta_update * 3 + timing_advance)/4;
UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = ul_cqi;
UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors = 0;
first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid];
......
......@@ -156,6 +156,9 @@ void handle_ulsch(UL_IND_t *UL_info) {
#define C do { size = 0; put(0); } while (0)
#define A(...) do { char t[4096]; sprintf(t, __VA_ARGS__); append_string(t); } while (0)
#if 0
/* eats lots of ms at startup, disrupts realtime */
static char *s;
static int size;
static int maxsize;
......@@ -169,6 +172,22 @@ static void put(char x)
s[size++] = x;
}
#else
/* eats nothing at startup, but fixed size */
#define SMAX 65536
static char s[SMAX];
static int size;
static int maxsize = SMAX;
static void put(char x)
{
if (size == maxsize) { printf("incrase SMAX\n"); exit(1); }
s[size++] = x;
}
#endif
static void append_string(char *t)
{
size--;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment