?? verifymulti.m
字號:
% Multicast Verification in GPRS network.
% One cell implementation.
% Without Link Adaptation
% Clear workspace
% clear
% clc
% Maximum time for simulation
t_max = 15*60; % seconds
% Sampling time
t_samp = 0.02; % the time is discrete, with sampling time is 20 ms
% Number of Time slots
num_ts = 4;
% Random Carrier to Interference
rctoi = 10 + 5*randn(30,(t_max/t_samp));
% Create Traffic
user_traffic = traff;
for p = 1:3
% Coding Scheme and user's C/I
% 3 different case
switch p
case 1
ctoi = 6*ones(30,(t_max/t_samp));
case 2
m = min(rctoi,[],2) * ones(1,(t_max/t_samp));
ctoi = rctoi - m + (6*ones(30,(t_max/t_samp)));
case 3
m = max(rctoi,[],2) * ones(1,(t_max/t_samp));
ctoi = rctoi - m + 6*ones(30,(t_max/t_samp));
end
%Fixed Coding Scheme
cs = ones(30,(t_max/t_samp));
% Initialization
buffhist = zeros(1,30);
overall_th = zeros(1,30);
packet_loss = zeros(1,30);
bits_loss = zeros(1,30);
% to make a graph, user 2-50
for N_user = 2:30
N_user
% Create Buffer
buffer = 0;
%user throughput
average_th = zeros(1,N_user);
data = zeros(1,N_user);
% User's delay
delay = zeros(1,N_user);
% Loss channel
p_loss_chan = zeros(1,N_user); %packet
b_loss_chan = zeros(1,N_user); %bits
% Let it start!!!
t_old = 0;
t_new = t_old + t_samp;
while (t_new<t_max-0.0001)
% Update buffer
buffer = buffer + sum(user_traffic(floor(t_old/t_samp+1):floor((t_new/t_samp)))); % fill buffer with packet
% transmitting data
switch (cs(N_user,floor((t_old/t_samp)+1)))
case 1
bitrate = num_ts*9050; %coding scheme 1
case 2
bitrate = num_ts*13400; %coding scheme 2
case 3
bitrate = num_ts*15600; %coding scheme 3
case 4
bitrate = num_ts*21400; %coding scheme 4
end
transmitted = bitrate * 0.0046 * 4; %4 RLC blocks
if (buffer < transmitted)
transmitted = buffer;
end
% emptying buffer
buffer = buffer-transmitted;
%calculating throughput
a = per(cs(N_user,floor((t_old/t_samp)+1)),ctoi(1:N_user,floor((t_old/t_samp)+1))');
aa = ones(num_ts,1)*a;
b = rand(num_ts,N_user);
for ts = 1:num_ts
success = find (b(ts,:) >= aa(ts,:));
data(success) = data(success) + (transmitted/num_ts);
fail = find (b(ts,:) < aa(ts,:));
p_loss_chan(fail) = p_loss_chan(fail) + 1 ;
b_loss_chan(fail) = b_loss_chan(fail) + (transmitted/num_ts);
end
t_old = t_new;
t_new = t_new + t_samp; % update time
end
% Overall throughput
average_th = data/t_max;
overall_th(N_user) = sum(average_th)/N_user;
%average packet loss
all_packet = N_user*(t_max/t_samp)*4;
packet_loss(N_user) = sum(p_loss_chan)/(all_packet);
%average bits loss
bits_loss(N_user) = sum(b_loss_chan)/(N_user*t_max);
%buffer history
buffhist(N_user) = sum(buffer);
end
x = 2:1:30;
figure(2)
switch p
case 1
th_multi_fixed = overall_th;
pl_multi_fixed = packet_loss;
bf_multi_fixed = buffhist;
subplot(3,1,1);plot(x,overall_th(2:30),'*');hold on;grid on;title('Multicast Throughput');
subplot(3,1,2);plot(x,packet_loss(2:30),'*');hold on;grid on;title('Multicast Block Error Rate');
subplot(3,1,3);plot(x,buffhist(2:30),'*');hold on;grid on;title('Multicast Bits Loss in Buffer');
case 2
th_multi_varplus = overall_th;
pl_multi_varplus = packet_loss;
bf_multi_varplus = buffhist;
subplot(3,1,1);plot(x,overall_th(2:30),'+');hold on;grid on;title('Multicast Throughput');
subplot(3,1,2);plot(x,packet_loss(2:30),'+');hold on;grid on;title('Multicast Block Error Rate');
subplot(3,1,3);plot(x,buffhist(2:30),'+');hold on;grid on;title('Multicast Bits Loss in Buffer');
case 3
th_multi_varmin = overall_th;
pl_multi_varmin = packet_loss;
bf_multi_varmin = buffhist;
subplot(3,1,1);plot(x,overall_th(2:30),'-');hold on;grid on;title('Multicast Throughput');
subplot(3,1,2);plot(x,packet_loss(2:30),'-');hold on;grid on;title('Multicast Block Error Rate');
subplot(3,1,3);plot(x,buffhist(2:30),'-');hold on;grid on;title('Multicast Bits Loss in Buffer');
end
end
clear overall_th buffhist packet_loss bits_loss ctoi average_th t_old t_new cs data N_user a b p_loss_chan b_loss_chan success fail transmitted user all_packet bitrate delay index user_traffic CIR_multi CIR_uni CIR buffer traff aa
save ver_multi
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -