-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput-stat.awk
81 lines (75 loc) · 2.08 KB
/
output-stat.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
NR==1 {
rttStart == 0
cwndState = 0
rtt_th = 200
window = 20000 # 20sec
interval = 40 # 40ms = 25fps
split(FILENAME, res, "[-.k]")
bwcut = int(res[5])
ratio = int(res[4])
lastTime = 0
}
NR==FNR {
if ($2 == "Time" && $3 >= bwcut * interval + window && $3 < bwcut * interval + 2 * window) {
if ($3 == lastTime) {
next
}
lastTime = $3
if ($1 == "[PacketSenderUdp]") {
cwnd += int(($9 - cwnd) / 8)
}
else if ($1 == "[PacketSenderTcp]") {
cwnd += int(($10 - cwnd) / 8)
}
stableRtt += int(($5 - stableRtt) / 8)
}
next
}
/Sender/ {
if ($3 == lastTime) {
next
}
lastTime = $3
if ($3 > bwcut * interval - window && $3 < bwcut * interval) {
if ($1 == "[PacketSenderUdp]") {
cwndPrev = cwndPrev > $9 ? cwndPrev : $9;
}
else if ($1 == "[PacketSenderTcp]") {
cwndPrev = cwndPrev > $10 ? cwndPrev : $10;
}
}
else if ($3 >= bwcut * interval && $3 < bwcut * interval + window) {
# calculate cwnd back to normal
if ($1 == "[PacketSenderUdp]" &&
($9 < cwnd || $9 / 1.25 < cwndPrev / ratio || $9 <= 1448 * 4) &&
cwndState == 0) {
print FILENAME, "cwnd", $3 - bwcut * interval;
cwndState = 1
}
else if ($1 == "[PacketSenderTcp]" &&
($10 < cwnd || $10 / 1.25 < cwndPrev / ratio || $10 <= 1448 * 4) &&
cwndState == 0) {
print FILENAME, "cwnd", $3 - bwcut * interval;
cwndState = 1
}
# calculate RTT deviations
if ($5 > rtt_th && rttStart == 0) {
rttStart = $3
}
if (($5 < rtt_th) && rttStart > 0) {
print FILENAME, "rtt", $3 - rttStart;
rttStart = -1
}
}
}
END {
if (cwndState == 0) {
print FILENAME, "cwnd", window
}
if (rttStart == 0) {
print FILENAME, "rtt", 0
}
else if (rttStart > 0) {
print FILENAME, "rtt", window
}
}