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

Last change on this file since 996 was 996, checked in by cfuguet, 10 years ago

reconf: introduce scripts to get transactions latency in the synthetic
platform.

  • Property svn:executable set to *
File size: 1.5 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.
6file=$1
7awk '
8BEGIN {
9        sent=0
10        last=0
11        failure=0
12}
13#   Parse coordinates of routers
14#   /DSPIN_GENERATOR/ {
15#       regex="\\[[0-9]+\\]\\[";
16#       if (match($2,regex)) {
17#               x=substr($2,RSTART+1,RLENGTH-3);
18#       }
19#       regex="\\]\\[[0-9]+\\]";
20#       if (match($2,regex)) {
21#               y=substr($2,RSTART+2,RLENGTH-3);
22#       }
23#   }
24
25#   Parse the number of sent broadcast packets
26/broadcast sent packets += +/ {
27        if ($6 != 0) {
28                sent=$6;
29        }
30}
31
32#   Parse the number of received broadcast packets
33/broadcast received packets +=/ {
34        if ($6 == 0) {
35                zero++;
36        }
37        else {
38                # store the number of received packets of a router that actually
39                # received packets.
40                if (last == 0) {
41                        last=$6
42                }
43                # test if the error is too important. The error is defined as
44                # difference between the number of packets received by different
45                # routers.
46                error=last - $6
47                if ((error > 20) || (error < -20)) {
48                        failure=1
49                        exit;
50                }
51        }
52}
53
54#   Validate the file
55END {
56        # an error was too important
57        if (failure == 1) {
58                exit 1
59        }
60
61        # it should be only two routers that do not receive the broadcast:
62        # the source and the faulty router.
63        if (zero != 2) {
64                exit 1;
65        }
66
67        # test if the error is too important
68        error=last - sent
69        if ((error > 20) || (error < -20)) {
70                exit 1;
71        }
72
73        exit 0;
74}' $file
75if [[ $? == 1 ]]; then exit 1; fi
76
Note: See TracBrowser for help on using the repository browser.