Browse Source

Matlab code for data processing added

tags/v1.0-b1
parent
commit
64604aa687
4 changed files with 206 additions and 0 deletions
  1. +53
    -0
      matlab/ARQ_error.m
  2. +29
    -0
      matlab/ARQ_time.m
  3. +25
    -0
      matlab/Echo_time.m
  4. +99
    -0
      matlab/data_processing.m

+ 53
- 0
matlab/ARQ_error.m View File

@@ -0,0 +1,53 @@
function [x, Fe, l, ber] = ARQ_error(fileName)
%Parse AQR log file
% x: Number of re-transmissions vector
% Fe: Frequency of transmissions vector, where index implies Nbr of
% transmission
% l: Average tries per package
% ber: Bit error rate
%
% author:
% Christos Choutouridis AEM:8997
% cchoutou@ece.auth.gr

pkg_size = 128;
x = [0 1 2 3 4 5 6 7 8 9]';
Fe = zeros (10, 1);
data = fopen (fileName);
A = textscan(data,'%s','Delimiter','\n');
B = A{1,1};
fclose(data);
s = size (B);

j =1;
for i = 2:s(1)
C = textscan(B{i,1},'%s','Delimiter',' ');
D = C{1};
e = str2num(D{10});
E(j) = e;
j = j+1;
end
s = size (E);
for i = 2:s(2)
if (E(i) == 0)
if (E(i-1) == 0)
Fe(1) = Fe(1) +1;
else
if (E(i-1) <= 9)
Fe(E(i-1)+1) = Fe(E(i-1)+1) +1;
end
end
end
end
l =0;
for i=1:10
l = l + Fe(i)*i;
end
l = l / sum(Fe);
ber = 1 - (1/l)^(1/pkg_size);
end


+ 29
- 0
matlab/ARQ_time.m View File

@@ -0,0 +1,29 @@
function [F, T] = ARQ_time(fileName)
%Parse ARQ log file
% F: Frequency vector
% T: Time vector
%
% author:
% Christos Choutouridis AEM:8997
% cchoutou@ece.auth.gr


data = fopen (fileName);
A = textscan(data,'%s','Delimiter','\n');
B = A{1,1};
fclose(data);
s = size (B);
T_ = zeros(s(1)-1, 1);
j =1;
for i = 2:s(1)
C = textscan(B{i,1},'%s','Delimiter',' ');
D = C{1};
if str2num(D{18}) ~= 0 % it Total != 0
T_(j) = str2num(D{15}); % get server response time
j = j+1;
end
end
T = T_(1:j);
F = histcounts(T, 1:max(T));
end


+ 25
- 0
matlab/Echo_time.m View File

@@ -0,0 +1,25 @@
function [F,T] = Echo_time(fileName)
%Parse echo log file
% T response time vector
% F frequency vector of Tr
%
% author:
% Christos Choutouridis AEM:8997
% cchoutou@ece.auth.gr

data = fopen (fileName);
A = textscan(data,'%s','Delimiter','\n');
B = A{1,1};
fclose(data);
s = size (B);
T = zeros(s(1)-1, 1);
for i = 2:s(1)
C = textscan(B{i,1},'%s','Delimiter',' ');
D = C{1};
T(i-1) = str2num(D{8});
end

F = histcounts(T, 1:1000);

end


+ 99
- 0
matlab/data_processing.m View File

@@ -0,0 +1,99 @@
%
% Network Lab session data processing
%
% author:
% Christos Choutouridis AEM:8997
% cchoutou@ece.auth.gr

% Select title font size
titleFontSize =10;
max_echoDist =350;
max_arqDist =600;

% Select witch session using MATLAB comments. Ctrl-T/CtrlR
% session 1
% Ecode = 'E7837';
% Qcode = 'Q5137';
% Rcode = 'R8316';
% Etime = '2020-04-11-19:00:52';
% ARQtime = '2020-04-12-12:46:05';

% session 2
Ecode = 'E1510';
Qcode = 'Q1643';
Rcode = 'R7877';
Etime = '2020-04-14-16:12:13';
ARQtime = '2020-04-15-11:00:14';

% make titles and filenames
file_echo = sprintf('%s-%s.log', Ecode, Etime);
file_arq = sprintf('%s-%s-%s.log', Qcode, Rcode, ARQtime);

title_Echo = sprintf('\\fontsize{%d}Code:%s Timestamp:%s', titleFontSize, Ecode, Etime);
title_echoDist = sprintf('\\fontsize{%d}%s: Response time distribution', titleFontSize, Ecode);
title_ARQ = sprintf('\\fontsize{%d}Code:%s/%s Timestamp:%s', titleFontSize, Qcode, Rcode, ARQtime);
title_ARQDist = sprintf('\\fontsize{%d}%s/%s: Response time distribution', titleFontSize, Qcode, Rcode);
title_ARQ_bar = sprintf('\\fontsize{%d}Distribution of ARQ Transmissions', titleFontSize);
title_ARQ_norm = sprintf('\\fontsize{%d}Propability Distribution of ARQ Re-transmissions', titleFontSize);

% Echo mechanism
[Fe Te] = Echo_time (file_echo); % analyze Echo timing

figure('Position', [0 0 1024 600]); % G1: response time
stairs (Te);
title (title_Echo);
xlabel('Package Nbr');
ylabel('Response time [msec]');

figure('Position', [0 0 1024 600]); % G1 helper: Response time distribution
bar (Fe(1:max_echoDist));
title (title_echoDist);
xlabel('Response time [msec]');
ylabel('Packages');


% ARQ mechanism - time analysis
[Fqr, Tqr] = ARQ_time (file_arq); % analyze ARQ timing

figure('Position', [0 0 1024 600]); % G2: response time
stairs(Tqr);
title (title_ARQ);
xlabel('Package Nbr');
ylabel('Response time [msec]');

figure('Position', [0 0 1024 600]); % G2 helper: Response time distribution
bar (Fqr(1:max_arqDist));
title (title_ARQDist);
xlabel('Response time [msec]');
ylabel('Packages');

% ARQ mechanism - error analysis
[x, Fe, l, ber] = ARQ_error (file_arq); % analyze ARQ error
Fe_norm = Fe / sum(Fe); % normalize ARQ error
ft = fittype('a*exp(-b*x)'); % curve fiting
[fitFe] = fit (x, Fe_norm, ft);

figure('Position', [0 0 1024 900]); % Error distribution analysis
subplot(2,1,1);
b = bar(Fe);
xtips = b.XEndPoints;
ytips = b.YEndPoints;
labels = string(b.YData);
text(xtips,ytips,labels,'HorizontalAlignment','center','VerticalAlignment','bottom');
title (title_ARQ_bar);
xlabel('Number of Transmissions');
ylabel('Number of packages');
t = sprintf ('Average tries / pkg = %g', l);
text (8, max(Fe), t);
t = sprintf ('Bit error rate = %g', ber);
text (8, max(Fe)*0.92, t);

subplot(2,1,2); stem(x, Fe_norm); % G3 helper: Normalized and curve fiting
hold on
plot (fitFe);
title (title_ARQ_norm);
xlabel('Number of Re-transmissions');
ylabel('Package %');
txt = sprintf ('\\leftarrow %gexp(-%gx)', fitFe.a, fitFe.b);
text(0.5, fitFe.a*exp(-fitFe.b*0.5), txt);


Loading…
Cancel
Save