Showing posts with label Traffic Modelling. Show all posts
Showing posts with label Traffic Modelling. Show all posts

Saturday, June 25, 2011

Generation of Voice traffic [Matlab]


clc;
clear all;
use=input('Enter the no of users: ');
ts=input('Enter the no. of time slots: ');
on=0.35;
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
voice=64000*n;
% time slot vs bw
d=sum(voice);
figure(1);
bar(d);
xlabel('Timeslot');
ylabel('Bandwidth(bps)');
% time slots vs error rate
e=zeros(1,ts);
bm=1540000;
for i=1:ts
if d(i) > bm
e(i)=d(i)-bm;
end
end
figure(2);
bar(e);
xlabel('Timeslots');
ylabel('Error rate (bps)');
avg=sum(e')/ts;
ber=avg/bm;
buff=0;
disp('Average bit error rate without buffers:');
disp(ber);
while ber > 1e-6
buff=buff+10;
bm=bm+10;
for i=1:ts
if e(i)>0
e(i)=d(i)-bm;
end
end
s=sum(e');
ber=s/(ts*bm);
end
disp('BER with buffer:');
disp(ber);
disp('Optimum buffer size');
disp(buff);

Generation of Video traffic [Matlab]


clc;
clear all;
use=input('Enter The Number Of Users: ');
ts=input('Enter The Number Of Time Slots: ');
on=0.35;
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
test=randint(use,ts,[1,1000]);
data=n;
for i=1:use
for j=1:ts
if n(i,j)==1
if test(i,j)>=1 && test(i,j)<=980
data(i,j)=64000;
else
data(i,j)=384000;
end
end
end
end
%Time Slot Vs Bandwidth
d=sum(data);
figure(1);
bar(d);
xlabel('Time Slot');
ylabel('Bandwidth (bps)');
%Time Slots Vs Error Rate
e=zeros(1,ts);
bm=1540000;
for i=1:ts
if d(i)>bm
e(i)=d(i)-bm;
end
end
figure(2);
bar(e);
xlabel('Time Slot');
ylabel('Error Rate (bps)');
avg=sum(e)/ts;
ber=avg/bm;
buff=0;
disp('Average Bit Error Rate without Buffering: ');
disp(ber);
while ber>1e-6
buff =buff+10;
bm=bm+10;
for i=1:ts
if e(i)>0
e(i)=d(i)-bm;
end
end
s=sum(e);
ber=s/(ts*bm);
end
disp('Bit Error Rate with Buffer: ');
disp(ber);
disp('Optimum Buffer Size: ');
disp(buff);

Generation of PN sequence and verification of randomness properties [Matlab]


clc;
clear all;
len = input ('Enter the length of the sequence: ');
disp ('Generator Polynomial Example [1 0 0 1...1] ');
poly = input ('Enter the polynomial: ');
disp ('Initial state Example [1 0 0 1...0]');
ini = input ('Enter the initial state: ');
ff = log2(len+1);
%pn sequence generation
a = zeros(len,ff);
a(1,(1:ff)) = ini ;
for i = 1:(len-1)
x = 0;
for j = 2:(ff+1)
if (poly (1,j) == 1)
x = xor (x,a(i,(j-1)));
end
end
a ((i+1),1:ff) = circshift(a(i,1:ff),[0 1]);
a ((i+1),1) = x;
end
for i = 1:len
h(1,i) = a(i,ff);
end
fprintf ('The generated sequence is: \n');
disp (h);
%balance property
check = 0;
one = 0;
zero = 0;
for i = 1:len
if ( h(1,i) == 0)
zero= zero+1;
else
one = one+1;
end
end
disp ('BALANCE PROPERTY');
disp ('Number of ones: ');
disp (one);
disp ('Number of zeros: ');
disp (zero);
if ((one-zero) == 1)
fprintf ( 'Balance property is satisfied\n\n');
else
fprintf ( 'Balance property is not satisfied\n\n');
check = 2;
end
%autocorelation property
while (check == 0)
for i= 1:len
y(i,:) = xor (h,circshift(h,[0 i]));
end
for i = 1:len
one = 0;
zero = 0;
for j = 1:len
if ( y(i,j) == 0 );
zero = zero+1;
else
one = one+1;
end
end
z(i,1) = zero - one;
end
for i = 1: (len-1)
g(i,1) = -1;
end
g (len,1) = len;
disp ('AUTOCORRELATION PROPERTY');
disp (z);
t=1:1:(len);
plot(t,z);
if(z == g);
fprintf ( 'Auto correlation property is satisfied\n\n');
check = 3;
else
fprintf ( 'Auto correlation property is satisfied\n\n');
check = 2;
end
end
% run property
while( check == 3);
runs = ((len+1)/2);
u = ff;
r = zeros (1,u);
count = 1;
for i = 1:len-1
if (h(1,i) == h(1,i+1))
count = count+1;
else
r(1,count) = r(1,count)+1;
count = 1;
end
end
r(1,count) = r(1,count)+1;
s = zeros(1,u);
for i = 1:(u-1)
s(1,i) = runs / (2.^i) ;
end
s(1,u) = 1;
disp ('RUN PROPERTY');
fprintf ('Runs\t\t\t Run Length \n');
for i = 1:u
fprintf ('%d\t\t\t\t %d\n',r(1,i),i);
end
if (r == s)
fprintf ('Run Property is satisfied\n\n');
check = 4;
else
fprintf ('Run Property is not satisfied\n\n');
check = 2;
end
end
if (check == 2)
disp ('The given sequence is not a PN sequence');
else
disp ('The given sequence is a PN sequence');
end

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 ?