-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtp_avg_wireless_both_ok.awk
51 lines (42 loc) · 1.02 KB
/
tp_avg_wireless_both_ok.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
# Final awk script to measure average throughput for wireless network(OLD+NEW).
BEGIN {
recvdSize = 0
startTime = 1e6
stopTime = 0
}
{
# Trace line format: NORMAL
if ($2 != "-t") {
event = $1
time = $2
level=$4
pkt_size = $8
}
# Trace line format: NEW
if ($2 == "-t") {
event = $1
time = $3
level = $19
pkt_size = $37
}
# Store start time
if (level == "AGT" && event == "s" && pkt_size >= 512) {
if (time < startTime) {
startTime = time
}
}
# Update total received packets' size and store packets arrival time
if (level == "AGT" && event == "r" && pkt_size >= 512) {
if (time > stopTime) {
stopTime = time
}
# Rip off the header
hdr_size = pkt_size % 512
pkt_size = pkt_size - hdr_size
# Store received packet's size
recvdSize = recvdSize + pkt_size
}
}
END {
printf("Average Throughput[kbps] = %.2f\t\t StartTime=%.2f\tStopTime=%.2f\n",(recvdSize/(stopTime-startTime))*(8/1000),startTime,stopTime)
}