-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJitter2007.awk
84 lines (74 loc) · 2.2 KB
/
Jitter2007.awk
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
# http://mailman.isi.edu/pipermail/ns-users/2007-August/060808.html
#
# AWK script for compute delay jitter
# Jitter.awk
#
BEGIN {
num_recv=0
}
{
# Trace line format: normal
if ($2 != "-t") {
event = $1
time = $2
if (event == "+" || event == "-") node_id = $3
if (event == "r" || event == "d") node_id = $4
flow_id = $8
pkt_id = $12
pkt_size = $6
flow_t = $5
level = "AGT"
}
# Trace line format: new
if ($2 == "-t") {
event = $1
time = $3
node_id = $5
flow_id = $39
pkt_id = $41
pkt_size = $37
flow_t = $45
level = $19
}
# Store packets send time
if (level == "AGT" && sendTime[pkt_id] == 0 && (event == "+" || event == "s") && pkt_size >= 512) {
sendTime[pkt_id] = time
}
# Store packets arrival time
if (level == "AGT" && event == "r" && pkt_size >= 512) {
recvTime[pkt_id] = time
num_recv++
}
}
END {
# Compute average jitter
jitter1 = jitter2 = tmp_recv = 0
prev_time = delay = prev_delay = processed = 0
prev_delay = -1
for (i=0; processed<num_recv; i++) {
if(recvTime[i] != 0) {
tmp_recv++
if(prev_time != 0) {
delay = recvTime[i] - prev_time
e2eDelay = recvTime[i] - sendTime[i]
if(delay < 0) delay = 0
if(prev_delay != -1) {
jitter1 += abs(e2eDelay - prev_e2eDelay)
jitter2 += abs(delay-prev_delay)
}
prev_delay = delay
prev_e2eDelay = e2eDelay
}
prev_time = recvTime[i]
}
processed++
}
}
END {
printf("Jitter1 = %.2f\n",jitter1*1000/tmp_recv);
printf("Jitter2 = %.2f\n",jitter2*1000/tmp_recv);
}
function abs(value) {
if (value < 0) value = 0-value
return value
}