Commit 3e0361dd authored by wangdong's avatar wangdong

ondemand

parent 39d367a7
......@@ -14,7 +14,7 @@ eNBs =
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 1;
plmn_list = ( { mcc = 208; mnc = 95; mnc_length = 2; } );
plmn_list = ( { mcc = 208; mnc = 92; mnc_length = 2; } );
tr_s_preference = "local_mac"
......@@ -174,7 +174,7 @@ eNBs =
////////// MME parameters:
mme_ip_address = ( { ipv4 = "192.168.1.36";
mme_ip_address = ( { ipv4 = "192.168.1.177";
ipv6 = "192:168:30::17";
active = "yes";
preference = "ipv4";
......@@ -242,7 +242,7 @@ THREAD_STRUCT = (
#three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT"
parallel_config = "PARALLEL_SINGLE_THREAD";
#two option for worker "WORKER_DISABLE" or "WORKER_ENABLE"
worker_config = "WORKER_ENABLE";
worker_config = "WORKER_DISABLE";
}
);
......
......@@ -17,7 +17,7 @@ eNBs =
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 1;
plmn_list = ( { mcc = 208; mnc = 95; mnc_length = 2; } );
plmn_list = ( { mcc = 208; mnc = 92; mnc_length = 2; } );
tr_s_preference = "local_mac"
......@@ -176,7 +176,7 @@ eNBs =
////////// MME parameters:
mme_ip_address = (
{
ipv4 = "192.168.1.36";
ipv4 = "192.168.1.177";
ipv6 = "192:168:30::17";
active = "yes";
preference = "ipv4";
......@@ -199,7 +199,7 @@ eNBs =
MACRLCs = ({
num_cc = 1;
local_s_if_name = "enp1s0";
remote_s_address = "192.168.1.214";
remote_s_address = "192.168.1.212";
local_s_address = "192.168.1.193";
local_s_portc = 50001;
remote_s_portc = 50000;
......
......@@ -1826,7 +1826,7 @@ set(L2_RRC_SRC
)
set(L2_LTE_SRC
${RLC_V2}
${RLC_V1}
)
set(L2_NR_SRC
......
......@@ -81,8 +81,8 @@ message flex_slice_scn19 {
optional uint32 posHigh = 4;
optional float tmax = 5;
optional float logdelta = 6;
optional uint32 tau = 7;
optional uint32 delay = 8;
optional float tau = 7;
optional float delay = 8;
optional string type = 9;
optional uint32 typeid = 10;
}
......
......@@ -878,6 +878,8 @@ typedef struct {
uint32_t dl_pdus_in_buffer[MAX_NUM_LCID];
/// creation time of the downlink buffer head for each LCID
uint32_t dl_buffer_head_sdu_creation_time[MAX_NUM_LCID];
/// creation time of the downlink buffer head for each LCID
uint32_t dl_buffer_head_sdu_creation_time_scn19[MAX_NUM_LCID];
/// maximum creation time of the downlink buffer head across all LCID
uint32_t dl_buffer_head_sdu_creation_time_max;
/// a flag indicating that the downlink head SDU is segmented
......
......@@ -884,13 +884,14 @@ store_dlsch_buffer(module_id_t Mod_id,
*/
if (UE_template->dl_buffer_info[lcid] > 0)
LOG_D(MAC,
"[eNB %d] Frame %d Subframe %d : RLC status for UE %d in LCID%d: total of %d pdus and size %d, head sdu queuing time %d, remaining size %d, is segmeneted %d \n",
"[eNB %d] Frame %d Subframe %d : RLC status for UE %d in LCID%d: total of %d pdus and size %d, head sdu queuing time %d, remaining size %d, is segmeneted %d total_buffer %d\n",
Mod_id, frameP,
subframeP, UE_id, lcid, UE_template->dl_pdus_in_buffer[lcid],
UE_template->dl_buffer_info[lcid],
UE_template->dl_buffer_head_sdu_creation_time[lcid],
UE_template->dl_buffer_head_sdu_remaining_size_to_send[lcid],
UE_template->dl_buffer_head_sdu_is_segmented[lcid]);
UE_template->dl_buffer_head_sdu_is_segmented[lcid],
UE_template->dl_buffer_total);
#endif
}
......@@ -908,10 +909,11 @@ store_dlsch_buffer(module_id_t Mod_id,
if (UE_template->dl_buffer_total > 0)
LOG_D(MAC,
"[eNB %d] Frame %d Subframe %d : RLC status for UE %d : total DL buffer size %d and total number of pdu %d \n",
"[eNB %d] Frame %d Subframe %d : RLC status for UE %d : total DL buffer size %d and total number of pdu %d ...%d\n",
Mod_id, frameP, subframeP, UE_id,
UE_template->dl_buffer_total,
UE_template->dl_pdus_total);
UE_template->dl_pdus_total,
UE_template->dl_buffer_head_sdu_creation_time[0]);
}
}
......
......@@ -96,6 +96,7 @@ RB_slice_alloc_save(1:num_frames*10, num_RBs) = 0;
for f=1:num_frames
printf("%.2f%%\r", f/num_frames*100);
fflush(stdout);
% current_time frame
for s=1:10
current_time = (s-1) + 10*(f-1);
......
......@@ -1125,7 +1125,23 @@ uint16_t get_slice_thrpt(module_id_t mod_id, UE_list_t *UE_list ){
return slice_thrpt;
}
/**
* Schedule R D parameters
*/
uint16_t get_slice_RATE(module_id_t mod_id, UE_list_t *UE_list,int CC_id ){
UE_info_t *UE_info = &(RC.mac[mod_id]->UE_info);
uint16_t slice_RATE=0;
for (int UE_id =UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) {
slice_RATE += flexran_get_tx_queue_size(mod_id,UE_id,3);
// printf("buffer_size %d\n",slice_RATE);
}
/* only calculate the DRBs */
return slice_RATE;
}
#define randomss(x) (rand()%x)
/**
* 返回数组最大值的下标(如果最大值有多个,则会随机输出)
......@@ -1169,6 +1185,58 @@ int arr_max(const float arr[],int n,int con)
}
void sortA1(float* a, int length,int* index){
int i, j, temp1;
float temp;
const float ESP= 10e-4;
for(i = 0; i < length; ++i){
for(j = i + 1; j < length; ++j){
if( a[j] -a[i] >ESP){ //如果后一个元素小于前一个元素则交换
temp = a[i];
a[i] = a[j];
a[j] = temp;
temp1 = index[i];
index[i] = index[j];
index[j] = temp1;
}
}
}
}
uint16_t get_slice_DELAY(module_id_t mod_id, UE_list_t *UE_list,int CC_id,frame_t frame,sub_frame_t subframe ){
UE_info_t *UE_info = &(RC.mac[mod_id]->UE_info);
uint16_t slice_DELAY=0;
for (int UE_id =UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) {
//LOG_I(MAC,"UE %d, HOL_delay %d\n",UE_id,flexran_get_hol_delay(mod_id,UE_id,3));
slice_DELAY = slice_DELAY<flexran_get_hol_delay(mod_id,UE_id,3)?flexran_get_hol_delay(mod_id,UE_id,3):slice_DELAY;
}
/* only calculate the DRBs */
return slice_DELAY;
}
void scn19_dl(module_id_t mod_id,
int CC_id,
frame_t frame,
......@@ -1218,7 +1286,7 @@ void scn19_dl(module_id_t mod_id,
float *aweight = (float *) malloc ( sizeof( float ) * s->num );
float *adweight = (float *) malloc ( sizeof( float ) * s->num );
int *index = (int *) malloc ( sizeof( int ) * s->num );
/** calculating the weight of ondemand and dynamic slices*/
/**
......@@ -1240,12 +1308,11 @@ void scn19_dl(module_id_t mod_id,
scn19_slice_param_t *p = s->s[i]->algo_data;
if(p->typeid==1) {
aweight[i]=0;
adweight[i]=0;
if (s->s[i]->UEs.head < 0)
continue;
uint8_t rbgalloc_slice_mask[N_RBG_MAX];
memset(rbgalloc_slice_mask, 0, sizeof(rbgalloc_slice_mask));
int n_rbg_sched = 0;
for (int rbg = p->posLow; rbg <= p->posHigh && rbg <= N_RBG; ++rbg) {
//LOG_I(FLEXRAN_AGENT, " slice id type %s posHigh %d posLow %d \n",p->type,s->s[i]->id,p->posHigh,p->posLow);
......@@ -1266,6 +1333,131 @@ void scn19_dl(module_id_t mod_id,
}
}
uint8_t srbgalloc_mask_ondemand[N_RBG_MAX];
uint8_t remain_mask_ondemand[N_RBG_MAX] ;//remains of static allocated
vrb_map = RC.mac[mod_id]->common_channels[CC_id].vrb_map;
memset(remain_mask_ondemand, 0, sizeof(remain_mask_ondemand));
for (int i = 0; i < N_RBG; i++) {
// calculate mask: init to one + "AND" with vrb_map:
// if any RB in vrb_map is blocked (1), the current RBG will be 0
srbgalloc_mask_ondemand[i] = 1;
for (int j = 0; j < RBGsize; j++)
srbgalloc_mask_ondemand[i] &= !vrb_map[RBGsize * i + j];
if(static_rbgalloc_slice_mask[i]==0){
remain_mask_ondemand[i]=srbgalloc_mask_ondemand[i];
}
}
// for(int i=0;i<N_RBG_MAX;i++){
// if(remain_mask_ondemand[i]==1){
// ondemand_n_rbg_sched+=remain_mask_ondemand[i];
// }
// }
// B. Based on the SLA of On-Demand slices, first allocate the dedicated requested resources
boolean_t ondemand_ues = false;
for (int i = 0; i < s->num; ++i) {
if (s->s[i]->UEs.head < 0)
continue;
scn19_slice_param_t *p = s->s[i]->algo_data;
if(p->typeid==3) {
ondemand_ues = true;
uint16_t inst = 0;
uint16_t RATE = get_slice_RATE(mod_id,&s->s[i]->UEs,CC_id);
uint16_t DELAY = get_slice_DELAY(mod_id,&s->s[i]->UEs,CC_id, frame,subframe)==0?1:get_slice_DELAY(mod_id,&s->s[i]->UEs,CC_id, frame,subframe);
if(p->rbs > 0){
inst = get_slice_thrpt(mod_id,&s->s[i]->UEs)/8000;
}
p->fexp=(1-BETA)*p->fexp+BETA*inst;
p->weight=RATE/ p->fexp;
p->dweight=p->logdelta/p->tau*DELAY*p->weight;
p->texp=(1 -1/p->tau)*p->texp+1/p->tau*p->rbs/RB_NUMS;
float tmax=p->tau*p->tmax+(1-p->tau)*p->texp;
if(p->weight>tmax){
p->weight=tmax;
}
printf("p->weight %d \n",p->weight);
aweight[i]=0;
adweight[i]=p->dweight;
p->rbs = 0;
}
}
int ri =0;
for(int i=0;i<s->num;i++){
index[i]=i;
}
int ondemand_buffer[RB_NUMS]={0};
sortA1(adweight,s->num,index);
// for(int i=0;i<s->num;i++){
// printf("%f<-%d ",adweight[i],index[i]);
// if(i==s->num-1){
// printf("\n");
// }
// }
for(int i=0;i<s->num;i++){
int ondemand_n_rbg_sched=0;
if (s->s[i]->UEs.head < 0)
continue;
scn19_slice_param_t *p = s->s[index[i]]->algo_data;
if(p->typeid!=3)
continue;
if(adweight[i]-0<=0.0001){
continue;
}
int slen = (int)(p->weight*RB_NUMS+0.5);
printf("Slen %d\n",slen);
for(int i=0;i<N_RBG;i++){
printf("_%d_",remain_mask_ondemand[i]);
if(i==N_RBG-1){
printf("\n");
}
}
while(slen>0&&ri < N_RBG){
if(remain_mask_ondemand[ri]==1){
ondemand_buffer[ri]=1;
remain_mask_ondemand[ri]==0;
slen -=1;
ondemand_n_rbg_sched+=1;
}
ri++;
}
if(ondemand_n_rbg_sched>0){
p->weight=0;
p->rbs=ondemand_n_rbg_sched*RBGsize;
s->s[index[i]]->dl_algo.run(mod_id,
CC_id,
frame,
subframe,
&s->s[index[i]]->UEs,
max_num_ue, // max_num_ue
ondemand_n_rbg_sched,
ondemand_buffer,
s->s[index[i]]->dl_algo.data);
}
}
uint8_t srbgalloc_mask[N_RBG_MAX];
uint8_t remain_mask[N_RBG_MAX] ;//remains of static allocated
vrb_map = RC.mac[mod_id]->common_channels[CC_id].vrb_map;
......@@ -1278,10 +1470,10 @@ void scn19_dl(module_id_t mod_id,
for (int j = 0; j < RBGsize; j++)
srbgalloc_mask[i] &= !vrb_map[RBGsize * i + j];
if(static_rbgalloc_slice_mask[i]==0){
remain_mask[i]=srbgalloc_mask[i];
remain_mask[i]=srbgalloc_mask[i]-ondemand_buffer[i];
}
}
for(int i=0;i<N_RBG_MAX;i++){
for(int i=0;i<N_RBG_MAX;i++){
if(remain_mask[i]==1){
dynamic_n_rbg_sched+=remain_mask[i];
}
......@@ -1293,12 +1485,13 @@ void scn19_dl(module_id_t mod_id,
boolean_t dynamic_ues = false;
// B. Based on the SLA of dynamic slices, first allocate the dedicated requested resources
// C. Based on the SLA of dynamic slices, first allocate the dedicated requested resources
for (int i = 0; i < s->num; ++i) {
if (s->s[i]->UEs.head < 0)
continue;
scn19_slice_param_t *p = s->s[i]->algo_data;
if(p->typeid==2) {
adweight[i]=0;
dynamic_ues = true;
uint16_t inst = get_slice_thrpt(mod_id,&s->s[i]->UEs)/8000;
if(p->rbs > 0){
......@@ -1331,11 +1524,11 @@ void scn19_dl(module_id_t mod_id,
max_index = arr_max(aweight,s->num, subframe);
scn19_slice_param_t *p = s->s[max_index]->algo_data;
LOG_I(FLEXRAN_AGENT, " ---%.2f ---%.2f ---%.2f ---%.2f \n",aweight[0],aweight[1],aweight[2],aweight[3]);
//LOG_I(FLEXRAN_AGENT, " ---%.2f ---%.2f ---%.2f ---%.2f \n",aweight[0],aweight[1],aweight[2],aweight[3]);
if(p->typeid == 2 && dynamic_ues){
LOG_I(FLEXRAN_AGENT, "1254 %d static_n_rbg_sched %d dynamic_n_rbg_sched %.2f weight of slice %d \n",static_n_rbg_sched,dynamic_n_rbg_sched,aweight[max_index],max_index);
//LOG_I(FLEXRAN_AGENT, "1254 %d static_n_rbg_sched %d dynamic_n_rbg_sched %.2f weight of slice %d \n",static_n_rbg_sched,dynamic_n_rbg_sched,aweight[max_index],max_index);
//LOG_I(FLEXRAN_AGENT, "1257 %d static_n_rbg_sched %d dynamic_n_rbg_sched \n",static_n_rbg_sched,dynamic_n_rbg_sched);
// LOG_I(FLEXRAN_AGENT, " %d static_n_rbg_sched %d dynamic_n_rbg_sched \n",static_n_rbg_sched,dynamic_n_rbg_sched);
......
......@@ -63,7 +63,7 @@ int slicing_get_UE_slice_idx(slice_info_t *si, int UE_id);
#define STATIC_SLICING 10
#define SCN19_SLICING 11
/* only four static slices for UL, DL resp. (not enough DCIs) */
#define MAX_STATIC_SLICES 4
#define MAX_STATIC_SLICES 10
#define MAX_DYNAMIC_SLICES 10
#define RB_NUMS 25
#define BETA 0.1
......
......@@ -480,8 +480,8 @@ rlc_am_mac_status_indication (
* which calls this function. But the init was not finished yet
* and we have a crash below when testing mem_block != NULL.
*/
if (rlc->input_sdus == NULL) return status_resp;
if (rlc->last_absolute_subframe_status_indication != (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP))) {
rlc_am_check_timer_poll_retransmit(ctxt_pP, rlc);
rlc_am_check_timer_reordering(ctxt_pP, rlc);
......@@ -516,6 +516,8 @@ rlc_am_mac_status_indication (
status_resp.buffer_occupancy_in_pdus = rlc->nb_sdu;
diff_time = ctxt_pP->frame - ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->data))->sdu_creation_time;
status_resp.head_sdu_creation_time = (diff_time > 0 ) ? (uint32_t) diff_time : (uint32_t)(0xffffffff - diff_time + ctxt_pP->frame) ;
//LOG_I(RLC,"[eNB AM status_resp.head_sdu_creation_time ] %d \n",status_resp.head_sdu_creation_time);
sdu_size = ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->data))->sdu_size;
sdu_remaining_size = ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->data))->sdu_remaining_size;
status_resp.head_sdu_remaining_size_to_send = sdu_remaining_size;
......
......@@ -154,7 +154,7 @@ rlc_tm_mac_status_indication (
struct mac_status_ind tx_statusP)
{
struct mac_status_resp status_resp;
printf("TM aaaa");
status_resp.buffer_occupancy_in_bytes = ((rlc_tm_entity_t *) rlc_pP)->buffer_occupancy;
status_resp.buffer_occupancy_in_pdus = status_resp.buffer_occupancy_in_bytes / ((rlc_tm_entity_t *) rlc_pP)->rlc_pdu_size;
status_resp.rlc_info.rlc_protocol_state = ((rlc_tm_entity_t *) rlc_pP)->protocol_state;
......
......@@ -382,7 +382,7 @@ rlc_um_mac_status_indication (const protocol_ctxt_t *const ctxt_pP, void *rlc_pP
status_resp.head_sdu_remaining_size_to_send = 0;
status_resp.head_sdu_creation_time = 0;
status_resp.head_sdu_is_segmented = 0;
printf("UM sssaaasss\n");
if (rlc_pP) {
status_resp.rlc_info.rlc_protocol_state = rlc_p->protocol_state;
rlc_um_check_timer_dar_time_out(ctxt_pP, rlc_p);
......@@ -399,6 +399,8 @@ rlc_um_mac_status_indication (const protocol_ctxt_t *const ctxt_pP, void *rlc_pP
diff_time = ctxt_pP->frame - ((struct rlc_um_tx_sdu_management *)mb_p->data)->sdu_creation_time;
status_resp.head_sdu_creation_time = (diff_time > 0 ) ? (uint32_t) diff_time : (uint32_t)(0xffffffff - diff_time + ctxt_pP->frame) ;
//msg("rlc_p status for ctxt_pP->frame %d diff time %d resp %d\n", ctxt_pP->frame, diff_time,status_resp.head_sdu_creation_time) ;
LOG_I(RLC,"[eNB UM status_resp.head_sdu_creation_time ] %d \n",status_resp.head_sdu_creation_time);
sdu_size = ((struct rlc_um_tx_sdu_management *) mb_p->data)->sdu_size;
sdu_remaining_size = ((struct rlc_um_tx_sdu_management *) mb_p->data)->sdu_remaining_size;
status_resp.head_sdu_remaining_size_to_send = sdu_remaining_size;
......
......@@ -106,6 +106,7 @@ typedef struct {
rlc_buffer_occupancy_t bytes_in_buffer; /*!< \brief Bytes buffered in RLC protocol instance. */
rlc_buffer_occupancy_t pdus_in_buffer; /*!< \brief Number of PDUs buffered in RLC protocol instance (OBSOLETE). */
frame_t head_sdu_creation_time; /*!< \brief Head SDU creation time. */
frame_t head_sdu_creation_time_scn19; /*!< \brief Head SDU creation time. */
sdu_size_t head_sdu_remaining_size_to_send; /*!< \brief remaining size of sdu: could be the total size or the remaining size of already segmented sdu */
boolean_t head_sdu_is_segmented; /*!< \brief 0 if head SDU has not been segmented, 1 if already segmented */
} mac_rlc_status_resp_t;
......
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