Last change
on this file since 997 was
997,
checked in by cfuguet, 9 years ago
|
reconf: improve the recovery broadcast replication policy
- Improve the validation scripts for this replication policy.
|
-
Property svn:executable set to
*
|
File size:
1.6 KB
|
Rev | Line | |
---|
[994] | 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 |
---|
[997] | 12 | min=99999999 |
---|
| 13 | max=0 |
---|
[994] | 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 | } |
---|
[996] | 33 | |
---|
[994] | 34 | # Parse the number of received broadcast packets |
---|
| 35 | /broadcast received packets +=/ { |
---|
| 36 | if ($6 == 0) { |
---|
| 37 | zero++; |
---|
| 38 | } |
---|
| 39 | else { |
---|
[997] | 40 | # store the min and max number of received packets |
---|
| 41 | if ($6 < min) { |
---|
| 42 | min=$6; |
---|
[994] | 43 | } |
---|
[997] | 44 | if ($6 > max) { |
---|
| 45 | max=$6; |
---|
[994] | 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. |
---|
[997] | 54 | if (zero > 2) { |
---|
| 55 | print "error: some routers did not received broadcasts\n"; |
---|
[994] | 56 | exit 1; |
---|
| 57 | } |
---|
| 58 | |
---|
[997] | 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"; |
---|
[994] | 62 | exit 1; |
---|
| 63 | } |
---|
| 64 | |
---|
[997] | 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 > 20) { |
---|
| 72 | print "error: the number of broadcast received by a router is inferior " |
---|
| 73 | print "to the error threshold\n"; |
---|
| 74 | exit 1; |
---|
| 75 | } |
---|
| 76 | |
---|
[994] | 77 | exit 0; |
---|
| 78 | }' $file |
---|
| 79 | if [[ $? == 1 ]]; then exit 1; fi |
---|
| 80 | |
---|
Note: See
TracBrowser
for help on using the repository browser.