Commit 41cfeb6c authored by wangdong's avatar wangdong

Fix Some Bugs And New Features

parent f1230a28
No preview for this file type
...@@ -20,9 +20,15 @@ ...@@ -20,9 +20,15 @@
s2j_struct_get_basic_element(struct_subframe, json_obj, int, Mod_id); s2j_struct_get_basic_element(struct_subframe, json_obj, int, Mod_id);
s2j_struct_get_basic_element(struct_subframe, json_obj, int, frame); s2j_struct_get_basic_element(struct_subframe, json_obj, int, frame);
s2j_struct_get_basic_element(struct_subframe, json_obj, int, subframe); s2j_struct_get_basic_element(struct_subframe, json_obj, int, subframe);
s2j_struct_get_basic_element(struct_subframe, json_obj, int, nb_rb_max);
s2j_struct_get_basic_element(struct_subframe, json_obj, int, N_RBG);
s2j_struct_get_basic_element(struct_subframe, json_obj, int, RBGsize);
s2j_struct_get_basic_element(struct_subframe, json_obj, int, RBGlastsize);
s2j_struct_get_basic_element(struct_subframe, json_obj, int, dl_Bandwidth);
s2j_struct_get_array_element(struct_subframe, json_obj, int, rnti); s2j_struct_get_array_element(struct_subframe, json_obj, int, rnti);
s2j_struct_get_array_element(struct_subframe, json_obj, int, ammount); s2j_struct_get_array_element(struct_subframe, json_obj, int, ammount);
s2j_struct_get_array_element(struct_subframe, json_obj, int, allocate); s2j_struct_get_array_element(struct_subframe, json_obj, int, allocate);
s2j_struct_get_array_element(struct_subframe, json_obj, int, total_buffer);
/* return Student structure object pointer */ /* return Student structure object pointer */
...@@ -46,9 +52,15 @@ ...@@ -46,9 +52,15 @@
s2j_json_set_basic_element(json_subframe, struct_subframe, int, Mod_id); s2j_json_set_basic_element(json_subframe, struct_subframe, int, Mod_id);
s2j_json_set_basic_element(json_subframe, struct_subframe, int, frame); s2j_json_set_basic_element(json_subframe, struct_subframe, int, frame);
s2j_json_set_basic_element(json_subframe, struct_subframe, int, subframe); s2j_json_set_basic_element(json_subframe, struct_subframe, int, subframe);
s2j_json_set_basic_element(json_subframe, struct_subframe, int, nb_rb_max);
s2j_json_set_basic_element(json_subframe, struct_subframe, int, N_RBG);
s2j_json_set_basic_element(json_subframe, struct_subframe, int, RBGsize);
s2j_json_set_basic_element(json_subframe, struct_subframe, int, RBGlastsize);
s2j_json_set_basic_element(json_subframe, struct_subframe, int, dl_Bandwidth);
s2j_json_set_array_element(json_subframe, struct_subframe, int, rnti, 4); s2j_json_set_array_element(json_subframe, struct_subframe, int, rnti, 4);
s2j_json_set_array_element(json_subframe, struct_subframe, int, ammount, 4); s2j_json_set_array_element(json_subframe, struct_subframe, int, ammount, 4);
s2j_json_set_array_element(json_subframe, struct_subframe, int, allocate, 4); s2j_json_set_array_element(json_subframe, struct_subframe, int, allocate, 4);
s2j_json_set_array_element(json_subframe, struct_subframe, int, total_buffer, 4);
/* serialize data to Student.Hometown JSON object. */ /* serialize data to Student.Hometown JSON object. */
......
...@@ -18,9 +18,17 @@ typedef struct ...@@ -18,9 +18,17 @@ typedef struct
uint16_t Mod_id; uint16_t Mod_id;
uint32_t frame; uint32_t frame;
uint32_t subframe; uint32_t subframe;
uint16_t nb_rb_max;
uint16_t N_RBG;
uint16_t RBGsize;
uint16_t RBGlastsize;
uint16_t dl_Bandwidth;
uint16_t rnti[4]; uint16_t rnti[4];
//required
int ammount[4]; int ammount[4];
//Modified by py. A hook!
int allocate[4]; int allocate[4];
int total_buffer[4];
} Subframe; } Subframe;
cJSON *soctet_to_py(Subframe *info2send, int sockfd); cJSON *soctet_to_py(Subframe *info2send, int sockfd);
......
...@@ -100,9 +100,15 @@ int rr_dl_run(module_id_t Mod_id, ...@@ -100,9 +100,15 @@ int rr_dl_run(module_id_t Mod_id,
.Mod_id = Mod_id, .Mod_id = Mod_id,
.frame = frame, .frame = frame,
.subframe = subframe, .subframe = subframe,
.N_RBG = N_RBG,
.RBGsize = RBGsize,
.RBGlastsize = RBGlastsize,
.dl_Bandwidth = RC.mac[Mod_id]->common_channels[CC_id].mib->message.dl_Bandwidth,
.nb_rb_max = 0,
.rnti = {0, 0, 0, 0}, .rnti = {0, 0, 0, 0},
.ammount = {0,0,0,0}, .ammount = {0,0,0,0},
.allocate = {0,0,0,0}, .allocate = {0,0,0,0},
.total_buffer = {0,0,0,0},
}; };
int rbg = 0; int rbg = 0;
for (; !rbgalloc_mask[rbg]; rbg++) for (; !rbgalloc_mask[rbg]; rbg++)
...@@ -116,11 +122,13 @@ int rr_dl_run(module_id_t Mod_id, ...@@ -116,11 +122,13 @@ int rr_dl_run(module_id_t Mod_id,
int UE_id = *start_ue; int UE_id = *start_ue;
UE_list_t UE_sched; UE_list_t UE_sched;
int *cur_UE = &UE_sched.head; int *cur_UE = &UE_sched.head;
// Allocate retransmissions, and mark UEs with new transmissions
// Allocate retransmissions, and mark UEs with new transmissions,亦是是每帧执行
do { do {
// check whether there are HARQ retransmissions // check whether there are HARQ retransmissions
const COMMON_channels_t *cc = &RC.mac[Mod_id]->common_channels[CC_id]; const COMMON_channels_t *cc = &RC.mac[Mod_id]->common_channels[CC_id];
const uint8_t harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config, frame, subframe); const uint8_t harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config, frame, subframe);//fdd固定每8帧
UE_sched_ctrl_t *ue_ctrl = &UE_info->UE_sched_ctrl[UE_id]; UE_sched_ctrl_t *ue_ctrl = &UE_info->UE_sched_ctrl[UE_id];
const uint8_t round = ue_ctrl->round[CC_id][harq_pid]; const uint8_t round = ue_ctrl->round[CC_id][harq_pid];
if (round != 8) { // retransmission: allocate if (round != 8) { // retransmission: allocate
...@@ -129,7 +137,7 @@ int rr_dl_run(module_id_t Mod_id, ...@@ -129,7 +137,7 @@ int rr_dl_run(module_id_t Mod_id,
goto skip_ue; goto skip_ue;
int nb_rbg = (nb_rb + (nb_rb % RBGsize)) / RBGsize; int nb_rbg = (nb_rb + (nb_rb % RBGsize)) / RBGsize;
// needs more RBGs than we can allocate // needs more RBGs than we can allocate
if (nb_rbg > n_rbg_sched) { if (nb_rbg > n_rbg_sched) {//这一帧的家伙满足不了了
LOG_D(MAC, LOG_D(MAC,
"retransmission of UE %d needs more RBGs (%d) than we have (%d)\n", "retransmission of UE %d needs more RBGs (%d) than we have (%d)\n",
UE_id, nb_rbg, n_rbg_sched); UE_id, nb_rbg, n_rbg_sched);
...@@ -174,7 +182,8 @@ int rr_dl_run(module_id_t Mod_id, ...@@ -174,7 +182,8 @@ int rr_dl_run(module_id_t Mod_id,
return n_rbg_sched; return n_rbg_sched;
for (; !rbgalloc_mask[rbg]; rbg++) /* fast-forward */ ; for (; !rbgalloc_mask[rbg]; rbg++) /* fast-forward */ ;
} else { } else {
if (UE_info->UE_template[CC_id][UE_id].dl_buffer_total > 0) { if (UE_info->UE_template[CC_id][UE_id].dl_buffer_total > 0) {//获取该dl的buffer,如果没Buffer就后面跳过了!!!
subframe_t.total_buffer[UE_id]=UE_info->UE_template[CC_id][UE_id].dl_buffer_total;
*cur_UE = UE_id; *cur_UE = UE_id;
cur_UE = &UE_sched.next[UE_id]; cur_UE = &UE_sched.next[UE_id];
} }
...@@ -183,19 +192,15 @@ int rr_dl_run(module_id_t Mod_id, ...@@ -183,19 +192,15 @@ int rr_dl_run(module_id_t Mod_id,
skip_ue: skip_ue:
UE_id = next_ue_list_looped(UE_list, UE_id); UE_id = next_ue_list_looped(UE_list, UE_id);
} while (UE_id != *start_ue); } while (UE_id != *start_ue);
*cur_UE = -1; // mark end *cur_UE = -1; // mark end,巧妙的Hack!
if (UE_sched.head < 0) if (UE_sched.head < 0)
return n_rbg_sched; // no UE has a transmission return n_rbg_sched; // no UE has a transmission
// after allocating retransmissions: pre-allocate CCE, compute number of // after allocating retransmissions: pre-allocate CCE, compute number of
// requested RBGs // requested RBGs
// 计算每个调度帧内UE所需的RB // 计算每个调度帧内UE所需的RB
max_num_ue = min(max_num_ue, n_rbg_sched); max_num_ue = min(max_num_ue, n_rbg_sched);
int rb_required[MAX_MOBILES_PER_ENB]; // how much UEs request int rb_required[MAX_MOBILES_PER_ENB]; // how much UEs request
cur_UE = &UE_sched.head; cur_UE = &UE_sched.head;
LOG_I(MAC, "%d.%d debug: before compute [UE], \n",frame,subframe);
while (*cur_UE >= 0 && max_num_ue > 0) { while (*cur_UE >= 0 && max_num_ue > 0) {
const int UE_id = *cur_UE; const int UE_id = *cur_UE;
cur_UE = &UE_sched.next[UE_id]; // go to next cur_UE = &UE_sched.next[UE_id]; // go to next
...@@ -212,20 +217,47 @@ skip_ue: ...@@ -212,20 +217,47 @@ skip_ue:
UE_info->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = mcs; UE_info->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = mcs;
const uint32_t B = UE_info->UE_template[CC_id][UE_id].dl_buffer_total; const uint32_t B = UE_info->UE_template[CC_id][UE_id].dl_buffer_total;
rb_required[UE_id] = find_nb_rb_DL(mcs, B, n_rbg_sched * RBGsize, RBGsize); rb_required[UE_id] = find_nb_rb_DL(mcs, B, n_rbg_sched * RBGsize, RBGsize);
subframe_t.nb_rb_max = n_rbg_sched * RBGsize;
subframe_t.rnti[UE_id] = rnti; subframe_t.rnti[UE_id] = rnti;
subframe_t.ammount[UE_id] = rb_required[UE_id]; subframe_t.ammount[UE_id] = rb_required[UE_id];
LOG_I(MAC, "debug: compute for UE %d, \n", subframe_t.ammount[UE_id]);
max_num_ue--; max_num_ue--;
} }
//在这里篡改需要传送的rbs
cJSON *data_t = NULL;
// data = soctet_to_py(&subframe, RC.sockfd);sss
char *json_data = NULL;
char buf[MAXLINE];
int n = 0;
memset(buf, 0, MAXLINE);
cJSON *json_to_sent = struct_to_json(&subframe_t);
json_data = cJSON_Print(json_to_sent);
printf("[SOCKET]Brfore: %s\n", json_data);
n = strlen(json_data);
write(RC.sockfd, json_data, n);
read(RC.sockfd, buf, MAXLINE);
cJSON *res = cJSON_Parse(buf);
//printf("[SOCKET]After: %s\n", cJSON_Print(res));
//json_data = cJSON_Print(struct_to_json(&subframe));
//data = cJSON_Parse(json_data);
//printf("[SOCKET]Response 01: %s\n", cJSON_Print(data));
// PARTITIONING
// Reduces the available RBs according to slicing configuration
//
*cur_UE = -1; // not all UEs might be allocated, mark end *cur_UE = -1; // not all UEs might be allocated, mark end
/* for one UE after the next: allocate resources */ /* for one UE after the next: allocate resources */
LOG_I(MAC, "%d.%d debug: before allocated [UE], \n",frame,subframe);
cur_UE = &UE_sched.head; cur_UE = &UE_sched.head;
while (*cur_UE >= 0) { while (*cur_UE >= 0) {
const int UE_id = *cur_UE; const int UE_id = *cur_UE;
LOG_I(MAC, "%d.%d debug: allocate for [UE %d], \n",frame,subframe ,UE_id);
UE_sched_ctrl_t *ue_ctrl = &UE_info->UE_sched_ctrl[UE_id]; UE_sched_ctrl_t *ue_ctrl = &UE_info->UE_sched_ctrl[UE_id];
ue_ctrl->rballoc_sub_UE[CC_id][rbg] = 1;//该次轮询给 *** ue_ctrl->rballoc_sub_UE[CC_id][rbg] = 1;//该次轮询给 ***
rbgalloc_mask[rbg] = 0;//该RBG已分配 rbgalloc_mask[rbg] = 0;//该RBG已分配
...@@ -244,7 +276,6 @@ skip_ue: ...@@ -244,7 +276,6 @@ skip_ue:
break;//如果该次调度所有的rbg均被分配,则跳出资源分配 break;//如果该次调度所有的rbg均被分配,则跳出资源分配
for (rbg++; !rbgalloc_mask[rbg]; rbg++) /* fast-forward */ ; for (rbg++; !rbgalloc_mask[rbg]; rbg++) /* fast-forward */ ;
} }
LOG_I(MAC, "debug: end \n");
return n_rbg_sched; return n_rbg_sched;
//* 分配的结果:将结果都存储到了 ue_ctrl->rballoc_sub_UE[CC_id][rbg] 之中!!!,最后所有rbg都分配 //* 分配的结果:将结果都存储到了 ue_ctrl->rballoc_sub_UE[CC_id][rbg] 之中!!!,最后所有rbg都分配
...@@ -363,8 +394,6 @@ int pf_wbcqi_dl_run(module_id_t Mod_id, ...@@ -363,8 +394,6 @@ int pf_wbcqi_dl_run(module_id_t Mod_id,
const int mcs = cqi_to_mcs[UE_info->UE_sched_ctrl[UE_id].dl_cqi[CC_id]]; const int mcs = cqi_to_mcs[UE_info->UE_sched_ctrl[UE_id].dl_cqi[CC_id]];
const uint32_t tbs = get_TBS_DL(mcs, RBGsize); const uint32_t tbs = get_TBS_DL(mcs, RBGsize);
coeff_ue[UE_id] = (float) tbs / thr_ue[UE_id]; coeff_ue[UE_id] = (float) tbs / thr_ue[UE_id];
//LOG_I(MAC, " pf UE %d: old TBS %d thr %f MCS %d TBS %d coeff %f\n",
// UE_id, b, thr_ue[UE_id], mcs, tbs, coeff_ue[UE_id]);
*uep = UE_id; *uep = UE_id;
uep = &UE_sched.next[UE_id]; uep = &UE_sched.next[UE_id];
} }
...@@ -753,7 +782,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, ...@@ -753,7 +782,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id,
if (ue_sched_ctrl->pre_nb_available_rbs[CC_id] == 0) if (ue_sched_ctrl->pre_nb_available_rbs[CC_id] == 0)
continue; continue;
LOG_I(MAC, LOG_D(MAC,
"debug %4d.%d UE%d %d RBs allocated, pre MCS %d\n", "debug %4d.%d UE%d %d RBs allocated, pre MCS %d\n",
frameP, frameP,
subframeP, subframeP,
...@@ -768,7 +797,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, ...@@ -768,7 +797,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id,
continue; continue;
for (int j = 0; j < RBGsize; j++) { for (int j = 0; j < RBGsize; j++) {
if (vrb_map[RBGsize*i+j] != 0) { if (vrb_map[RBGsize*i+j] != 0) {
LOG_I(MAC, " %4d.%d DL scheduler allocation list: %s\n", frameP, subframeP, t); LOG_D(MAC, " %4d.%d DL scheduler allocation list: %s\n", frameP, subframeP, t);
LOG_E(MAC, " %4d.%d: UE %d allocated at locked RB %d/RBG %d\n", frameP, LOG_E(MAC, " %4d.%d: UE %d allocated at locked RB %d/RBG %d\n", frameP,
subframeP, UE_id, RBGsize * i + j, i); subframeP, UE_id, RBGsize * i + j, i);
} }
...@@ -778,7 +807,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, ...@@ -778,7 +807,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id,
} }
} }
if (print) if (print)
LOG_I(MAC, " %4d.%d DL scheduler allocation list: %s\n", frameP, subframeP, t); LOG_D(MAC, " %4d.%d DL scheduler allocation list: %s\n", frameP, subframeP, t);
//#endif //#endif
} }
......
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