2022-12-21 13:08:24 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
#MAX and MIN for topics and num nodes
|
|
|
|
MIN=5
|
|
|
|
MAX=100
|
|
|
|
|
|
|
|
#requires bc
|
|
|
|
getrand(){
|
|
|
|
orig=$(od -An -N1 -i /dev/urandom)
|
|
|
|
range=`echo "$MIN + ($orig % ($MAX - $MIN + 1))" | bc`
|
|
|
|
RANDOM=$range
|
|
|
|
}
|
|
|
|
|
|
|
|
getrand1(){
|
|
|
|
orig=$(od -An -N1 -i /dev/urandom)
|
|
|
|
range=`echo "$MIN + ($orig % ($MAX - $MIN + 1))" | bc`
|
|
|
|
return range
|
|
|
|
#getrand1 # call the fun and use the return value
|
|
|
|
#n=$?
|
|
|
|
}
|
|
|
|
|
2022-12-30 13:47:21 +00:00
|
|
|
if [ "$#" -ne 2 ] || [ $2 -le 0 ] ; then
|
2022-12-21 13:08:24 +00:00
|
|
|
echo "usage: $0 <output dir> <#json files needed>" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
path=$1
|
|
|
|
nfiles=$2
|
2022-12-30 13:47:21 +00:00
|
|
|
mkdir -p $path
|
2022-12-21 13:08:24 +00:00
|
|
|
|
|
|
|
echo "Ok, will generate $nfiles networks & put them under '$path'."
|
2022-12-30 13:47:21 +00:00
|
|
|
|
2023-01-06 11:56:57 +00:00
|
|
|
nwtype="newmanwattsstrogatz"
|
|
|
|
nodetype="desktop"
|
2022-12-21 13:08:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
for i in $(seq $nfiles)
|
|
|
|
do
|
|
|
|
getrand
|
|
|
|
n=$((RANDOM+1))
|
|
|
|
getrand
|
|
|
|
t=$((RANDOM+1))
|
2023-01-06 11:56:57 +00:00
|
|
|
getrand
|
|
|
|
s=`expr $((RANDOM+1)) % $n`
|
|
|
|
|
2022-12-30 13:47:21 +00:00
|
|
|
dirname="$path/$i/Waku"
|
|
|
|
mkdir "$path/$i"
|
2023-01-06 11:56:57 +00:00
|
|
|
echo "Generating ./generate_network.py --dirname $dirname --num-nodes $n --num-topics $t --nw-type $nwtype --node-type $nodetype --num-partitions 1 --num-subnets $s ...."
|
|
|
|
$(./generate_network.py --dirname $dirname --num-nodes $n --num-topics $t --nw-type $nwtype --node-type $nodetype --num-partitions 1 --num-subnets $s)
|
2022-12-21 13:08:24 +00:00
|
|
|
done
|