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

Fixed bug in ACK SEQNUM for the receiver

parent 84f7a419
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -19,13 +19,13 @@ RECEIVER = receiver ...@@ -19,13 +19,13 @@ RECEIVER = receiver
all: $(SENDER) $(RECEIVER) all: $(SENDER) $(RECEIVER)
$(SENDER): $(SENDER_OBJECTS) $(SENDER): $(SENDER_OBJECTS)
@$(CC) $(SENDER_OBJECTS) -o $@ $(LDFLAGS) $(CC) $(SENDER_OBJECTS) -o $@ $(LDFLAGS)
$(RECEIVER): $(RECEIVER_OBJECTS) $(RECEIVER): $(RECEIVER_OBJECTS)
@$(CC) $(RECEIVER_OBJECTS) -o $@ $(LDFLAGS) $(CC) $(RECEIVER_OBJECTS) -o $@ $(LDFLAGS)
%.o: %.c %.o: %.c
@$(CC) $(HEADERS_DIR) $(CFLAGS) $< -o $@ $(LDFLAGS) $(CC) $(HEADERS_DIR) $(CFLAGS) $< -o $@ $(LDFLAGS)
.PHONY: clean mrproper cleanlogs .PHONY: clean mrproper cleanlogs
......
...@@ -112,12 +112,14 @@ int update_buffer_upon_new_data(con_state_t * state, pkt_t * pkt) ...@@ -112,12 +112,14 @@ int update_buffer_upon_new_data(con_state_t * state, pkt_t * pkt)
int update_state_data_pkt(con_state_t * state, pkt_t * pkt) int update_state_data_pkt(con_state_t * state, pkt_t * pkt)
{ {
if (update_buffer_upon_new_data(state, pkt) != 0) return -1; if (update_buffer_upon_new_data(state, pkt) != 0) return -1;
uint8_t expecting = (state->last_received_in_order + 1) % TWO_EXP_EIGHT;
if ( state->ack_to_send != NULL ) /* There's an unsent ack to send */ if ( state->ack_to_send != NULL ) /* There's an unsent ack to send */
{ {
if (pkt_set_seqnum(state->ack_to_send, state->last_received_in_order) != 0) if (pkt_set_window(state->ack_to_send, state->curr_recv_window) != 0 ||
pkt_set_seqnum(state->ack_to_send, expecting) != 0)
{ {
ERROR("When setting the seqnum of an existing ack that hasn't been sent yet."); ERROR("When updating an ACK that hasn't been done.");
return -1; return -1;
} }
} else /* We have to create an ack to send */ } else /* We have to create an ack to send */
...@@ -130,7 +132,7 @@ int update_state_data_pkt(con_state_t * state, pkt_t * pkt) ...@@ -130,7 +132,7 @@ int update_state_data_pkt(con_state_t * state, pkt_t * pkt)
} }
if (pkt_set_type(state->ack_to_send, PTYPE_ACK) != 0 || pkt_set_tr(state->ack_to_send, 0) || if (pkt_set_type(state->ack_to_send, PTYPE_ACK) != 0 || pkt_set_tr(state->ack_to_send, 0) ||
pkt_set_seqnum(state->ack_to_send, state->last_received_in_order) != 0) pkt_set_seqnum(state->ack_to_send, expecting) != 0)
{ {
ERROR("Setting up a ACK packet to send."); ERROR("Setting up a ACK packet to send.");
return -1; return -1;
...@@ -224,7 +226,7 @@ void reception_loop(struct pollfd * pfd, con_state_t * state) ...@@ -224,7 +226,7 @@ void reception_loop(struct pollfd * pfd, con_state_t * state)
{ {
int ready = poll(pfd, 1, -1); int ready = poll(pfd, 1, -1);
gettimeofday(&curr, NULL); gettimeofday(&curr, NULL);
if (ready == -1 || (curr.tv_sec - last_recv.tv_sec) > 2) if (ready == -1 || (curr.tv_sec - last_recv.tv_sec) > 3)
{ {
DEBUG("Timed out."); DEBUG("Timed out.");
return; return;
......
Hello World!
\ No newline at end of file
...@@ -7,7 +7,7 @@ PS: Drink a beer when you pass the test. Share your knowledge to others, compute ...@@ -7,7 +7,7 @@ PS: Drink a beer when you pass the test. Share your knowledge to others, compute
science isn't a field for selfishness. If you want to switch to Law, Economy, some shit science isn't a field for selfishness. If you want to switch to Law, Economy, some shit
Hi Vany I love reading from you. As you know I'm working sometime a bit late in the night. Hi Vany I love reading from you. As you know I'm working sometime a bit late in the night.
In a few hour you'll be in th famous "Salle Intel" to be really productive as you are. In a few hour you'll be in the famous "Salle Intel" to be really productive as you are.
Best regards, Best regards,
......
...@@ -7,13 +7,14 @@ fi ...@@ -7,13 +7,14 @@ fi
FILENAME=$1 FILENAME=$1
BASENAME=$(basename $FILENAME) BASENAME=$(basename $FILENAME)
BASENAME_PREFIX="${BASENAME%.*}" BASENAME_PREFIX="${BASENAME%.*}"
BASENAME_EXTENSION="${BASENAME##*.}"
# cleanup d'un test précédent # cleanup d'un test précédent
rm -f ./unwanted_logs/${BASENAME_PREFIX}_received_file ./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}_valgrind_receiver.log ./unwanted_logs/${BASENAME_PREFIX}_valgrind_sender.log
touch ./unwanted_logs/${BASENAME_PREFIX}_received_file ./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
# On lance le receiver et capture sa sortie standard # 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 2> ./unwanted_logs/${BASENAME_PREFIX}_valgrind_receiver.log & 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 &
receiver_pid=$! receiver_pid=$!
cleanup() cleanup()
...@@ -46,10 +47,10 @@ else # On teste la valeur de retour du receiver ...@@ -46,10 +47,10 @@ else # On teste la valeur de retour du receiver
fi fi
# On vérifie que le transfert s'est bien déroulé # On vérifie que le transfert s'est bien déroulé
if [[ "$(md5sum ${FILENAME} | awk '{print $1}')" != "$(md5sum ./unwanted_logs/${BASENAME_PREFIX}_received_file | awk '{print $1}')" ]]; then if [[ "$(md5sum ${FILENAME} | awk '{print $1}')" != "$(md5sum ./unwanted_logs/${BASENAME_PREFIX}_received_file.${BASENAME_EXTENSION} | awk '{print $1}')" ]]; then
echo "Le transfert a corrompu le fichier!" echo "Le transfert a corrompu le fichier!"
echo "Diff binaire des deux fichiers: (attendu vs produit)" echo "Diff binaire des deux fichiers: (attendu vs produit)"
diff -C 9 <(od -Ax -t x1z ${FILENAME}) <(od -Ax -t x1z ./unwanted_logs/${BASENAME_PREFIX}_received_file) diff -C 9 <(od -Ax -t x1z ${FILENAME}) <(od -Ax -t x1z ./unwanted_logs/${BASENAME_PREFIX}_received_file.${BASENAME_EXTENSION})
exit 1 exit 1
else else
echo "Le transfert est réussi!" echo "Le transfert est réussi!"
......
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