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

Simulating Inginious tests

parent e4547a1c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -5,4 +5,5 @@ log_files/ ...@@ -5,4 +5,5 @@ log_files/
*.zip *.zip
linksimulator/ linksimulator/
demo.* demo.*
interpo/ interpo/
\ No newline at end of file noice/
\ No newline at end of file
...@@ -16,7 +16,9 @@ RECEIVER_OBJECTS = $(RECEIVER_SOURCES:.c=.o) ...@@ -16,7 +16,9 @@ RECEIVER_OBJECTS = $(RECEIVER_SOURCES:.c=.o)
SENDER = sender SENDER = sender
RECEIVER = receiver RECEIVER = receiver
all: $(RECEIVER) $(SENDER) all: debug
aux: $(RECEIVER) $(SENDER)
$(SENDER): $(SENDER_OBJECTS) $(SENDER): $(SENDER_OBJECTS)
$(CC) $(SENDER_OBJECTS) -o $@ $(LDFLAGS) $(CC) $(SENDER_OBJECTS) -o $@ $(LDFLAGS)
...@@ -46,7 +48,7 @@ tests: debug ...@@ -46,7 +48,7 @@ tests: debug
# 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 all debug: clean aux
# Place the zip in the parent repository of the project # Place the zip in the parent repository of the project
ZIP_NAME="../projet1_ingenzi_demeester.zip" ZIP_NAME="../projet1_ingenzi_demeester.zip"
......
...@@ -38,7 +38,7 @@ int send_if_inneed(struct pollfd * pfd, receiver_state_t * state) ...@@ -38,7 +38,7 @@ int send_if_inneed(struct pollfd * pfd, receiver_state_t * state)
size_t written = write(pfd->fd, (void *) buffer, len); size_t written = write(pfd->fd, (void *) buffer, len);
if (written != len) if (written != len)
{ {
ERROR("When witing a ACK to socket, didn't written the correct len"); ERROR("When writing ACK to socket, didn't write the correct len");
return -1; return -1;
} }
DEBUG("Sent ACK saying we are waiting for %d, timestamp %d", pkt_get_seqnum(state->ack_to_send), pkt_get_timestamp(state->ack_to_send)); DEBUG("Sent ACK saying we are waiting for %d, timestamp %d", pkt_get_seqnum(state->ack_to_send), pkt_get_timestamp(state->ack_to_send));
...@@ -89,6 +89,8 @@ int update_buffer_upon_new_data(receiver_state_t * state, const pkt_t * pkt) ...@@ -89,6 +89,8 @@ int update_buffer_upon_new_data(receiver_state_t * state, const pkt_t * pkt)
return 0; return 0;
} }
// We only reach here when we received packets in sequence.
uint16_t next_wait = state->last_received_in_order; uint16_t next_wait = state->last_received_in_order;
while (state->recvd_buf[next_wait] != NULL) while (state->recvd_buf[next_wait] != NULL)
{ {
...@@ -100,7 +102,6 @@ int update_buffer_upon_new_data(receiver_state_t * state, const pkt_t * pkt) ...@@ -100,7 +102,6 @@ int update_buffer_upon_new_data(receiver_state_t * state, const pkt_t * pkt)
state->curr_recv_window = (state->curr_recv_window < RECV_MAX_SLCTV_RPT_WDW) ? state->curr_recv_window+1 : RECV_MAX_SLCTV_RPT_WDW; state->curr_recv_window = (state->curr_recv_window < RECV_MAX_SLCTV_RPT_WDW) ? state->curr_recv_window+1 : RECV_MAX_SLCTV_RPT_WDW;
state->recv_window_start = (state->recv_window_start + 1) % TWO_EXP_EIGHT; state->recv_window_start = (state->recv_window_start + 1) % TWO_EXP_EIGHT;
next_wait = (next_wait + 1) % TWO_EXP_EIGHT; next_wait = (next_wait + 1) % TWO_EXP_EIGHT;
} }
return 0; return 0;
} }
...@@ -309,7 +310,6 @@ int handle_incoming(struct pollfd * pfd, receiver_state_t * state) ...@@ -309,7 +310,6 @@ int handle_incoming(struct pollfd * pfd, receiver_state_t * state)
*/ */
void reception_loop(struct pollfd * pfd, receiver_state_t * state) void reception_loop(struct pollfd * pfd, receiver_state_t * state)
{ {
uint8_t chance_to_send_ack_nack = 1; // Allows the receive to send ATLEAST an ACK each 1/1O iteration
struct timeval current_time, last_packet_received; struct timeval current_time, last_packet_received;
while (state->ack_to_send != NULL || state->transfer_done == 0) while (state->ack_to_send != NULL || state->transfer_done == 0)
{ {
...@@ -321,7 +321,7 @@ void reception_loop(struct pollfd * pfd, receiver_state_t * state) ...@@ -321,7 +321,7 @@ void reception_loop(struct pollfd * pfd, receiver_state_t * state)
return; return;
} }
if (pfd->revents & POLLIN && chance_to_send_ack_nack % 10 != 0) if (pfd->revents & POLLIN)
{ {
if (handle_incoming(pfd, state) != 0) if (handle_incoming(pfd, state) != 0)
return; return;
...@@ -343,7 +343,6 @@ void reception_loop(struct pollfd * pfd, receiver_state_t * state) ...@@ -343,7 +343,6 @@ void reception_loop(struct pollfd * pfd, receiver_state_t * state)
return; return;
} }
} }
chance_to_send_ack_nack++;
} }
} }
......
test_files/noice.gif

1020 ko

...@@ -26,11 +26,11 @@ touch "${TEST_OUTPUT_FILES}/adv_${BSN_PRE}_received_file.${BSN_EXT}" \ ...@@ -26,11 +26,11 @@ touch "${TEST_OUTPUT_FILES}/adv_${BSN_PRE}_received_file.${BSN_EXT}" \
# The next 2 lines come from: https://unix.stackexchange.com/questions/55913/whats-the-easiest-way-to-find-an-unused-local-port # 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 # We use this to be sure we're using unused port
port1=$(comm -23 <(seq 49152 65535 | sort) <(ss -Htan | awk '{print $4}' | cut -d':' -f2 | sort -u) | shuf | head -n 1) 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 49152 65535 | 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)
# We first launch the link simulator # We first launch the link simulator
./linksimulator/link_sim -p $port2 -P $port1 -l 70 -d 1500 -e 20 -c 10 -R \ ./linksimulator/link_sim -p $port2 -P $port1 -l 0 -d 0 -e 0 -c 0 -R \
&>${TEST_OUTPUT_FILES}/adv_${BSN_PRE}_link.log & link_pid=$! &>${TEST_OUTPUT_FILES}/adv_${BSN_PRE}_link.log & link_pid=$!
# We launch the receiver and capture its output # We launch the receiver and capture its output
......
...@@ -8,20 +8,20 @@ TEST_FILES_DIR=./test_files/ ...@@ -8,20 +8,20 @@ TEST_FILES_DIR=./test_files/
rm -rf ./unwanted_logs/* rm -rf ./unwanted_logs/*
# We want our tests to always use valgrind # We want our tests to always use valgrind
echo -e "\nStarting simple tests ...\n" #echo -e "\nStarting simple tests ...\n"
for FILENAME in "$TEST_FILES_DIR"/* #for FILENAME in "$TEST_FILES_DIR"/*
do #do
FILESIZE=$(stat -c%s "$FILENAME") # FILESIZE=$(stat -c%s "$FILENAME")
echo -e "Sending $FILENAME \t\t [$FILESIZE bytes], \t\t with Valgrind" # echo -e "Sending $FILENAME \t\t [$FILESIZE bytes], \t\t with Valgrind"
./tests/simple_test.sh $FILENAME # ./tests/simple_test.sh $FILENAME
if [ $? -ne 0 ]; then # if [ $? -ne 0 ]; then
echo "Tests terminated cause of a failed test" # echo "Tests terminated cause of a failed test"
exit 0 # exit 0
fi # fi
done #done
echo -e "Finished Simple tests." #echo -e "Finished Simple tests."
if [ -d linksimulator/ ]; then if [ -d linksimulator/ ]; then
echo -e "\nStarting advanced tests ...\n" echo -e "\nStarting advanced tests ...\n"
......
...@@ -28,7 +28,7 @@ touch "${TEST_OUTPUT_FILES}/${BSNM_PRE}_received_file.${BSNM_EXT}" \ ...@@ -28,7 +28,7 @@ touch "${TEST_OUTPUT_FILES}/${BSNM_PRE}_received_file.${BSNM_EXT}" \
# The next line come from: https://unix.stackexchange.com/questions/55913/whats-the-easiest-way-to-find-an-unused-local-port # 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 # We use this to be sure we're using unused port
port=$(comm -23 <(seq 49152 65535 | sort) <(ss -Htan | awk '{print $4}' | cut -d':' -f2 | sort -u) | shuf | head -n 1) port=$(comm -23 <(seq 65000 65200 | sort) <(ss -Htan | awk '{print $4}' | cut -d':' -f2 | sort -u) | shuf | head -n 1)
# We launch the receiver and capture its output # We launch the receiver and capture its output
valgrind --leak-check=full --log-file=${TEST_OUTPUT_FILES}/valgrind_${BSNM_PRE}_receiver.log \ valgrind --leak-check=full --log-file=${TEST_OUTPUT_FILES}/valgrind_${BSNM_PRE}_receiver.log \
......
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