예제 #1
0
void phy_scope_eNB(FD_lte_phy_scope_enb *form, 
                   PHY_VARS_eNB *phy_vars_enb,
                   int UE_id) {
    int eNB_id = 0;
    int i,arx,atx,ind,k;
    LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_enb->lte_frame_parms;
    int nsymb_ce = 12*frame_parms->N_RB_UL*frame_parms->symbols_per_tti;
    uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx;
    uint8_t nb_antennas_tx = 1; // frame_parms->nb_antennas_tx; // in LTE Rel. 8 and 9 only a single transmit antenna is assumed at the UE
    int16_t **rxsig_t;
    int16_t **chest_t;
    int16_t **chest_f;
    int16_t *pusch_llr;
    int16_t *pusch_comp;
    float Re,Im,ymax;
    float *llr, *bit;
    float I[nsymb_ce*2], Q[nsymb_ce*2];
    float rxsig_t_dB[nb_antennas_rx][FRAME_LENGTH_COMPLEX_SAMPLES];
    float chest_t_abs[nb_antennas_rx][frame_parms->ofdm_symbol_size];
    float *chest_f_abs;
    float time[FRAME_LENGTH_COMPLEX_SAMPLES];
    float freq[nsymb_ce*nb_antennas_rx*nb_antennas_tx];
    int frame = phy_vars_enb->proc[0].frame_tx;
    uint32_t total_dlsch_bitrate = phy_vars_enb->total_dlsch_bitrate;
    int coded_bits_per_codeword = 0;
    uint8_t harq_pid; // in TDD config 3 it is sf-2, i.e., can be 0,1,2
    int mcs = 0;
    // choose max MCS to compute coded_bits_per_codeword
    if (phy_vars_enb->ulsch_eNB[UE_id]!=NULL) {
        for (harq_pid=0;harq_pid<3;harq_pid++) {
            mcs = cmax(phy_vars_enb->ulsch_eNB[UE_id]->harq_processes[harq_pid]->mcs,mcs);
        }
    }

    coded_bits_per_codeword = frame_parms->N_RB_UL*12*get_Qm(mcs)*frame_parms->symbols_per_tti;

    chest_f_abs = (float*) calloc(nsymb_ce*nb_antennas_rx*nb_antennas_tx,sizeof(float));    
    llr = (float*) calloc(coded_bits_per_codeword,sizeof(float)); // init to zero
    bit = malloc(coded_bits_per_codeword*sizeof(float));
    
    rxsig_t = (int16_t**) phy_vars_enb->lte_eNB_common_vars.rxdata[eNB_id];
    chest_t = (int16_t**) phy_vars_enb->lte_eNB_pusch_vars[UE_id]->drs_ch_estimates_time[eNB_id];
    chest_f = (int16_t**) phy_vars_enb->lte_eNB_pusch_vars[UE_id]->drs_ch_estimates[eNB_id];
    pusch_llr = (int16_t*) phy_vars_enb->lte_eNB_pusch_vars[UE_id]->llr;
    pusch_comp = (int16_t*) phy_vars_enb->lte_eNB_pusch_vars[UE_id]->rxdataF_comp[eNB_id][0];
    
    // Received signal in time domain of receive antenna 0
    if (rxsig_t != NULL) { 
        if (rxsig_t[0] != NULL) { 
            for (i=0; i<FRAME_LENGTH_COMPLEX_SAMPLES; i++) {
                rxsig_t_dB[0][i] = 10*log10(1.0+(float) ((rxsig_t[0][2*i])*(rxsig_t[0][2*i])+(rxsig_t[0][2*i+1])*(rxsig_t[0][2*i+1])));
                time[i] = (float) i;
            }
            fl_set_xyplot_data(form->rxsig_t,time,rxsig_t_dB[0],FRAME_LENGTH_COMPLEX_SAMPLES,"","","");
        }
        
        for (arx=1;arx<nb_antennas_rx;arx++) {
            if (rxsig_t[arx] != NULL) { 
                for (i=0; i<FRAME_LENGTH_COMPLEX_SAMPLES; i++) {
                    rxsig_t_dB[arx][i] = 10*log10(1.0+(float) ((rxsig_t[arx][2*i])*(rxsig_t[arx][2*i])+(rxsig_t[arx][2*i+1])*(rxsig_t[arx][2*i+1])));
                }
                fl_add_xyplot_overlay(form->rxsig_t,arx,time,rxsig_t_dB[arx],FRAME_LENGTH_COMPLEX_SAMPLES,rx_antenna_colors[arx]);
            }
        }
    }
    
    // Channel Impulse Response (still repeated format)
    if (chest_t != NULL) {
        ymax = 0;
        if (chest_t[0] !=NULL) {
            for (i=0; i<(frame_parms->ofdm_symbol_size); i++) {
                chest_t_abs[0][i] = (float) (chest_t[0][4*i]*chest_t[0][4*i]+chest_t[0][4*i+1]*chest_t[0][4*i+1]);
                if (chest_t_abs[0][i] > ymax) 
                    ymax = chest_t_abs[0][i];
            }
            fl_set_xyplot_data(form->chest_t,time,chest_t_abs[0],(frame_parms->ofdm_symbol_size),"","","");
        }
        for (arx=1;arx<nb_antennas_rx;arx++) {
            if (chest_t[arx] !=NULL) {
                for (i=0; i<(frame_parms->ofdm_symbol_size>>3); i++) {
                    chest_t_abs[arx][i] = (float) (chest_t[arx][4*i]*chest_t[arx][4*i]+chest_t[arx][4*i+1]*chest_t[arx][4*i+1]);
                    if (chest_t_abs[arx][i] > ymax) 
                        ymax = chest_t_abs[arx][i];
                }
                fl_add_xyplot_overlay(form->chest_t,arx,time,chest_t_abs[arx],(frame_parms->ofdm_symbol_size>>3),rx_antenna_colors[arx]);
                fl_set_xyplot_overlay_type(form->chest_t,arx,FL_DASHED_XYPLOT);
            }
        }
        // Avoid flickering effect
        //        fl_get_xyplot_ybounds(form->chest_t,&ymin,&ymax);
        fl_set_xyplot_ybounds(form->chest_t,0,ymax);
    }
예제 #2
0
void plot_graphes_dl(int src, int dst, int ctime)  //eNB -->UE
{

int i, dst_idx=1, curve_id=1;
char loss_rate[100];
char curve_label[100];
char simu_time[100];
int x_key_position=27;
int y_key_position=75;

if (otg_forms_info->idx_dl[src][dst]==MAX_SAMPLES-1){

  fl_update_display(1); //the function flushes the X buffer so the drawing requests are on their way to the server


 
  if (otg_forms_info->is_data_plot_dl == -1) 
    otg_forms_info->is_data_plot_dl=dst;

  if (otg_forms_info->is_data_plot_dl == dst) {
    fl_set_xyplot_data (form_dl->owd, otg_forms_info->data_ctime_dl[src][dst],
    otg_forms_info->data_owd_dl[src][dst], otg_forms_info->idx_dl[src][dst], "", "time", "ms"); 
		sprintf(curve_label, "%d%s%d", src,"-->", dst);
    fl_set_xyplot_key(form_dl->owd, 0, curve_label);
		fl_set_xyplot_key_position(form_dl->owd, x_key_position,y_key_position,   FL_ALIGN_BOTTOM_LEFT);   
    fl_set_xyplot_data (form_dl->throughput, otg_forms_info->data_ctime_dl[src][dst],
    otg_forms_info->data_throughput_dl[src][dst], otg_forms_info->idx_dl[src][dst], "", "time", "kbit/s"); 
		sprintf(curve_label, "%d%s%d", src,"-->", dst);
    fl_set_xyplot_key(form_dl->throughput, 0, curve_label);
		fl_set_xyplot_key_position(form_dl->throughput, x_key_position,y_key_position,   FL_ALIGN_BOTTOM_LEFT);   
                otg_kpi_nb_loss_pkts();
		sprintf(loss_rate, "%s%d","NB Loss pkts DL=",otg_info->total_loss_dl);
		fl_set_object_label(form_dl->loss_ratio, loss_rate);

		sprintf(simu_time, "%s%d","Simulation Time(ms)=", ctime);
		fl_set_object_label(form_dl->simu_time, simu_time);

  } 
  else {
    fl_set_xyplot_data (form_dl->owd, otg_forms_info->data_ctime_dl[src][otg_forms_info->is_data_plot_dl],
    otg_forms_info->data_owd_dl[src][otg_forms_info->is_data_plot_dl], otg_forms_info->idx_dl[src][otg_forms_info->is_data_plot_dl], "", "time", "ms");  
		sprintf(curve_label, "%d%s%d", src,"-->", otg_forms_info->is_data_plot_dl);
    fl_set_xyplot_key(form_dl->owd, 0, curve_label);
		fl_set_xyplot_key_position(form_dl->owd, x_key_position,y_key_position,   FL_ALIGN_BOTTOM_LEFT);  
    fl_set_xyplot_data (form_dl->throughput, otg_forms_info->data_ctime_dl[src][otg_forms_info->is_data_plot_dl],
    otg_forms_info->data_throughput_dl[src][otg_forms_info->is_data_plot_dl], otg_forms_info->idx_dl[src][otg_forms_info->is_data_plot_dl], "", "time", "kB/s");
		sprintf(curve_label, "%d%s%d", src,"-->",otg_forms_info->is_data_plot_dl);
    fl_set_xyplot_key(form_dl->throughput, 0, curve_label);
		fl_set_xyplot_key_position(form_dl->throughput,x_key_position,y_key_position,   FL_ALIGN_BOTTOM_LEFT);  
  
                otg_kpi_nb_loss_pkts();
		sprintf(loss_rate, "%s%d","NB Loss pkts DL=",otg_info->total_loss_dl);
		fl_set_object_label(form_dl->loss_ratio, loss_rate);
		sprintf(simu_time, "%s%d","Simulation Time(ms)=", ctime);
		fl_set_object_label(form_dl->simu_time, simu_time);
  }

  for (dst_idx=1;dst_idx<=NB_UE_INST;dst_idx++){
    if (dst_idx!=otg_forms_info->is_data_plot_dl){
      fl_add_xyplot_overlay(form_dl->owd,curve_id++,
      otg_forms_info->data_ctime_dl[src][dst_idx],
      otg_forms_info->data_owd_dl[src][dst_idx],
      otg_forms_info->idx_dl[src][dst_idx],dst_idx+6);
			sprintf(curve_label, "%d%s%d", src,"-->", dst_idx);
    	fl_set_xyplot_key(form_dl->owd,  curve_id-1, curve_label);	
			fl_set_xyplot_key_position(form_dl->owd, x_key_position,y_key_position,   FL_ALIGN_BOTTOM_LEFT); 

      fl_add_xyplot_overlay(form_dl->throughput,curve_id++,
      otg_forms_info->data_ctime_dl[src][dst_idx],
      otg_forms_info->data_throughput_dl[src][dst_idx],
      otg_forms_info->idx_dl[src][dst_idx],dst_idx+6);
			sprintf(curve_label, "%d%s%d", src,"-->", dst_idx);
	    fl_set_xyplot_key(form_dl->throughput,  curve_id-1, curve_label);
			fl_set_xyplot_key_position(form_dl->throughput, x_key_position,y_key_position,   FL_ALIGN_BOTTOM_LEFT); 


    } 
  }

  for (i=0;i<otg_forms_info->idx_dl[src][dst];i++){
    otg_forms_info->data_ctime_dl[src][dst][otg_forms_info->idx_dl[src][dst]]=i;
    otg_forms_info->data_owd_dl[src][dst][i]= otg_forms_info->data_owd_dl[src][dst][i+1];
    otg_forms_info->data_throughput_dl[src][dst][i]= otg_forms_info->data_throughput_dl[src][dst][i+1];
  }
  otg_forms_info->idx_dl[src][dst]--;
}

   fl_check_forms();

}
예제 #3
0
파일: unit.c 프로젝트: a4a881d4/oai
void
do_forms (FD_phy_procedures_sim * form,
	  LTE_UE_DLSCH ** lte_ue_dlsch_vars, LTE_eNB_ULSCH ** lte_eNB_ulsch_vars, struct complex **ch, u32 ch_len)
{

  s32 j, s, i;
  float I[3600], Q[3600], I2[3600], Q2[3600], I3[300], Q3[300];

  j = 0;
  //  printf("rxdataF_comp %p, lte_ue_dlsch_vars[0] %p\n",lte_ue_dlsch_vars[0]->rxdataF_comp[0],lte_ue_dlsch_vars[0]);
  for (s = 4; s < 12; s++) {
    for (i = 0; i < 12 * 12; i++) {
      I[j] = (float) ((short *)
		      lte_ue_dlsch_vars[0]->rxdataF_comp[0])[(2 * 25 * 12 * s) + 2 * i];
      Q[j] = (float) ((short *)
		      lte_ue_dlsch_vars[0]->rxdataF_comp[0])[(2 * 25 * 12 * s) + 2 * i + 1];
      //      printf("%d (%d): %f,%f : %d,%d\n",j,(25*12*s)+i,I[j],Q[j],lte_ue_dlsch_vars[0]->rxdataF_comp[0][(2*25*12*s)+2*i],lte_ue_dlsch_vars[0]->rxdataF_comp[0][(2*25*12*s)+2*i+1]);
      j++;
    }
    if (s == 5)
      s = 6;
    else if (s == 8)
      s = 9;
  }
  if (j > 0)
    fl_set_xyplot_data (form->pdsch_constellation, I, Q, j, "", "", "");


  //fl_set_xyplot_xbounds(form->pdsch_constellation,-800,800);
  //fl_set_xyplot_ybounds(form->pdsch_constellation,-800,800);


  j = 0;
  //  printf("rxdataF_comp %p, lte_ue_dlsch_vars[0] %p\n",lte_ue_dlsch_vars[0]->rxdataF_comp[0],lte_ue_dlsch_vars[0]);
  for (s = 0; s < 12; s++) {
    for (i = 0; i < 6 * 12; i++) {
      I2[j] = (float) ((short *)
		       lte_eNB_ulsch_vars[0]->rxdataF_comp[0][0])[(2 * 25 * 12 * s) + 2 * i];
      Q2[j] = (float) ((short *)
		       lte_eNB_ulsch_vars[0]->rxdataF_comp[0][0])[(2 * 25 * 12 * s) + 2 * i + 1];
      //      printf("%d (%d): %f,%f : %d,%d\n",j,(25*12*s)+i,I[j],Q[j],lte_ue_dlsch_vars[0]->rxdataF_comp[0][(2*25*12*s)+2*i],lte_ue_dlsch_vars[0]->rxdataF_comp[0][(2*25*12*s)+2*i+1]);
      j++;
    }
    if (s == 1)
      s = 2;
    else if (s == 7)
      s = 8;
  }
  if (j > 0)
    fl_set_xyplot_data (form->pusch_constellation, I2, Q2, j, "", "", "");

  fl_set_xyplot_xbounds(form->pusch_constellation,-800,800);
  fl_set_xyplot_ybounds(form->pusch_constellation,-800,800);

  for (j = 0; j < ch_len; j++) {

    I3[j] = j;
    Q3[j] = 10 * log10 (ch[0][j].x * ch[0][j].x + ch[0][j].y * ch[0][j].y);
  }

  fl_set_xyplot_data (form->ch00, I3, Q3, ch_len, "", "", "");
  //fl_set_xyplot_ybounds(form->ch00,-20,20);
}
예제 #4
0
void PlotButtonCB(FL_OBJECT *p0, long p1) {
  FL_OBJECT *np = the_gui->NEntry;
  FL_OBJECT *sp = the_gui->ProgressSlider;
  FL_OBJECT *cp = the_gui->DistributionChoice;
  FL_OBJECT *xyp = the_gui->xyplot;
  RNG *rng = CreateRNG();
  int n = atoi(fl_get_input(np));
  double r;
  int i, j;
  int distrib[NB];
  float xv[NB];
  float yv[NB];
  int di;
  float dx;
  unsigned long xl;
  double sum, sumsq;
  static char *mstring = new char[80];
  static char *sdstring = new char[80];
  int ymax;
  double xmin, xmax;

  if (rng == NULL)
    return;

  for (i=0; i<NB; i++)
    distrib[i] = 0;
  sum = sumsq = 0.0;
  ymax = 0;
  
  if (n >= PROGRESS_THRESHOLD) {
    di = n/100;			// update slider every 'di' points
    fl_set_slider_value(sp,0.0);
    fl_show_object(sp);
  }
  else
    di = 0;			// n too small; don't draw slider

  xmin = atof(fl_get_input(the_gui->MinEntry));
  xmax = atof(fl_get_input(the_gui->MaxEntry));

  for (i=0; i<n; i++) {
    r = ++(*rng);		// get a sample from current distribution
    sum += r;
    sumsq += r*r;

    j = fl_get_choice(cp);
    if ((j == Binomial) || (j == Poisson))
      r *= 10.0;		// spread out integer values so we can see them
    
    if (j == CDF)		// 'dx' is a value added to each sample
      dx = 0.0005;		// the CDF demo RNG returns values that are exactly
    else			// on the divide between two bins, and roundoff
      dx = 0.0;			// errors lead to funny looking plots....

    j = floor((r+dx-xmin)*NB/(xmax-xmin));
    
    if ((j >= 0) && (j < NB)) {
      distrib[j] += 1;
      if (distrib[j] > ymax)
	ymax = distrib[j];
    }
    if (di && ((i%di)==0))
      fl_set_slider_value(sp,(double)i/(double)n);
  }

  fl_hide_object(sp);		// all done; put away the slider

  // Bins filled; transfer to x and y vectors and plot.  The xyplot
  // widget will scale x and y automatically.

  fl_delete_xyplot_text(xyp,mstring);
  fl_delete_xyplot_text(xyp,sdstring);

  for (i=0; i<NB; i++) {
    xv[i] = (float)i*(xmax-xmin)/NB + xmin;
    yv[i] = (float)distrib[i];
  }

  if (xmin == xmax)
    fl_set_xyplot_xbounds(xyp,xmin+1.0,xmax); 	// auto-scale if min>max
  else
    fl_set_xyplot_xbounds(xyp,xmin,xmax);
  fl_set_xyplot_data(xyp, xv, yv, NB, "", "", "");

  // compute, display sample mean and sample standard deviation

  double dn = double(n);
  double mean = sum/dn;
  double sd = sqrt(dn*((sumsq/dn)-mean*mean)/(dn-1));

  sprintf(mstring,"Sample Mean =  %f",mean);
  sprintf(sdstring,"Standard Dev = %f",sd);

  // The (x,y) coords of the string are defined in terms of scaled plot
  // units.  If the right edge of the x scale is at 100, put the text
  // at 80.  Put the top string near the top of the plot, and the bottom
  // string 10% lower.

  double y1 = double(ymax) - .05*(double(ymax));
  double y2 = double(ymax) - .10*(double(ymax));

  fl_add_xyplot_text(xyp,(xmax-xmin)*0.8+xmin,y1,mstring,FL_ALIGN_CENTER,FL_BLACK);
  fl_add_xyplot_text(xyp,(xmax-xmin)*0.8+xmin,y2,sdstring,FL_ALIGN_CENTER,FL_BLACK);
  
  delete rng;			// some RNGs allocate internal tables....
}