Skip to content
Extraits de code Groupes Projets
Valider 939c9265 rédigé par Vany Ingenzi's avatar Vany Ingenzi
Parcourir les fichiers

Added the advanced tests

parent c73d17a2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -16,7 +16,7 @@ RECEIVER_OBJECTS = $(RECEIVER_SOURCES:.c=.o)
SENDER = sender
RECEIVER = receiver
all: $(SENDER) $(RECEIVER)
all: $(SENDER) $(RECEIVER) makelinksim
$(SENDER): $(SENDER_OBJECTS)
$(CC) $(SENDER_OBJECTS) -o $@ $(LDFLAGS)
......@@ -41,7 +41,7 @@ makelinksim:
@make -C linksimulator/
# It is likely that you will need to update this
tests: all makelinksim
tests: all
@./tests/run_tests.sh
# By default, logs are disabled. But you can enable them with the debug target.
......
# Implementation of TRTP Protocol - LINFO1341 Project
## Introduction
## 1. Introduction
For a 3rd year bachelors Computer Networks given to computer science students at UCLouvain, we had to implement a transport protocol. The protocol is entitled Truncated Relieable Transport Protocol (TRTP)on top of a Ipv6 Network layer. The implementation also implement the Forward Erasure Correction (FEC) to recover corrupted packets. The full description is to be found in the `statement.pdf`.
For the course **LINFO1341 : Conputer Network**, given to 3rd year computer science students at UCLouvain, we had to implement a transport protocol. The protocol is entitled **Truncated Relieable Transport Protocol (TRTP)** on top of a Ipv6 Network layer. The protocol also implement the **Forward Erasure Correction (FEC)** to recover corrupted packets. The full description of the protocol is to be found in the `statement.pdf`.
## Folder Organization
## 2. Execution
In order to execute the code, one must first execute the Makefile:
```
| `headers\`
| `src\`
| `tests\`
make
```
For debugging please run
```
make debug
```
Then use the specified arguments explained in the `statement.pdf`.
## 3. Folder Organization
```
| headers/
| linksimulator/
| src/
| test_files/
| tests/
| unwanted_logs/
```
### 3. 1. `linksimulator/`
This folder contains a [git repository](https://github.com/cnp3/Linksimulator). We use the linksimulaor to simulate a network with certain configurations like packets loss, delays, etc. Full description in the `linksimulator/README.md`. We did not write any of the code in the folder.
### 3. 2. `test_files/`
This folder contains testing files that we will be sendig between the `receiver` and the `sender`. Any file added to this folder will automatically be used in tests suites.
## 4. Testing
For the testing we have a specific directory that contains our shell script tests. In order to execute our tests we advise to run the following Makefile command
```
make tests -s
```
The silent argument `-s` is to silence any Makefile output and only leave the messages of the tests. In order to test the transfer of a file, you have to add a file in the `test_files`. The suite cases will automatically load the fle and transfer using our protocol.
We have two types of tests suites. *Simple* and *Advanced* test suites.
### 4. 1. *Simple* Test Suites
Simple tests don't use `linksimulator`, however they use `Valgrind` to check memory usage in both the sender and the receiver. After executing the `make [debug]`. One can run a simple test with the following command :
```
./tests/simple_test.sh <path_to_file>
```
The output for each file sent using the simple test is to be found in the `unwanted_logs/`. They respect the following format :
| File in `unwanted_logs/` | Contains |
| :-- | :-- |
| `<file_basename>`_received_file.`<file_extension>` | This is the file received by the `receiver`.|
| `<file_basename>`_receiver.log | Contains the valgrind log of the `receiver`. |
| `<file_basename>`_sender.log | Contains the valgrind log of the `sender`. |
| receiver.log | Contains the output on the stderr of the `receiver`. |
| sender.log | Contains the output on the stderr of the `sender`. |
## Execution
In order to execute the code, one must first execute the Makefile. For debugging please run `make debug`.
The stdout prints *Le transfert est réussi!*, upon success else it prints the comparison between the sent file and the received file.
## Testing
For the testing we have a specific directory that contains our tests. In order to execute our tests we advise to run the folowing Makefile command `make tests -s`. The silent argument is to silence any makefile output and only leave the messages of the tests.
We use the LinkSimulator given on the Moodle of the course for advanced tests. And we use Valgrind for the simple tests.
### 4. 2. *Advanced* Test Suites
In order to test the transfer of a file then you have to add a file in the testfiles. The suite cases will automatically load the fle and transfer using our protocol.
TBA ...
### Results
Our results on the test files are ...
## 5. System Architecture
## System Architecture
\ No newline at end of file
TBA ...
\ No newline at end of file
Fichier supprimé
test_files/thumbs-up-nod.gif

2,21 Mo

#!/bin/bash
if [ -z "$1" ]; then
echo "Not given the file to send"
exit 1
fi
FILENAME=$1
BASENAME=$(basename $FILENAME)
BSN_PRE="${BASENAME%.*}"
BSN_EXT="${BASENAME##*.}"
# cleanup d'un test précédent
rm -f ./unwanted_logs/adv_${BSN_PRE}_received_file.${BSN_EXT} ./unwanted_logs/adv_${BSN_PRE}_valgrind_receiver.log ./unwanted_logs/adv_${BSN_PRE}_valgrind_sender.log
touch ./unwanted_logs/adv_${BSN_PRE}_received_file.${BSN_EXT} ./unwanted_logs/adv_${BSN_PRE}_valgrind_receiver.log ./unwanted_logs/adv_${BSN_PRE}_valgrind_sender.log
# We first launch the link simulator
./linksimulator/link_sim -p 65027 -P 65119 -l 10 -d 20 -R &>./unwanted_logs/link.log &
link_pid=$!
# On lance le receiver et capture sa sortie standard
valgrind --leak-check=full --log-file=./unwanted_logs/adv_${BSN_PRE}_valgrind_receiver.log ./receiver ::1 65119 1> ./unwanted_logs/adv_${BSN_PRE}_received_file.${BSN_EXT} 2> ./unwanted_logs/adv_${BSN_PRE}_valgrind_receiver.log &
receiver_pid=$!
cleanup()
{
kill -9 $receiver_pid
kill -9 $link_pid
exit 0
}
trap cleanup SIGINT # Kill les process en arrière plan en cas de ^-C
# On démarre le transfert
if ! valgrind --leak-check=full --log-file=./unwanted_logs/valgrind_sender.log ./sender -f ${FILENAME} ::1 65027 2> ./unwanted_logs/sender.log ; then
echo "Crash du sender!"
cat ./unwanted_logs/sender.log
err=1 # On enregistre l'erreur
fi
sleep 5 # On attend 5 seconde que le receiver finisse
if kill -0 $receiver_pid &> /dev/null ; then
echo "Le receiver ne s'est pas arreté à la fin du transfert!"
kill -9 $receiver_pid
err=1
else # On teste la valeur de retour du receiver
if ! wait $receiver_pid ; then
echo "Crash du receiver!"
cat ./unwanted_logs/adv_${BSN_PRE}_valgrind_receiver.log
err=1
fi
fi
# Stop the link simulator
kill -9 $link_pid
wait $link_pid 2>/dev/null
# On vérifie que le transfert s'est bien déroulé
if [[ "$(md5sum ${FILENAME} | awk '{print $1}')" != "$(md5sum ./unwanted_logs/adv_${BSN_PRE}_received_file.${BSN_EXT} | awk '{print $1}')" ]]; then
echo "Le transfert a corrompu le fichier!"
echo "Diff binaire des deux fichiers: (attendu vs produit)"
diff -C 9 <(od -Ax -t x1z ${FILENAME}) <(od -Ax -t x1z ./unwanted_logs/adv_${BSN_PRE}_received_file.${BSN_EXT})
exit 1
else
echo "Le transfert est réussi!"
exit ${err:-0} # En cas d'erreurs avant, on renvoie le code d'erreur
fi
\ No newline at end of file
......@@ -8,4 +8,13 @@ do
FILESIZE=$(stat -c%s "$FILENAME")
echo "Sending $FILENAME \t [$FILESIZE bytes], \t with Valgrind"
./tests/simple_test.sh $FILENAME
done
# Now we ran advnced tests
for FILENAME in "$TEST_FILES_DIR"/*
do
FILESIZE=$(stat -c%s "$FILENAME")
echo "Sending $FILENAME \t [$FILESIZE bytes], \t with Valgrind"
./tests/advanced_test.sh $FILENAME
done
\ No newline at end of file
......@@ -10,11 +10,12 @@ BASENAME_PREFIX="${BASENAME%.*}"
BASENAME_EXTENSION="${BASENAME##*.}"
# cleanup d'un test précédent
rm -f ./unwanted_logs/${BASENAME_PREFIX}_received_file.${BASENAME_EXTENSION} ./unwanted_logs/${BASENAME_PREFIX}_valgrind_receiver.log ./unwanted_logs/${BASENAME_PREFIX}_valgrind_sender.log
touch ./unwanted_logs/${BASENAME_PREFIX}_received_file.${BASENAME_EXTENSION} ./unwanted_logs/${BASENAME_PREFIX}_valgrind_receiver.log ./unwanted_logs/${BASENAME_PREFIX}_valgrind_sender.log
rm -f ./unwanted_logs/${BASENAME_PREFIX}_received_file.${BASENAME_EXTENSION} ./unwanted_logs/${BASENAME_PREFIX}_receiver.log ./unwanted_logs/${BASENAME_PREFIX}_sender.log
touch ./unwanted_logs/${BASENAME_PREFIX}_received_file.${BASENAME_EXTENSION} ./unwanted_logs/${BASENAME_PREFIX}_receiver.log ./unwanted_logs/${BASENAME_PREFIX}_sender.log
# On lance le receiver et capture sa sortie standard
valgrind --leak-check=full --log-file=./unwanted_logs/${BASENAME_PREFIX}_valgrind_receiver.log ./receiver ::1 12345 1> ./unwanted_logs/${BASENAME_PREFIX}_received_file.${BASENAME_EXTENSION} 2> ./unwanted_logs/${BASENAME_PREFIX}_valgrind_receiver.log &
valgrind --leak-check=full --log-file=./unwanted_logs/${BASENAME_PREFIX}_receiver.log ./receiver :: 65197 1> ./unwanted_logs/${BASENAME_PREFIX}_received_file.${BASENAME_EXTENSION} 2> ./unwanted_logs/receiver.log &
receiver_pid=$!
cleanup()
......@@ -26,7 +27,7 @@ cleanup()
trap cleanup SIGINT # Kill les process en arrière plan en cas de ^-C
# On démarre le transfert
if ! valgrind --leak-check=full --log-file=./unwanted_logs/valgrind_sender.log ./sender -f ${FILENAME} ::1 12345 2> ./unwanted_logs/sender.log ; then
if ! valgrind --leak-check=full --log-file=./unwanted_logs/${BASENAME_PREFIX}_sender.log ./sender -f ${FILENAME} :: 65197 2> ./unwanted_logs/sender.log ; then
echo "Crash du sender!"
cat ./unwanted_logs/sender.log
err=1 # On enregistre l'erreur
......@@ -41,7 +42,7 @@ if kill -0 $receiver_pid &> /dev/null ; then
else # On teste la valeur de retour du receiver
if ! wait $receiver_pid ; then
echo "Crash du receiver!"
cat ./unwanted_logs/${BASENAME_PREFIX}_valgrind_receiver.log
cat ./unwanted_logs/${BASENAME_PREFIX}_receiver.log
err=1
fi
fi
......
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