Created
May 31, 2019 09:28
-
-
Save Raniita/5897a1b17d3fcbfac7b386fbecefd987 to your computer and use it in GitHub Desktop.
Obtención de medidas de SDL ALOHA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Extraccion de los valores de la simulacion | |
% Datos de la practica | |
N_nodos = 6; | |
ranuras = 10000; | |
% Valores de PG probados | |
PG = {'0', '01', '025', '05', '075', '1', '125', '150', '175', '2', '25', '3', '35', '4', '45', '5', '6', '7', '8', '9', '95'}; | |
TO = zeros(1,21); | |
TC = zeros(1,21); | |
TP = zeros(1,21); | |
TS = zeros(1,21); | |
for i=1:length(PG) | |
file = strcat('aloha_0_',PG{i},'.txt'); | |
fid = fopen(file); | |
% Valores para un PG exacto | |
TO_emisor = zeros(1,N_nodos); | |
TC_emisor = zeros(1,N_nodos); | |
TP_emisor = zeros(1,N_nodos); | |
TS_emisor = zeros(1,N_nodos); | |
while feof(fid) == 0 | |
line = fgetl(fid); | |
if isempty(line) | |
continue | |
else | |
r = textscan(line, 'Command : Examine-Variable ( Emisor %d %s'); | |
end | |
if isempty(r{1,2}) | |
continue | |
else | |
line = fgetl(fid); | |
if(strcmp(r{1,2},'TOemisor')) | |
value = textscan(line, 'TOemisor (integer) = %d'); | |
TO_emisor(r{1,1}) = value{1}; | |
elseif strcmp(r{1,2},'TCemisor') | |
value = textscan(line, 'TCemisor (integer) = %d'); | |
TC_emisor(r{1,1}) = value{1}; | |
elseif strcmp(r{1,2},'TPemisor') | |
value = textscan(line, 'TPemisor (integer) = %d'); | |
TP_emisor(r{1,1}) = value{1}; | |
elseif strcmp(r{1,2},'TStotal') | |
value = textscan(line, 'TStotal (integer) = %d'); | |
TS_emisor(r{1,1}) = value{1}; | |
end | |
end | |
end | |
% Calculamos la media y dividimos por las ranuras | |
TC_nodo = (sum(TC_emisor)/N_nodos)/ranuras; | |
TO_nodo = (sum(TO_emisor)/N_nodos)/ranuras; | |
TP_nodo = (sum(TP_emisor)/N_nodos)/ranuras; | |
TS_nodo = (sum(TS_emisor)/N_nodos)/ranuras; | |
% Guardamos dependiendo del PG | |
TC(i) = TC_nodo; | |
TO(i) = TO_nodo; | |
TP(i) = TP_nodo; | |
TS(i) = TS_nodo; | |
fclose(fid); | |
end | |
%% Curva eficiencia del canal (tc vs to) | |
figure | |
plot(TO,TC,'-o'); | |
title('Trafico cursado VS Trafico ofrecido'); | |
xlabel('Trafico ofrecido'); | |
ylabel('Trafico cursado'); | |
%% Grafica Tiempo de servicio vs trafico cursado | |
figure; | |
plot(TC,TS,'-o'); | |
title('Tiempo de servicio VS Trafico cursado'); | |
xlabel('Trafico cursado'); | |
ylabel('Tiempo de servicio'); | |
%% Grafica trafico perdido vs trafico cursado | |
figure | |
plot(TC,TP,'-o'); | |
title('Trafico perdido vs trafico cursado'); | |
xlabel('Trafico cursado'); | |
ylabel('Trafico perdido'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment