Saturday, 7 September 2013

Generation of Integrated (ISDN) traffic [Matlab]

Generation of Integrated (ISDN) traffic [Matlab]
 
clc;

clear all;

use=input('Enter the Number of users: ');

ts=input('Enter the Number of Time Slots: ');

on=0.35;

voiceuser=0;

datauser=0;

voipuser=0;

ton=zeros(use,ts);

n=ton;

for i=1:use

for j=1:ts

ton(i,:)=poissrnd((on*10),1,ts);

if (ton(i,j)>=3.5)

n(i,j)=1;

end

end

end

userprob=randint(1,use,[1,10]);

useriden=ones(1,use);

for i=1:use

if (userprob(i)>=1 & userprob<=5)

useriden(i)=1;

voiceuser=voiceuser+1;

elseif (userprob(i)>5 & userprob(i)<=8)

useriden(i)=2;

voipuser=voipuser+1;

else

useriden(i)=3;

datauser=datauser+1;

end

end

newuseriden=sort(useriden);

isdn=64000*n;

test=randint(voipuser,ts,[1,1000]);

for i=voiceuser+1:voipuser+voiceuser

for j=1:ts

if n(i,j)==1

if test(i-voiceuser,j)>=1 & test(i-voiceuser,j)<=800

isdn(i,j)=64000;

else

isdn(i,j)=384000;

end

end

end

end

test1=randint(datauser,ts,[1,1000]);

for i=voiceuser+voipuser+1:use

for j=1:ts

if n(i,j)==1

if test1(i-(voiceuser+voipuser),j)>=1 & test1(i-(voiceuser+voipuser),j)<=800

isdn(i,j)=64000;

elseif test1(i-(voiceuser+voipuser),j)>800 & test1(i-(voiceuser+voipuser),j)<=900

isdn(i,j)=128000;

elseif test1(i-(voiceuser+voipuser),j)>900 & test1(i-(voiceuser+voipuser),j)<=950

isdn(i,j)=256000;

else

isdn(i,j)=512000;

end

end

end

end

%Time Slots Vs Bandwidth

d=sum(isdn);

figure(1);

bar(d);

xlabel('Time Slots');

ylabel('Bandwidth(bps)');

%Time Slots Vs Error Rate

e=zeros(1,ts);

bm=1984000;

for i=1:ts

if d(i)>bm

e(i)=d(i)-bm;

end

end

figure(2);

bar(e);

xlabel('Time Slots');

ylabel('Error Rate(bps)');

buff=0;

newbw=1984000+buff;

prisdn=isdn(1:voiceuser,:);

voipsort=isdn(voiceuser+1:voiceuser+voipuser,:);

prisdn(voiceuser+1:voiceuser+voipuser,:)=sort(voipsort,1);

datasort=isdn(voiceuser+voipuser+1:use,:);

prisdn(voiceuser+voipuser+1:use,:)=sort(datasort,1);

%To Find How many users go unserved with or without buffer?

unservedvoice=zeros(1,ts);

unservedvoip=zeros(1,ts);

unserveddata=zeros(1,ts);

for i=1:ts

j=0;

bwalloc=0;

while (bwalloc<=newbw & j

j=j+1;

bwalloc=bwalloc+prisdn(j,i);

end

ch=j;

if ch

unservedvoice(i)=voiceuser-ch;

unservedvoip(i)=voipuser;

unserveddata(i)=datauser;

elseif ch>=(voiceuser) & ch<(voiceuser+voipuser)

unservedvoip(i)=voiceuser+voipuser-ch;

unserveddata(i)=datauser;

elseif ch>=(voipuser+voiceuser) & ch

unserveddata(i)=use-ch;

end

end

figure(3);

bar(unservedvoice);

xlabel('Time Slot');

ylabel('Unserved Voice User');

figure(4);

bar(unservedvoip);

xlabel('Time Slot');

ylabel('Unserved VOIP User');

figure(5);

bar(unserveddata);

xlabel('Time Slot');

ylabel('Unserved Data User');

No comments:

Post a Comment