Commit ab7515e2 authored by Cedric Roux's avatar Cedric Roux

basic simulator: handle discontinuities in output

In TDD mode the eNB does not output data all the time,
only in downlink and special subframes.

The basic simulator needs a continuous stream of samples.

So let's fill the blank with silence.
parent 957bd567
......@@ -44,6 +44,7 @@ typedef struct {
int sock;
int samples_per_subframe;
uint64_t timestamp;
uint64_t next_tx_timestamp;
int is_enb;
} tcp_bridge_state_t;
......@@ -141,11 +142,27 @@ int tcp_bridge_write(openair0_device *device, openair0_timestamp timestamp, void
{
if (cc != 1) { printf("tcp_bridge: only 1 antenna supported\n"); exit(1); }
tcp_bridge_state_t *t = device->priv;
/* deal with discontinuities in output (think: eNB in TDD mode) */
if (t->next_tx_timestamp && timestamp != t->next_tx_timestamp) {
uint32_t b[4096];
uint64_t to_send = timestamp - t->next_tx_timestamp;
memset(b, 0, 4096 * sizeof(uint32_t));
while (to_send) {
int len = to_send > 4096 ? 4096 : to_send;
int n = fullwrite(t->sock, b, len * 4);
if (n != len * 4) {
printf("tcp_bridge: write error ret %d error %s\n", n, strerror(errno));
abort();
}
to_send -= len;
}
}
int n = fullwrite(t->sock, buff[0], nsamps * 4);
if (n != nsamps * 4) {
printf("tcp_bridge: write error ret %d (wanted %d) error %s\n", n, nsamps*4, strerror(errno));
abort();
}
t->next_tx_timestamp = timestamp + nsamps;
return nsamps;
}
......
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