zonewalk-to-types.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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. NUM_CLIENTS=3
  6. # How many different groups of names should we
  7. # create? 1/N will be in the 'shared' group.
  8. # FILE ($1) contains results from DNS lookup; strip
  9. # everything but the hostnames, remove duplicates
  10. # and then randomize the order.
  11. cat $1 | grep -v SOA | awk '{print $1}' | sort | uniq | shuf > $1.tmp
  12. TOTAL=`cat $1.tmp | wc -l`
  13. GROUP_SIZE=`expr $TOTAL / \( $NUM_CLIENTS + 1 \)`
  14. echo "Creating $NUM_CLIENTS benchmark sets with 2x $GROUP_SIZE entries each."
  15. # First group (0) is to be shared among all clients
  16. for i in `seq 1 $NUM_CLIENTS`
  17. do
  18. cat $1.tmp | head -n $GROUP_SIZE | awk "{print 0 \" \" \$1}" > $1.$i.tmp
  19. done
  20. # Second group (1) is unique per client
  21. OFF=$GROUP_SIZE
  22. for i in `seq 1 $NUM_CLIENTS`
  23. do
  24. END=`expr $OFF + $GROUP_SIZE`
  25. cat $1.tmp | head -n $END | tail -n $GROUP_SIZE | awk "{print 1 \" \" \$1}" >> $1.$i.tmp
  26. # Shuffle again, so we mix the different request categories in terms of
  27. # when we issue the queries.
  28. cat $1.$i.tmp | shuf > $1.$i
  29. OFF="$END"
  30. rm $1.$i.tmp
  31. done
  32. rm $1.tmp