2019-01-17 19:14:45 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-08-02 09:06:39 +02:00
|
|
|
export nwif=eth0
|
|
|
|
bandwidth=1e9
|
|
|
|
remotedir="$PWD"
|
|
|
|
provision=false
|
|
|
|
asynclist="sync async"
|
|
|
|
modelist="listener polling waitset"
|
|
|
|
sizelist="0 20 50 100 200 500 1000 2000 5000 10000 20000 50000 100000 200000 500000 1000000"
|
|
|
|
timeout=30
|
|
|
|
loopback=true
|
|
|
|
resultdir="throughput-result"
|
|
|
|
|
2019-01-21 17:22:21 +01:00
|
|
|
usage () {
|
|
|
|
cat >&2 <<EOF
|
|
|
|
usage: $0 [OPTIONS] user@remote [user@remote...]
|
2019-01-17 19:14:45 +01:00
|
|
|
|
2019-01-21 17:22:21 +01:00
|
|
|
OPTIONS
|
2019-08-02 09:06:39 +02:00
|
|
|
-i IF use network interface IF (default: $nwif)
|
|
|
|
-b 100|1000|B network bandwidth (100Mbps/1000Gbps or B bits/sec) for
|
|
|
|
calculating load % given load in bytes/second (default: 1000)
|
2019-01-21 17:22:21 +01:00
|
|
|
-d DIR use DIR on remote (default: PWD)
|
2019-08-02 09:06:39 +02:00
|
|
|
-p provision required binaries in DIR (default: $provision)
|
2019-01-21 17:22:21 +01:00
|
|
|
first ssh's in to try mkdir -p DIR, then follows up with scp
|
2019-08-02 09:06:39 +02:00
|
|
|
-t DUR run for DUR seconds per size (default $timeout)
|
|
|
|
-a ASYNCLIST run for delivery async settings ASYNCLIST (default:
|
|
|
|
"$asynclist")
|
|
|
|
-m MODELIST run with subscriber mode settings MODELIST (default:
|
|
|
|
"$modelist")
|
|
|
|
-s SIZELIST run for sizes in SIZELIST (default: "$sizelist")
|
|
|
|
if SIZELIST is empty, it uses ddsperf's OU topic instead
|
|
|
|
-l LOOPBACK enable/disable multicast loopback (true/false, default: $loopback)
|
|
|
|
-o DIR store results in dir (default: $resultdir)
|
2019-01-21 17:22:21 +01:00
|
|
|
|
2019-08-02 09:06:39 +02:00
|
|
|
Local host runs "ddsperf" in subscriber mode, first remote runs it publisher
|
|
|
|
mode, further remotes also run subcribers. It assumes these are available in
|
|
|
|
DIR/bin. It also assumes that ssh user@remote works without requiring a
|
|
|
|
password.
|
2019-01-17 19:14:45 +01:00
|
|
|
EOF
|
|
|
|
exit 1
|
2019-01-21 17:22:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
while getopts "i:b:d:pa:m:s:t:o:l:" opt ; do
|
|
|
|
case $opt in
|
|
|
|
i) nwif="$OPTARG" ;;
|
2019-08-02 09:06:39 +02:00
|
|
|
b) case "$OPTARG" in
|
|
|
|
100) bandwidth=1e8 ;;
|
|
|
|
1000) bandwidth=1e9 ;;
|
|
|
|
*) bandwidth="$OPTARG" ;;
|
|
|
|
esac ;;
|
2019-01-21 17:22:21 +01:00
|
|
|
d) remotedir="$OPTARG" ;;
|
|
|
|
p) provision=true ;;
|
|
|
|
a) asynclist="$OPTARG" ;;
|
|
|
|
m) modelist="$OPTARG" ;;
|
|
|
|
s) sizelist="$OPTARG" ;;
|
|
|
|
l) loopback="OPTARG" ;;
|
|
|
|
t) timeout="$OPTARG" ;;
|
|
|
|
o) resultdir="$OPTARG" ;;
|
|
|
|
h) usage ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $((OPTIND-1))
|
|
|
|
if [ $# -lt 1 ] ; then usage ; fi
|
|
|
|
pubremote=$1
|
|
|
|
shift
|
2019-01-17 19:14:45 +01:00
|
|
|
|
|
|
|
cfg=cdds-simple.xml
|
|
|
|
cat >$cfg <<EOF
|
|
|
|
<CycloneDDS>
|
|
|
|
<Domain>
|
|
|
|
<Id>17</Id>
|
|
|
|
</Domain>
|
2019-08-02 09:06:39 +02:00
|
|
|
<General>
|
|
|
|
<NetworkInterfaceAddress>$nwif</NetworkInterfaceAddress>
|
|
|
|
<EnableMulticastLoopback>$loopback</EnableMulticastLoopback>
|
|
|
|
<MaxMessageSize>65500B</MaxMessageSize>
|
|
|
|
<FragmentSize>4000B</FragmentSize>
|
|
|
|
</General>
|
|
|
|
<Internal>
|
|
|
|
<Watermarks>
|
|
|
|
<WhcHigh>500kB</WhcHigh>
|
|
|
|
</Watermarks>
|
|
|
|
<SynchronousDeliveryPriorityThreshold>\${async:-0}</SynchronousDeliveryPriorityThreshold>
|
|
|
|
<LeaseDuration>3s</LeaseDuration>
|
|
|
|
</Internal>
|
|
|
|
<Tracing>
|
|
|
|
<Verbosity>config</Verbosity>
|
|
|
|
</Tracing>
|
2019-01-17 19:14:45 +01:00
|
|
|
</CycloneDDS>
|
|
|
|
EOF
|
|
|
|
|
2019-08-02 09:06:39 +02:00
|
|
|
if [ ! -x bin/ddsperf ] ; then
|
|
|
|
echo "bin/ddsperf not found on the local machine" >&2
|
2019-01-17 19:14:45 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-01-21 17:22:21 +01:00
|
|
|
[ -d $resultdir ] || { echo "output directory $resultdir doesn't exist" >&2 ; exit 1 ; }
|
|
|
|
|
|
|
|
if $provision ; then
|
|
|
|
echo "provisioning ..."
|
|
|
|
for r in $pubremote "$@" ; do
|
|
|
|
ssh $r mkdir -p $remotedir $remotedir/bin $remotedir/lib
|
|
|
|
scp lib/libddsc.so.0 $r:$remotedir/lib
|
2019-08-02 09:06:39 +02:00
|
|
|
scp bin/ddsperf $r:$remotedir/bin
|
2019-01-21 17:22:21 +01:00
|
|
|
done
|
|
|
|
fi
|
2019-01-17 19:14:45 +01:00
|
|
|
|
2019-08-02 09:06:39 +02:00
|
|
|
topic=KS
|
|
|
|
[ -z "$sizelist" ] && topic=OU
|
|
|
|
|
2019-01-17 19:14:45 +01:00
|
|
|
export CYCLONEDDS_URI=file://$PWD/$cfg
|
2019-01-21 17:22:21 +01:00
|
|
|
for r in $pubremote "$@" ; do
|
|
|
|
scp $cfg $r:$remotedir || { echo "failed to copy $cfg to $remote:$PWD" >&2 ; exit 1 ; }
|
|
|
|
done
|
2019-01-17 19:14:45 +01:00
|
|
|
|
2019-08-02 09:06:39 +02:00
|
|
|
for async_mode in $asynclist ; do
|
|
|
|
case "$async_mode" in
|
|
|
|
sync) async=0 ;;
|
|
|
|
async) async=1 ;;
|
|
|
|
*) echo "$async_mode: invalid setting for ASYNC" >&2 ; continue ;;
|
|
|
|
esac
|
2019-01-21 17:22:21 +01:00
|
|
|
export async
|
2019-08-02 09:06:39 +02:00
|
|
|
for sub_mode in $modelist ; do
|
|
|
|
echo "======== ASYNC $async MODE $sub_mode ========="
|
2019-01-21 17:22:21 +01:00
|
|
|
|
2019-01-17 19:14:45 +01:00
|
|
|
cat > run-publisher.tmp <<EOF
|
2019-01-21 17:22:21 +01:00
|
|
|
export CYCLONEDDS_URI=file://$remotedir/$cfg
|
|
|
|
export async=$async
|
|
|
|
cd $remotedir
|
2019-08-02 09:06:39 +02:00
|
|
|
for size in ${sizelist:-0} ; do
|
2019-01-17 19:14:45 +01:00
|
|
|
echo "size \$size"
|
2019-08-02 09:06:39 +02:00
|
|
|
bin/ddsperf -D $timeout -T $topic pub size \$size > pub.log
|
2019-01-17 19:14:45 +01:00
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
wait
|
|
|
|
EOF
|
2019-01-21 17:22:21 +01:00
|
|
|
scp run-publisher.tmp $pubremote:$remotedir || { echo "failed to copy $cfg to $remote:$PWD" >&2 ; exit 2 ; }
|
|
|
|
killremotesubs=""
|
|
|
|
if [ $# -gt 0 ] ; then
|
|
|
|
cat > run-subscriber.tmp <<EOF
|
|
|
|
export CYCLONEDDS_URI=file://$remotedir/$cfg
|
|
|
|
export async=$async
|
|
|
|
cd $remotedir
|
2019-08-02 09:06:39 +02:00
|
|
|
nohup bin/ddsperf -T $topic sub $sub_mode > /dev/null &
|
2019-01-21 17:22:21 +01:00
|
|
|
echo \$!
|
|
|
|
EOF
|
|
|
|
for r in "$@" ; do
|
|
|
|
scp run-subscriber.tmp $r:$remotedir
|
|
|
|
rsubpid=`ssh $r ". $remotedir/run-subscriber.tmp"`
|
|
|
|
killremotesubs="$killremotesubs ssh $r kill -9 $rsubpid &"
|
|
|
|
done
|
|
|
|
fi
|
2019-08-02 09:06:39 +02:00
|
|
|
|
|
|
|
outdir=$resultdir/$async_mode-$sub_mode
|
2019-01-17 19:14:45 +01:00
|
|
|
mkdir $outdir
|
|
|
|
|
2019-08-02 09:06:39 +02:00
|
|
|
bin/ddsperf -d $nwif:$bandwidth -c -T $topic sub $sub_mode > $outdir/sub.log & spid=$!
|
2019-01-17 19:14:45 +01:00
|
|
|
tail -f $outdir/sub.log & xpid=$!
|
2019-01-21 17:22:21 +01:00
|
|
|
ssh $pubremote ". $remotedir/run-publisher.tmp"
|
2019-08-02 09:06:39 +02:00
|
|
|
kill $spid
|
2019-01-21 17:22:21 +01:00
|
|
|
eval $killremotesubs
|
2019-01-17 19:14:45 +01:00
|
|
|
sleep 1
|
2019-08-02 09:06:39 +02:00
|
|
|
kill $xpid
|
2019-01-17 19:14:45 +01:00
|
|
|
wait
|
2019-08-02 09:06:39 +02:00
|
|
|
scp $pubremote:$remotedir/pub.log $outdir
|
2019-01-17 19:14:45 +01:00
|
|
|
done
|
|
|
|
done
|