动态TDD
function [] = TDD_reconfig(TTI_index,Macro_eff_RE_per_subband_D, Macro_eff_RE_per_subband_S,...
TDD_reconfig_period,Macro_eff_RE_per_subband_U, total_Macro_num, total_Pico_num, enable_Macro_flag, ...
enable_dynamic_TDD, pico_group_index);
global total_Macro;
global total_Pico;
global total_UE;
global term_DL_throughput;
global term_UL_throughput;
DL_transported = 0;
UL_transported = 0;
% 1: DL; 0: Speical subframe; -1: UL
TDD_mode = [
1 0 -1 -1 -1 1 0 -1 -1 -1;
1 0 -1 -1 1 1 0 -1 -1 1;
1 0 -1 1 1 1 0 -1 1 1;
1 0 -1 -1 -1 1 1 1 1 1;
1 0 -1 -1 1 1 1 1 1 1;
1 0 -1 1 1 1 1 1 1 1;
1 0 -1 -1 -1 1 0 -1 -1 1];%7??10????....??????
DL_UL_ratio = [
(Macro_eff_RE_per_subband_D.*2+Macro_eff_RE_per_subband_S.*2)./(Macro_eff_RE_per_subband_U.*6);
(Macro_eff_RE_per_subband_D.*4+Macro_eff_RE_per_subband_S.*2)./(Macro_eff_RE_per_subband_U.*4);
(Macro_eff_RE_per_subband_D.*6+Macro_eff_RE_per_subband_S.*2)./(Macro_eff_RE_per_subband_U.*2);
(Macro_eff_RE_per_subband_D.*6+Macro_eff_RE_per_subband_S.*1)./(Macro_eff_RE_per_subband_U.*3);
(Macro_eff_RE_per_subband_D.*7+Macro_eff_RE_per_subband_S.*1)./(Macro_eff_RE_per_subband_U.*2);
(Macro_eff_RE_per_subband_D.*8+Macro_eff_RE_per_subband_S.*1)./(Macro_eff_RE_per_subband_U.*1);
(Macro_eff_RE_per_subband_D.*3+Macro_eff_RE_per_subband_S.*2)./(Macro_eff_RE_per_subband_U.*5)];%??????????
if enable_Macro_flag==1
for Macro_index=1:total_Macro_num
total_Macro.Macro(Macro_index).TDD_mode = TDD_mode(2,:);%Macro????????????
end
end
if total_Pico_num>0
%----------------fixed TDD ,algorithm 0---------------
if enable_dynamic_TDD==0
for Pico_index=1:total_Pico_num
total_Pico.Pico(Pico_index).TDD_mode = TDD_mode(2,:);
end
%----------------dynamic TDD ,algorithm 1 ,without pico grouping---------------
elseif enable_dynamic_TDD==1
for Pico_index=1:total_Pico_num
DL_traffic = 0;
buf_pkt_num = total_Pico.Pico(Pico_index).DL_buffer.pkt_num;%?????? ????????
if buf_pkt_num>0
for n=1:buf_pkt_num
finished_flag = total_Pico.Pico(Pico_index).DL_buffer.pkt_info(n).finished_flag;
buf_pkt_size = total_Pico.Pico(Pico_index).DL_buffer.pkt_info(n).buf_pkt_size;
if (finished_flag==1) && (buf_pkt_size>0)
error('wrong DL buffer packet size');
end
DL_traffic = DL_traffic + buf_pkt_size;
end
end
DL_HARQ_num = total_Pico.Pico(Pico_index).DL_HARQ_num;
if DL_HARQ_num>0
for n=1:DL_HARQ_num
HARQ_thr = total_Pico.Pico(Pico_index).DL_HARQ_info(n).HARQ_thr;
if HARQ_thr<1e-6
error('wrong DL HARQ packet size');
end
DL_traffic = DL_traffic + HARQ_thr;
end
end
UL_traffic = 0;
buf_pkt_num = total_Pico.Pico(Pico_index).UL_buffer.pkt_num;
if buf_pkt_num>0
for n=1:buf_pkt_num
finished_flag = total_Pico.Pico(Pico_index).UL_buffer.pkt_info(n).finished_flag;
buf_pkt_size = total_Pico.Pico(Pico_index).UL_buffer.pkt_info(n).buf_pkt_size;
if (finished_flag==1) && (buf_pkt_size>0)
error('wrong UL buffer packet size');
end
UL_traffic = UL_traffic + buf_pkt_size;
end
end
UL_HARQ_num = total_Pico.Pico(Pico_index).UL_HARQ_num;
if UL_HARQ_num>0
for n=1:UL_HARQ_num
HARQ_thr = total_Pico.Pico(Pico_index).UL_HARQ_info(n).HARQ_thr;
if HARQ_thr<1e-6
error('wrong UL HARQ packet size');
end
UL_traffic = UL_traffic + HARQ_thr;
end
end
if DL_traffic==0
TDD_mode_index = 1;
elseif UL_traffic==0
TDD_mode_index = 6;
else
traffic_DL_UL_ratio = DL_traffic./UL_traffic;
diff = abs(DL_UL_ratio - traffic_DL_UL_ratio);
[t1, TDD_mode_index] = min(diff);
end
total_Pico.Pico(Pico_index).TDD_mode = TDD_mode(TDD_mode_index, :);
end