Commit 364ea768 authored by Laurent THOMAS's avatar Laurent THOMAS

fix warings

parent b3515527
......@@ -56,7 +56,7 @@ void lte_gold(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_table[20][2][14]
(((1+(Nid_cell<<1))*(1 + (((frame_parms->Ncp==0)?4:3)*l) + (7*(1+ns))))<<10); //cinit
//x2 = frame_parms->Ncp + (Nid_cell<<1) + (1+(Nid_cell<<1))*(1 + (3*l) + (7*(1+ns))); //cinit
//n = 0
x1 = 1+ (1<<31);
x1 = 1+ (1U<<31);
x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
// skip first 50 double words (1600 bits)
......@@ -103,7 +103,7 @@ void lte_gold_ue_spec(uint32_t lte_gold_uespec_table[2][20][2][21],uint16_t Nid_
//x2 = frame_parms->Ncp + (Nid_cell<<1) + (1+(Nid_cell<<1))*(1 + (3*l) + (7*(1+ns))); //cinit
//n = 0
// printf("cinit (ns %d, l %d) => %d\n",ns,l,x2);
x1 = 1+ (1<<31);
x1 = 1+ (1U<<31);
x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
// skip first 50 double words (1600 bits)
......@@ -143,7 +143,7 @@ void lte_gold_ue_spec_port5(uint32_t lte_gold_uespec_port5_table[20][38],uint16_
//x2 = frame_parms->Ncp + (Nid_cell<<1) + (1+(Nid_cell<<1))*(1 + (3*l) + (7*(1+ns))); //cinit
//n = 0
//printf("cinit (ns %d, l %d) => %d\n",ns,l,x2);
x1 = 1+ (1<<31);
x1 = 1+ (1U<<31);
x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
//skip first 50 double words (1600 bits)
......
......@@ -59,7 +59,7 @@ void lte_gold_mbsfn(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_mbsfn_tabl
//n = 0
// printf("cinit (sfn %d, l %d) => %d\n",sfn,l,x2);
// Initializing the Sequence
x1 = 1+ (1<<31);
x1 = 1+ (1U<<31);
x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
// skip first 50 double words (1600 bits)
// printf("n=0 : x1 %x, x2 %x\n",x1,x2);
......@@ -90,7 +90,7 @@ void lte_gold_mbsfn_khz_1dot25(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold
for (sfn=0; sfn<10; sfn++) {
x2 = (Nid_mbsfn) + (((1+(Nid_mbsfn<<1))*(1 + (7*(1+sfn))))<<9); //cinit
x1 = 1+ (1<<31);
x1 = 1+ (1U<<31);
x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
for (n=1; n<50; n++) {
......
......@@ -121,7 +121,7 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms,
for (n=0; n<(1+(G>>5)); n++) {
#ifdef DEBUG_SCRAMBLING
for (int k=0; k<32; k++) printf("scrambling %d : %d xor %d = %d\n",k+(n<<5),e[k],(s>>k)&1,e[k]^((s>>k)&1));
for (int k=0; k<32; k++) printf("scrambling %d : %x xor %x = %d\n",k+(n<<5),e[k],(s>>k)&1,e[k]^((s>>k)&1));
#endif
e[0] = (e[0]) ^ (s&1);
......
......@@ -41,7 +41,7 @@ extern inline uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t res
{
// Init value for x1: x1(0) = 1, x1(n) = 0, n=1,2,...,30
// x1(31) = [x1(3) + x1(0)]mod2 = 1
*x1 = 1 + (1<<31);
*x1 = 1 + (1U<<31);
// Init value for x2: cinit = sum_{i=0}^30 x2*2^i
// x2(31) = [x2(3) + x2(2) + x2(1) + x2(0)]mod2
// = (*x2>>3) ^ (*x2>>2) + (*x2>>1) + *x2
......
......@@ -374,7 +374,7 @@ static inline unsigned int lte_gold_unscram(unsigned int *x1, unsigned int *x2,
int n;
if (reset) {
*x1 = 1+ (1<<31);
*x1 = 1+ (1U<<31);
*x2=*x2 ^ ((*x2 ^ (*x2>>1) ^ (*x2>>2) ^ (*x2>>3))<<31);
// skip first 50 double words (1600 bits)
......
......@@ -150,7 +150,7 @@ void pseudo_random_sequence_optimised(unsigned int size, uint32_t *c, uint32_t c
unsigned int n,x1,x2;
/* init of m-sequences */
x1 = 1+ (1<<31);
x1 = 1+ (1U<<31);
x2 = cinit;
x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
......
......@@ -50,7 +50,7 @@ static int channelmod_print_help(char *buff, int debug, telnet_printfunc_t prnt)
static telnetshell_cmddef_t channelmod_cmdarray[] = {
{"help","",channelmod_print_help},
{"show","<predef,current>",channelmod_show_cmd},
{"modify","<channelid> <param> <value>",channelmod_modify_cmd},
{"modify","<channelid> <param> <value>",channelmod_modify_cmd},
{"","",NULL},
};
......@@ -62,7 +62,7 @@ static double snr_dB=25;
static double sinr_dB=0;
static unsigned int max_chan;
static channel_desc_t **defined_channels;
static char modellist_name[MAX_OPTNAME_SIZE]={0};
static char modellist_name[MAX_OPTNAME_SIZE]= {0};
void fill_channel_desc(channel_desc_t *chan_desc,
......@@ -71,7 +71,7 @@ void fill_channel_desc(channel_desc_t *chan_desc,
uint8_t nb_taps,
uint8_t channel_length,
double *amps,
double *delays,
double *delays,
struct complex **R_sqrt,
double Td,
double sampling_rate,
......@@ -139,8 +139,10 @@ void fill_channel_desc(channel_desc_t *chan_desc,
if (R_sqrt == NULL) {
chan_desc->R_sqrt = (struct complex **) calloc(nb_taps,sizeof(struct complex *));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_NTAPS ;
for (i = 0; i<nb_taps; i++) {
chan_desc->R_sqrt[i] = (struct complex *) calloc(nb_tx*nb_rx*nb_tx*nb_rx,sizeof(struct complex));
chan_desc->R_sqrt[i] = (struct complex *) calloc(nb_tx*nb_rx*nb_tx*nb_rx,sizeof(struct complex));
for (j = 0; j<nb_tx*nb_rx*nb_tx*nb_rx; j+=(nb_tx*nb_rx+1)) {
chan_desc->R_sqrt[i][j].x = 1.0;
chan_desc->R_sqrt[i][j].y = 0.0;
......@@ -148,7 +150,7 @@ void fill_channel_desc(channel_desc_t *chan_desc,
}
} else {
chan_desc->R_sqrt = (struct complex **) calloc(nb_taps,sizeof(struct complex *));
for (i = 0; i<nb_taps; i++) {
//chan_desc->R_sqrt[i] = (struct complex*) calloc(nb_tx*nb_rx*nb_tx*nb_rx,sizeof(struct complex));
//chan_desc->R_sqrt = (struct complex*)&R_sqrt[i][0];
......@@ -178,218 +180,228 @@ void fill_channel_desc(channel_desc_t *chan_desc,
double mbsfn_delays[] = {0,.03,.15,.31,.37,1.09,12.490,12.52,12.64,12.80,12.86,13.58,27.49,27.52,27.64,27.80,27.86,28.58};
double mbsfn_amps_dB[] = {0,-1.5,-1.4,-3.6,-0.6,-7.0,-10,-11.5,-11.4,-13.6,-10.6,-17.0,-20,-21.5,-21.4,-23.6,-20.6,-27};
double scm_c_delays[] = {0, 0.0125, 0.0250, 0.3625, 0.3750, 0.3875, 0.2500, 0.2625, 0.2750, 1.0375, 1.0500, 1.0625, 2.7250, 2.7375, 2.7500, 4.6000, 4.6125, 4.6250};
double scm_c_delays[] = {0, 0.0125, 0.0250, 0.3625, 0.3750, 0.3875, 0.2500, 0.2625, 0.2750, 1.0375, 1.0500, 1.0625, 2.7250, 2.7375, 2.7500, 4.6000, 4.6125, 4.6250};
double scm_c_amps_dB[] = {0.00, -2.22, -3.98, -1.86, -4.08, -5.84, -1.08, -3.30, -5.06, -9.08, -11.30, -13.06, -15.14, -17.36, -19.12, -20.64, -22.85, -24.62};
double tdl_a_delays[] = {0.0000,
0.3819,
0.4025,
0.5868,
0.4610,
0.5375,
0.6708,
0.5750,
0.7618,
1.5375,
1.8978,
2.2242,
2.1718,
2.4942,
2.5119,
3.0582,
4.0810,
4.4579,
4.5695,
4.7966,
5.0066,
5.3043,
9.6586};
0.3819,
0.4025,
0.5868,
0.4610,
0.5375,
0.6708,
0.5750,
0.7618,
1.5375,
1.8978,
2.2242,
2.1718,
2.4942,
2.5119,
3.0582,
4.0810,
4.4579,
4.5695,
4.7966,
5.0066,
5.3043,
9.6586
};
double tdl_a_amps_dB[] = {-13.4,
0,
-2.2,
-4,
-6,
-8.2,
-9.9,
-10.5,
-7.5,
-15.9,
-6.6,
-16.7,
-12.4,
-15.2,
-10.8,
-11.3,
-12.7,
-16.2,
-18.3,
-18.9,
-16.6,
-19.9,
-29.7};
0,
-2.2,
-4,
-6,
-8.2,
-9.9,
-10.5,
-7.5,
-15.9,
-6.6,
-16.7,
-12.4,
-15.2,
-10.8,
-11.3,
-12.7,
-16.2,
-18.3,
-18.9,
-16.6,
-19.9,
-29.7
};
double tdl_b_delays[] = {0.0000,
0.1072,
0.2155,
0.2095,
0.2870,
0.2986,
0.3752,
0.5055,
0.3681,
0.3697,
0.5700,
0.5283,
1.1021,
1.2756,
1.5474,
1.7842,
2.0169,
2.8294,
3.0219,
3.6187,
4.1067,
4.2790,
4.7834};
0.1072,
0.2155,
0.2095,
0.2870,
0.2986,
0.3752,
0.5055,
0.3681,
0.3697,
0.5700,
0.5283,
1.1021,
1.2756,
1.5474,
1.7842,
2.0169,
2.8294,
3.0219,
3.6187,
4.1067,
4.2790,
4.7834
};
double tdl_b_amps_dB[] = {0,
-2.2,
-4,
-3.2,
-9.8,
-1.2,
-3.4,
-5.2,
-7.6,
-3,
-8.9,
-9,
-4.8,
-5.7,
-7.5,
-1.9,
-7.6,
-12.2,
-9.8,
-11.4,
-14.9,
-9.2,
-11.3};
-2.2,
-4,
-3.2,
-9.8,
-1.2,
-3.4,
-5.2,
-7.6,
-3,
-8.9,
-9,
-4.8,
-5.7,
-7.5,
-1.9,
-7.6,
-12.2,
-9.8,
-11.4,
-14.9,
-9.2,
-11.3
};
double tdl_c_delays[] = {0,
0.2099,
0.2219,
0.2329,
0.2176,
0.6366,
0.6448,
0.6560,
0.6584,
0.7935,
0.8213,
0.9336,
1.2285,
1.3083,
2.1704,
2.7105,
4.2589,
4.6003,
5.4902,
5.6077,
6.3065,
6.6374,
7.0427,
8.6523};
0.2099,
0.2219,
0.2329,
0.2176,
0.6366,
0.6448,
0.6560,
0.6584,
0.7935,
0.8213,
0.9336,
1.2285,
1.3083,
2.1704,
2.7105,
4.2589,
4.6003,
5.4902,
5.6077,
6.3065,
6.6374,
7.0427,
8.6523
};
double tdl_c_amps_dB[] = {-4.4,
-1.2,
-3.5,
-5.2,
-2.5,
0,
-2.2,
-3.9,
-7.4,
-7.1,
-10.7,
-11.1,
-5.1,
-6.8,
-8.7,
-13.2,
-13.9,
-13.9,
-15.8,
-17.1,
-16,
-15.7,
-21.6,
-22.8};
-1.2,
-3.5,
-5.2,
-2.5,
0,
-2.2,
-3.9,
-7.4,
-7.1,
-10.7,
-11.1,
-5.1,
-6.8,
-8.7,
-13.2,
-13.9,
-13.9,
-15.8,
-17.1,
-16,
-15.7,
-21.6,
-22.8
};
double tdl_d_delays[] = {//0,
0,
0.035,
0.612,
1.363,
1.405,
1.804,
2.596,
1.775,
4.042,
7.937,
9.424,
9.708,
12.525};
0,
0.035,
0.612,
1.363,
1.405,
1.804,
2.596,
1.775,
4.042,
7.937,
9.424,
9.708,
12.525
};
double tdl_d_amps_dB[] = {//-0.2,
//-13.5,
-.00147,
-18.8,
-21,
-22.8,
-17.9,
-20.1,
-21.9,
-22.9,
-27.8,
-23.6,
-24.8,
-30.0,
-27.7};
//-13.5,
-.00147,
-18.8,
-21,
-22.8,
-17.9,
-20.1,
-21.9,
-22.9,
-27.8,
-23.6,
-24.8,
-30.0,
-27.7
};
#define TDL_D_RICEAN_FACTOR .046774
double tdl_e_delays[] = {0,
0.5133,
0.5440,
0.5630,
0.5440,
0.7112,
1.9092,
1.9293,
1.9589,
2.6426,
3.7136,
5.4524,
12.0034,
20.6519};
0.5133,
0.5440,
0.5630,
0.5440,
0.7112,
1.9092,
1.9293,
1.9589,
2.6426,
3.7136,
5.4524,
12.0034,
20.6519
};
double tdl_e_amps_dB[] = {//-0.03,
//-22.03,
-.00433,
-15.8,
-18.1,
-19.8,
-22.9,
-22.4,
-18.6,
-20.8,
-22.6,
-22.3,
-25.6,
-20.2,
-29.8,
-29.2};
//-22.03,
-.00433,
-15.8,
-18.1,
-19.8,
-22.9,
-22.4,
-18.6,
-20.8,
-22.6,
-22.3,
-25.6,
-20.2,
-29.8,
-29.2
};
#define TDL_E_RICEAN_FACTOR 0.0063096
......@@ -492,33 +504,101 @@ struct complex *R_sqrt_22_EPA_medium[1] = {R_sqrt_22_EPA_medium_tap};
//Rayleigh1_orth_eff_ch_TM4
void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS_TDL, channel_desc_t *chan_desc ) {
int nb_rx=chan_desc-> nb_rx;
int nb_tx=chan_desc-> nb_tx;
int tdl_pathsby3 = tdl_paths/3;
if ((tdl_paths%3)>0)
tdl_pathsby3++;
chan_desc->nb_taps = tdl_paths;
chan_desc->Td = tdl_delays[tdl_paths-1]*DS_TDL;
printf("last path (%d) at %f * %e = %e\n",tdl_paths-1,tdl_delays[tdl_paths-1],DS_TDL,chan_desc->Td);
chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td +
1 +
2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td));
printf("TDL : %f Ms/s, nb_taps %d, Td %e, channel_length %d\n",chan_desc->sampling_rate,tdl_paths,chan_desc->Td,chan_desc->channel_length);
double sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
for (int i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*tdl_amps_dB[i]);
sum_amps += chan_desc->amps[i];
}
for (int i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] /= sum_amps;
tdl_delays[i] *= DS_TDL;
}
chan_desc->delays = tdl_delays;
chan_desc->aoa = 0;
chan_desc->random_aoa = 0;
chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *));
chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *));
chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *));
for (int i = 0; i<nb_tx*nb_rx; i++)
chan_desc->ch[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex));
for (int i = 0; i<nb_tx*nb_rx; i++)
chan_desc->chF[i] = (struct complex *) malloc(1200 * sizeof(struct complex));
for (int i = 0; i<chan_desc->nb_taps; i++)
chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex));
chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **));
if (nb_tx==2 && nb_rx==2) {
for (int i = 0; i<(tdl_pathsby3); i++)
chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0];
} else if (nb_tx==2 && nb_rx==1) {
for (int i = 0; i<(tdl_pathsby3); i++)
chan_desc->R_sqrt[i] = (struct complex *) &R21_sqrt[i][0];
} else if (nb_tx==1 && nb_rx==2) {
for (int i = 0; i<(tdl_pathsby3); i++)
chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0];
} else {
for (int i = 0; i<(tdl_pathsby3); i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
for (int j = 0; j<nb_tx*nb_rx*nb_tx*nb_rx; j+=(nb_tx*nb_rx+1)) {
chan_desc->R_sqrt[i][j].x = 1.0;
chan_desc->R_sqrt[i][j].y = 0.0;
}
LOG_W(OCM,"correlation matrix not implemented for nb_tx==%d and nb_rx==%d, using identity\n", nb_tx, nb_rx);
}
}
}
channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
uint8_t nb_rx,
SCM_t channel_model,
double sampling_rate,
double channel_bandwidth,
double DS_TDL,
double DS_TDL,
double forgetting_factor,
int32_t channel_offset,
double path_loss_dB,
float noise_power_dB) {
float noise_power_dB) {
channel_desc_t *chan_desc = (channel_desc_t *)calloc(1,sizeof(channel_desc_t));
for(int i=0; i<max_chan;i++) {
if (defined_channels[i] == NULL) {
defined_channels[i]=chan_desc;
chan_desc->chan_idx=i;
break;
}
else {
AssertFatal(i<(max_chan-1),
"No more channel descriptors available, increase channelmod.max_chan parameter above %u\n",max_chan);
}
for(int i=0; i<max_chan; i++) {
if (defined_channels[i] == NULL) {
defined_channels[i]=chan_desc;
chan_desc->chan_idx=i;
break;
} else {
AssertFatal(i<(max_chan-1),
"No more channel descriptors available, increase channelmod.max_chan parameter above %u\n",max_chan);
}
}
uint16_t i,j;
double sum_amps;
double aoa,ricean_factor,Td,maxDoppler;
int channel_length,nb_taps;
chan_desc->modelid = channel_model;
chan_desc->nb_tx = nb_tx;
......@@ -531,9 +611,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
chan_desc->first_run = 1;
chan_desc->ip = 0.0;
chan_desc->noise_power_dB = noise_power_dB;
LOG_I(OCM,"Channel Model (inside of new_channel_desc_scm)=%d\n\n", channel_model);
int tdl_paths=0;
double *tdl_amps_dB;
double *tdl_delays;
......@@ -556,7 +634,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td));
sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]);
sum_amps += chan_desc->amps[i];
......@@ -594,10 +673,11 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
for (i = 0; i<6; i++)
chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0];
} else {
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ;
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ;
for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
for (j = 0; j<nb_tx*nb_rx*nb_tx*nb_rx; j+=(nb_tx*nb_rx+1)) {
chan_desc->R_sqrt[i][j].x = 1.0;
chan_desc->R_sqrt[i][j].y = 0.0;
......@@ -617,6 +697,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]);
sum_amps += chan_desc->amps[i];
......@@ -654,7 +735,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
for (i = 0; i<6; i++)
chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0];
} else {
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ;
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ;
for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
......@@ -668,95 +750,41 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
}
break;
/* tapped delay line (TDL) channel model from TR 38.901 Section 7.7.2 */
/* tapped delay line (TDL) channel model from TR 38.901 Section 7.7.2 */
#define tdl_m(MoDel)\
DevAssert(sizeof(tdl_ ## MoDel ## _amps_dB) == sizeof(tdl_ ## MoDel ## _delays)); \
tdl_paths=sizeof(tdl_ ## MoDel ## _amps_dB)/sizeof(*tdl_ ## MoDel ## _amps_dB);\
tdl_delays=tdl_ ## MoDel ## _delays;\
tdl_amps_dB=tdl_ ## MoDel ## _amps_dB
DevAssert(sizeof(tdl_ ## MoDel ## _amps_dB) == sizeof(tdl_ ## MoDel ## _delays)); \
tdl_paths=sizeof(tdl_ ## MoDel ## _amps_dB)/sizeof(*tdl_ ## MoDel ## _amps_dB);\
tdl_delays=tdl_ ## MoDel ## _delays;\
tdl_amps_dB=tdl_ ## MoDel ## _amps_dB
case TDL_A:
case TDL_B:
case TDL_C:
case TDL_D:
case TDL_E:
chan_desc->ricean_factor = 1;
if (channel_model == TDL_A) {
tdl_m(a);
}else if (channel_model == TDL_B) {
tdl_m(b);
}
else if (channel_model == TDL_C) {
tdl_m(c);
} else if (channel_model == TDL_D) {
tdl_m(d);
chan_desc->ricean_factor = TDL_D_RICEAN_FACTOR;
} else if (channel_model == TDL_E) {
tdl_m(e);
chan_desc->ricean_factor = TDL_E_RICEAN_FACTOR;
}
int tdl_pathsby3 = tdl_paths/3;
if ((tdl_paths%3)>0) tdl_pathsby3++;
chan_desc->nb_taps = tdl_paths;
chan_desc->Td = tdl_delays[tdl_paths-1]*DS_TDL;
printf("last path (%d) at %f * %e = %e\n",tdl_paths-1,tdl_delays[tdl_paths-1],DS_TDL,chan_desc->Td);
chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td));
printf("TDL : %f Ms/s, nb_taps %d, Td %e, channel_length %d\n",chan_desc->sampling_rate,tdl_paths,chan_desc->Td,chan_desc->channel_length);
sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*tdl_amps_dB[i]);
sum_amps += chan_desc->amps[i];
}
for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] /= sum_amps;
tdl_delays[i] *= DS_TDL;
}
chan_desc->delays = tdl_delays;
chan_desc->aoa = 0;
chan_desc->random_aoa = 0;
chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *));
chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *));
chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *));
for (i = 0; i<nb_tx*nb_rx; i++)
chan_desc->ch[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex));
for (i = 0; i<nb_tx*nb_rx; i++)
chan_desc->chF[i] = (struct complex *) malloc(1200 * sizeof(struct complex));
for (i = 0; i<chan_desc->nb_taps; i++)
chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex));
chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **));
tdl_m(a);
tdlModel(tdl_paths, tdl_delays, tdl_amps_dB, DS_TDL, chan_desc);
break;
if (nb_tx==2 && nb_rx==2) {
for (i = 0; i<(tdl_pathsby3); i++)
chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0];
} else if (nb_tx==2 && nb_rx==1) {
for (i = 0; i<(tdl_pathsby3); i++)
chan_desc->R_sqrt[i] = (struct complex *) &R21_sqrt[i][0];
} else if (nb_tx==1 && nb_rx==2) {
for (i = 0; i<(tdl_pathsby3); i++)
chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0];
} else {
for (i = 0; i<(tdl_pathsby3); i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
case TDL_B:
chan_desc->ricean_factor = 1;
tdl_m(b);
tdlModel(tdl_paths, tdl_delays, tdl_amps_dB, DS_TDL, chan_desc);
break;
for (j = 0; j<nb_tx*nb_rx*nb_tx*nb_rx; j+=(nb_tx*nb_rx+1)) {
chan_desc->R_sqrt[i][j].x = 1.0;
chan_desc->R_sqrt[i][j].y = 0.0;
}
case TDL_C:
chan_desc->ricean_factor = 1;
tdl_m(c);
tdlModel(tdl_paths, tdl_delays, tdl_amps_dB, DS_TDL, chan_desc);
break;
LOG_W(OCM,"correlation matrix not implemented for nb_tx==%d and nb_rx==%d, using identity\n", nb_tx, nb_rx);
}
}
case TDL_D:
chan_desc->ricean_factor = TDL_D_RICEAN_FACTOR;
tdl_m(d);
tdlModel(tdl_paths, tdl_delays, tdl_amps_dB, DS_TDL, chan_desc);
break;
case TDL_E:
chan_desc->ricean_factor = TDL_E_RICEAN_FACTOR;
tdl_m(e);
tdlModel(tdl_paths, tdl_delays, tdl_amps_dB, DS_TDL, chan_desc);
break;
case EPA:
......@@ -766,6 +794,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]);
sum_amps += chan_desc->amps[i];
......@@ -784,7 +813,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
for (i = 0; i<nb_tx*nb_rx; i++)
chan_desc->ch[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex));
for (i = 0; i<nb_tx*nb_rx; i++)
chan_desc->chF[i] = (struct complex *) malloc(1200 * sizeof(struct complex));
......@@ -799,6 +828,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
} else {
chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ;
for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
......@@ -820,6 +850,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]);
sum_amps += chan_desc->amps[i];
......@@ -865,7 +896,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n");
}
}*/
break;
break;
case EPA_high:
chan_desc->nb_taps = 7;
......@@ -874,6 +905,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]);
sum_amps += chan_desc->amps[i];
......@@ -927,7 +959,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td));
sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]);
sum_amps += chan_desc->amps[i];
......@@ -982,6 +1015,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*eva_amps_dB[i]);
sum_amps += chan_desc->amps[i];
......@@ -1015,7 +1049,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
} else {
chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ;
for (i = 0; i<6; i++) {
for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
for (j = 0; j<nb_tx*nb_rx*nb_tx*nb_rx; j+=(nb_tx*nb_rx+1)) {
......@@ -1036,6 +1071,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*etu_amps_dB[i]);
sum_amps += chan_desc->amps[i];
......@@ -1069,6 +1105,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
} else {
chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ;
for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
......@@ -1090,6 +1127,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*mbsfn_amps_dB[i]);
sum_amps += chan_desc->amps[i];
......@@ -1117,6 +1155,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex *));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6;
for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
......@@ -1628,13 +1667,14 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
return(chan_desc);
} /* channel_desc_t *new_channel_desc_scm */
channel_desc_t * find_channel_desc_fromname( char *modelname ) {
for(int i=0; i<max_chan;i++) {
if (defined_channels[i] != NULL) {
if (strcmp(defined_channels[i]->model_name,modelname) == 0)
return defined_channels[i];
}
}
channel_desc_t *find_channel_desc_fromname( char *modelname ) {
for(int i=0; i<max_chan; i++) {
if (defined_channels[i] != NULL) {
if (strcmp(defined_channels[i]->model_name,modelname) == 0)
return defined_channels[i];
}
}
LOG_E(OCM,"Model %s not found \n", modelname);
return NULL;
} /* channel_desc_t * new_channel_desc_fromconfig */
......@@ -1643,41 +1683,48 @@ channel_desc_t * find_channel_desc_fromname( char *modelname ) {
void free_channel_desc_scm(channel_desc_t *ch) {
// Must be made cleanly, a lot of leaks...
defined_channels[ch->chan_idx]=NULL;
defined_channels[ch->chan_idx]=NULL;
if(ch->free_flags&CHANMODEL_FREE_AMPS)
free(ch->amps);
for (int i = 0; i<ch->nb_tx*ch->nb_rx; i++) {
for (int i = 0; i<ch->nb_tx*ch->nb_rx; i++) {
free(ch->ch[i]);
free(ch->chF[i]);
}
for (int i = 0; i<ch->nb_taps; i++) {
free(ch->a[i]);
}
free(ch->a[i]);
}
if(ch->free_flags&CHANMODEL_FREE_DELAY)
free(ch->delays);
free(ch->delays);
if(ch->free_flags&CHANMODEL_FREE_RSQRT_6)
for (int i = 0; i<6; i++)
free(ch->R_sqrt[i]);
for (int i = 0; i<6; i++)
free(ch->R_sqrt[i]);
if(ch->free_flags&CHANMODEL_FREE_RSQRT_NTAPS)
for (int i = 0; i<ch->nb_taps;i++)
free(ch->R_sqrt[i]);
free(ch->R_sqrt);
free(ch->ch);
for (int i = 0; i<ch->nb_taps; i++)
free(ch->R_sqrt[i]);
free(ch->R_sqrt);
free(ch->ch);
free(ch->chF);
free(ch->a);
free(ch->model_name);
free(ch);
free(ch);
}
void set_channeldesc_owner(channel_desc_t *cdesc, uint32_t module_id) {
cdesc->module_id=module_id;
cdesc->module_id=module_id;
}
void set_channeldesc_name(channel_desc_t *cdesc,char *modelname) {
if(cdesc->model_name != NULL)
free(cdesc->model_name);
cdesc->model_name=strdup(modelname);
if(cdesc->model_name != NULL)
free(cdesc->model_name);
cdesc->model_name=strdup(modelname);
}
int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) {
......@@ -1798,14 +1845,14 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) {
desc->ch[aarx+(aatx*desc->nb_rx)][k].x += s*desc->a[l][aarx+(aatx*desc->nb_rx)].x;
desc->ch[aarx+(aatx*desc->nb_rx)][k].y += s*desc->a[l][aarx+(aatx*desc->nb_rx)].y;
// printf("l %d : desc->ch.x %f, s %e, delay %f\n",l,desc->a[l][aarx+(aatx*desc->nb_rx)].x,s,desc->delays[l]);
// printf("l %d : desc->ch.x %f, s %e, delay %f\n",l,desc->a[l][aarx+(aatx*desc->nb_rx)].x,s,desc->delays[l]);
} //nb_taps
#ifdef DEBUG_CH
printf("(%d,%d,%d)->(%e,%e)\n",k,aarx,aatx,desc->ch[aarx+(aatx*desc->nb_rx)][k].x,desc->ch[aarx+(aatx*desc->nb_rx)][k].y);
#endif
} //channel_length
}
}
} //aatx
} //aarx
......@@ -1817,7 +1864,7 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) {
return (0);
}
double N_RB2sampling_rate(uint16_t N_RB) {
double sampling_rate;
......@@ -1869,127 +1916,141 @@ double N_RB2channel_bandwidth(uint16_t N_RB) {
LOG_E(OCM,"Unknown N_PRB\n");
return(-1);
}
return(channel_bandwidth);
}
}
static int channelmod_print_help(char *buff, int debug, telnet_printfunc_t prnt ) {
prnt("channelmod commands can be used to display or modify channel models parameters\n");
prnt("channelmod show predef: display predefined model algorithms available in oai\n");
prnt("channelmod show current: display the currently used models in the running executable\n");
prnt("channelmod modify <model index> <param name> <param value>: set the specified parameters in a current model to the given value\n");
prnt(" <model index> specifies the model, the show current model command can be used to list the current models indexes\n");
prnt(" <param name> can be one of \"riceanf\", \"aoa\", \"randaoa\", \"ploss\", \"noise_power_dB\", \"offset\", \"forgetf\"\n");
return CMDSTATUS_FOUND;
prnt("channelmod commands can be used to display or modify channel models parameters\n");
prnt("channelmod show predef: display predefined model algorithms available in oai\n");
prnt("channelmod show current: display the currently used models in the running executable\n");
prnt("channelmod modify <model index> <param name> <param value>: set the specified parameters in a current model to the given value\n");
prnt(" <model index> specifies the model, the show current model command can be used to list the current models indexes\n");
prnt(" <param name> can be one of \"riceanf\", \"aoa\", \"randaoa\", \"ploss\", \"noise_power_dB\", \"offset\", \"forgetf\"\n");
return CMDSTATUS_FOUND;
}
static void display_channelmodel(channel_desc_t *cd,int debug, telnet_printfunc_t prnt) {
char *module_id_str[]=MODULEID_STR_INIT;
prnt("model owner: %s\n",(cd->module_id != 0)?module_id_str[cd->module_id]:"not set");
prnt("nb_tx: %i nb_rx: %i taps: %i bandwidth: %lf sampling: %lf\n",cd->nb_tx, cd->nb_rx, cd->nb_taps, cd->channel_bandwidth, cd->sampling_rate);
prnt("channel length: %i Max path delay: %lf ricean fact.: %lf angle of arrival: %lf (randomized:%s)\n",
cd->channel_length, cd->Td, cd->ricean_factor, cd->aoa, (cd->random_aoa?"Yes":"No"));
prnt("max Doppler: %lf path loss: %lf noise: %lf rchannel offset: %i forget factor; %lf\n",
cd->max_Doppler, cd->path_loss_dB, cd->noise_power_dB, cd->channel_offset, cd->forgetting_factor);
prnt("Initial phase: %lf nb_path: %i \n",
cd->ip, cd->nb_paths);
for (int i=0; i<cd->nb_taps ; i++) {
prnt("taps: %i lin. ampli. : %lf delay: %lf \n",i,cd->amps[i], cd->delays[i]);
}
char *module_id_str[]=MODULEID_STR_INIT;
prnt("model owner: %s\n",(cd->module_id != 0)?module_id_str[cd->module_id]:"not set");
prnt("nb_tx: %i nb_rx: %i taps: %i bandwidth: %lf sampling: %lf\n",cd->nb_tx, cd->nb_rx, cd->nb_taps, cd->channel_bandwidth, cd->sampling_rate);
prnt("channel length: %i Max path delay: %lf ricean fact.: %lf angle of arrival: %lf (randomized:%s)\n",
cd->channel_length, cd->Td, cd->ricean_factor, cd->aoa, (cd->random_aoa?"Yes":"No"));
prnt("max Doppler: %lf path loss: %lf noise: %lf rchannel offset: %i forget factor; %lf\n",
cd->max_Doppler, cd->path_loss_dB, cd->noise_power_dB, cd->channel_offset, cd->forgetting_factor);
prnt("Initial phase: %lf nb_path: %i \n",
cd->ip, cd->nb_paths);
for (int i=0; i<cd->nb_taps ; i++) {
prnt("taps: %i lin. ampli. : %lf delay: %lf \n",i,cd->amps[i], cd->delays[i]);
}
}
static int channelmod_show_cmd(char *buff, int debug, telnet_printfunc_t prnt) {
char *subcmd=NULL;
char *subcmd=NULL;
int s = sscanf(buff,"%ms\n",&subcmd);
if (s>0) {
if ( strcmp(subcmd,"predef") == 0) {
for (int i=0; channelmod_names[i].name != NULL ; i++) {
prnt(" %i %s\n", i, map_int_to_str(channelmod_names,i ));
}
}
} else if ( strcmp(subcmd,"current") == 0) {
for (int i=0; i < max_chan ; i++) {
if (defined_channels[i] != NULL) {
prnt("model %i %s type %s: \n----------------\n", i, (defined_channels[i]->model_name !=NULL)?defined_channels[i]->model_name:"(no name set)",
map_int_to_str(channelmod_names,defined_channels[i]->modelid));
display_channelmodel(defined_channels[i],debug,prnt);
if (defined_channels[i] != NULL) {
prnt("model %i %s type %s: \n----------------\n", i, (defined_channels[i]->model_name !=NULL)?defined_channels[i]->model_name:"(no name set)",
map_int_to_str(channelmod_names,defined_channels[i]->modelid));
display_channelmodel(defined_channels[i],debug,prnt);
}
}
} else {
channelmod_print_help(buff, debug, prnt);
channelmod_print_help(buff, debug, prnt);
}
free(subcmd);
free(subcmd);
}
return CMDSTATUS_FOUND;
}
static int channelmod_modify_cmd(char *buff, int debug, telnet_printfunc_t prnt) {
char *param=NULL, *value=NULL;
char *param=NULL, *value=NULL;
int cd_id= -1;
int s = sscanf(buff,"%i %ms %ms \n",&cd_id,&param, &value);
if (cd_id<0 || cd_id >= max_chan) {
prnt("ERROR, %i: Channel model id outof range (0-%i)\n",cd_id,max_chan-1);
return CMDSTATUS_FOUND;
prnt("ERROR, %i: Channel model id outof range (0-%i)\n",cd_id,max_chan-1);
return CMDSTATUS_FOUND;
}
if (defined_channels[cd_id]==NULL) {
prnt("ERROR, %i: Channel model has not been set\n",cd_id);
return CMDSTATUS_FOUND;
}
prnt("ERROR, %i: Channel model has not been set\n",cd_id);
return CMDSTATUS_FOUND;
}
if (s==3) {
if ( strcmp(param,"riceanf") == 0) {
double dbl = atof(value);
if (dbl <0 || dbl > 1)
prnt("ERROR: ricean factor range: 0 to 1, %lf is outof range\n",dbl);
else
defined_channels[cd_id]->ricean_factor=dbl;
double dbl = atof(value);
if (dbl <0 || dbl > 1)
prnt("ERROR: ricean factor range: 0 to 1, %lf is outof range\n",dbl);
else
defined_channels[cd_id]->ricean_factor=dbl;
} else if ( strcmp(param,"aoa") == 0) {
double dbl = atof(value);
if (dbl <0 || dbl >6.28)
prnt("ERROR: angle of arrival range: 0 to 2*Pi, %lf is outof range\n",dbl);
else
defined_channels[cd_id]->aoa=dbl;
double dbl = atof(value);
if (dbl <0 || dbl >6.28)
prnt("ERROR: angle of arrival range: 0 to 2*Pi, %lf is outof range\n",dbl);
else
defined_channels[cd_id]->aoa=dbl;
} else if ( strcmp(param,"randaoa") == 0) {
int i = atoi(value);
if (i!=0 && i!=1)
prnt("ERROR: randaoa is a boolean, must be 0 or 1\n");
else
defined_channels[cd_id]->random_aoa=i;
int i = atoi(value);
if (i!=0 && i!=1)
prnt("ERROR: randaoa is a boolean, must be 0 or 1\n");
else
defined_channels[cd_id]->random_aoa=i;
} else if ( strcmp(param,"ploss") == 0) {
double dbl = atof(value);
defined_channels[cd_id]->path_loss_dB=dbl;
double dbl = atof(value);
defined_channels[cd_id]->path_loss_dB=dbl;
} else if ( strcmp(param,"noise_power_dB") == 0) {
double dbl = atof(value);
defined_channels[cd_id]->noise_power_dB=dbl;
} else if ( strcmp(param,"offset") == 0) {
int i = atoi(value);
defined_channels[cd_id]->channel_offset=i;
int i = atoi(value);
defined_channels[cd_id]->channel_offset=i;
} else if ( strcmp(param,"forgetf") == 0) {
double dbl = atof(value);
if (dbl <0 || dbl > 1)
prnt("ERROR: forgetting factor range: 0 to 1 (disable variation), %lf is outof range\n",dbl);
else
defined_channels[cd_id]->forgetting_factor=dbl;
double dbl = atof(value);
if (dbl <0 || dbl > 1)
prnt("ERROR: forgetting factor range: 0 to 1 (disable variation), %lf is outof range\n",dbl);
else
defined_channels[cd_id]->forgetting_factor=dbl;
} else {
prnt("ERROR: %s, unknown channel parameter\n",param);
return CMDSTATUS_FOUND;
prnt("ERROR: %s, unknown channel parameter\n",param);
return CMDSTATUS_FOUND;
}
display_channelmodel(defined_channels[cd_id],debug,prnt);
free(param);
free(value);
random_channel(defined_channels[cd_id],false);
display_channelmodel(defined_channels[cd_id],debug,prnt);
free(param);
free(value);
random_channel(defined_channels[cd_id],false);
}
return CMDSTATUS_FOUND;
return CMDSTATUS_FOUND;
}
int modelid_fromstrtype(char *modeltype) {
int modelid=map_str_to_int(channelmod_names,modeltype);
if (modelid < 0)
int modelid_fromstrtype(char *modeltype) {
int modelid=map_str_to_int(channelmod_names,modeltype);
if (modelid < 0)
LOG_E(OCM,"random_channel.c: Error channel model %s unknown\n",modeltype);
return modelid;
}
......@@ -2003,13 +2064,11 @@ double channelmod_get_sinr_dB(void) {
void init_channelmod(void) {
paramdef_t channelmod_params[] = CHANNELMOD_PARAMS_DESC;
int numparams=sizeof(channelmod_params)/sizeof(paramdef_t);
int ret = config_get( channelmod_params,numparams,CHANNELMOD_SECTION);
AssertFatal(ret >= 0, "configuration couldn't be performed");
defined_channels=calloc(max_chan,sizeof( channel_desc_t*));
defined_channels=calloc(max_chan,sizeof( channel_desc_t *));
AssertFatal(defined_channels!=NULL, "couldn't allocate %u channel descriptors\n",max_chan);
/* look for telnet server, if it is loaded, add the channel modeling commands to it */
add_telnetcmd_func_t addcmd = (add_telnetcmd_func_t)get_shlibmodule_fptr("telnetsrv", TELNET_ADDCMD_FNAME);
......@@ -2024,37 +2083,40 @@ int load_channellist(uint8_t nb_tx, uint8_t nb_rx, double sampling_rate, double
paramlist_def_t channel_list;
memset(&channel_list,0,sizeof(paramlist_def_t));
memcpy(channel_list.listname,modellist_name,sizeof(channel_list.listname)-1);
int numparams = sizeof(achannel_params)/sizeof(paramdef_t);
config_getlist( &channel_list,achannel_params,numparams, CHANNELMOD_SECTION);
AssertFatal(channel_list.numelt>0, "List %s.%s not found in config file\n",CHANNELMOD_SECTION,channel_list.listname);
int pindex_NAME = config_paramidx_fromname(achannel_params,numparams, CHANNELMOD_MODEL_NAME_PNAME);
int pindex_NAME = config_paramidx_fromname(achannel_params,numparams, CHANNELMOD_MODEL_NAME_PNAME);
int pindex_DT = config_paramidx_fromname(achannel_params,numparams, CHANNELMOD_MODEL_DT_PNAME );
int pindex_FF = config_paramidx_fromname(achannel_params,numparams, CHANNELMOD_MODEL_FF_PNAME );
int pindex_CO = config_paramidx_fromname(achannel_params,numparams, CHANNELMOD_MODEL_CO_PNAME );
int pindex_PL = config_paramidx_fromname(achannel_params,numparams, CHANNELMOD_MODEL_PL_PNAME );
int pindex_NP = config_paramidx_fromname(achannel_params,numparams, CHANNELMOD_MODEL_NP_PNAME );
int pindex_TYPE = config_paramidx_fromname(achannel_params,numparams, CHANNELMOD_MODEL_TYPE_PNAME);
for (int i=0; i<channel_list.numelt; i++) {
for (int i=0; i<channel_list.numelt; i++) {
int modid = modelid_fromstrtype( *(channel_list.paramarray[i][pindex_TYPE].strptr) );
if (modid <0) {
LOG_E(OCM,"Valid channel model types:\n");
for (int m=0; channelmod_names[i].name != NULL ; m++) {
printf(" %s ", map_int_to_str(channelmod_names,m ));
LOG_E(OCM,"Valid channel model types:\n");
for (int m=0; channelmod_names[i].name != NULL ; m++) {
printf(" %s ", map_int_to_str(channelmod_names,m ));
}
AssertFatal(0, "\n Choose a valid model type\n");
}
channel_desc_t *channeldesc_p = new_channel_desc_scm(nb_tx,nb_rx,modid,sampling_rate,channel_bandwidth,
*(channel_list.paramarray[i][pindex_DT].dblptr), *(channel_list.paramarray[i][pindex_FF].dblptr),
*(channel_list.paramarray[i][pindex_CO].iptr), *(channel_list.paramarray[i][pindex_PL].dblptr),
*(channel_list.paramarray[i][pindex_NP].dblptr) );
AssertFatal( (channeldesc_p!= NULL), "Could not allocate channel %s type %s \n",*(channel_list.paramarray[i][pindex_NAME].strptr), *(channel_list.paramarray[i][pindex_TYPE].strptr));
channeldesc_p->model_name = strdup(*(channel_list.paramarray[i][pindex_NAME].strptr));
LOG_I(OCM,"Model %s type %s allocated from config file, list %s\n",*(channel_list.paramarray[i][pindex_NAME].strptr),
*(channel_list.paramarray[i][pindex_TYPE].strptr), modellist_name);
*(channel_list.paramarray[i][pindex_DT].dblptr), *(channel_list.paramarray[i][pindex_FF].dblptr),
*(channel_list.paramarray[i][pindex_CO].iptr), *(channel_list.paramarray[i][pindex_PL].dblptr),
*(channel_list.paramarray[i][pindex_NP].dblptr) );
AssertFatal( (channeldesc_p!= NULL), "Could not allocate channel %s type %s \n",*(channel_list.paramarray[i][pindex_NAME].strptr), *(channel_list.paramarray[i][pindex_TYPE].strptr));
channeldesc_p->model_name = strdup(*(channel_list.paramarray[i][pindex_NAME].strptr));
LOG_I(OCM,"Model %s type %s allocated from config file, list %s\n",*(channel_list.paramarray[i][pindex_NAME].strptr),
*(channel_list.paramarray[i][pindex_TYPE].strptr), modellist_name);
} /* for loop on channel_list */
return channel_list.numelt;
} /* load_channelist */
......
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