Network programming assignment for University
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

ARQ_error.m 1.1 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. function [x, Fe, l, ber] = ARQ_error(fileName)
  2. %Parse AQR log file
  3. % x: Number of re-transmissions vector
  4. % Fe: Frequency of transmissions vector, where index implies Nbr of
  5. % transmission
  6. % l: Average tries per package
  7. % ber: Bit error rate
  8. %
  9. % author:
  10. % Christos Choutouridis AEM:8997
  11. % cchoutou@ece.auth.gr
  12. pkg_size = 128;
  13. x = [0 1 2 3 4 5 6 7 8 9]';
  14. Fe = zeros (10, 1);
  15. data = fopen (fileName);
  16. A = textscan(data,'%s','Delimiter','\n');
  17. B = A{1,1};
  18. fclose(data);
  19. s = size (B);
  20. j =1;
  21. for i = 2:s(1)
  22. C = textscan(B{i,1},'%s','Delimiter',' ');
  23. D = C{1};
  24. e = str2num(D{10});
  25. E(j) = e;
  26. j = j+1;
  27. end
  28. s = size (E);
  29. for i = 2:s(2)
  30. if (E(i) == 0)
  31. if (E(i-1) == 0)
  32. Fe(1) = Fe(1) +1;
  33. else
  34. if (E(i-1) <= 9)
  35. Fe(E(i-1)+1) = Fe(E(i-1)+1) +1;
  36. end
  37. end
  38. end
  39. end
  40. l =0;
  41. for i=1:10
  42. l = l + Fe(i)*i;
  43. end
  44. l = l / sum(Fe);
  45. ber = 1 - (1/l)^(1/pkg_size);
  46. end