-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpropagation.sh
executable file
·48 lines (45 loc) · 1.26 KB
/
propagation.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
timestamp() {
date '+%s%N' --date="$1"
}
echo "Insert number of sealers nodes"
read sealers
echo "Insert total number of nodes"
read nodes
for((c=1;c<=$sealers;c++))
do
awk /'mined/ {print $8}' node$c.txt | cut -c 6- >> hashnode$c.txt
done
cat hashnode*.txt > totalhash.txt
rm hashnode*.txt
tot=`wc -l < totalhash.txt`
echo $tot
for((x=1;x<=$tot;x++))
do
for ((y=1;y<=$nodes;y++))
do
var1=`sed -n "$x"p totalhash.txt`
mod=`grep -- "$var1" node$y.txt | awk '{print $2}'`
echo $mod | cut -c 8- | rev | cut -c 2- | rev >> temp/filenode$x.txt
done
awk '{ print $1}' temp/filenode$x.txt > temp/finalfilenode$x.txt
done
sed -i '/^$/d' temp/*.txt
rm temp/filenode*.txt
for((p=1;p<=$tot;p++))
do
cut -d ']' -f 1 temp/finalfilenode$p.txt > temp/final$p.txt
done
rm temp/finalfile*.txt
for((p=1;p<=$tot;p++))
do
min=`sort temp/final$p.txt | head -1`
max=`sort temp/final$p.txt | tail -1`
difference="$(( $(timestamp "$max") - $(timestamp "$min") ))"
totaldiff=`echo $difference / 1000000 | bc -l`
echo $totaldiff
echo $totaldiff >> timepropagation.txt
done
average_prop=`awk '{s+=$1} END {print s/NR}' timepropagation.txt`
echo "The propagation time on average is " $average_prop "ms"
echo $average_prop >> /home/ubuntu/statistiche/$nodes/average_prop.txt