Commit a1007751 authored by Cedric Roux's avatar Cedric Roux

channel_simulator: synch eNBs in time and some bugs fixed

By default, eNB are now frame/subframe synchronized in time (that is they
all transmit the exact same frame and subframe at the same time).
Use -no-sync to disable synchronization.

Some bugs were fixed:
- memory initialized to 0
- ignore SIGPIPE that was delivered sometimes when an eNB disconnects
- set tx_sample_advance to 40, which is used in the usrp lib of openair
  (srsUE did not connect well with 0)
parent 621ba724
...@@ -97,6 +97,7 @@ static int find_or_create_channel(channel_simulator *c, uint64_t freq, ...@@ -97,6 +97,7 @@ static int find_or_create_channel(channel_simulator *c, uint64_t freq,
chan->sample_advance = sample_advance; chan->sample_advance = sample_advance;
if (posix_memalign((void **)&chan->data, 32, c->n_samples * 4) != 0) if (posix_memalign((void **)&chan->data, 32, c->n_samples * 4) != 0)
goto oom; goto oom;
memset(chan->data, 0, c->n_samples * 4);
chan->connection_count = 0; chan->connection_count = 0;
return i; return i;
...@@ -124,12 +125,14 @@ void channel_simulator_add_connection(channel_simulator *c, ...@@ -124,12 +125,14 @@ void channel_simulator_add_connection(channel_simulator *c,
con->socket = socket; con->socket = socket;
if (posix_memalign((void **)&con->iq_buffer, 32, c->n_samples * 4) != 0) if (posix_memalign((void **)&con->iq_buffer, 32, c->n_samples * 4) != 0)
goto oom; goto oom;
memset(con->iq_buffer, 0, c->n_samples * 4);
con->rx_frequency = rx_frequency; con->rx_frequency = rx_frequency;
con->tx_frequency = tx_frequency; con->tx_frequency = tx_frequency;
con->rx_channel_index = find_or_create_channel(c, rx_frequency, con->rx_channel_index = find_or_create_channel(c, rx_frequency,
rx_sample_advance); rx_sample_advance);
con->tx_channel_index = find_or_create_channel(c, tx_frequency, con->tx_channel_index = find_or_create_channel(c, tx_frequency,
tx_sample_advance); tx_sample_advance);
con->running = 0;
c->channels[con->rx_channel_index].connection_count++; c->channels[con->rx_channel_index].connection_count++;
c->channels[con->tx_channel_index].connection_count++; c->channels[con->tx_channel_index].connection_count++;
......
...@@ -20,6 +20,8 @@ typedef struct { ...@@ -20,6 +20,8 @@ typedef struct {
int tx_channel_index; int tx_channel_index;
/* gain to apply to rx and tx data */ /* gain to apply to rx and tx data */
void *gain; /* actually __m256i * */ void *gain; /* actually __m256i * */
/* running: used to synchronize eNB in time */
int running;
} connection; } connection;
typedef struct { typedef struct {
......
...@@ -2,15 +2,35 @@ ...@@ -2,15 +2,35 @@
#include "connection_manager.h" #include "connection_manager.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <signal.h>
int main(void) void usage(void)
{
printf("options:\n");
printf(" -no-sync\n");
printf(" do not synchronize eNBs in time\n");
exit(0);
}
int main(int n, char **v)
{ {
channel_simulator c; channel_simulator c;
connection_manager cm; connection_manager cm;
int i; int i;
int samplerate = 7680000; int samplerate = 7680000;
int do_synchronize = 1;
for (i = 1; i < n; i++) {
if (!strcmp(v[i], "-h") || !strcmp(v[i], "--help")) usage();
if (!strcmp(v[i], "-no-sync")) { do_synchronize = 0; continue; }
usage();
}
signal(SIGPIPE, SIG_IGN);
init_connection_manager(&cm, "0.0.0.0", 4024); init_connection_manager(&cm, "0.0.0.0", 4024);
init_channel_simulator(&c, samplerate, 512); init_channel_simulator(&c, samplerate, 512);
...@@ -39,6 +59,11 @@ int main(void) ...@@ -39,6 +59,11 @@ int main(void)
connection *con = &c.connections[i]; connection *con = &c.connections[i];
channel *ch_rx = &c.channels[con->rx_channel_index]; channel *ch_rx = &c.channels[con->rx_channel_index];
channel *ch_tx = &c.channels[con->tx_channel_index]; channel *ch_tx = &c.channels[con->tx_channel_index];
if (do_synchronize && con->running == 0) {
if (c.timestamp % (samplerate/1000*1024*10))
continue;
con->running = 1;
}
connection_send_rx(con, c.timestamp + ch_rx->sample_advance, connection_send_rx(con, c.timestamp + ch_rx->sample_advance,
ch_rx->data, c.n_samples); ch_rx->data, c.n_samples);
connection_receive_tx(&c, con, c.timestamp + ch_tx->sample_advance connection_receive_tx(&c, con, c.timestamp + ch_tx->sample_advance
......
...@@ -128,7 +128,7 @@ int main(void) ...@@ -128,7 +128,7 @@ int main(void)
uint64_t sim_timestamp; uint64_t sim_timestamp;
uint64_t usrp_timestamp; uint64_t usrp_timestamp;
int samples_per_subframe = 7680; int samples_per_subframe = 7680;
int tx_sample_advance = 0; //40; int tx_sample_advance = 40;
char *usrp_data; char *usrp_data;
go_realtime(); go_realtime();
...@@ -145,6 +145,7 @@ int main(void) ...@@ -145,6 +145,7 @@ int main(void)
printf("ERROR: out of memory\n"); printf("ERROR: out of memory\n");
exit(1); exit(1);
} }
memset(usrp_data, 0, buf.n_samples * 4);
send_to_channel_simulator(sock, usrp_data, buf.n_samples, sim_timestamp); send_to_channel_simulator(sock, usrp_data, buf.n_samples, sim_timestamp);
sim_timestamp += buf.n_samples; sim_timestamp += buf.n_samples;
......
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