Skip to content
Extraits de code Groupes Projets
Valider 6a4b4685 rédigé par Samuel de Meester de Ravestein's avatar Samuel de Meester de Ravestein
Parcourir les fichiers

impr tests

parent 68fe64b0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Fichier ajouté
......@@ -197,12 +197,12 @@ int handle_returning_ack_nack(sender_state_t *state, int socket_fd)
gettimeofday(&time, NULL);
unsigned long long int delta_time = time_milliseconds(&time) - time_milliseconds(&state->timers_first_send[state->tail]);
float used_for_calculation = state->stats->avg_rtt * (state->nbr_of_acked_packets);
used_for_calculation += delta_time;
float temp_for_calculation = state->stats->avg_rtt * (state->nbr_of_acked_packets);
temp_for_calculation += delta_time;
state->nbr_of_acked_packets++;
used_for_calculation /= state->nbr_of_acked_packets;
temp_for_calculation /= state->nbr_of_acked_packets;
state->stats->avg_rtt = used_for_calculation;
state->stats->avg_rtt = (unsigned long long int) temp_for_calculation;
if (state->stats->min_rtt == 0 || state->stats->min_rtt > delta_time)
{
......
#!/bin/bash
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
if [ -z "$1" ]; then
echo "Not given the file to send"
exit 1
fi
# If the directory does not exist, we create it
if [ ! -d "tests_logs/advanced_tests/" ]; then
mkdir 'tests_logs/advanced_tests/' 2>/dev/null
fi
FILENAME=$1
BASENAME=$(basename $FILENAME)
BSN_PRE="${BASENAME%.*}"
BSN_EXT="${BASENAME##*.}"
TEST_OUTPUT_FILES="tests_logs/advanced_tests/${BSN_PRE}"
mkdir "${TEST_OUTPUT_FILES}/" 2>/dev/null
MODES=(
'with_FEC'
'without_FEC'
)
ERROR_RATE=10
CUT_RATE=1
DELAY=290
JITTER=30
LOSS_RATE=1
echo -e "The linksimulator paramateres are:
\t\t-ERROR RATE: ${ERROR_RATE}% \t-DELAY: ${DELAY}ms
\t\t-CUT RATE: ${CUT_RATE}% \t-JITTER: ${JITTER}ms
\t\t-LOSS RATE: ${LOSS_RATE}%\n"
for MODE in "${MODES[@]}"; do
mkdir "${TEST_OUTPUT_FILES}/${MODE}/" 2>/dev/null
DIR="${TEST_OUTPUT_FILES}/${MODE}"
touch "${DIR}/adv_${BSN_PRE}_received_file.${BSN_EXT}" \
"${DIR}/adv_valgrind_${BSN_PRE}_receiver.log" \
"${DIR}/adv_valgrind_${BSN_PRE}_sender.log" \
"${DIR}/${BSN_PRE}_receiver_stats.csv" \
"${DIR}/${BSN_PRE}_sender_stats.csv"
# The next 2 lines come from: https://unix.stackexchange.com/questions/55913/whats-the-easiest-way-to-find-an-unused-local-port
# We use this to be sure we're using unused port
port1=$(comm -23 <(seq 65000 65200 | sort) <(ss -Htan | awk '{print $4}' | cut -d':' -f2 | sort -u) | shuf | head -n 1)
port2=$(comm -23 <(seq 65000 65200 | sort) <(ss -Htan | awk '{print $4}' | cut -d':' -f2 | sort -u) | shuf | head -n 1)
##### Launching the link simulator #####
./linksimulator/link_sim -p $port2 -P $port1 -l $LOSS_RATE -d $DELAY -e $ERROR_RATE -c $CUT_RATE -j $JITTER \
&>${DIR}/adv_${BSN_PRE}_link.log & link_pid=$!
##### Launching the receiver and capturinig its output #####
valgrind --leak-check=full --log-file=${DIR}/adv_valgrind_${BSN_PRE}_receiver.log \
./receiver ::1 $port1 -s ${DIR}/${BSN_PRE}_receiver_stats.csv 1> ${DIR}/adv_${BSN_PRE}_received_file.${BSN_EXT} \
2> ${DIR}/adv_${BSN_PRE}_receiver.log & receiver_pid=$!
cleanup()
{
kill -9 $receiver_pid
kill -9 $link_pid
exit 0
}
trap cleanup SIGINT # Kill the background procces in case of ^-C
# Checking the mode (with out without FEC)
if [ $MODE = "with_FEC" ]; then
# We start the transfer
if ! valgrind --leak-check=full --log-file=${DIR}/adv_valgrind_${BSN_PRE}_sender.log \
./sender -f ${FILENAME} ::1 $port2 -c -s ${DIR}/${BSN_PRE}_sender_stats.csv 2> ${DIR}/adv_${BSN_PRE}_sender.log ; then
echo "The sender crashed!"
cat ${DIR}/adv_${BSN_PRE}_sender.log
err=1 # We record the error
fi
else
# We start the transfer
if ! valgrind --leak-check=full --log-file=${DIR}/adv_valgrind_${BSN_PRE}_sender.log \
./sender -f ${FILENAME} ::1 $port2 -s ${DIR}/${BSN_PRE}_sender_stats.csv 2> ${DIR}/adv_${BSN_PRE}_sender.log ; then
echo "The sender crashed!"
cat ${DIR}/adv_${BSN_PRE}_sender.log
err=1 # We record the error
fi
fi
sleep 5 # We wait 5s for the receiver to finish up
if kill -0 $receiver_pid &> /dev/null ; then
echo "The receiver didn't stop at the end of the transfer!"
kill -9 $receiver_pid
err=1
else # We check the return value of the receiver
if ! wait $receiver_pid ; then
echo "Crash of the receiver!"
cat ${DIR}/adv_${BSN_PRE}_receiver.log
err=1
fi
fi
# Stop the link simulator
kill -9 $link_pid
wait $link_pid 2>/dev/null
# We verify that the transfer ran through properly
if [[ "$(md5sum ${FILENAME} | awk '{print $1}')" != "$(md5sum ${DIR}/adv_${BSN_PRE}_received_file.${BSN_EXT} | awk '{print $1}')" ]]; then
echo "The transfer corrupted the file!"
echo "Binary difference between the 2 files: (expected vs actual)"
diff -C 9 <(od -Ax -t x1z ${FILENAME}) <(od -Ax -t x1z ${DIR}/adv_${BSN_PRE}_received_file.${BSN_EXT})
if [ $MODE = "with_FEC" ]; then
echo -e "${RED}The transfer (with FEC) has failed!${NC}"
else
echo -e "${RED}The transfer (without FEC) has failed!${NC}"
fi
exit 1
else
if [ $MODE = "with_FEC" ]; then
echo -e "${GREEN}The transfer (with FEC) has succeeded!${NC}"
else
echo -e "${GREEN}The transfer (without FEC) has succeeded!${NC}"
fi
fi
done
exit ${err:-0} # In case of error, we return the error code
\ No newline at end of file
......@@ -13,18 +13,19 @@ NC='\033[0m'
input_files=(
'tests_files/greeting.txt'
'tests_files/smile.png'
'tests_files/noice.gif'
)
modes=(
'with_FEC'
'without_FEC'
'with_FEC'
)
ERROR_RATE=2
ERROR_RATE=10
CUT_RATE=5
DELAY=100
JITTER=100
LOSS_RATE=5
LOSS_RATE=20
dir="tests_logs/interop/"
......@@ -42,7 +43,7 @@ i=1
for receiver in $receivers; do
chmod +x $receiver
receiver_name="${receiver##*/}"
echo -e "\n${BROWN}($i/${#receivers[@]}) Testing with ${receiver_name}:\n${NC}"
echo -e "\n${BROWN}Testing with ${receiver_name}:\n${NC}"
j=1
for file in "${input_files[@]}"; do
filesize=$(stat -c%s "$file")
......@@ -67,7 +68,7 @@ i=1
for sender in $senders; do
chmod +x $sender
sender_name="${sender##*/}"
echo -e "\n${BROWN}($i/${#senders[@]}) Testing with ${sender_name}\n${NC}"
echo -e "\n${BROWN} Testing with ${sender_name}\n${NC}"
j=1
for file in "${input_files[@]}"; do
filesize=$(stat -c%s "$file")
......
......@@ -175,7 +175,7 @@ fi
if [ $err -ne 1 ]; then
# We verify that the transfer ran through properly
if [[ "$(md5sum ${input_file} | awk '{print $1}')" != "$(md5sum ${output_file} | awk '{print $1}')" ]]; then
echo "The transfer corrupted the file!"
echo "${RED}The transfer corrupted the file!${NC}"
echo "Binary difference between the 2 files: (expected vs actual)"
diff -C 9 <(od -Ax -t x1z ${input_file}) <(od -Ax -t x1z ${output_file})
if [ $mode = "with_FEC" ]; then
......
......@@ -60,17 +60,16 @@ modes=(
advanced_test_files=(
'tests_files/greeting.txt'
'tests_files/long_message.txt'
'tests_files/thumbs-up-nod.gif'
'tests_files/smile.png'
'tests_files/noice.gif'
)
ERROR_RATE=5
CUT_RATE=5
DELAY=100
ERROR_RATE=10
CUT_RATE=10
DELAY=200
JITTER=100
LOSS_RATE=10
LOSS_RATE=20
if [ -d linksimulator/ ]; then
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter