aboutsummaryrefslogtreecommitdiff
path: root/contrib/scripts/zonewalk-to-types.sh
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/scripts/zonewalk-to-types.sh')
-rwxr-xr-xcontrib/scripts/zonewalk-to-types.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/contrib/scripts/zonewalk-to-types.sh b/contrib/scripts/zonewalk-to-types.sh
new file mode 100755
index 000000000..c453702e6
--- /dev/null
+++ b/contrib/scripts/zonewalk-to-types.sh
@@ -0,0 +1,35 @@
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
6NUM_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.
13cat $1 | awk '{print $1}' | sort | uniq | shuf > $1.tmp
14TOTAL=`cat $1.tmp | wc -l`
15GROUP_SIZE=`expr $TOTAL / \( $NUM_TYPES + 1 \)`
16
17# First group (0) is to be shared among all clients
18for i in `seq 1 $NUM_CLIENTS`
19do
20 cat $1.tmp | head -n $GROUP_SIZE | awk "{print 0 \" \" \$1}" > $1.$i.tmp
21done
22
23# Second group (1) is unique per client
24OFF=0
25for i in `seq 1 $NUM_CLIENTS`
26do
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
34done
35rm $1.tmp