docs: add todo's from Sibir's repo
[netsniff-ng.git] / scripts / view_rtp_avg.py
blob5f4fe4ab7b8eeaf941282df65e72d53ecaf9fef2
1 #!/usr/bin/env python
3 # view_rtp_avg.py - A datafile viewer for Mausezahn
4 # Copyright (C) 2008 Herbert Haas
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License version 2 as published
8 # by the Free Software Foundation.
9 #
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, see http://www.gnu.org/licenses/gpl-2.0.html
17 from matplotlib import rcParams
18 from pylab import *
19 import sys
21 if size(sys.argv) < 2: ### no data file given
22 print "You must specify a data file as argument!"
23 exit()
25 print "Read datafile. Please be patient..."
27 datfile = open(sys.argv[1],'r');
29 javg_list = []
31 for line in datfile.readlines():
32 if len(line)>1:
33 words = line.split(" ")
34 if words[0]!='#':
35 javg = line.split(", ");
36 javg_list.append(float(javg[4])/1000) # [x] means xth column (columns 0,1,..)
37 #### column 2 is jitter, column 4 is RFC 3550 jitter
39 datfile.close()
41 print "Data imported. Now calculating statistics..."
43 # Erase statistical exceptions
45 javg_list_ordered = sort(javg_list)
47 s = size(javg_list_ordered);
48 s=int(s*0.95) ## assume that at maximum 5% of the data are exceptions
50 print "Will remove exceptional data points. A total of %d packets will be processed." % (s, )
51 ## the histogram of the data
52 n, bins, patches = hist(javg_list_ordered[1:s], 100, normed=False)
54 ## add a 'best fit' line
55 #y = normpdf( bins, mu, sigma)
56 #l = plot(bins, y, 'r--', linewidth=2)
57 #xlim(40, 160)
59 xlabel('Jitter (msec)')
60 ylabel('Number of Packets')
61 title("Average Jitter Probability")
62 #title(r'$\rm{IQ:}\/ \mu=100,\/ \sigma=15$')
63 ####suptitle("Mausezahn Viewer (Avg RTP Jitter)")
64 show()