-
Notifications
You must be signed in to change notification settings - Fork 8
/
computejitter.py
executable file
·86 lines (70 loc) · 2.51 KB
/
computejitter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python
#
# Copyright 2009 Claudio Pisa (claudio dot pisa at uniroma2 dot it)
#
# This file is part of SVEF (SVC Streaming Evaluation Framework).
#
# SVEF is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SVEF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SVEF. If not, see <http://www.gnu.org/licenses/>.
#
import sys
from nalulib import *
import os
if(len(sys.argv) < 3):
print """
Compute the jitter for each NAL unit and the average jitter.
Usage: %s <sent trace file> <received trace file>
<sent trace file>: JSVM BitstreamExtractor trace file with a
further column containing the timestamps corresponding to the sending
time for each NAL unit. This trace may be obtained from the /streamer/
module.
<received trace file>: JSVM BitstreamExtractor trace file with a
further column containing the timestamps corresponding to the receiving
time for each NAL unit. This trace may be obtained from the /receiver/
module.
""" % os.path.basename(sys.argv[0])
sys.exit(1)
senttracefilename = sys.argv[1]
receivedtracefilename = sys.argv[2]
senttracefile = open(senttracefilename)
sentnalulist = []
sentnaludict = {}
for line in senttracefile:
nalu = NALU(line)
if nalu.packettype == "SliceData":
sentnalulist.append(nalu)
sentnaludict.update({nalu.id: nalu})
senttracefile.close()
receivedtracefile = open(receivedtracefilename)
receivednalulist = []
for line in receivedtracefile:
nalu = NALU(line)
if nalu.packettype == "SliceData":
nalu.senttimestamp = sentnaludict[nalu.id].timestamp
receivednalulist.append(nalu)
receivedtracefile.close()
def absD(i ,j):
return abs((j.timestamp - i.timestamp) - (j.senttimestamp - i.senttimestamp))
i=0
predjitter = 0
jitters = []
while i < len(receivednalulist):
nalui = receivednalulist[i]
prednalu = receivednalulist[i-1]
jitter = predjitter + (absD(nalui, prednalu) - predjitter)/16.0
predjitter = jitter
if i>0:
jitters.append(jitter)
print "0x%x\t%f" % (nalui.id, jitter)
i+=1
print "Average jitter: %f milliseconds" % (sum(jitters)/len(jitters),)