-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathawk-sat.awk
101 lines (72 loc) · 2.03 KB
/
awk-sat.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
BEGIN {
max_node = 2000;
nSentPackets = 0.0 ;
nReceivedPackets = 0.0 ;
rTotalDelay = 0.0 ;
max_pckt = 10000;
idHighestPacket = 0;
idLowestPacket = 100000;
rStartTime = 10000.0;
rEndTime = 0.0;
nReceivedBytes = 0;
for(i = 0; i < max_pckt; i++){
sent[i] = 0;
}
PKT_SIZE_CBR=210;
}
{
# + 2 8 7 tcp 40 ------- 0 8.0 13.0 0 4
strEvent = $1;
rTime = $2;
from_node = $3;
to_node = $4;
pkt_type = $5;
pkt_size = $6;
flgStr = $7;
flow_id = $8;
src_addr = $9;
dest_addr = $10;
pkt_id = $11;
sub(/^_*/, "", node);
sub(/_*$/, "", node);
if(pkt_type == "cbr"){
if (pkt_id > idHighestPacket) idHighestPacket = pkt_id;
if (pkt_id < idLowestPacket) idLowestPacket = pkt_id;
if(rTime<rStartTime) rStartTime=rTime;
if(rTime>rEndTime) rEndTime=rTime;
if ( strEvent == "+" && pkt_size == PKT_SIZE_CBR) {
source = int(from_node)
potential_source = int(src_addr)
if(source == potential_source) {
nSentPackets += 1 ;
rSentTime[ pkt_id ] = rTime ;
sent[pkt_id] = 1;
}
}
potential_dest = int(to_node)
dest = int(dest_addr)
if ( strEvent == "r" && potential_dest == dest && pkt_size == PKT_SIZE_CBR && sent[pkt_id] == 1) {
nReceivedPackets += 1 ;
nReceivedBytes += pkt_size;
rReceivedTime[ pkt_id ] = rTime ;
rDelay[pkt_id] = rReceivedTime[ pkt_id] - rSentTime[ pkt_id ];
rTotalDelay += rDelay[pkt_id];
}
if(strEvent == "d" && pkt_size == PKT_SIZE_CBR){
# printf("Packet Dropped\n");
nDropPackets += 1;
}
}
}
END {
rTime = rEndTime - rStartTime ;
rThroughput = nReceivedBytes*8 / rTime;
rPacketDeliveryRatio = (nReceivedPackets / nSentPackets) * 100 ;
rPacketDropRatio = (nDropPackets / nSentPackets) * 100;
if ( nReceivedPackets != 0 ) {
rAverageDelay = rTotalDelay / nReceivedPackets ;
}
printf( "%15.2f\n%15.5f\n%15.2f\n%15.2f\n", rThroughput, rAverageDelay, nSentPackets, nReceivedPackets);
printf( "%15.2f\n%10.2f\n%10.2f\n%10.5f\n", nDropPackets, rPacketDeliveryRatio, rPacketDropRatio,rTime);
printf("%15.5f\n",rTotalDelay);
}