?? throughput_schemeab.m
字號:
% Schemes A and B
% delay under Poisson Traffic
clear all
close all
G=4; %number of subchannels
M=2000; % total simulation slots
J=32; % number of users
simurange=20; % nuber of points of Traffic
BufSize = M;
num_trial=20; % number of Monto-Carlo experiments
throughput1=zeros(1,simurange); % scheme B
throughput2=zeros(1,simurange); % scheme A
for ss=1:num_trial
ss
% generate the traffic
[Traffic,WorkLoad] = gen_traffic(M, J, simurange);
for ii = 1:simurange
sm_traffic = G*Traffic(:,:,ii); % Generate new traffic
Loads = zeros(1,J);
flag=zeros(1,J);
time_table=zeros(J,(M+J)*G);
time_table1=zeros(J,(M+J)*G);
time_table2=zeros(J,(M+J)*G);
% positions of packets in time axix
pos_pack=zeros(J,(M+J)*G);
for nn=1:J
temp=find(Traffic(nn,:,ii)>=1);
for mm=1:G
pos_pack(nn,mm:G:G*(length(temp)-1)+mm)=temp;
end
end
count_pack1=0;
count_pack2=0;
flag_CTE=0;
Relay =1;
for t1 = 1:M
newLoads = sm_traffic(:,t1)'; % new traffic
Loads = Loads + newLoads; % new traffic added to buffer
flag_CTE=max(0,flag_CTE-1);
if flag_CTE==0
Trans=Loads>0;
num_active=sum(Trans);
active = find(Trans)';
if num_active>0
flag_CTE=num_active;
% calculate the successful packets using ML
% equalizer
%[succ Raysucc]=allian(t1,HH,HA,active1,subch,ch,G,Relay,ML);
% From extensive simulations, we have found the ML equalizer is
% very robust even under low to moderate SNR and high collision
% orders, i.e., it can successfully recover packets
% without errors
% in the following , for convenience, we assume the use of the ML
% to greatly save the simulation time
succ1 = num_active*G;
succ2 = num_active*G;
count_pack1=count_pack1+num_active*G;
count_pack2=count_pack2+num_active*G;
ret_array = zeros(1,J);
ret_array(active)=G;
Loads = Loads - ret_array;
end
end
end
if count_pack1>0
throughput1(ii)=throughput1(ii)+count_pack1/M/G;
throughput2(ii)=throughput2(ii)+count_pack2/M/G;
end
end
end
WorkLoad=[0:simurange-1]/simurange+0.01;
figure
hold on
plot(WorkLoad,throughput1/num_trial,'k-o','linewidth',2)
plot(WorkLoad,throughput2/num_trial,'k-*','linewidth',2)
legend('Scheme B','Scheme A')
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -