Last change
on this file since 1016 was
998,
checked in by cfuguet, 9 years ago
|
reconf: several improvements in the dspin_router synthetic test platform
|
-
Property svn:executable set to
*
|
File size:
1.6 KB
|
Line | |
---|
1 | #!/usr/bin/env sh |
---|
2 | # @author Cesar Armando Fuguet Tortolero |
---|
3 | # @date 24 May, 2015 |
---|
4 | # @brief This script validates that a broadcast transaction reaches once |
---|
5 | # and only once every non-faulty router in the platform. |
---|
6 | file=$1 |
---|
7 | awk ' |
---|
8 | BEGIN { |
---|
9 | sent=0 |
---|
10 | last=0 |
---|
11 | failure=0 |
---|
12 | min=99999999 |
---|
13 | max=0 |
---|
14 | } |
---|
15 | # Parse coordinates of routers |
---|
16 | # /DSPIN_GENERATOR/ { |
---|
17 | # regex="\\[[0-9]+\\]\\["; |
---|
18 | # if (match($2,regex)) { |
---|
19 | # x=substr($2,RSTART+1,RLENGTH-3); |
---|
20 | # } |
---|
21 | # regex="\\]\\[[0-9]+\\]"; |
---|
22 | # if (match($2,regex)) { |
---|
23 | # y=substr($2,RSTART+2,RLENGTH-3); |
---|
24 | # } |
---|
25 | # } |
---|
26 | |
---|
27 | # Parse the number of sent broadcast packets |
---|
28 | /broadcast sent packets += +/ { |
---|
29 | if ($6 != 0) { |
---|
30 | sent=$6; |
---|
31 | } |
---|
32 | } |
---|
33 | |
---|
34 | # Parse the number of received broadcast packets |
---|
35 | /broadcast received packets +=/ { |
---|
36 | if ($6 == 0) { |
---|
37 | zero++; |
---|
38 | } |
---|
39 | else { |
---|
40 | # store the min and max number of received packets |
---|
41 | if ($6 < min) { |
---|
42 | min=$6; |
---|
43 | } |
---|
44 | if ($6 > max) { |
---|
45 | max=$6; |
---|
46 | } |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | # Validate the file |
---|
51 | END { |
---|
52 | # it should be only two routers that do not receive the broadcast: |
---|
53 | # the source and the faulty router. |
---|
54 | if (zero > 2) { |
---|
55 | print "error: some routers did not received broadcasts\n"; |
---|
56 | exit 1; |
---|
57 | } |
---|
58 | |
---|
59 | if (max > sent) { |
---|
60 | print "error: at least a router received a number of broadcast greater" |
---|
61 | print "than the number of broadcast sent\n"; |
---|
62 | exit 1; |
---|
63 | } |
---|
64 | |
---|
65 | if (zero == 1) { |
---|
66 | print "error: the broadcast source received broadcasts\n"; |
---|
67 | exit 1; |
---|
68 | } |
---|
69 | |
---|
70 | error=sent - min |
---|
71 | if (error > 0) { |
---|
72 | print "error: the number of broadcast received by a router is inferior " |
---|
73 | print "to the error threshold: error = " error "\n"; |
---|
74 | exit 1; |
---|
75 | } |
---|
76 | |
---|
77 | exit 0; |
---|
78 | }' $file |
---|
79 | if [[ $? == 1 ]]; then exit 1; fi |
---|
80 | |
---|
Note: See
TracBrowser
for help on using the repository browser.