Generation of G|G|1 model [Matlab]
clc;
clear
all;
arrival_rate=input('Enter the
Data Arrival Rate: ');
service_rate=input('Enter the
Data Service Rate: ');
error_rate=input('Enter the
maximum acceptable Packet Loss Rate: ');
timeslots=100;
t=1:timeslots;
tarr=zeros(1,timeslots);
tser=zeros(1,timeslots);
tarr1(1,:)=normrnd((arrival_rate),5,1,timeslots);
tarr=round(tarr1);
tser1(1,:)=exprnd((service_rate),1,timeslots);
tser=round(tser1);
%Time
Slots Vs Packet Loss
n=zeros(1,timeslots);
for
j=1:timeslots
if(tarr(1,j)>tser(1,j));
n(1,j)=tarr(1,j)-tser(1,j);
end
end
bar(t,n,0.01);
xlabel('Time
Slots');
ylabel('Packet
Loss');
disp('The maximum
Packet Loss is: ');
disp(max(n));
disp('The Average
Packet Loss before Buffering is: ');
avg=mean(n);
disp(avg);
%Buffer
Size Vs Packet Loss
buff=0;
count=1;
avg_loss(1,count)=avg;
buffer_size(1,count)=buff;
while(avg>error_rate)
count=count+1;
buff=buff+1;
tser=tser+1;
for
j=1:timeslots
if
n(1,j)>0
n(1,j)=tarr(1,j)-tser(1,j);
end
end
avg=mean(n);
avg_loss(1,count)=avg;
buffer_size(1,count)=buff;
end
disp('The maximum
Packet Loss after Buffering is: ');
disp(max(n));
disp('The Average
Packet Loss after Buffering is: ');
disp(avg);
disp('The maximum
Buffer Size for the given Error Rate is: ');
disp(buff);
figure(2);
line(buffer_size,avg_loss);
xlabel('Buffer
Size');
ylabel('Packet
Loss');
No comments:
Post a Comment