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

sender ok

parent 1dac9e64
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -46,6 +46,9 @@ makelinksim: ...@@ -46,6 +46,9 @@ makelinksim:
tests: debug tests: debug
@./tests/run_tests.sh @./tests/run_tests.sh
interop: debug
@./tests/run_interop.sh
# By default, logs are disabled. But you can enable them with the debug target. # By default, logs are disabled. But you can enable them with the debug target.
debug: CFLAGS += -D_DEBUG debug: CFLAGS += -D_DEBUG
debug: clean aux debug: clean aux
......
Fichier ajouté
Fichier ajouté
...@@ -77,6 +77,9 @@ bool can_send(sender_state_t *state) ...@@ -77,6 +77,9 @@ bool can_send(sender_state_t *state)
/** Cautious this function is used for sending and sending back pkt ! */ /** Cautious this function is used for sending and sending back pkt ! */
int send_pkt(sender_state_t *state, pkt_t *pkt, uint8_t position, int socket_fd) int send_pkt(sender_state_t *state, pkt_t *pkt, uint8_t position, int socket_fd)
{ {
// The next line is important for pkt that are sent back (maybe our window size has changed since the last time)
pkt_set_window(pkt, state->s_window_size);
DEBUG("Sending the pkt with seqnum: %d", pkt_get_seqnum(pkt)); DEBUG("Sending the pkt with seqnum: %d", pkt_get_seqnum(pkt));
char packet_to_be_sent[PKT_MAX_LEN]; char packet_to_be_sent[PKT_MAX_LEN];
size_t len = PKT_MAX_LEN; size_t len = PKT_MAX_LEN;
......
#!/bin/bash
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
FILENAME=(
'tests_files/greetings.txt'
'tests_files/smile.png'
)
rm -rf ./tests_logs/*
mkdir 'tests_logs/interop_tests/' 2>/dev/null
function run_sender_receiver {
sender=$1
receiver=$2
FILENAME=$3
name_type_of_test=$4 # directory where all the output files are stored (REQUIRE "/" at the end)
if [ ! d "${name_type_of_test}" ]; then
mkdir '${name_of_the_type_of_test}' 2>/dev/null
fi
BASENAME=$(basename $FILENAME)
BSN_PRE="${BASENAME%.*}"
BSN_EXT="${BASENAME##*.}"
DIR="${name_type_of_test}${BSN_PRE}/"
mkdir "${DIR}/" 2>/dev/null
# Checking if we're using the linksimulator or not
if [ "$#" -gt 4 ]; then
ERROR_RATE=$5
CUT_RATE=$6
DELAY=$7
JITTER=$8
LOSS_RATE=$9
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"
# 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)
linksimulator_logs=${DIR}/adv_${BSN_PRE}_link.log
##### Launching the link simulator #####
./linksimulator/link_sim -p $port2 -P $port1 -l $LOSS_RATE -d $DELAY -e $ERROR_RATE -c $CUT_RATE -j $JITTER \
&> $linksimulator_logs & link_pid=$!
else
# The next line 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=$port1
fi
MODES=(
'with_FEC'
'without_FEC'
)
for MODE in "${MODES[@]}"; do
SUB_DIR="${DIR}${MODE}/"
mkdir "${SUB_DIR}" 2>/dev/null
output_file="${SUB_DIR}adv_${BSN_PRE}_received_file.${BSN_EXT}"
sender_valgrind="${SUB_DIR}valgrind_${BSN_PRE}_${sender}.log"
receiver_valgrind="${SUB_DIR}valgrind_${BSN_PRE}_${receiver}.log"
sender_stats="${SUB_DIR}${BSN_PRE}_${sender}_stats.csv"
receiver_stats="${SUB_DIR}${BSN_PRE}_${receiver}_stats.csv"
touch output_file sender_valgrind receiver_valgrind sender_stats receiver_stats
receiver_logs="${SUB_DIR}${BSN_PRE}_${receiver}.log"
sender_logs="${SUB_DIR}${BSN_PRE}_${sender}.log"
##### Launching the receiver and capturinig its output #####
valgrind --leak-check=full --log-file=${receiver_valgrind} \
./receiver ::1 $port1 \
-s ${receiver_stats} \
1> ${output_file} \
2> ${receiver_logs} & 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
}
### Testing our sender with a receiver from another group ###
### Testing our receiver with a sender from another group ###
\ No newline at end of file
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