Added different data sources and sinks

master
Xavier Arteaga 8 years ago
parent 19bc98081a
commit 6a45147f45

@ -99,6 +99,9 @@ srslte_netsink_t net_sink;
int prbset_num = 1, last_prbset_num = 1;
int prbset_orig = 0;
#define DATA_BUFF_SZ 1024*1024
uint8_t *data[2], data2[DATA_BUFF_SZ];
uint8_t data_tmp[DATA_BUFF_SZ];
void usage(char *prog) {
printf("Usage: %s [agmfoncvpuM]\n", prog);
@ -204,6 +207,16 @@ void base_init() {
exit(-1);
}
/* Allocate memory */
for(i = 0; i < nof_tb; i++) {
data[i] = srslte_vec_malloc(sizeof(uint8_t) * SOFTBUFFER_SIZE);
if (!data[i]) {
perror("malloc");
exit(-1);
}
bzero(data[i], sizeof(uint8_t) * SOFTBUFFER_SIZE);
}
/* init memory */
for (i = 0; i < cell.nof_ports; i++) {
sf_buffer[i] = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
@ -322,6 +335,12 @@ void base_free() {
srslte_ofdm_tx_free(&ifft);
for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) {
if (data[i]) {
free(data[i]);
}
}
for (i = 0; i < SRSLTE_MAX_PORTS; i++) {
if (sf_buffer[i]) {
free(sf_buffer[i]);
@ -468,10 +487,6 @@ int update_control() {
}
}
#define DATA_BUFF_SZ 1024*128
uint8_t data[8*DATA_BUFF_SZ], data2[DATA_BUFF_SZ];
uint8_t data_tmp[DATA_BUFF_SZ];
/** Function run in a separate thread to receive UDP data */
void *net_thread_fnc(void *arg) {
int n;
@ -480,14 +495,16 @@ void *net_thread_fnc(void *arg) {
do {
n = srslte_netsource_read(&net_source, &data2[rpm], DATA_BUFF_SZ-rpm);
if (n > 0) {
int nbytes = 1+(pdsch_cfg.grant.mcs.tbs-1)/8;
// FIXME: I assume that both transport blocks have same size in case of 2 tb are active
int nbytes = 1 + (pdsch_cfg.grant.mcs.tbs + pdsch_cfg.grant.mcs2.tbs - 1) / 8;
rpm += n;
INFO("received %d bytes. rpm=%d/%d\n",n,rpm,nbytes);
wpm = 0;
while (rpm >= nbytes) {
// wait for packet to be transmitted
sem_wait(&net_sem);
memcpy(data, &data2[wpm], nbytes);
memcpy(data[0], &data2[wpm], nbytes / (size_t) 2);
memcpy(data[1], &data2[wpm], nbytes / (size_t) 2);
INFO("Sent %d/%d bytes ready\n", nbytes, rpm);
rpm -= nbytes;
wpm += nbytes;
@ -663,8 +680,11 @@ int main(int argc, char **argv) {
}
} else {
INFO("SF: %d, Generating %d random bits\n", sf_idx, pdsch_cfg.grant.mcs.tbs);
for (i=0;i<pdsch_cfg.grant.mcs.tbs/8;i++) {
data[i] = rand()%256;
for (i = 0; i < pdsch_cfg.grant.mcs.tbs / 8; i++) {
data[0][i] = rand() % 256;
}
for (i = 0; i < pdsch_cfg.grant.mcs2.tbs / 8; i++) {
data[1][i] = rand() % 256;
}
/* Uncomment this to transmit on sf 0 and 5 only */
if (sf_idx != 0 && sf_idx != 5) {
@ -706,17 +726,23 @@ int main(int argc, char **argv) {
}
/* Encode PDSCH */
if (srslte_pdsch_encode_multi(&pdsch, &pdsch_cfg, softbuffers, (uint8_t*[2]){data, data}, UE_CRNTI,
if (srslte_pdsch_encode_multi(&pdsch, &pdsch_cfg, softbuffers, data, UE_CRNTI,
sf_symbols)) {
fprintf(stderr, "Error encoding PDSCH\n");
exit(-1);
}
if (net_port > 0 && net_packet_ready) {
if (null_file_sink) {
srslte_bit_pack_vector(data, data_tmp, pdsch_cfg.grant.mcs.tbs);
srslte_bit_pack_vector(data[0], data_tmp, pdsch_cfg.grant.mcs.tbs);
if (srslte_netsink_write(&net_sink, data_tmp, 1+(pdsch_cfg.grant.mcs.tbs-1)/8) < 0) {
fprintf(stderr, "Error sending data through UDP socket\n");
}
if (nof_tb > 1) {
srslte_bit_pack_vector(data[1], data_tmp, pdsch_cfg.grant.mcs2.tbs);
if (srslte_netsink_write(&net_sink, data_tmp, 1 + (pdsch_cfg.grant.mcs2.tbs - 1) / 8) < 0) {
fprintf(stderr, "Error sending data through UDP socket\n");
}
}
}
net_packet_ready = false;
sem_post(&net_sem);

@ -36,6 +36,9 @@
#include <signal.h>
#include <pthread.h>
#include <semaphore.h>
#include <srslte/srslte.h>
#include <srslte/phy/phch/pdsch_cfg.h>
#include <srslte/phy/phch/ra.h>
#include "srslte/srslte.h"
@ -508,7 +511,7 @@ int main(int argc, char **argv) {
// Variables for measurements
uint32_t nframes=0;
float rsrp0=0.0, rsrp1=0.0, rsrq=0.0, noise=0.0;
float rsrp0=0.0, rsrp1=0.0, rsrq=0.0, noise=0.0, enodebrate = 0.0, uerate = 0.0;
bool decode_pdsch = false;
#ifndef DISABLE_RF
@ -584,7 +587,9 @@ int main(int argc, char **argv) {
/* Send data if socket active */
if (prog_args.net_port > 0) {
srslte_netsink_write(&net_sink, data, 1+(n-1)/8);
// FIXME: UDP Data transmission does not work
srslte_netsink_write(&net_sink, data[0], 1 + (ue_dl.pdsch_cfg.grant.mcs.tbs - 1) / 8);
srslte_netsink_write(&net_sink, data[1], 1 + (ue_dl.pdsch_cfg.grant.mcs2.tbs - 1) / 8);
}
#ifdef PRINT_CHANGE_SCHEDULIGN
@ -609,6 +614,8 @@ int main(int argc, char **argv) {
rsrp0 = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrp_port(&ue_dl.chest, 0), rsrp0, 0.05);
rsrp1 = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrp_port(&ue_dl.chest, 1), rsrp1, 0.05);
noise = SRSLTE_VEC_EMA(srslte_chest_dl_get_noise_estimate(&ue_dl.chest), noise, 0.05);
enodebrate = SRSLTE_VEC_EMA((ue_dl.pdsch_cfg.grant.mcs.tbs + ue_dl.pdsch_cfg.grant.mcs2.tbs)/1000.0, enodebrate, 0.05);
uerate = SRSLTE_VEC_EMA((n>0)?(ue_dl.pdsch_cfg.grant.mcs.tbs + ue_dl.pdsch_cfg.grant.mcs2.tbs)/1000.0:0.0, uerate, 0.01);
nframes++;
if (isnan(rsrq)) {
rsrq = 0;
@ -640,14 +647,17 @@ int main(int argc, char **argv) {
100 * (1 - (float) ue_dl.nof_detected / nof_trials),
(float) 100 * ue_dl.pkt_errors / ue_dl.pkts_total);
} else {
printf("CFO: %+6.2f kHz, "
"SNR port 0: %4.1f dB, "
"SNR port 1: %4.1f dB, "
"PDCCH-Miss: %5.2f%%, PDSCH-BLER: %5.2f%%\r",
printf("CFO: %+5.2f kHz, "
"SNR: %+5.1f dB | %+5.1f dB, "
"Rb: %6.2f / %6.2f Mbps, "
"PDCCH-Miss: %5.2f%%, "
"PDSCH-BLER: %5.2f%%\r",
srslte_ue_sync_get_cfo(&ue_sync) / 1000,
10 * log10(rsrp0 / noise),
10 * log10(rsrp1 / noise),
uerate,
enodebrate,
100 * (1 - (float) ue_dl.nof_detected / nof_trials),
(float) 100 * ue_dl.pkt_errors / ue_dl.pkts_total);
}

Loading…
Cancel
Save