2017-11-05 20:47:39 +00:00
|
|
|
#!/bin/bash
|
2018-05-19 15:50:10 +00:00
|
|
|
source ../utils.sh
|
2017-11-05 20:47:39 +00:00
|
|
|
|
|
|
|
# Contiki directory
|
|
|
|
CONTIKI=$1
|
|
|
|
|
|
|
|
# Simulation file
|
|
|
|
BASENAME=$2
|
|
|
|
|
2017-11-10 20:32:46 +00:00
|
|
|
# Destination IPv6
|
|
|
|
IPADDR=$3
|
|
|
|
|
2018-03-27 09:01:41 +00:00
|
|
|
# Time allocated for convergence
|
|
|
|
WAIT_TIME=$4
|
|
|
|
|
2018-04-06 19:19:23 +00:00
|
|
|
# Payload len. Default is ping6's default, 56.
|
|
|
|
PING_SIZE=${5:-56}
|
|
|
|
|
|
|
|
# Inter-ping delay. Default is ping6's default, 1s.
|
|
|
|
PING_DELAY=${6:-1}
|
|
|
|
|
2018-01-27 16:27:02 +00:00
|
|
|
# ICMP request-reply count
|
|
|
|
COUNT=5
|
|
|
|
|
2017-11-05 20:47:39 +00:00
|
|
|
# Start simulation
|
|
|
|
echo "Starting Cooja simulation $BASENAME.csc"
|
2017-11-11 14:05:27 +00:00
|
|
|
java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$BASENAME.csc -contiki=$CONTIKI > $BASENAME.coojalog &
|
2017-11-05 20:47:39 +00:00
|
|
|
JPID=$!
|
|
|
|
sleep 20
|
|
|
|
|
2018-05-28 18:56:12 +00:00
|
|
|
# Connect to the simulation
|
2017-11-05 20:47:39 +00:00
|
|
|
echo "Starting tunslip6"
|
2018-05-28 18:56:12 +00:00
|
|
|
make -C $CONTIKI/examples/rpl-border-router/ connect-router-cooja TARGET=zoul >> $BASENAME.tunslip6.log 2>&1 &
|
2017-11-05 20:47:39 +00:00
|
|
|
MPID=$!
|
2018-03-27 09:01:41 +00:00
|
|
|
printf "Waiting for network formation (%d seconds)\n" "$WAIT_TIME"
|
|
|
|
sleep $WAIT_TIME
|
2017-11-05 20:47:39 +00:00
|
|
|
|
|
|
|
# Do ping
|
|
|
|
echo "Pinging"
|
2018-04-06 19:19:23 +00:00
|
|
|
ping6 $IPADDR -c $COUNT -s $PING_SIZE -i $PING_DELAY | tee $BASENAME.scriptlog
|
2017-11-05 20:47:39 +00:00
|
|
|
# Fetch ping6 status code (not $? because this is piped)
|
|
|
|
STATUS=${PIPESTATUS[0]}
|
2018-01-27 16:27:02 +00:00
|
|
|
REPLIES=`grep -c 'icmp_seq=' $BASENAME.scriptlog`
|
2017-11-05 20:47:39 +00:00
|
|
|
|
|
|
|
echo "Closing simulation and tunslip6"
|
2017-11-11 14:05:27 +00:00
|
|
|
sleep 1
|
2018-05-19 15:50:10 +00:00
|
|
|
kill_bg $JPID
|
|
|
|
kill_bg $MPID
|
2017-11-11 14:05:27 +00:00
|
|
|
sleep 1
|
|
|
|
rm COOJA.testlog
|
|
|
|
rm COOJA.log
|
2017-11-05 20:47:39 +00:00
|
|
|
|
2018-01-27 16:27:02 +00:00
|
|
|
if [ $STATUS -eq 0 ] && [ $REPLIES -eq $COUNT ] ; then
|
2017-11-14 09:00:15 +00:00
|
|
|
printf "%-32s TEST OK\n" "$BASENAME" | tee $BASENAME.testlog;
|
2017-11-05 20:47:39 +00:00
|
|
|
else
|
2017-11-17 22:24:28 +00:00
|
|
|
echo "==== $BASENAME.coojalog ====" ; cat $BASENAME.coojalog;
|
2018-05-28 18:56:12 +00:00
|
|
|
echo "==== $BASENAME.tunslip6.log ====" ; cat $BASENAME.tunslip6.log;
|
2017-11-17 22:24:28 +00:00
|
|
|
echo "==== $BASENAME.scriptlog ====" ; cat $BASENAME.scriptlog;
|
2017-11-11 14:05:27 +00:00
|
|
|
|
2017-11-14 09:00:15 +00:00
|
|
|
printf "%-32s TEST FAIL\n" "$BASENAME" | tee $BASENAME.testlog;
|
2017-11-05 20:47:39 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# We do not want Make to stop -> Return 0
|
|
|
|
# The Makefile will check if a log contains FAIL at the end
|
|
|
|
|
|
|
|
exit 0
|