Cce and Aggregation Level Function
Cce and Aggregation Level Function
#include<stdio.h>
#include<math.h>
int calc_cce(int, int, int);
int calc_agg_level(int,int);
void main(void) {
int cce_count,user,aggregationlevel;
int system_bw,pcfich,Ng;
printf("enter the maximum n o of users");
scanf("%d",&user);
printf("enter system bandwidth");
scanf("%d",&system_bw);
printf("enter pcfich value");
scanf("%d",&pcfich);
printf("enter the value NG coming from MIB");
scanf("%d",&Ng);
cce_count=calc_cce(system_bw,pcfich,Ng);
aggregationlevel=calc_agg_level(user,cce_count);
printf("the total number of cce avilable are %d for system bw %d ",
cce_count,system_bw);
printf("the aggregation level is %d for max users %d",
aggregationlevel,user);
}
int calc_agg_level(int user,int nb_cce)
{
int agg_level;
int new_nb_cce;
if(nb_cce<4)
return -1;
else
{
new_nb_cce=nb_cce-4; //removing 4 cce for SIB
agg_level=new_nb_cce/(2*user);
if(agg_level>8)
agg_level=8;
if(agg_level>4 && agg_level<8)
agg_level=4;
if(agg_level>2 && agg_level<4)
agg_level=2;
if(agg_level<1)
{
new_nb_cce=nb_cce+4;
agg_level=new_nb_cce/(2*user);
}
return agg_level;
}