-
Notifications
You must be signed in to change notification settings - Fork 1
/
paket_delivery_ratio.awk
107 lines (45 loc) · 1.32 KB
/
paket_delivery_ratio.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
## AWK file for Packet Delivery Ratio ##
BEGIN {
maxpac_id=0;
recevepkt = 0;
sendspkt = 0;
routingpkts = 0;
receivespkt = 0;
sum = 0;
}
{
evento = $1;
tempo = $3;
pac_id = $41;
agt = $4;
tcbr = $35;
token19 = $4;
token1 = $1;
token35 = $35;
if ( token1 == "s" && token19=="AGT")
sendspkt++;
if ( (token1 == "s" || token1 == "f") && token19=="RTR")
rountingpkts++;
if ( token1 == "r" && token19=="AGT")
receivespkt++;
if ( evento == "r" && agt=="AGT")
recevepkt++;
if ( pac_id > maxpac_id ) maxpac_id = pac_id;
if ( ! ( pac_id in tempIn ) ) tempIn[pac_id] = tempo;
if ( evento != "d" ) {
if ( evento == "r" ) tempoFim[pac_id] = tempo;
} else tempoFim[pac_id] = 0;
}
END {
for ( pac_id = 0; pac_id <= maxpac_id + 1; pac_id++ ) {
duracao = tempoFim[pac_id] - tempIn[pac_id];
if ( duracao > 0 ) {
sum = sum + duracao;
}
}
printf("Packets Sent = %d pkts\n", sendspkt);
printf("Packets Received = %d pkts\n", receivespkt);
printf("Packet Delivery Ratio = %f \n", recevepkt/sendspkt*100);
printf("Network Overhead = %d pkts\n", rountingpkts);
exit 0
}