Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Universidade Federal de Minas Gerais
- Departamento de Ciência da Computação
- Programa de Pós-Graduação em Ciência da Computação
- Redes sem Fio
- Gerador de Gráficos
- Feito por Gabriel de Biasi, 2016672212.
- """
- import sys, re
- import matplotlib.pyplot as plt
- def line_to_list(string):
- return [float(x) for x in re.findall(r'[+-]?\d+\.*\d*', string)]
- def on_key(event):
- if event.key == 'escape':
- exit()
- if __name__ == '__main__':
- # Teste de parâmetro.
- if len(sys.argv) != 2:
- print 'fail'
- exit()
- # Abertura dos arquivos.
- data_x1 = []
- data_y1 = []
- data_x2 = []
- data_y2 = []
- data_x3 = []
- data_y3 = []
- data_x4 = []
- data_y4 = []
- with open(sys.argv[1], 'r') as handle:
- p1, p2 = data_x1, data_y1
- for line in handle:
- qq = line_to_list(line)
- x = qq[0]
- y = qq[1]
- if x == -1.0 and y == -1.0:
- p1, p2 = data_x2, data_y2
- elif x == -2.0 and y == -2.0:
- p1, p2 = data_x3, data_y3
- elif x == -3.0 and y == -3.0:
- p1, p2 = data_x4, data_y4
- else:
- p1.append(float(x))
- p2.append(float(y))
- figura = plt.figure()
- figura.canvas.set_window_title(u'Redes sem Fio')
- figura.canvas.mpl_connect('key_press_event', on_key)
- plt.axvline(x=150, color='k', linestyle='--', linewidth=1.4)
- plt.axvline(x=350, color='k', linestyle='--', linewidth=1.4)
- plt.plot(data_x1, data_y1, 'g', label=u'Clean', markevery=7, marker='o')
- plt.errorbar(data_x1, data_y1, [5,5,5], None, 'g', linestyle='None')
- plt.plot(data_x3, data_y3, 'r', label=u'DDoS', markevery=9, marker='D')
- plt.errorbar(data_x3, data_y3, [5,5,5], None, 'r', linestyle='None')
- plt.plot(data_x2, data_y2, 'b', label=u'Black Hole', markersize=8, markevery=8, marker='^')
- plt.errorbar(data_x2, data_y2, [5,5,5], None, 'b', linestyle='None')
- plt.plot(data_x4, data_y4, 'y', label=u'Overflow', markevery=8, marker='s')
- plt.errorbar(data_x4, data_y4, [5,5,5], None, 'y', linestyle='None')
- plt.legend(loc=3)
- #plt.gca().set_title(u'Result')
- #plt.gca().set_aspect('auto')
- plt.ylabel(u'Packet Delivery Rate (PDR)')
- plt.xlabel(u'Time (s)')
- plt.ylim((0,105))
- plt.xlim((1, 500))
- plt.grid(True)
- plt.draw()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement