enhance channel model configuration
This commit is contained in:
@@ -61,7 +61,9 @@ static telnetshell_vardef_t channelmod_vardef[] = {
|
||||
static double snr_dB=25;
|
||||
static double sinr_dB=0;
|
||||
static unsigned int max_chan;
|
||||
static channel_desc_t** defined_channels;
|
||||
static channel_desc_t **defined_channels;
|
||||
static char modellist_name[MAX_OPTNAME_SIZE]="";
|
||||
|
||||
void fill_channel_desc(channel_desc_t *chan_desc,
|
||||
uint8_t nb_tx,
|
||||
uint8_t nb_rx,
|
||||
@@ -494,16 +496,17 @@ struct complex *R_sqrt_22_EPA_medium[1] = {R_sqrt_22_EPA_medium_tap};
|
||||
|
||||
//Rayleigh1_orth_eff_ch_TM4
|
||||
|
||||
|
||||
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) {
|
||||
@@ -540,6 +543,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
|
||||
double *tdl_amps_dB;
|
||||
double *tdl_delays;
|
||||
|
||||
/* Spatial Channel Models (SCM) channel model from TR 38.901 Section 7.7.2 */
|
||||
switch (channel_model) {
|
||||
case SCM_A:
|
||||
LOG_W(OCM,"channel model not yet supported\n");
|
||||
@@ -670,6 +674,7 @@ 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 */
|
||||
case TDL_A:
|
||||
case TDL_B:
|
||||
case TDL_C:
|
||||
@@ -1631,8 +1636,21 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
|
||||
|
||||
chan_desc->nb_paths = 10;
|
||||
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];
|
||||
}
|
||||
}
|
||||
LOG_E(OCM,"Model %s not found \n", modelname);
|
||||
return NULL;
|
||||
} /* channel_desc_t * new_channel_desc_fromconfig */
|
||||
|
||||
|
||||
|
||||
void free_channel_desc_scm(channel_desc_t *ch) {
|
||||
// Must be made cleanly, a lot of leaks...
|
||||
defined_channels[ch->chan_idx]=NULL;
|
||||
@@ -1657,7 +1675,8 @@ void free_channel_desc_scm(channel_desc_t *ch) {
|
||||
free(ch->R_sqrt);
|
||||
free(ch->ch);
|
||||
free(ch->chF);
|
||||
free(ch->a);
|
||||
free(ch->a);
|
||||
free(ch->model_name);
|
||||
free(ch);
|
||||
}
|
||||
|
||||
@@ -1665,6 +1684,12 @@ void set_channeldesc_owner(channel_desc_t *cdesc, uint32_t 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);
|
||||
}
|
||||
|
||||
int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) {
|
||||
double s;
|
||||
int i,k,l,aarx,aatx;
|
||||
@@ -1851,7 +1876,7 @@ double N_RB2channel_bandwidth(uint16_t N_RB) {
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_E(PHY,"Unknown N_PRB\n");
|
||||
LOG_E(OCM,"Unknown N_PRB\n");
|
||||
return(-1);
|
||||
}
|
||||
return(channel_bandwidth);
|
||||
@@ -1871,9 +1896,7 @@ static int channelmod_print_help(char *buff, int debug, telnet_printfunc_t prnt
|
||||
|
||||
static void display_channelmodel(channel_desc_t *cd,int debug, telnet_printfunc_t prnt) {
|
||||
char *module_id_str[]=MODULEID_STR_INIT;
|
||||
if (cd->module_id != 0) {
|
||||
prnt("model owner: %s\n",module_id_str[cd->module_id]);
|
||||
}
|
||||
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"));
|
||||
@@ -1899,7 +1922,8 @@ static int channelmod_show_cmd(char *buff, int debug, telnet_printfunc_t prnt) {
|
||||
} else if ( strcmp(subcmd,"current") == 0) {
|
||||
for (int i=0; i < max_chan ; i++) {
|
||||
if (defined_channels[i] != NULL) {
|
||||
prnt("model %i %s: \n----------------\n", i, map_int_to_str(channelmod_names,defined_channels[i]->modelid));
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1972,10 +1996,10 @@ static int channelmod_modify_cmd(char *buff, int debug, telnet_printfunc_t prnt)
|
||||
return CMDSTATUS_FOUND;
|
||||
}
|
||||
|
||||
int modelid_fromname(char *modelname) {
|
||||
int modelid=map_str_to_int(channelmod_names,modelname);
|
||||
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",modelname);
|
||||
LOG_E(OCM,"random_channel.c: Error channel model %s unknown\n",modeltype);
|
||||
return modelid;
|
||||
}
|
||||
|
||||
@@ -1989,18 +2013,59 @@ double channelmod_get_sinr_dB(void) {
|
||||
|
||||
void init_channelmod(void) {
|
||||
paramdef_t channelmod_params[] = CHANNELMOD_PARAMS_DESC;
|
||||
int ret = config_get( channelmod_params,sizeof(channelmod_params)/sizeof(paramdef_t),CHANNELMOD_SECTION);
|
||||
|
||||
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*));
|
||||
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);
|
||||
|
||||
if (addcmd != NULL) {
|
||||
addcmd("channelmod",channelmod_vardef,channelmod_cmdarray);
|
||||
}
|
||||
}
|
||||
} /* init_channelmod */
|
||||
|
||||
int load_channellist(uint8_t nb_tx, uint8_t nb_rx, double sampling_rate, double channel_bandwidth) {
|
||||
paramdef_t achannel_params[] = CHANNELMOD_MODEL_PARAMS_DESC;
|
||||
paramlist_def_t channel_list;
|
||||
memset(&channel_list,0,sizeof(paramlist_def_t));
|
||||
strncpy(channel_list.listname,modellist_name,MAX_OPTNAME_SIZE-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_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++) {
|
||||
|
||||
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 ));
|
||||
}
|
||||
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);
|
||||
} /* for loop on channel_list */
|
||||
return channel_list.numelt;
|
||||
} /* load_channelist */
|
||||
|
||||
#ifdef RANDOM_CHANNEL_MAIN
|
||||
#define sampling_rate 5.0
|
||||
|
||||
@@ -107,8 +107,10 @@ typedef struct {
|
||||
unsigned int chan_idx;
|
||||
/// id of the channel modeling algorithm
|
||||
int modelid;
|
||||
/// identifies channel descriptor owner (the module which created this descriptor)
|
||||
/// identifies channel descriptor owner (the module which created this descriptor
|
||||
channelmod_moduleid_t module_id;
|
||||
/// name of this descriptor,used for model created from config file at init time
|
||||
char *model_name;
|
||||
/// flags to properly trigger memory free
|
||||
unsigned int free_flags;
|
||||
} channel_desc_t;
|
||||
@@ -242,12 +244,37 @@ typedef enum {
|
||||
|
||||
#define CONFIG_HLP_SNR "Set average SNR in dB (for --siml1 option)\n"
|
||||
#define CHANNELMOD_SECTION "channelmod"
|
||||
|
||||
/* global channel modelization parameters */
|
||||
#define CHANNELMOD_MODELLIST_PARANAME "modellist"
|
||||
|
||||
#define CHANNELMOD_HELP_MODELLIST "<list name> channel list name in config file describing the model type and its parameters\n"
|
||||
#define CHANNELMOD_PARAMS_DESC { \
|
||||
{"s" , CONFIG_HLP_SNR, PARAMFLAG_CMDLINE_NOPREFIXENABLED, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0},\
|
||||
{"sinr_dB", NULL, 0 , dblptr:&sinr_dB, defdblval:0 , TYPE_DOUBLE, 0},\
|
||||
{"max_chan, CONFIG_HLP_MAX_CHAN", 0, uptr:&max_chan, defintval:10, TYPE_UINT, 0},\
|
||||
{"s" , CONFIG_HLP_SNR, PARAMFLAG_CMDLINE_NOPREFIXENABLED, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0},\
|
||||
{"sinr_dB", NULL, 0, dblptr:&sinr_dB, defdblval:0 , TYPE_DOUBLE, 0},\
|
||||
{"max_chan", "Max number of runtime models", 0, uptr:&max_chan, defintval:10, TYPE_UINT, 0},\
|
||||
{CHANNELMOD_MODELLIST_PARANAME, CHANNELMOD_HELP_MODELLIST, 0, strptr:(char **)&modellist_name, defstrval:"DefaultChannelList", TYPE_STRING, 60 },\
|
||||
}
|
||||
|
||||
/* parameters for one model */
|
||||
#define CHANNELMOD_MODEL_NAME_PNAME "model_name"
|
||||
#define CHANNELMOD_MODEL_TYPE_PNAME "type"
|
||||
#define CHANNELMOD_MODEL_PL_PNAME "ploss_dB"
|
||||
#define CHANNELMOD_MODEL_NP_PNAME "noise_power_dB"
|
||||
#define CHANNELMOD_MODEL_FF_PNAME "forgetfact"
|
||||
#define CHANNELMOD_MODEL_CO_PNAME "offset"
|
||||
#define CHANNELMOD_MODEL_DT_PNAME "ds_tdl"
|
||||
|
||||
#define CHANNELMOD_MODEL_PARAMS_DESC { \
|
||||
{CHANNELMOD_MODEL_NAME_PNAME, "name of the model\n", 0, strptr:NULL , defstrval:"", TYPE_STRING, 0 },\
|
||||
{CHANNELMOD_MODEL_TYPE_PNAME, "name of the model type\n", 0, strptr:NULL , defstrval:"AWGN", TYPE_STRING, 0 },\
|
||||
{CHANNELMOD_MODEL_PL_PNAME, "channel path loss in dB\n", 0, dblptr:NULL, defdblval:0, TYPE_DOUBLE, 0 },\
|
||||
{CHANNELMOD_MODEL_NP_PNAME, "channel noise in dB\n", 0, dblptr:NULL, defdblval:0, TYPE_DOUBLE, 0 },\
|
||||
{CHANNELMOD_MODEL_FF_PNAME, "channel forget factor ((0 to 1)\n", 0, dblptr:NULL, defdblval:0, TYPE_DOUBLE, 0 },\
|
||||
{CHANNELMOD_MODEL_CO_PNAME, "channel offset in samps\n", 0, iptr:NULL, defintval:0, TYPE_INT, 0 },\
|
||||
{CHANNELMOD_MODEL_DT_PNAME, "delay spread for TDL models\n", 0, dblptr:NULL, defdblval:0, TYPE_DOUBLE, 0 }\
|
||||
}
|
||||
|
||||
#include "platform_constants.h"
|
||||
|
||||
typedef struct {
|
||||
@@ -276,13 +303,17 @@ typedef struct {
|
||||
channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
|
||||
uint8_t nb_rx,
|
||||
SCM_t channel_model,
|
||||
double sampling_rate,
|
||||
double sampling_rate,
|
||||
double channel_bandwidth,
|
||||
double TDL_DS,
|
||||
double TDL_DS,
|
||||
double forgetting_factor,
|
||||
int32_t channel_offset,
|
||||
double path_loss_dB,
|
||||
float noise_power_dB);
|
||||
float noise_power_dB);
|
||||
|
||||
channel_desc_t *find_channel_desc_fromname( char *modelname );
|
||||
|
||||
|
||||
/**
|
||||
\brief free memory allocated for a model descriptor
|
||||
\param ch points to the model, which cannot be used after calling this fuction
|
||||
@@ -295,6 +326,12 @@ void free_channel_desc_scm(channel_desc_t *ch);
|
||||
\param module_id identifies the channel model. should be define as a macro in simu.h
|
||||
*/
|
||||
void set_channeldesc_owner(channel_desc_t *cdesc, channelmod_moduleid_t module_id);
|
||||
/**
|
||||
\brief This function set a model name to a model descriptor, can be later used to identify a allocated channel model
|
||||
\param cdesc points to the model descriptor
|
||||
\param module_name is the C string to use as model name for the channel pointed by cdesc
|
||||
*/
|
||||
void set_channeldesc_name(channel_desc_t *cdesc,char *modelname);
|
||||
/** \fn void random_channel(channel_desc_t *desc)
|
||||
\brief This routine generates a random channel response (time domain) according to a tapped delay line model.
|
||||
\param desc Pointer to the channel descriptor
|
||||
@@ -454,11 +491,11 @@ void multipath_tv_channel(channel_desc_t *desc,
|
||||
/**@} */
|
||||
/**@} */
|
||||
|
||||
int modelid_fromname(char *modelname);
|
||||
int modelid_fromstrtype(char *modeltype);
|
||||
double channelmod_get_snr_dB(void);
|
||||
double channelmod_get_sinr_dB(void);
|
||||
void init_channelmod(void) ;
|
||||
|
||||
int load_channellist(uint8_t nb_tx, uint8_t nb_rx, double sampling_rate, double channel_bandwidth) ;
|
||||
double N_RB2sampling_rate(uint16_t N_RB);
|
||||
double N_RB2channel_bandwidth(uint16_t N_RB);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user