fix #5676
[oweals/gnunet.git] / contrib / scripts / zonewalk-to-types.sh
1 #!/bin/sh
2 # This script is in the public domain.
3 # Converts the output of gnunet-zonewalk (DNS resolutions)
4 # into a proper input for gnunet-gns-benchmark.
5
6 NUM_CLIENTS=3
7 # How many different groups of names should we
8 # create?  1/N will be in the 'shared' group.
9
10 # FILE ($1) contains results from DNS lookup; strip
11 # everything but the hostnames, remove duplicates
12 # and then randomize the order.
13 cat $1 | grep -v SOA | awk '{print $1}' | sort | uniq | shuf > $1.tmp
14 TOTAL=`cat $1.tmp | wc -l`
15 GROUP_SIZE=`expr $TOTAL / \( $NUM_CLIENTS + 1 \)`
16 echo "Creating $NUM_CLIENTS benchmark sets with 2x $GROUP_SIZE entries each."
17 # First group (0) is to be shared among all clients
18 for i in `seq 1 $NUM_CLIENTS`
19 do
20   cat $1.tmp | head -n $GROUP_SIZE | awk "{print 0 \" \" \$1}" > $1.$i.tmp
21 done
22
23 # Second group (1) is unique per client
24 OFF=$GROUP_SIZE
25 for i in `seq 1 $NUM_CLIENTS`
26 do
27   END=`expr $OFF + $GROUP_SIZE`
28   cat $1.tmp | head -n $END | tail -n $GROUP_SIZE | awk "{print 1 \" \" \$1}" >> $1.$i.tmp
29 # Shuffle again, so we mix the different request categories in terms of
30 # when we issue the queries.
31   cat $1.$i.tmp | shuf > $1.$i
32   OFF="$END"
33   rm $1.$i.tmp
34 done
35 rm $1.tmp