Network programming assignment for University
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

100 lignes
3.1 KiB

  1. %
  2. % Network Lab session data processing
  3. %
  4. % author:
  5. % Christos Choutouridis AEM:8997
  6. % cchoutou@ece.auth.gr
  7. % Select title font size
  8. titleFontSize =10;
  9. max_echoDist =350;
  10. max_arqDist =600;
  11. % Select witch session using MATLAB comments. Ctrl-T/CtrlR
  12. % session 1
  13. % Ecode = 'E7837';
  14. % Qcode = 'Q5137';
  15. % Rcode = 'R8316';
  16. % Etime = '2020-04-11-19:00:52';
  17. % ARQtime = '2020-04-12-12:46:05';
  18. % session 2
  19. Ecode = 'E1510';
  20. Qcode = 'Q1643';
  21. Rcode = 'R7877';
  22. Etime = '2020-04-14-16:12:13';
  23. ARQtime = '2020-04-15-11:00:14';
  24. % make titles and filenames
  25. file_echo = sprintf('%s-%s.log', Ecode, Etime);
  26. file_arq = sprintf('%s-%s-%s.log', Qcode, Rcode, ARQtime);
  27. title_Echo = sprintf('\\fontsize{%d}Code:%s Timestamp:%s', titleFontSize, Ecode, Etime);
  28. title_echoDist = sprintf('\\fontsize{%d}%s: Response time distribution', titleFontSize, Ecode);
  29. title_ARQ = sprintf('\\fontsize{%d}Code:%s/%s Timestamp:%s', titleFontSize, Qcode, Rcode, ARQtime);
  30. title_ARQDist = sprintf('\\fontsize{%d}%s/%s: Response time distribution', titleFontSize, Qcode, Rcode);
  31. title_ARQ_bar = sprintf('\\fontsize{%d}Distribution of ARQ Transmissions', titleFontSize);
  32. title_ARQ_norm = sprintf('\\fontsize{%d}Propability Distribution of ARQ Re-transmissions', titleFontSize);
  33. % Echo mechanism
  34. [Fe Te] = Echo_time (file_echo); % analyze Echo timing
  35. figure('Position', [0 0 1024 600]); % G1: response time
  36. stairs (Te);
  37. title (title_Echo);
  38. xlabel('Package Nbr');
  39. ylabel('Response time [msec]');
  40. figure('Position', [0 0 1024 600]); % G1 helper: Response time distribution
  41. bar (Fe(1:max_echoDist));
  42. title (title_echoDist);
  43. xlabel('Response time [msec]');
  44. ylabel('Packages');
  45. % ARQ mechanism - time analysis
  46. [Fqr, Tqr] = ARQ_time (file_arq); % analyze ARQ timing
  47. figure('Position', [0 0 1024 600]); % G2: response time
  48. stairs(Tqr);
  49. title (title_ARQ);
  50. xlabel('Package Nbr');
  51. ylabel('Response time [msec]');
  52. figure('Position', [0 0 1024 600]); % G2 helper: Response time distribution
  53. bar (Fqr(1:max_arqDist));
  54. title (title_ARQDist);
  55. xlabel('Response time [msec]');
  56. ylabel('Packages');
  57. % ARQ mechanism - error analysis
  58. [x, Fe, l, ber] = ARQ_error (file_arq); % analyze ARQ error
  59. Fe_norm = Fe / sum(Fe); % normalize ARQ error
  60. ft = fittype('a*exp(-b*x)'); % curve fiting
  61. [fitFe] = fit (x, Fe_norm, ft);
  62. figure('Position', [0 0 1024 900]); % Error distribution analysis
  63. subplot(2,1,1);
  64. b = bar(Fe);
  65. xtips = b.XEndPoints;
  66. ytips = b.YEndPoints;
  67. labels = string(b.YData);
  68. text(xtips,ytips,labels,'HorizontalAlignment','center','VerticalAlignment','bottom');
  69. title (title_ARQ_bar);
  70. xlabel('Number of Transmissions');
  71. ylabel('Number of packages');
  72. t = sprintf ('Average tries / pkg = %g', l);
  73. text (8, max(Fe), t);
  74. t = sprintf ('Bit error rate = %g', ber);
  75. text (8, max(Fe)*0.92, t);
  76. subplot(2,1,2); stem(x, Fe_norm); % G3 helper: Normalized and curve fiting
  77. hold on
  78. plot (fitFe);
  79. title (title_ARQ_norm);
  80. xlabel('Number of Re-transmissions');
  81. ylabel('Package %');
  82. txt = sprintf ('\\leftarrow %gexp(-%gx)', fitFe.a, fitFe.b);
  83. text(0.5, fitFe.a*exp(-fitFe.b*0.5), txt);