Blogger Tips and TricksLatest Tips And TricksBlogger Tricks

Thursday 5 February 2015

Matlab code for Traffic Measurement

Matlab Code for Traffic measurement
% Define the erlang function
function B = erlangb(N, A)
if (length(N)~=1) | (fix(N) ~= N) | (N < 0)
  error('N must be a scalar positive integer');
end
% TODO: test that elements of A are real and positive here?
esum = zeros(size(A));
for ii=0:N
    esum = esum + A .^ ii ./ factorial(ii);
end
B = A .^ N ./ (factorial(N) .* esum);


% ex1.m example for erlangb function
close all
clear all
lambda=0:0.0001:0.0065; % mean arrival rate (calls per second)
d=200; % mean duration (seconds per call)
a = lambda.*d; % traffic intensity in Erlangs
n = 1;
b = erlangb(n, a); % n channels/servers
ii=find(b<0.1);
plot(a(ii), b(ii), 'b')
hold on
n = 2;
b = erlangb(n, a); % n channels/servers
ii=find(b<0.1);
plot(a(ii), b(ii), 'g')
n = 3;
b = erlangb(n, a); % n channels/servers
plot(a, b, 'r')
n = 4;
b = erlangb(n, a); % n channels/servers
plot(a, b, 'k')
legend('1''2''3''4 channels', 0)
xlabel('Traffic Intensity (Erlangs)');
ylabel('Blocking Probability');
title('Erlang B formula');
plot(a, 0.02, ':k'% 2% line
grid on;

The erlang (symbol E) is a dimensionless unit that is used in telephony as a measure of offered load or carried load on service-providing elements such as telephone circuits or telephone switching equipment. For example, a single cord circuit has the capacity to be used for 60 minutes in one hour. If one hundred six-minute calls are received on a group of such circuits, then the total traffic in that hour is six hundred minutes or 10 erlangs.
Blocking in telecommunication systems is when a circuit group is fully occupied and unable to accept further calls. It also referred to as congestion. Due to blocking in telecommunications systems, calls are either queued (but not lost) or are lost (all calls made over congested group of circuits fail).
Blocking probability is that describes the probability of call losses for a group of identical parallel resources.



Where,        A is the total traffic offered in units of Erlangs
N is the number of circuits. 
PB is the probability that a customer's request will be rejected due to lack of resources.