Last change
on this file since 1020 was
1020,
checked in by cfuguet, 8 years ago
|
reconf: improving dspin_router transition function.
|
-
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 | fname=$1 |
---|
7 | npkts=$2 |
---|
8 | |
---|
9 | awk ' |
---|
10 | BEGIN { |
---|
11 | npkts=50 |
---|
12 | |
---|
13 | rcvpkts=0 |
---|
14 | nrecvrs=0 |
---|
15 | |
---|
16 | sndpkts=0 |
---|
17 | nsendrs=0 |
---|
18 | } |
---|
19 | |
---|
20 | # Parse the number of sent broadcast packets |
---|
21 | /broadcast sent packets += +/ { |
---|
22 | sent=$6 |
---|
23 | if (sent > 0) { |
---|
24 | if (nsendrs > 1) { |
---|
25 | print "error: more than one initiator sent broadcast packets\n" |
---|
26 | exit 1 |
---|
27 | } |
---|
28 | if (sent != npkts) { |
---|
29 | print "error: the number of sent broadcast packets does not " |
---|
30 | print "correspond to the one specified\n" |
---|
31 | exit 1 |
---|
32 | } |
---|
33 | nsendrs++; |
---|
34 | sndpkts=sent; |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | # Parse the number of received broadcast packets |
---|
39 | /broadcast received packets +=/ { |
---|
40 | received=$6 |
---|
41 | if (received == 0) { |
---|
42 | zero++; |
---|
43 | } |
---|
44 | else { |
---|
45 | if (received != npkts) { |
---|
46 | print "error: at least a router received a number of broadcast "; |
---|
47 | if (received > npkts) { |
---|
48 | print "greater than the number of broadcast sent\n"; |
---|
49 | } |
---|
50 | else { |
---|
51 | print "less than the number of broadcast sent\n"; |
---|
52 | } |
---|
53 | exit 1 |
---|
54 | } |
---|
55 | nrecvrs++; |
---|
56 | rcvpkts=received |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
60 | # Validate the file |
---|
61 | END { |
---|
62 | # it should be only two routers that do not receive the broadcast: |
---|
63 | # the source and the faulty router. |
---|
64 | if (zero > 2) { |
---|
65 | print "error: some routers did not received broadcasts\n"; |
---|
66 | exit 1; |
---|
67 | } |
---|
68 | if (zero == 1) { |
---|
69 | print "error: the broadcast source received broadcasts\n"; |
---|
70 | exit 1; |
---|
71 | } |
---|
72 | |
---|
73 | print "sent: " sndpkts " / # senders: " nsendrs; |
---|
74 | print "received: " rcvpkts " / # receivers " nrecvrs "\n"; |
---|
75 | exit 0; |
---|
76 | }' $fname |
---|
77 | if [[ $? == 1 ]]; then exit 1; fi |
---|
78 | |
---|
Note: See
TracBrowser
for help on using the repository browser.