Skip to content
Snippets Groups Projects
Commit e4619854 authored by Tobias Kahlki's avatar Tobias Kahlki
Browse files

scripts:network: Add UDP network test service

parent 53b93b15
No related branches found
No related tags found
1 merge request!270tests:network: Add UDP echo server and client
#!/bin/sh
#
# Idea of the test: l2test send and receives packages, and dumps them to a logfile
# This script, clears the logfile a start, waits some time, then checks the log
# for new received packages.
#
LOGFILE=""
COUNT=0
NUMBER=-1
if [ -z "$1" ]; then
echo "Path to logfile must be set; Exiting ..."
exit 1
fi
LOGFILE="$1"
true > "$LOGFILE"
sleep 0.5
while read -r no
do
nodec="$( printf "%d" "${no}" 2>/dev/null )";
if [ $? != 0 ];
then
echo "Sequence number format mismatch"
continue
fi
echo "SEQ: $nodec"
COUNT=$(( COUNT + 1 ))
if [ "$NUMBER" = -1 ]
then
NUMBER="$nodec"
continue
else
NUMBER="$(( NUMBER + 1 ))"
if [ "$NUMBER" != "$nodec" ]
then
echo "Sequence number did not match"
exit 1
fi
fi
done <<< $( sed -n 's/SEQ: \([0-9]\+\) .*/\1/p' ${LOGFILE} )
if [ $COUNT -lt 3 ]
then
echo "Not enough packages received ( $COUNT )."
exit 1
fi
echo "Received $COUNT packages."
exit 0
#!/bin/sh
TARGET="192.168.3.100"
if [ -n "$1" ]; then
TARGET="$1"
fi
if [ -n "$2" ]; then
LOGFILE="$2"
else
LOGFILE="/tmp/network_$TARGET.log"
fi
echo "Start echo client to $TARGET (Logfile: $LOGFILE)"
true > "$LOGFILE"
while true
do
/root/udp_client "$TARGET" >> "$LOGFILE"
sleep 0.3
echo "Restarting echo client to $TARGET"
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment