source: branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/broadcast_check.sh @ 1029

Last change on this file since 1029 was 1020, checked in by cfuguet, 9 years ago

reconf: improving dspin_router transition function.

  • Property svn:executable set to *
File size: 1.6 KB
RevLine 
[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.
[1020]6fname=$1
7npkts=$2
8
[994]9awk '
10BEGIN {
[1020]11        npkts=50
12
13        rcvpkts=0
14        nrecvrs=0
15
16        sndpkts=0
17        nsendrs=0
[994]18}
19
20#   Parse the number of sent broadcast packets
21/broadcast sent packets += +/ {
[1020]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;
[994]35        }
36}
[996]37
[994]38#   Parse the number of received broadcast packets
39/broadcast received packets +=/ {
[1020]40        received=$6
41        if (received == 0) {
[994]42                zero++;
43        }
44        else {
[1020]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
[994]54                }
[1020]55                nrecvrs++;
56                rcvpkts=received
[994]57        }
58}
59
60#   Validate the file
61END {
62        # it should be only two routers that do not receive the broadcast:
63        # the source and the faulty router.
[997]64        if (zero > 2) {
65                print "error: some routers did not received broadcasts\n";
[994]66                exit 1;
67        }
[997]68        if (zero == 1) {
69                print "error: the broadcast source received broadcasts\n";
70                exit 1;
71        }
72
[1020]73        print "sent: " sndpkts " / # senders: " nsendrs;
74        print "received: " rcvpkts " / # receivers " nrecvrs "\n";
[994]75        exit 0;
[1020]76}' $fname
[994]77if [[ $? == 1 ]]; then exit 1; fi
78
Note: See TracBrowser for help on using the repository browser.