Saturday, June 25, 2011

Generation of M|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);
tarr(1,:)=poissrnd((arrival_rate),1,timeslots);
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: ');
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: ');
disp(buff);
figure(2);
line(buffer_size,avg_loss);
xlabel('Buffer Size');
ylabel('Packet Loss');

No comments:

Google : The top most search engine

Google : MAGIC BOX

nRelate - Posts and Homepage

LinkWithin

Related Posts Plugin for WordPress, Blogger...

Which is the toughest subject ?