Changed UDP sink and source. Fixed some issues in pdsch_ue. Added PDSCH and TDECODER MEX.

master
ismagom 10 years ago
parent fe948dc9e8
commit 636cb301f8

@ -27,7 +27,7 @@ FIND_LIBRARY(
# Some functions are not defined in old volk versions
IF(${VOLK_FOUND})
IF(NOT ${VOLK_LIBRARIES} STREQUAL "")
SET(CMAKE_REQUIRED_LIBRARIES ${VOLK_LIBRARIES} m)
CHECK_FUNCTION_EXISTS_MATH(volk_32f_index_max_16u HAVE_VOLK_MAX_FUNCTION)
CHECK_FUNCTION_EXISTS_MATH(volk_32f_accumulator_s32f HAVE_VOLK_ACC_FUNCTION)
@ -129,4 +129,4 @@ IF(${VOLK_FOUND})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(VOLK DEFAULT_MSG VOLK_LIBRARIES VOLK_INCLUDE_DIRS)
MARK_AS_ADVANCED(VOLK_LIBRARIES VOLK_INCLUDE_DIRS VOLK_DEFINITIONS)
ENDIF(${VOLK_FOUND})
ENDIF(NOT ${VOLK_LIBRARIES} STREQUAL "")

@ -124,6 +124,8 @@ int cuhd_open(char *args, void **h)
// handler->usrp = uhd::usrp::multi_usrp::make(_args + ", master_clock_rate=50000000" + ", num_recv_frames=512");
handler->usrp->set_clock_source("internal");
uhd::msg::register_handler(my_handler);
std::string otw, cpu;
otw = "sc16";
cpu = "fc32";
@ -147,16 +149,14 @@ int cuhd_close(void *h)
double cuhd_set_rx_srate(void *h, double freq)
{
cuhd_handler *handler = static_cast < cuhd_handler * >(h);
printf("Changing sampling freq now to %.2f MHz\n", freq/1000000);
handler->usrp->set_rx_rate(freq);
printf("Done\n");
/*
double ret = handler->usrp->get_rx_rate();
if ((int) ret != (int) freq) {
printf("Got %f!=%f. setting master clock rate to %f\n",ret, freq, freq);
handler->usrp->set_master_clock_rate(freq);
handler->usrp->set_rx_rate(freq);
}
*/
return freq;
}
@ -170,9 +170,7 @@ double cuhd_set_rx_gain(void *h, double gain)
double cuhd_set_rx_freq(void *h, double freq)
{
cuhd_handler *handler = static_cast < cuhd_handler * >(h);
printf("Tunning receiver to %.3f MHz\n", (double ) freq/1000000);
handler->usrp->set_rx_freq(freq);
printf("Done\n");
return freq;
}

@ -55,7 +55,7 @@
int band = -1;
int earfcn_start=-1, earfcn_end = -1;
cell_search_cfg_t config = {500, 50, 1.1};
cell_search_cfg_t config = {100, 10, 16};
float uhd_gain = 60.0;
@ -140,16 +140,15 @@ int main(int argc, char **argv) {
exit(-1);
}
for (freq=0;freq<nof_freqs;freq+=10) {
for (freq=0;freq<nof_freqs;freq++) {
/* set uhd_freq */
cuhd_set_rx_freq(uhd, (double) channels[freq].fd * MHZ);
cuhd_rx_wait_lo_locked(uhd);
usleep(10000);
INFO("Set uhd_freq to %.3f MHz\n", (double) channels[freq].fd * MHZ/1000000);
printf("[%3d/%d]: EARFCN %d Freq. %.2f MHz looking for PSS. \r", freq, nof_freqs,
channels[freq].id, channels[freq].fd);fflush(stdout);
printf("[%3d/%d]: EARFCN %d Freq. %.2f MHz looking for PSS. \n", freq, nof_freqs,
channels[freq].id, channels[freq].fd);
if (VERBOSE_ISINFO()) {
printf("\n");

@ -50,13 +50,16 @@ lte_cell_t cell = {
PHICH_NORM // PHICH length
};
int udp_port = -1; // -1 generates random data
uint32_t cfi=1;
uint32_t mcs_idx = 12;
int nof_frames = -1;
char *uhd_args = "";
float uhd_amp = 0.1, uhd_gain = 40.0, uhd_freq = 2400000000;
float uhd_amp = 0.1, uhd_gain = 70.0, uhd_freq = 2400000000;
udpsource_t udp_source;
filesink_t fsink;
lte_fft_t ifft;
pbch_t pbch;
@ -70,7 +73,7 @@ cf_t *sf_buffer = NULL, *output_buffer = NULL;
int sf_n_re, sf_n_samples;
void usage(char *prog) {
printf("Usage: %s [agmfoncvp]\n", prog);
printf("Usage: %s [agmfoncvpu]\n", prog);
#ifndef DISABLE_UHD
printf("\t-a UHD args [Default %s]\n", uhd_args);
printf("\t-l UHD amplitude [Default %.2f]\n", uhd_amp);
@ -84,12 +87,13 @@ void usage(char *prog) {
printf("\t-n number of frames [Default %d]\n", nof_frames);
printf("\t-c cell id [Default %d]\n", cell.id);
printf("\t-p nof_prb [Default %d]\n", cell.nof_prb);
printf("\t-u listen UDP port for input data (-1 is random) [Default %d]\n", udp_port);
printf("\t-v [set verbose to debug, default none]\n");
}
void parse_args(int argc, char **argv) {
int opt;
while ((opt = getopt(argc, argv, "aglfmoncpv")) != -1) {
while ((opt = getopt(argc, argv, "aglfmoncpvu")) != -1) {
switch (opt) {
case 'a':
uhd_args = argv[optind];
@ -109,6 +113,9 @@ void parse_args(int argc, char **argv) {
case 'm':
mcs_idx = atoi(argv[optind]);
break;
case 'u':
udp_port = atoi(argv[optind]);
break;
case 'n':
nof_frames = atoi(argv[optind]);
break;
@ -166,6 +173,27 @@ void base_init() {
#endif
}
if (udp_port > 0) {
if (udpsource_init(&udp_source, "0.0.0.0", udp_port)) {
fprintf(stderr, "Error creating input UDP socket at port %d\n", udp_port);
exit(-1);
}
/*
if (udpsource_set_nonblocking(&udp_source)) {
fprintf(stderr, "Error setting non-blocking\n");
exit(-1);
}
*/
if (udpsource_set_timeout(&udp_source, 5)) {
fprintf(stderr, "Error setting UDP socket timeout\n");
exit(-1);
}
printf("Opened UDP socket at port %d\n", udp_port);
}
/* create ifft object */
if (lte_ifft_init(&ifft, CPNORM, cell.nof_prb)) {
fprintf(stderr, "Error creating iFFT object\n");
@ -232,8 +260,15 @@ void base_free() {
cuhd_close(&uhd);
#endif
}
if (udp_port > 0) {
udpsource_free(&udp_source);
}
}
uint8_t data[10000], data_unpacked[10000];
int main(int argc, char **argv) {
int nf, sf_idx, N_id_2;
cf_t pss_signal[PSS_LEN];
@ -243,8 +278,8 @@ int main(int argc, char **argv) {
ra_pdsch_t ra_dl;
ra_prb_t prb_alloc;
int i;
uint8_t *data;
cf_t *sf_symbols[MAX_PORTS];
cf_t *slot1_symbols[MAX_PORTS];
dci_msg_t dci_msg;
dci_location_t locations[NSUBFRAMES_X_FRAME][10];
uint32_t sfn;
@ -274,17 +309,15 @@ int main(int argc, char **argv) {
pss_generate(pss_signal, N_id_2);
sss_generate(sss_signal0, sss_signal5, cell.id);
//refsignal_cs_generate(&csr_signal, cell);
/* Generate CRS signals */
if (chest_dl_init(&est, cell)) {
fprintf(stderr, "Error initializing equalizer\n");
exit(-1);
}
for (i = 0; i < MAX_PORTS; i++) { // now there's only 1 port
sf_symbols[i] = sf_buffer;
slot1_symbols[i] = &sf_buffer[SLOT_LEN_RE(cell.nof_prb, cell.cp)];
}
#ifndef DISABLE_UHD
@ -318,12 +351,6 @@ int main(int argc, char **argv) {
pdcch_ue_locations(&pdcch, locations[i], 10, i, cfi, 1234);
}
data = malloc(sizeof(uint8_t) * ra_dl.mcs.tbs);
if (!data) {
perror("malloc");
exit(-1);
}
nf = 0;
if (pdsch_harq_setup(&harq_process, ra_dl.mcs, &prb_alloc)) {
@ -331,6 +358,8 @@ int main(int argc, char **argv) {
exit(-1);
}
bool send_data = false;
while (nf < nof_frames || nof_frames == -1) {
for (sf_idx = 0; sf_idx < NSUBFRAMES_X_FRAME && (nf < nof_frames || nof_frames == -1); sf_idx++) {
bzero(sf_buffer, sizeof(cf_t) * sf_n_re);
@ -340,23 +369,42 @@ int main(int argc, char **argv) {
sss_put_slot(sf_idx ? sss_signal5 : sss_signal0, sf_buffer, cell.nof_prb,
CPNORM);
}
refsignal_cs_put_sf(cell, 0, est.csr_signal.pilots[0][sf_idx], sf_buffer);
bcch_bch_pack(&cell, sfn, bch_payload_packed, BCH_PAYLOAD_LEN/8);
bit_pack_vector(bch_payload_packed, bch_payload, BCH_PAYLOAD_LEN);
if (sf_idx == 0) {
pbch_encode(&pbch, bch_payload, sf_symbols);
pbch_encode(&pbch, bch_payload, slot1_symbols);
}
pcfich_encode(&pcfich, cfi, sf_symbols, sf_idx);
/* Transmit PDCCH + PDSCH only when there is data to send */
if (sf_idx != 0) {
if (udp_port > 0) {
int n = udpsource_read(&udp_source, data_unpacked, 1+(ra_dl.mcs.tbs-1)/8);
if (n > 0) {
bit_pack_vector(data_unpacked, data, n*8);
send_data = true;
} else if (n == 0) {
send_data = false;
} else {
fprintf(stderr, "Error receiving from UDP socket\n");
exit(-1);
}
} else {
INFO("SF: %d, Generating %d random bits\n", sf_idx, ra_dl.mcs.tbs);
for (i=0;i<ra_dl.mcs.tbs;i++) {
data[i] = rand()%2;
}
send_data = true;
}
} else {
send_data = false;
}
INFO("Puttting DCI to location: n=%d, L=%d\n", locations[sf_idx][0].ncce, locations[sf_idx][0].L);
if (send_data) {
INFO("Putting DCI to location: n=%d, L=%d\n", locations[sf_idx][0].ncce, locations[sf_idx][0].L);
if (pdcch_encode(&pdcch, &dci_msg, locations[sf_idx][0], 1234, sf_symbols, sf_idx, cfi)) {
fprintf(stderr, "Error encoding DCI message\n");
exit(-1);
@ -366,6 +414,9 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error encoding PDSCH\n");
exit(-1);
}
}
refsignal_cs_put_sf(cell, 0, est.csr_signal.pilots[0][sf_idx], sf_buffer);
/* Transform to OFDM symbols */
lte_ifft_run_sf(&ifft, sf_buffer, output_buffer);

@ -70,6 +70,8 @@ typedef struct {
char *uhd_args;
float uhd_freq;
float uhd_gain;
int udp_port;
char *udp_address;
}prog_args_t;
void args_default(prog_args_t *args) {
@ -79,10 +81,12 @@ void args_default(prog_args_t *args) {
args->uhd_args = "";
args->uhd_freq = -1.0;
args->uhd_gain = 60.0;
args->udp_port = -1;
args->udp_address = "127.0.0.1";
}
void usage(prog_args_t *args, char *prog) {
printf("Usage: %s [agldnrv] -f rx_frequency (in Hz)\n", prog);
printf("Usage: %s [agldnruv] -f rx_frequency (in Hz)\n", prog);
printf("\t-a UHD args [Default %s]\n", args->uhd_args);
printf("\t-g UHD RX gain [Default %.2f dB]\n", args->uhd_gain);
printf("\t-r RNTI [Default 0x%x]\n",args->rnti);
@ -93,13 +97,15 @@ void usage(prog_args_t *args, char *prog) {
printf("\t plots are disabled. Graphics library not available\n");
#endif
printf("\t-n nof_subframes [Default %d]\n", args->nof_subframes);
printf("\t-u remote UDP port to send data (-1 does nothing with it) [Default %d]\n", args->udp_port);
printf("\t-U remote UDP address to send data [Default %s]\n", args->udp_address);
printf("\t-v [set verbose to debug, default none]\n");
}
void parse_args(prog_args_t *args, int argc, char **argv) {
int opt;
args_default(args);
while ((opt = getopt(argc, argv, "agldnvrf")) != -1) {
while ((opt = getopt(argc, argv, "agldnvrfuU")) != -1) {
switch (opt) {
case 'a':
args->uhd_args = argv[optind];
@ -119,6 +125,12 @@ void parse_args(prog_args_t *args, int argc, char **argv) {
case 'l':
args->force_N_id_2 = atoi(argv[optind]);
break;
case 'u':
args->udp_port = atoi(argv[optind]);
break;
case 'U':
args->udp_address = argv[optind];
break;
case 'd':
args->disable_plots = true;
break;
@ -138,7 +150,7 @@ void parse_args(prog_args_t *args, int argc, char **argv) {
/**********************************************************************/
/* TODO: Do something with the output data */
uint8_t data[10000], data_unpacked[1000];
uint8_t data[10000], data_packed[10000];
bool go_exit = false;
@ -156,7 +168,7 @@ int cuhd_recv_wrapper(void *h, void *data, uint32_t nsamples) {
extern float mean_exec_time;
enum receiver_state { DECODE_MIB, DECODE_SIB} state;
enum receiver_state { DECODE_MIB, DECODE_PDSCH} state;
int main(int argc, char **argv) {
@ -174,8 +186,17 @@ int main(int argc, char **argv) {
int n;
uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_unpacked[BCH_PAYLOAD_LEN];
uint32_t sfn_offset;
udpsink_t udp_sink;
parse_args(&prog_args, argc, argv);
if (prog_args.udp_port > 0) {
if (udpsink_init(&udp_sink, prog_args.udp_address, prog_args.udp_port)) {
fprintf(stderr, "Error initiating UDP socket to %s:%d\n", prog_args.udp_address, prog_args.udp_port);
exit(-1);
}
}
printf("Opening UHD device...\n");
if (cuhd_open(prog_args.uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n");
@ -216,7 +237,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error initiating ue_sync\n");
exit(-1);
}
if (ue_dl_init(&ue_dl, cell, 1234)) { // This is the User RNTI
if (ue_dl_init(&ue_dl, cell, prog_args.rnti==SIRNTI?1:prog_args.rnti)) { // This is the User RNTI
fprintf(stderr, "Error initiating UE downlink processing module\n");
exit(-1);
}
@ -240,13 +261,12 @@ int main(int argc, char **argv) {
}
#endif
cuhd_start_rx_stream(uhd);
// Variables for measurements
uint32_t nframes=0;
float rsrp=0.0, rsrq=0.0, snr=0.0;
bool decode_pdsch;
/* Main loop */
while (!go_exit && (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1)) {
@ -271,18 +291,39 @@ int main(int argc, char **argv) {
bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn);
printf("Decoded MIB. SFN: %d, offset: %d\n", sfn, sfn_offset);
sfn = (sfn + sfn_offset)%1024;
state = DECODE_SIB;
state = DECODE_PDSCH;
}
}
break;
case DECODE_SIB:
/* We are looking for SI Blocks, search only in appropiate places */
case DECODE_PDSCH:
if (prog_args.rnti != SIRNTI) {
decode_pdsch = true;
} else {
/* We are looking for SIB1 Blocks, search only in appropiate places */
if ((ue_sync_get_sfidx(&ue_sync) == 5 && (sfn%2)==0)) {
n = ue_dl_decode_sib(&ue_dl, sf_buffer, data, ue_sync_get_sfidx(&ue_sync),
decode_pdsch = true;
} else {
decode_pdsch = false;
}
}
if (decode_pdsch) {
if (prog_args.rnti != SIRNTI) {
n = ue_dl_decode(&ue_dl, sf_buffer, data_packed, ue_sync_get_sfidx(&ue_sync));
} else {
n = ue_dl_decode_sib(&ue_dl, sf_buffer, data_packed, ue_sync_get_sfidx(&ue_sync),
((int) ceilf((float)3*(((sfn)/2)%4)/2))%4);
}
if (n < 0) {
fprintf(stderr, "Error decoding UE DL\n");fflush(stdout);
exit(-1);
} else if (n > 0) {
/* Send data if socket active */
if (prog_args.udp_port > 0) {
bit_unpack_vector(data_packed, data, n);
if (udpsink_write(&udp_sink, data, 1+(n-1)/8) < 0) {
fprintf(stderr, "Error sending data through UDP socket\n");
}
}
}
nof_trials++;
@ -363,12 +404,12 @@ void init_plots() {
plot_real_init(&poutfft);
plot_real_setTitle(&poutfft, "Output FFT - Magnitude");
plot_real_setLabels(&poutfft, "Index", "dB");
plot_real_setYAxisScale(&poutfft, -60, 0);
plot_real_setYAxisScale(&poutfft, -40, 40);
plot_real_init(&pce);
plot_real_setTitle(&pce, "Channel Response - Magnitude");
plot_real_setLabels(&pce, "Index", "dB");
plot_real_setYAxisScale(&pce, -60, 0);
plot_real_setYAxisScale(&pce, -40, 40);
plot_real_init(&p_sync);
plot_real_setTitle(&p_sync, "PSS Cross-Corr abs value");
@ -376,13 +417,13 @@ void init_plots() {
plot_scatter_init(&pscatequal);
plot_scatter_setTitle(&pscatequal, "PDSCH - Equalized Symbols");
plot_scatter_setXAxisScale(&pscatequal, -2, 2);
plot_scatter_setYAxisScale(&pscatequal, -2, 2);
plot_scatter_setXAxisScale(&pscatequal, -4, 4);
plot_scatter_setYAxisScale(&pscatequal, -4, 4);
plot_scatter_init(&pscatequal_pdcch);
plot_scatter_setTitle(&pscatequal_pdcch, "PDCCH - Equalized Symbols");
plot_scatter_setXAxisScale(&pscatequal_pdcch, -2, 2);
plot_scatter_setYAxisScale(&pscatequal_pdcch, -2, 2);
plot_scatter_setXAxisScale(&pscatequal_pdcch, -4, 4);
plot_scatter_setYAxisScale(&pscatequal_pdcch, -4, 4);
}

@ -183,6 +183,8 @@ LIBLTE_API uint32_t lte_voffset(uint32_t symbol_id,
LIBLTE_API int lte_cb_size(uint32_t index);
LIBLTE_API bool lte_cb_size_isvalid(uint32_t size);
LIBLTE_API char *lte_cp_string(lte_cp_t cp);
LIBLTE_API char *lte_mod_string(lte_mod_t mod);

@ -83,7 +83,7 @@ LIBLTE_API void tdec_decision(tdec_t * h,
uint8_t *output,
uint32_t long_cb);
LIBLTE_API void tdec_run_all(tdec_t * h,
LIBLTE_API int tdec_run_all(tdec_t * h,
llr_t * input,
uint8_t *output,
uint32_t nof_iterations,

@ -36,19 +36,22 @@
#include <stdlib.h>
#include "liblte/config.h"
#include "liblte/phy/io/format.h"
/* Low-level API */
typedef struct LIBLTE_API {
int sockfd;
struct sockaddr_in servaddr;
data_type_t type;
}udpsink_t;
LIBLTE_API int udpsink_init(udpsink_t *q, char *address, int port, data_type_t type);
LIBLTE_API int udpsink_init(udpsink_t *q,
char *address,
int port);
LIBLTE_API void udpsink_free(udpsink_t *q);
LIBLTE_API int udpsink_write(udpsink_t *q, void *buffer, int nsamples);
LIBLTE_API int udpsink_write(udpsink_t *q,
void *buffer,
int nof_bytes);
/* High-level API */

@ -29,7 +29,7 @@
#ifndef UDPSOURCE_
#define UDPSOURCE_
#include <stdbool.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
@ -37,19 +37,27 @@
#include <stdlib.h>
#include "liblte/config.h"
#include "liblte/phy/io/format.h"
/* Low-level API */
typedef struct LIBLTE_API {
int sockfd;
struct sockaddr_in servaddr;
data_type_t type;
}udpsource_t;
LIBLTE_API int udpsource_init(udpsource_t *q, char *address, int port, data_type_t type);
LIBLTE_API int udpsource_init(udpsource_t *q,
char *address,
int port);
LIBLTE_API void udpsource_free(udpsource_t *q);
LIBLTE_API int udpsource_read(udpsource_t *q, void *buffer, int nsamples);
LIBLTE_API int udpsource_set_nonblocking(udpsource_t *q);
LIBLTE_API int udpsource_read(udpsource_t *q,
void *buffer,
int nof_bytes);
LIBLTE_API int udpsource_set_timeout(udpsource_t *q,
uint32_t microseconds);
/* High-level API */

@ -301,8 +301,8 @@ float chest_dl_rssi(chest_dl_t *q, cf_t *input, uint32_t port_id) {
float rssi = 0;
uint32_t nsymbols = refsignal_cs_nof_symbols(port_id);
for (l=0;l<nsymbols;l++) {
cf_t *tmp = &input[refsignal_nsymbol(l,q->cell.cp, port_id) * q->cell.nof_prb * RE_X_RB];
rssi += vec_dot_prod_conj_ccc(tmp,tmp,q->cell.nof_prb * RE_X_RB);
cf_t *tmp = &input[refsignal_nsymbol(l, q->cell.cp, port_id) * q->cell.nof_prb * RE_X_RB];
rssi += vec_dot_prod_conj_ccc(tmp, tmp, q->cell.nof_prb * RE_X_RB);
}
return rssi/nsymbols;
}

@ -95,6 +95,8 @@ int lte_ifft_init(lte_fft_t *q, lte_cp_t cp, uint32_t nof_prb) {
ret = lte_fft_init_(q, cp, nof_prb, BACKWARD);
if (ret == LIBLTE_SUCCESS) {
dft_plan_set_norm(&q->fft_plan, true);
/* set now zeros at CP */
for (i=0;i<q->nof_symbols;i++) {
bzero(q->tmp, q->nof_guards * sizeof(cf_t));

@ -34,7 +34,7 @@
#include "liblte/phy/common/phy_common.h"
const int tc_cb_sizes[NOF_TC_CB_SIZES] = { 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120,
const uint32_t tc_cb_sizes[NOF_TC_CB_SIZES] = { 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120,
128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232,
240, 248, 256, 264, 272, 280, 288, 296, 304, 312, 320, 328, 336, 344,
352, 360, 368, 376, 384, 392, 400, 408, 416, 424, 432, 440, 448, 456,
@ -117,12 +117,21 @@ bool lte_N_id_1_isvalid(uint32_t N_id_1) {
*/
int lte_cb_size(uint32_t index) {
if (index < NOF_TC_CB_SIZES) {
return tc_cb_sizes[index];
return (int) tc_cb_sizes[index];
} else {
return LIBLTE_ERROR;
}
}
bool lte_cb_size_isvalid(uint32_t size) {
for (int i=0;i<NOF_TC_CB_SIZES;i++) {
if (tc_cb_sizes[i] == size) {
return true;
}
}
return false;
}
char *lte_mod_string(lte_mod_t mod) {
switch (mod) {
case LTE_BPSK:

@ -325,12 +325,14 @@ void tdec_decision(tdec_t * h, uint8_t *output, uint32_t long_cb)
}
}
void tdec_run_all(tdec_t * h, llr_t * input, uint8_t *output,
int tdec_run_all(tdec_t * h, llr_t * input, uint8_t *output,
uint32_t nof_iterations, uint32_t long_cb)
{
uint32_t iter = 0;
tdec_reset(h, long_cb);
if (tdec_reset(h, long_cb)) {
return LIBLTE_ERROR;
}
do {
tdec_iteration(h, input, long_cb);
@ -338,4 +340,6 @@ void tdec_run_all(tdec_t * h, llr_t * input, uint8_t *output,
} while (iter < nof_iterations);
tdec_decision(h, output, long_cb);
return LIBLTE_SUCCESS;
}

@ -42,13 +42,15 @@ ADD_TEST(rm_turbo_test_2 rm_turbo_test -t 1920 -r 480 -i 3)
########################################################################
# Turbo Coder TEST
########################################################################
ADD_EXECUTABLE(turbocoder_test turbocoder_test.c)
TARGET_LINK_LIBRARIES(turbocoder_test lte_phy)
ADD_EXECUTABLE(turbodecoder_test turbodecoder_test.c)
TARGET_LINK_LIBRARIES(turbodecoder_test lte_phy)
ADD_TEST(turbocoder_test_504_1 turbocoder_test -n 100 -s 1 -l 504 -e 1.0 -t)
ADD_TEST(turbocoder_test_504_2 turbocoder_test -n 100 -s 1 -l 504 -e 2.0 -t)
ADD_TEST(turbocoder_test_6114_1_5 turbocoder_test -n 100 -s 1 -l 6144 -e 1.5 -t)
ADD_TEST(turbocoder_test_known turbocoder_test -n 1 -s 1 -k -e 0.5)
ADD_TEST(turbodecoder_test_504_1 turbodecoder_test -n 100 -s 1 -l 504 -e 1.0 -t)
ADD_TEST(turbodecoder_test_504_2 turbodecoder_test -n 100 -s 1 -l 504 -e 2.0 -t)
ADD_TEST(turbodecoder_test_6114_1_5 turbodecoder_test -n 100 -s 1 -l 6144 -e 1.5 -t)
ADD_TEST(turbodecoder_test_known turbodecoder_test -n 1 -s 1 -k -e 0.5)
BuildMex(MEXNAME turbodecoder SOURCES turbodecoder_test_mex.c LIBRARIES lte_phy liblte_mex)
########################################################################
# Viterbi TEST

@ -37,7 +37,7 @@
#include <time.h>
#include "liblte/phy/phy.h"
#include "turbocoder_test.h"
#include "turbodecoder_test.h"
typedef _Complex float cf_t;

@ -37,16 +37,20 @@
#include "liblte/phy/io/udpsink.h"
int udpsink_init(udpsink_t *q, char *address, int port, data_type_t type) {
int udpsink_init(udpsink_t *q, char *address, int port) {
bzero(q, sizeof(udpsink_t));
q->sockfd=socket(AF_INET,SOCK_DGRAM,0);
if (q->sockfd < 0) {
perror("socket");
return -1;
}
q->servaddr.sin_family = AF_INET;
q->servaddr.sin_addr.s_addr=inet_addr(address);
q->servaddr.sin_port=htons(port);
q->type = type;
return 0;
}
@ -57,36 +61,15 @@ void udpsink_free(udpsink_t *q) {
bzero(q, sizeof(udpsink_t));
}
int udpsink_write(udpsink_t *q, void *buffer, int nsamples) {
int size;
switch(q->type) {
case FLOAT:
case COMPLEX_FLOAT:
case COMPLEX_SHORT:
fprintf(stderr, "Not implemented\n");
return -1;
case FLOAT_BIN:
case COMPLEX_FLOAT_BIN:
case COMPLEX_SHORT_BIN:
if (q->type == FLOAT_BIN) {
size = sizeof(float);
} else if (q->type == COMPLEX_FLOAT_BIN) {
size = sizeof(_Complex float);
} else if (q->type == COMPLEX_SHORT_BIN) {
size = sizeof(_Complex short);
}
return sendto(q->sockfd, buffer, nsamples * size, 0,
int udpsink_write(udpsink_t *q, void *buffer, int nof_bytes) {
return sendto(q->sockfd, buffer, nof_bytes, 0,
&q->servaddr, sizeof(struct sockaddr_in));
break;
}
return -1;
}
int udpsink_initialize(udpsink_hl* h) {
return udpsink_init(&h->obj, h->init.address, h->init.port, h->init.data_type);
return udpsink_init(&h->obj, h->init.address, h->init.port);
}
int udpsink_work(udpsink_hl* h) {

@ -29,23 +29,33 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <errno.h>
#include "liblte/phy/io/udpsource.h"
int udpsource_init(udpsource_t *q, char *address, int port, data_type_t type) {
int udpsource_init(udpsource_t *q, char *address, int port) {
bzero(q, sizeof(udpsource_t));
q->sockfd=socket(AF_INET,SOCK_DGRAM,0);
if (q->sockfd < 0) {
perror("socket");
return -1;
}
q->servaddr.sin_family = AF_INET;
q->servaddr.sin_addr.s_addr=inet_addr(address);
q->servaddr.sin_port=htons(port);
bind(q->sockfd,(struct sockaddr *)&q->servaddr,sizeof(struct sockaddr_in));
q->type = type;
if (bind(q->sockfd,(struct sockaddr *)&q->servaddr,sizeof(struct sockaddr_in))) {
perror("bind");
return -1;
}
return 0;
}
@ -56,34 +66,41 @@ void udpsource_free(udpsource_t *q) {
bzero(q, sizeof(udpsource_t));
}
int udpsource_read(udpsource_t *q, void *buffer, int nsamples) {
int size;
int udpsource_read(udpsource_t *q, void *buffer, int nbytes) {
int n = recv(q->sockfd, buffer, nbytes, 0);
switch(q->type) {
case FLOAT:
case COMPLEX_FLOAT:
case COMPLEX_SHORT:
fprintf(stderr, "Not implemented\n");
if (n == -1) {
if (errno == EAGAIN) {
return 0;
} else {
return -1;
case FLOAT_BIN:
case COMPLEX_FLOAT_BIN:
case COMPLEX_SHORT_BIN:
if (q->type == FLOAT_BIN) {
size = sizeof(float);
} else if (q->type == COMPLEX_FLOAT_BIN) {
size = sizeof(_Complex float);
} else if (q->type == COMPLEX_SHORT_BIN) {
size = sizeof(_Complex short);
}
return recv(q->sockfd, buffer, size * nsamples, 0);
break;
} else {
return n;
}
}
int udpsource_set_nonblocking(udpsource_t *q) {
if (fcntl(q->sockfd, F_SETFL, O_NONBLOCK)) {
perror("fcntl");
return -1;
}
return 0;
}
int udpsource_set_timeout(udpsource_t *q, uint32_t microseconds) {
struct timeval t;
t.tv_sec = 0;
t.tv_usec = microseconds;
if (setsockopt(q->sockfd, SOL_SOCKET, SO_RCVTIMEO, &t, sizeof(struct timeval))) {
perror("setsockopt");
return -1;
}
return 0;
}
int udpsource_initialize(udpsource_hl* h) {
return udpsource_init(&h->obj, h->init.address, h->init.port, h->init.data_type);
return udpsource_init(&h->obj, h->init.address, h->init.port);
}
int udpsource_work(udpsource_hl* h) {

@ -204,6 +204,7 @@ int pdsch_init(pdsch_t *q, lte_cell_t cell) {
if (precoding_init(&q->precoding, SF_LEN_RE(cell.nof_prb, cell.cp))) {
fprintf(stderr, "Error initializing precoding\n");
goto clean;
}
for (i = 0; i < 4; i++) {
@ -212,9 +213,11 @@ int pdsch_init(pdsch_t *q, lte_cell_t cell) {
}
}
if (crc_init(&q->crc_tb, LTE_CRC24A, 24)) {
fprintf(stderr, "Error initiating CRC\n");
goto clean;
}
if (crc_init(&q->crc_cb, LTE_CRC24B, 24)) {
fprintf(stderr, "Error initiating CRC\n");
goto clean;
}
@ -224,9 +227,11 @@ int pdsch_init(pdsch_t *q, lte_cell_t cell) {
q->rnti_is_set = false;
if (tcod_init(&q->encoder, MAX_LONG_CB)) {
fprintf(stderr, "Error initiating Turbo Coder\n");
goto clean;
}
if (tdec_init(&q->decoder, MAX_LONG_CB)) {
fprintf(stderr, "Error initiating Turbo Decoder\n");
goto clean;
}
@ -397,7 +402,7 @@ int pdsch_harq_init(pdsch_harq_t *p, pdsch_t *pdsch) {
// We add 50 % larger buffer to the maximum expected bits per subframe
// FIXME: Use HARQ buffer limitation based on UE category
p->w_buff_size = p->cell.nof_prb * MAX_PDSCH_RE(p->cell.cp) * 6 * 2 / p->max_cb;
p->w_buff_size = p->cell.nof_prb * MAX_PDSCH_RE(p->cell.cp) * 6 * 2;
for (i=0;i<p->max_cb;i++) {
p->pdsch_w_buff_f[i] = vec_malloc(sizeof(float) * p->w_buff_size);
if (!p->pdsch_w_buff_f[i]) {
@ -851,7 +856,8 @@ int pdsch_encode(pdsch_t *q, uint8_t *data, cf_t *sf_symbols[MAX_PORTS], uint32_
if (q != NULL &&
data != NULL &&
subframe < 10 &&
harq_process != NULL)
harq_process != NULL &&
harq_process->mcs.mod > 0)
{
if (q->rnti_is_set) {

@ -146,7 +146,7 @@ void ue_dl_free(ue_dl_t *q) {
void ue_dl_set_rnti(ue_dl_t *q, uint16_t rnti) {
q->current_rnti = rnti;
pdsch_set_rnti(&q->pdsch, SIRNTI);
pdsch_set_rnti(&q->pdsch, rnti);
}
void ue_dl_reset(ue_dl_t *q) {
@ -155,7 +155,7 @@ void ue_dl_reset(ue_dl_t *q) {
LIBLTE_API float mean_exec_time=0;
dci_format_t ue_formats[] = {Format1A,Format1}; // Format1B should go here also
dci_format_t ue_formats[] = {Format1,Format1A}; // Format1B should go here also
const uint32_t nof_ue_formats = 2;
dci_format_t common_formats[] = {Format1A,Format1C};
@ -253,7 +253,9 @@ int ue_dl_decode_sib(ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx, ui
}
}
if (q->harq_process[0].mcs.mod > 0) {
ret = pdsch_decode(&q->pdsch, q->sf_symbols, q->ce, chest_dl_get_noise_estimate(&q->chest), data, sf_idx,
ret = pdsch_decode(&q->pdsch, q->sf_symbols, q->ce,
chest_dl_get_noise_estimate(&q->chest),
data, sf_idx,
&q->harq_process[0], rvidx);
if (ret == LIBLTE_ERROR) {
q->pkt_errors++;

@ -100,7 +100,7 @@ int ue_sync_init(ue_sync_t *q,
sync_correct_cfo(&q->sfind, true);
sync_correct_cfo(&q->strack, true);
sync_set_threshold(&q->sfind, 1.1);
sync_set_threshold(&q->sfind, 1.3);
sync_set_em_alpha(&q->sfind, 0.01);
q->nof_avg_find_frames = FIND_NOF_AVG_FRAMES;
sync_set_threshold(&q->strack, 1.2);

Loading…
Cancel
Save