forked from wolfSSL/wolfssl
Able to adjust DTLS version globally
This commit is contained in:
@ -24,6 +24,7 @@ trap cleanup err exit
|
|||||||
|
|
||||||
WOLFSSL_ROOT=${WOLFSSL_ROOT:-$(pwd)}
|
WOLFSSL_ROOT=${WOLFSSL_ROOT:-$(pwd)}
|
||||||
UDP_PROXY_BIN=${UDP_PROXY_BIN:-"udp_proxy"}
|
UDP_PROXY_BIN=${UDP_PROXY_BIN:-"udp_proxy"}
|
||||||
|
DTLS_VERSION=${DTLS_VERSION:-"-v4"}
|
||||||
PROXY_PORT=1234
|
PROXY_PORT=1234
|
||||||
SERVER_PORT=4321
|
SERVER_PORT=4321
|
||||||
KEY_UPDATE_SIZE=35
|
KEY_UPDATE_SIZE=35
|
||||||
@ -37,13 +38,13 @@ prepend() { # Usage: cmd 2>&1 | prepend "sometext "
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_test() { # usage: run_test "<udp-proxy args>" "<server args>" "<client args>"
|
run_test() { # usage: run_test "<udp-proxy args>" "<server args>" "<client args>"
|
||||||
stdbuf -oL -eL $WOLFSSL_ROOT/examples/server/server -u -p$SERVER_PORT $2 2>&1 | prepend "[server] " &
|
stdbuf -oL -eL $WOLFSSL_ROOT/examples/server/server -u -p$SERVER_PORT $DTLS_VERSION $2 2>&1 | prepend "[server] " &
|
||||||
SERVER_PID=$!
|
SERVER_PID=$!
|
||||||
stdbuf -oL -eL $UDP_PROXY_BIN -p $PROXY_PORT -s 127.0.0.1:$SERVER_PORT -u $1 2>&1 | prepend "[udp-proxy] " &
|
stdbuf -oL -eL $UDP_PROXY_BIN -p $PROXY_PORT -s 127.0.0.1:$SERVER_PORT -u $1 2>&1 | prepend "[udp-proxy] " &
|
||||||
UDP_PROXY_PID=$(($! - 1))
|
UDP_PROXY_PID=$(($! - 1))
|
||||||
echo "UDP-proxy: $UDP_PROXY_PID"
|
echo "UDP-proxy: $UDP_PROXY_PID"
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
timeout -s KILL 5m stdbuf -oL -eL $WOLFSSL_ROOT/examples/client/client -u -p$PROXY_PORT $3 2>&1 | prepend "[client] "
|
timeout -s KILL 5m stdbuf -oL -eL $WOLFSSL_ROOT/examples/client/client -u -p$PROXY_PORT $DTLS_VERSION $3 2>&1 | prepend "[client] "
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "Test failed"
|
echo "Test failed"
|
||||||
((NUM_TESTS_FAILED++))
|
((NUM_TESTS_FAILED++))
|
||||||
@ -58,20 +59,20 @@ run_test() { # usage: run_test "<udp-proxy args>" "<server args>" "<client args>
|
|||||||
test_dropping_packets () {
|
test_dropping_packets () {
|
||||||
for i in $(seq 3 11);do
|
for i in $(seq 3 11);do
|
||||||
echo -e "\ndropping ${i}th packet\n"
|
echo -e "\ndropping ${i}th packet\n"
|
||||||
run_test "-d $i" "-v4 -Ta" "-v4"
|
run_test "-d $i" "-Ta" ""
|
||||||
done
|
done
|
||||||
|
|
||||||
# dropping last ack would be client error as wolfssl_read doesn't support WANT_WRITE as returned error
|
# dropping last ack would be client error as wolfssl_read doesn't support WANT_WRITE as returned error
|
||||||
for i in $(seq 0 10);do
|
for i in $(seq 0 10);do
|
||||||
echo -e "\nTesting WANT_WRITE: dropping packet $i\n"
|
echo -e "\nTesting WANT_WRITE: dropping packet $i\n"
|
||||||
run_test "-f $i" "-v4 -Ta -6" "-v4 -6"
|
run_test "-f $i" "-Ta -6" "-6"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# this test is based on detecting newSessionTicket message by its size. This is rather fragile.
|
# this test is based on detecting newSessionTicket message by its size. This is rather fragile.
|
||||||
test_dropping_new_session_ticket() { # usage: test_dropping_new_session_ticket <size>
|
test_dropping_new_session_ticket() { # usage: test_dropping_new_session_ticket <size>
|
||||||
echo -e "\ndropping new session ticket packet of size $1\n"
|
echo -e "\ndropping new session ticket packet of size $1\n"
|
||||||
run_test "-F $1" "-v4 -w" "-v4 -w --waitTicket"
|
run_test "-F $1" "-w" "-w --waitTicket"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_permutations () {
|
test_permutations () {
|
||||||
@ -86,7 +87,7 @@ EOF
|
|||||||
echo -e "\nTesting $SIDE permutations order $i...\n"
|
echo -e "\nTesting $SIDE permutations order $i...\n"
|
||||||
UDP_LOGFILE=/tmp/udp-$SIDE-$i
|
UDP_LOGFILE=/tmp/udp-$SIDE-$i
|
||||||
rm -f $UDP_LOGFILE
|
rm -f $UDP_LOGFILE
|
||||||
run_test "-r $i -S $SIDE -l $UDP_LOGFILE" "-v4 -Ta -w" "-v4 -w"
|
run_test "-r $i -S $SIDE -l $UDP_LOGFILE" "-Ta -w" "-w"
|
||||||
echo "...produced $(grep -P 'client:|server:' $UDP_LOGFILE | wc -l) messages"
|
echo "...produced $(grep -P 'client:|server:' $UDP_LOGFILE | wc -l) messages"
|
||||||
done
|
done
|
||||||
echo "All $SIDE msg permutations succeeded"
|
echo "All $SIDE msg permutations succeeded"
|
||||||
@ -108,13 +109,13 @@ EOF
|
|||||||
echo -e "\nTesting delay $DELAY...\n"
|
echo -e "\nTesting delay $DELAY...\n"
|
||||||
UDP_LOGFILE=/tmp/udp-delay-$DELAY
|
UDP_LOGFILE=/tmp/udp-delay-$DELAY
|
||||||
rm -f $UDP_LOGFILE
|
rm -f $UDP_LOGFILE
|
||||||
run_test "-l $UDP_LOGFILE -t $DELAY" "-v4 -Ta -w" "-v4 -w"
|
run_test "-l $UDP_LOGFILE -t $DELAY" "-Ta -w" "-w"
|
||||||
echo "...produced $(grep -P 'client:|server:' $UDP_LOGFILE | wc -l) messages"
|
echo "...produced $(grep -P 'client:|server:' $UDP_LOGFILE | wc -l) messages"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Starting capture"
|
echo "Starting capture"
|
||||||
tcpdump -i lo -n port ${SERVER_PORT} -w ./dtls.pcap -U &
|
tcpdump -i lo -n port ${SERVER_PORT} -w ./dtls${DTLS_VERSION}.pcap -U &
|
||||||
TCPDUMP_PID=$!
|
TCPDUMP_PID=$!
|
||||||
|
|
||||||
test_dropping_packets
|
test_dropping_packets
|
||||||
|
Reference in New Issue
Block a user