diff --git a/src/receiver_utils.c b/src/receiver_utils.c
index a25dd7e48a99f3ac3487c113e634db5f69c151d5..f970bc3ea691d2b3e8be90857e80304301fa4d3e 100644
--- a/src/receiver_utils.c
+++ b/src/receiver_utils.c
@@ -255,7 +255,6 @@ int prepare_ack_to_send(receiver_state_t * state)
  */
 int handle_data_pkt(receiver_state_t * state, const pkt_t * pkt)
 {
-    
     DEBUG("Received data packet seqnum %d with timestamp %d | current_window_size : %d, current_window_start : %d", 
                pkt_get_seqnum(pkt), pkt_get_timestamp(pkt), state->curr_recv_window, state->recv_window_start);
                
@@ -268,7 +267,6 @@ int handle_data_pkt(receiver_state_t * state, const pkt_t * pkt)
     {
         state->last_packet = pkt_get_seqnum(pkt);
         DEBUG("Received the last packet");
-        return prepare_ack_to_send(state);
     }
     /* This is the last packet with length 0 and everything has been received */
     if (state->last_packet == state->last_received_in_order)
@@ -554,30 +552,34 @@ int handle_incoming(struct pollfd * pfd, receiver_state_t * state)
  */
 void reception_loop(struct pollfd * pfd, receiver_state_t * state)
 {   
-    struct timeval current_time, last_packet_received;
+    struct timeval current_time, last_packet_received, last_ack_nack_sent; 
+    gettimeofday(&last_ack_nack_sent, NULL);
+    int can_send;
     while (state->ack_to_send != NULL || state->transfer_done == 0)
     {
         int ready = poll(pfd, 1, -1);
-
         if (ready == -1 || pfd->revents & POLLERR)              /* In case of error on socket */
         {
             DEBUG("Error on socket");
             return;
         }
 
+        gettimeofday(&current_time, NULL);
+        float interval = time_milliseconds(&current_time) - time_milliseconds(&last_ack_nack_sent);
+        can_send = interval > (float) MAX_NETWORK_DELAY;
         if (pfd->revents & POLLIN)
         {
             if (handle_incoming(pfd, state) != 0)   
-            {
                 return;
-            }
+
             if (state->last_data_packet < TWO_EXP_EIGHT)        /* This means we received last data packet transfer */     
                 gettimeofday(&last_packet_received, NULL);
  
-        } else if (pfd->revents & POLLOUT) 
+        } else if (pfd->revents & POLLOUT && can_send) 
         {
             if (send_if_inneed(pfd, state) != 0)    
                 return;
+            gettimeofday(&last_ack_nack_sent, NULL);
         } 
 
         if (state->last_data_packet < TWO_EXP_EIGHT)            /* This is a signal we use between us in order to mark the last datapacket containing data */
diff --git a/src/receiver_utils.h b/src/receiver_utils.h
index 3b265271661622be639ea82b39bb2d1d34dfa844..9f2f90246a8c0fd03b28655af104ef5b398c8696 100644
--- a/src/receiver_utils.h
+++ b/src/receiver_utils.h
@@ -32,6 +32,7 @@
 #define TIMER_MULTIPLIER_BY_2 2
 #define RECEIVER_INACTIVE_TIMEOUT 20
 #define FEC_CALCULATED_ON 4
+#define MAX_NETWORK_DELAY 2000 // In milliseconds
 
 
 /* Represent the receiver's connection state 
diff --git a/tests/advanced_test.sh b/tests/advanced_test.sh
index 92dfd19a8e06cd45dd4d8ac729a3633747ac09fd..c140a37b71b721c8a8541eaf14a0df4b51708562 100755
--- a/tests/advanced_test.sh
+++ b/tests/advanced_test.sh
@@ -27,11 +27,11 @@ MODES=(
   'without_FEC'
 )
 
-ERROR_RATE=20
-CUT_RATE=30
-DELAY=0
-JITTER=0
-LOSS_RATE=25
+ERROR_RATE=1
+CUT_RATE=1
+DELAY=100
+JITTER=100
+LOSS_RATE=1 
 
 echo -e "The linksimulator paramateres are:
         \t\t-ERROR RATE: ${ERROR_RATE}%    \t-DELAY:  ${DELAY}ms
diff --git a/tests/run_perfomance.sh b/tests/run_perfomance.sh
index 2a2128d2e454dc16c866c20d36e6444748ca5d53..491a8667093a4e698b42ba57d8791b8e618510a3 100755
--- a/tests/run_perfomance.sh
+++ b/tests/run_perfomance.sh
@@ -10,7 +10,7 @@ ERROR_RATE=1
 CUT_RATE=1
 DELAY=100
 JITTER=100
-LOSS_RATE=1
+LOSS_RATE=1 
 if [ ! -d "performance_results/" ]; then
   mkdir "performance_results/"
 fi
diff --git a/tests_logs/advanced_tests/greeting/with_FEC/adv_greeting_link.log b/tests_logs/advanced_tests/greeting/with_FEC/adv_greeting_link.log
index fbb5ddfe72d1ec44c55627cc4caccf26d3f363e0..d3af715735a6c2933b33eada6e2a31cab166363d 100644
--- a/tests_logs/advanced_tests/greeting/with_FEC/adv_greeting_link.log
+++ b/tests_logs/advanced_tests/greeting/with_FEC/adv_greeting_link.log
@@ -1,20 +1,22 @@
-@@ Using random seed: 1650927055
+@@ Using random seed: 1650983295
 @@ Using parameters:
-.. port: 65015
-.. forward_port: 65036
-.. delay: 0
-.. jitter: 0
-.. err_rate: 20
-.. cut_rate: 30
-.. loss_rate: 25
-.. seed: 1650927055
+.. port: 65086
+.. forward_port: 65117
+.. delay: 100
+.. jitter: 100
+.. err_rate: 1
+.. cut_rate: 1
+.. loss_rate: 1
+.. seed: 1650983295
 .. link_direction: Forward
-@@ Remote host is ::1 [41502]
-[SEQ   0] Corrupting packet: inverted byte #15
+@@ Remote host is ::1 [54141]
+[SEQ   0] Delayed packet by 109 ms
 [SEQ   0] Sent packet (Forward).
+[SEQ   0] Delayed packet by 9 ms
 [SEQ   0] Sent packet (Forward).
 [SEQ   1] Sent packet (Reverse).
+[SEQ   1] Delayed packet by 7 ms
+[FEC   0] Delayed packet by 162 ms
 [SEQ   1] Sent packet (Forward).
-[FEC   0] Corrupting packet: inverted byte #315
 [FEC   0] Sent packet (Forward).
 [SEQ   2] Sent packet (Reverse).
diff --git a/tests_logs/advanced_tests/greeting/with_FEC/adv_greeting_receiver.log b/tests_logs/advanced_tests/greeting/with_FEC/adv_greeting_receiver.log
index 5179c2b09336f1d539ac1dd46f41fdc6d85bb894..7a5fc8b8f18d99d9bbc9d8727d1ccc1323a3fd16 100644
--- a/tests_logs/advanced_tests/greeting/with_FEC/adv_greeting_receiver.log
+++ b/tests_logs/advanced_tests/greeting/with_FEC/adv_greeting_receiver.log
@@ -1,17 +1,17 @@
-[DEBUG] Receiver has following arguments: stats_filename is tests_logs/advanced_tests/greeting/with_FEC/greeting_receiver_stats.csv, listen_ip is ::1, listen_port is 65036
-[DEBUG] Successfully bound to IPv6 address : 0000:0000:0000:0000:0000:0000:0000:0001, port : 65036
-[DEBUG] Successfully connected to IPv6 addresss: 0000:0000:0000:0000:0000:0000:0000:0001, port : 65015
-[DEBUG] Received a damaged packet with 4 status. and seqnum as 0
+[DEBUG] Receiver has following arguments: stats_filename is tests_logs/advanced_tests/greeting/with_FEC/greeting_receiver_stats.csv, listen_ip is ::1, listen_port is 65117
+[DEBUG] Successfully bound to IPv6 address : 0000:0000:0000:0000:0000:0000:0000:0001, port : 65117
+[DEBUG] Successfully connected to IPv6 addresss: 0000:0000:0000:0000:0000:0000:0000:0001, port : 65086
 [DEBUG] Received data packet seqnum 0 with timestamp 984824098 | current_window_size : 31, current_window_start : 0
+[DEBUG] Received data packet seqnum 0 with timestamp 984824098 | current_window_size : 30, current_window_start : 0
 [DEBUG] Sent ACK saying we are waiting for 1, timestamp 0
 [DEBUG] Received data packet seqnum 1 with timestamp 0 | current_window_size : 30, current_window_start : 0
 [DEBUG] Going to consume the next 2 packets.
 [DEBUG] Consuming packet : 0 | curr_recv_window = 29, recv_window_start = 0
 [DEBUG] Consuming packet : 1 | curr_recv_window = 30, recv_window_start = 1
 [DEBUG] Received the last packet
-[DEBUG] Received a damaged packet with 4 status. and seqnum as 0
+[DEBUG] Received packet [0] Out of window with timestamp 0 | receive window start at : 2 (included) till 33 (excluded)
 [DEBUG] Sent ACK saying we are waiting for 2, timestamp 0
 [DEBUG] Done the transfer with done status being true
-[DEBUG] The difference between the two is 2.000000 seconds
-[DEBUG] The transfer took 2.000000 seconds
+[DEBUG] The difference between the two is 2014000.000000 seconds
+[DEBUG] The transfer took 2014.000000 seconds
 [DEBUG] Wrote the transfer statistics to tests_logs/advanced_tests/greeting/with_FEC/greeting_receiver_stats.csv.
diff --git a/tests_logs/advanced_tests/greeting/with_FEC/adv_greeting_sender.log b/tests_logs/advanced_tests/greeting/with_FEC/adv_greeting_sender.log
index 1b39d4750e78a07501cc1686395371bfdabdad93..b52647b5e5dec7112951ea1e898d90877ffd0bdf 100644
--- a/tests_logs/advanced_tests/greeting/with_FEC/adv_greeting_sender.log
+++ b/tests_logs/advanced_tests/greeting/with_FEC/adv_greeting_sender.log
@@ -3,8 +3,8 @@
 		stats_filename is tests_logs/advanced_tests/greeting/with_FEC/greeting_sender_stats.csv,
 		fec_enabled is 1,
 		receiver_ip is ::1,
-		receiver_port is 65015
-[DEBUG] Successfully connected to IPv6 addresss: 0000:0000:0000:0000:0000:0000:0000:0001, port : 65015
+		receiver_port is 65086
+[DEBUG] Successfully connected to IPv6 addresss: 0000:0000:0000:0000:0000:0000:0000:0001, port : 65086
 [DEBUG] The sender will send a pkt on the socket, the current sender window size is: 31 | receiver window size: 1
 [DEBUG] The LAST PTYPE_DATA is being sent !
 [DEBUG] Sending the pkt with seqnum: 0
diff --git a/tests_logs/advanced_tests/greeting/with_FEC/adv_valgrind_greeting_receiver.log b/tests_logs/advanced_tests/greeting/with_FEC/adv_valgrind_greeting_receiver.log
index b9472dbe1ae0ed031e5f6882c2111a3a69cf088d..7738d7cdede8b88a55c83c7e17ee7adbb2c3ec9a 100644
--- a/tests_logs/advanced_tests/greeting/with_FEC/adv_valgrind_greeting_receiver.log
+++ b/tests_logs/advanced_tests/greeting/with_FEC/adv_valgrind_greeting_receiver.log
@@ -1,15 +1,15 @@
-==16303== Memcheck, a memory error detector
-==16303== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
-==16303== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
-==16303== Command: ./receiver ::1 65036 -s tests_logs/advanced_tests/greeting/with_FEC/greeting_receiver_stats.csv
-==16303== Parent PID: 16271
-==16303== 
-==16303== 
-==16303== HEAP SUMMARY:
-==16303==     in use at exit: 0 bytes in 0 blocks
-==16303==   total heap usage: 15 allocs, 15 frees, 10,904 bytes allocated
-==16303== 
-==16303== All heap blocks were freed -- no leaks are possible
-==16303== 
-==16303== For lists of detected and suppressed errors, rerun with: -s
-==16303== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+==31031== Memcheck, a memory error detector
+==31031== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
+==31031== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
+==31031== Command: ./receiver ::1 65117 -s tests_logs/advanced_tests/greeting/with_FEC/greeting_receiver_stats.csv
+==31031== Parent PID: 30999
+==31031== 
+==31031== 
+==31031== HEAP SUMMARY:
+==31031==     in use at exit: 0 bytes in 0 blocks
+==31031==   total heap usage: 15 allocs, 15 frees, 10,928 bytes allocated
+==31031== 
+==31031== All heap blocks were freed -- no leaks are possible
+==31031== 
+==31031== For lists of detected and suppressed errors, rerun with: -s
+==31031== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
diff --git a/tests_logs/advanced_tests/greeting/with_FEC/adv_valgrind_greeting_sender.log b/tests_logs/advanced_tests/greeting/with_FEC/adv_valgrind_greeting_sender.log
index c2f34c47450f44cf1ecfdd0e254094de02fbd933..97b905e95a0dbbb9b0218c77f199ea6b6f7d6ecf 100644
--- a/tests_logs/advanced_tests/greeting/with_FEC/adv_valgrind_greeting_sender.log
+++ b/tests_logs/advanced_tests/greeting/with_FEC/adv_valgrind_greeting_sender.log
@@ -1,15 +1,15 @@
-==16304== Memcheck, a memory error detector
-==16304== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
-==16304== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
-==16304== Command: ./sender -f tests_files/greeting.txt ::1 65015 -c -s tests_logs/advanced_tests/greeting/with_FEC/greeting_sender_stats.csv
-==16304== Parent PID: 16271
-==16304== 
-==16304== 
-==16304== HEAP SUMMARY:
-==16304==     in use at exit: 0 bytes in 0 blocks
-==16304==   total heap usage: 11 allocs, 11 frees, 5,444 bytes allocated
-==16304== 
-==16304== All heap blocks were freed -- no leaks are possible
-==16304== 
-==16304== For lists of detected and suppressed errors, rerun with: -s
-==16304== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+==31032== Memcheck, a memory error detector
+==31032== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
+==31032== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
+==31032== Command: ./sender -f tests_files/greeting.txt ::1 65086 -c -s tests_logs/advanced_tests/greeting/with_FEC/greeting_sender_stats.csv
+==31032== Parent PID: 30999
+==31032== 
+==31032== 
+==31032== HEAP SUMMARY:
+==31032==     in use at exit: 0 bytes in 0 blocks
+==31032==   total heap usage: 10 allocs, 10 frees, 4,420 bytes allocated
+==31032== 
+==31032== All heap blocks were freed -- no leaks are possible
+==31032== 
+==31032== For lists of detected and suppressed errors, rerun with: -s
+==31032== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
diff --git a/tests_logs/advanced_tests/greeting/with_FEC/greeting_receiver_stats.csv b/tests_logs/advanced_tests/greeting/with_FEC/greeting_receiver_stats.csv
index 3cca460281121105c1ba413a67fa8bcc02be9900..6b0681cf928b713907fd74d0613a21845165739d 100644
--- a/tests_logs/advanced_tests/greeting/with_FEC/greeting_receiver_stats.csv
+++ b/tests_logs/advanced_tests/greeting/with_FEC/greeting_receiver_stats.csv
@@ -1,12 +1,12 @@
 data_sent:0
-data_received:2
+data_received:3
 data_truncated_received:0
 fec_sent:0
 fec_received:0
 ack_sent:2
 ack_received:0
 nack_received:0
-packet_ignored:2
-throughput:512.000000
-packet_duplicated:0
+packet_ignored:0
+throughput:47.666336
+packet_duplicated:1
 packet_recovered:0
diff --git a/tests_logs/advanced_tests/greeting/with_FEC/greeting_sender_stats.csv b/tests_logs/advanced_tests/greeting/with_FEC/greeting_sender_stats.csv
index 5e09fbfcb0032b636f16df62fe48569aee05947d..bc7c5b7e4536879356acf12cf3be45307f1cae05 100644
--- a/tests_logs/advanced_tests/greeting/with_FEC/greeting_sender_stats.csv
+++ b/tests_logs/advanced_tests/greeting/with_FEC/greeting_sender_stats.csv
@@ -7,7 +7,7 @@ ack_sent:0
 ack_received:2
 nack_received:0
 packet_ignored:0
-throughput:47.384007
-min_rtt:9
-max_rtt:2007
+throughput:23.295319
+min_rtt:1998
+max_rtt:2113
 packet_retransmitted:1
diff --git a/tests_logs/advanced_tests/greeting/without_FEC/adv_greeting_link.log b/tests_logs/advanced_tests/greeting/without_FEC/adv_greeting_link.log
index 8d764b6f82e3a42c3a1bf470883e35d6a28508b0..14a69bf7a58aa6df88497ed87578d6eb59c61327 100644
--- a/tests_logs/advanced_tests/greeting/without_FEC/adv_greeting_link.log
+++ b/tests_logs/advanced_tests/greeting/without_FEC/adv_greeting_link.log
@@ -1,19 +1,20 @@
-@@ Using random seed: 1650927063
+@@ Using random seed: 1650983305
 @@ Using parameters:
-.. port: 65120
-.. forward_port: 65052
-.. delay: 0
-.. jitter: 0
-.. err_rate: 20
-.. cut_rate: 30
-.. loss_rate: 25
-.. seed: 1650927063
+.. port: 65077
+.. forward_port: 65152
+.. delay: 100
+.. jitter: 100
+.. err_rate: 1
+.. cut_rate: 1
+.. loss_rate: 1
+.. seed: 1650983305
 .. link_direction: Forward
-@@ Remote host is ::1 [41832]
-[SEQ   0] Sent packet (Forward).
+@@ Remote host is ::1 [55093]
+[SEQ   0] Delayed packet by 9 ms
 [SEQ   0] Sent packet (Forward).
+[SEQ   0] Delayed packet by 53 ms
 [SEQ   1] Sent packet (Reverse).
-[SEQ   1] Dropping packet
-[SEQ   1] Dropping packet
+[SEQ   1] Delayed packet by 7 ms
 [SEQ   1] Sent packet (Forward).
+[SEQ   0] Sent packet (Forward).
 [SEQ   2] Sent packet (Reverse).
diff --git a/tests_logs/advanced_tests/greeting/without_FEC/adv_greeting_receiver.log b/tests_logs/advanced_tests/greeting/without_FEC/adv_greeting_receiver.log
index 48791b44ce977ae19240d7902541406199b66f4c..1c1369c429fccc9702d1a2f548ebc1c7550801ee 100644
--- a/tests_logs/advanced_tests/greeting/without_FEC/adv_greeting_receiver.log
+++ b/tests_logs/advanced_tests/greeting/without_FEC/adv_greeting_receiver.log
@@ -1,6 +1,6 @@
-[DEBUG] Receiver has following arguments: stats_filename is tests_logs/advanced_tests/greeting/without_FEC/greeting_receiver_stats.csv, listen_ip is ::1, listen_port is 65052
-[DEBUG] Successfully bound to IPv6 address : 0000:0000:0000:0000:0000:0000:0000:0001, port : 65052
-[DEBUG] Successfully connected to IPv6 addresss: 0000:0000:0000:0000:0000:0000:0000:0001, port : 65120
+[DEBUG] Receiver has following arguments: stats_filename is tests_logs/advanced_tests/greeting/without_FEC/greeting_receiver_stats.csv, listen_ip is ::1, listen_port is 65152
+[DEBUG] Successfully bound to IPv6 address : 0000:0000:0000:0000:0000:0000:0000:0001, port : 65152
+[DEBUG] Successfully connected to IPv6 addresss: 0000:0000:0000:0000:0000:0000:0000:0001, port : 65077
 [DEBUG] Received data packet seqnum 0 with timestamp 984824098 | current_window_size : 31, current_window_start : 0
 [DEBUG] Sent ACK saying we are waiting for 1, timestamp 0
 [DEBUG] Received data packet seqnum 1 with timestamp 0 | current_window_size : 30, current_window_start : 0
@@ -8,8 +8,9 @@
 [DEBUG] Consuming packet : 0 | curr_recv_window = 29, recv_window_start = 0
 [DEBUG] Consuming packet : 1 | curr_recv_window = 30, recv_window_start = 1
 [DEBUG] Received the last packet
+[DEBUG] Received packet [0] Out of window with timestamp 984824098 | receive window start at : 2 (included) till 33 (excluded)
 [DEBUG] Sent ACK saying we are waiting for 2, timestamp 0
 [DEBUG] Done the transfer with done status being true
-[DEBUG] The difference between the two is 4.000000 seconds
-[DEBUG] The transfer took 4.000000 seconds
+[DEBUG] The difference between the two is 2014000.000000 seconds
+[DEBUG] The transfer took 2014.000000 seconds
 [DEBUG] Wrote the transfer statistics to tests_logs/advanced_tests/greeting/without_FEC/greeting_receiver_stats.csv.
diff --git a/tests_logs/advanced_tests/greeting/without_FEC/adv_greeting_sender.log b/tests_logs/advanced_tests/greeting/without_FEC/adv_greeting_sender.log
index 5b9d5b7d3b0e648366264f184fb9ef16967e7e61..c4b0e6eb2e134a99888a6b3a2569a7884d92dd8b 100644
--- a/tests_logs/advanced_tests/greeting/without_FEC/adv_greeting_sender.log
+++ b/tests_logs/advanced_tests/greeting/without_FEC/adv_greeting_sender.log
@@ -3,8 +3,8 @@
 		stats_filename is tests_logs/advanced_tests/greeting/without_FEC/greeting_sender_stats.csv,
 		fec_enabled is 0,
 		receiver_ip is ::1,
-		receiver_port is 65120
-[DEBUG] Successfully connected to IPv6 addresss: 0000:0000:0000:0000:0000:0000:0000:0001, port : 65120
+		receiver_port is 65077
+[DEBUG] Successfully connected to IPv6 addresss: 0000:0000:0000:0000:0000:0000:0000:0001, port : 65077
 [DEBUG] The sender will send a pkt on the socket, the current sender window size is: 31 | receiver window size: 1
 [DEBUG] The LAST PTYPE_DATA is being sent !
 [DEBUG] Sending the pkt with seqnum: 0
@@ -17,10 +17,6 @@
 [DEBUG] The CLOSING pkt is being sent !
 [DEBUG] Sending the pkt with seqnum: 1
 [DEBUG] A timer of -> 30000ms <- has started after sending the last PTYPE_DATA pkt !
-[DEBUG] The pkt with seqnum: 1 has timeout
-[DEBUG] Sending the pkt with seqnum: 1
-[DEBUG] The pkt with seqnum: 1 has timeout
-[DEBUG] Sending the pkt with seqnum: 1
 [DEBUG] The sender is reading from the socket.
 [DEBUG] The ACK with the seqnum: 2 has been received
 [DEBUG] The sender is cumulatively acknowledging [1 : 2[ (place in the buffer) | [1, 2[ (seqnum)
diff --git a/tests_logs/advanced_tests/greeting/without_FEC/adv_valgrind_greeting_receiver.log b/tests_logs/advanced_tests/greeting/without_FEC/adv_valgrind_greeting_receiver.log
index d2d736b0c89f02b72428fd4edc9fa6598c199e9c..5f6ee5e897f9bd117bd31c3074b11952b1a4a5c2 100644
--- a/tests_logs/advanced_tests/greeting/without_FEC/adv_valgrind_greeting_receiver.log
+++ b/tests_logs/advanced_tests/greeting/without_FEC/adv_valgrind_greeting_receiver.log
@@ -1,15 +1,15 @@
-==16421== Memcheck, a memory error detector
-==16421== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
-==16421== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
-==16421== Command: ./receiver ::1 65052 -s tests_logs/advanced_tests/greeting/without_FEC/greeting_receiver_stats.csv
-==16421== Parent PID: 16271
-==16421== 
-==16421== 
-==16421== HEAP SUMMARY:
-==16421==     in use at exit: 0 bytes in 0 blocks
-==16421==   total heap usage: 13 allocs, 13 frees, 9,848 bytes allocated
-==16421== 
-==16421== All heap blocks were freed -- no leaks are possible
-==16421== 
-==16421== For lists of detected and suppressed errors, rerun with: -s
-==16421== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+==31095== Memcheck, a memory error detector
+==31095== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
+==31095== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
+==31095== Command: ./receiver ::1 65152 -s tests_logs/advanced_tests/greeting/without_FEC/greeting_receiver_stats.csv
+==31095== Parent PID: 30999
+==31095== 
+==31095== 
+==31095== HEAP SUMMARY:
+==31095==     in use at exit: 0 bytes in 0 blocks
+==31095==   total heap usage: 14 allocs, 14 frees, 10,400 bytes allocated
+==31095== 
+==31095== All heap blocks were freed -- no leaks are possible
+==31095== 
+==31095== For lists of detected and suppressed errors, rerun with: -s
+==31095== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
diff --git a/tests_logs/advanced_tests/greeting/without_FEC/adv_valgrind_greeting_sender.log b/tests_logs/advanced_tests/greeting/without_FEC/adv_valgrind_greeting_sender.log
index 103a6e97cbfed5bd567447933c3adb239c851e64..9af96f47dba10ab23148e7b609eb8b3e3a728488 100644
--- a/tests_logs/advanced_tests/greeting/without_FEC/adv_valgrind_greeting_sender.log
+++ b/tests_logs/advanced_tests/greeting/without_FEC/adv_valgrind_greeting_sender.log
@@ -1,15 +1,15 @@
-==16422== Memcheck, a memory error detector
-==16422== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
-==16422== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
-==16422== Command: ./sender -f tests_files/greeting.txt ::1 65120 -s tests_logs/advanced_tests/greeting/without_FEC/greeting_sender_stats.csv
-==16422== Parent PID: 16271
-==16422== 
-==16422== 
-==16422== HEAP SUMMARY:
-==16422==     in use at exit: 0 bytes in 0 blocks
-==16422==   total heap usage: 10 allocs, 10 frees, 4,916 bytes allocated
-==16422== 
-==16422== All heap blocks were freed -- no leaks are possible
-==16422== 
-==16422== For lists of detected and suppressed errors, rerun with: -s
-==16422== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+==31096== Memcheck, a memory error detector
+==31096== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
+==31096== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
+==31096== Command: ./sender -f tests_files/greeting.txt ::1 65077 -s tests_logs/advanced_tests/greeting/without_FEC/greeting_sender_stats.csv
+==31096== Parent PID: 30999
+==31096== 
+==31096== 
+==31096== HEAP SUMMARY:
+==31096==     in use at exit: 0 bytes in 0 blocks
+==31096==   total heap usage: 9 allocs, 9 frees, 3,892 bytes allocated
+==31096== 
+==31096== All heap blocks were freed -- no leaks are possible
+==31096== 
+==31096== For lists of detected and suppressed errors, rerun with: -s
+==31096== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
diff --git a/tests_logs/advanced_tests/greeting/without_FEC/greeting_receiver_stats.csv b/tests_logs/advanced_tests/greeting/without_FEC/greeting_receiver_stats.csv
index 4349be0fa8d77e66fbc554ac94172896255c0aa4..871b8b51b8e3f1cae814da55ac74c72393b649c2 100644
--- a/tests_logs/advanced_tests/greeting/without_FEC/greeting_receiver_stats.csv
+++ b/tests_logs/advanced_tests/greeting/without_FEC/greeting_receiver_stats.csv
@@ -7,6 +7,6 @@ ack_sent:2
 ack_received:0
 nack_received:0
 packet_ignored:0
-throughput:256.000000
+throughput:47.666336
 packet_duplicated:0
 packet_recovered:0
diff --git a/tests_logs/advanced_tests/greeting/without_FEC/greeting_sender_stats.csv b/tests_logs/advanced_tests/greeting/without_FEC/greeting_sender_stats.csv
index fa8aa91972f736a6b2e24485c66d12ee1868c564..f753a38ad773d672430f4eefe441923515938ae0 100644
--- a/tests_logs/advanced_tests/greeting/without_FEC/greeting_sender_stats.csv
+++ b/tests_logs/advanced_tests/greeting/without_FEC/greeting_sender_stats.csv
@@ -1,4 +1,4 @@
-data_sent:5
+data_sent:3
 data_received:0
 data_truncated_received:0
 fec_sent:0
@@ -7,7 +7,7 @@ ack_sent:0
 ack_received:2
 nack_received:0
 packet_ignored:0
-throughput:15.920398
-min_rtt:2015
-max_rtt:4006
-packet_retransmitted:3
+throughput:23.874659
+min_rtt:1998
+max_rtt:2014
+packet_retransmitted:1
diff --git a/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_link.log b/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_link.log
index 1f2eefe581c1802b98247118ce70cf2340b92802..d8c623dafb12014a16694bd87eae4912261c9a24 100644
--- a/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_link.log
+++ b/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_link.log
@@ -1,11 +1,29 @@
-@@ Using random seed: 1650927074
+@@ Using random seed: 1650983314
 @@ Using parameters:
-.. port: 65173
-.. forward_port: 65181
-.. delay: 0
-.. jitter: 0
-.. err_rate: 20
-.. cut_rate: 30
-.. loss_rate: 25
-.. seed: 1650927074
+.. port: 65022
+.. forward_port: 65119
+.. delay: 100
+.. jitter: 100
+.. err_rate: 1
+.. cut_rate: 1
+.. loss_rate: 1
+.. seed: 1650983314
 .. link_direction: Forward
+@@ Remote host is ::1 [60845]
+[SEQ   0] Delayed packet by 22 ms
+[SEQ   0] Sent packet (Forward).
+[SEQ   0] Delayed packet by 53 ms
+[SEQ   1] Sent packet (Reverse).
+[SEQ   1] Delayed packet by 129 ms
+[SEQ   2] Delayed packet by 79 ms
+[SEQ   0] Sent packet (Forward).
+[SEQ   2] Sent packet (Forward).
+[SEQ   1] Sent packet (Forward).
+[SEQ   3] Sent packet (Reverse).
+[SEQ   3] Delayed packet by 138 ms
+[FEC   0] Delayed packet by 147 ms
+[SEQ   3] Sent packet (Forward).
+[FEC   0] Sent packet (Forward).
+[SEQ   3] Delayed packet by 115 ms
+[SEQ   4] Sent packet (Reverse).
+[SEQ   3] Sent packet (Forward).
diff --git a/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_received_file.txt b/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_received_file.txt
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a18b03ec08fdc53c1f0a5e0fc9187b5a0f18568f 100644
--- a/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_received_file.txt
+++ b/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_received_file.txt
@@ -0,0 +1,29 @@
+Hello I'm a good friend, I've seen that you are writing a protocol named TRTP. 
+How is it going ? Hard ? Good for you. See life is full of hard things just like your 
+network course. But when you manage to thrive throgh tough times then sweet things are 
+ahead. So good luck have a nice day of testing and remember : Tough Times Never Last.
+
+PS: Drink a beer when you pass the test. Share your knowledge to others, computer 
+science isn't a field for selfishness. If you want to switch to Law, Economy, some shit
+
+Hi Vany I'm pleased to read some news from you. As you know I work sometime a bit late in the night.
+In a few hour you'll show up in the famous "Salle Intel" to be really productive as you are.
+
+Best regards,
+
+Samuel
+
+Sorry to be lazy but I'll past down what is above :')
+
+Hello I'm a good friend, I've seen that you are writing a protocol named TRTP. 
+How is it going ? Hard ? Good for you. See life is full of hard things just like your 
+network course. But when you manage to thrive throgh tough times then sweet things are 
+ahead. So good luck have a nice day of testing and remember : Tough Times Never Last.
+
+PS: Drink a beer when you pass the test. Share your knowledge to others, computer 
+science isn't a field for selfishness. If you want to switch to Law, Economy, some shit
+
+Hi Vany I'm pleased to read some news from you. As you know I work sometime a bit late in the night.
+In a few hour you'll show up in the famous "Salle Intel" to be really productive as you are.
+
+Best regards,
diff --git a/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_receiver.log b/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_receiver.log
index 2b8958496893c6c7727a939accdefcf5de3dcc6d..68d46c0f1ada4b5fb1ffd9b28df1cc375e69d8f3 100644
--- a/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_receiver.log
+++ b/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_receiver.log
@@ -1,2 +1,22 @@
-[DEBUG] Receiver has following arguments: stats_filename is tests_logs/advanced_tests/long_message/with_FEC/long_message_receiver_stats.csv, listen_ip is ::1, listen_port is 65181
-[DEBUG] Successfully bound to IPv6 address : 0000:0000:0000:0000:0000:0000:0000:0001, port : 65181
+[DEBUG] Receiver has following arguments: stats_filename is tests_logs/advanced_tests/long_message/with_FEC/long_message_receiver_stats.csv, listen_ip is ::1, listen_port is 65119
+[DEBUG] Successfully bound to IPv6 address : 0000:0000:0000:0000:0000:0000:0000:0001, port : 65119
+[DEBUG] Successfully connected to IPv6 addresss: 0000:0000:0000:0000:0000:0000:0000:0001, port : 65022
+[DEBUG] Received data packet seqnum 0 with timestamp 0 | current_window_size : 31, current_window_start : 0
+[DEBUG] Sent ACK saying we are waiting for 1, timestamp 0
+[DEBUG] Received data packet seqnum 0 with timestamp 0 | current_window_size : 30, current_window_start : 0
+[DEBUG] Received data packet seqnum 2 with timestamp 984824098 | current_window_size : 30, current_window_start : 0
+[DEBUG] Received data packet seqnum 1 with timestamp 0 | current_window_size : 29, current_window_start : 0
+[DEBUG] Sent ACK saying we are waiting for 3, timestamp 0
+[DEBUG] Received data packet seqnum 3 with timestamp 0 | current_window_size : 28, current_window_start : 0
+[DEBUG] Going to consume the next 4 packets.
+[DEBUG] Consuming packet : 0 | curr_recv_window = 27, recv_window_start = 0
+[DEBUG] Consuming packet : 1 | curr_recv_window = 28, recv_window_start = 1
+[DEBUG] Consuming packet : 2 | curr_recv_window = 29, recv_window_start = 2
+[DEBUG] Consuming packet : 3 | curr_recv_window = 30, recv_window_start = 3
+[DEBUG] Received the last packet
+[DEBUG] Received packet [0] Out of window with timestamp 0 | receive window start at : 4 (included) till 35 (excluded)
+[DEBUG] Sent ACK saying we are waiting for 4, timestamp 0
+[DEBUG] Done the transfer with done status being true
+[DEBUG] The difference between the two is 4142000.000000 seconds
+[DEBUG] The transfer took 4142.000000 seconds
+[DEBUG] Wrote the transfer statistics to tests_logs/advanced_tests/long_message/with_FEC/long_message_receiver_stats.csv.
diff --git a/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_sender.log b/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_sender.log
index 02d6e23c7374056465e69fc753e781663cf1d7fe..265b165e9099462d2aeb8b3f902b165af1be0ddd 100644
--- a/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_sender.log
+++ b/tests_logs/advanced_tests/long_message/with_FEC/adv_long_message_sender.log
@@ -3,6 +3,34 @@
 		stats_filename is tests_logs/advanced_tests/long_message/with_FEC/long_message_sender_stats.csv,
 		fec_enabled is 1,
 		receiver_ip is ::1,
-		receiver_port is 65173
-[DEBUG] Successfully connected to IPv6 addresss: 0000:0000:0000:0000:0000:0000:0000:0001, port : 65173
+		receiver_port is 65022
+[DEBUG] Successfully connected to IPv6 addresss: 0000:0000:0000:0000:0000:0000:0000:0001, port : 65022
 [DEBUG] The sender will send a pkt on the socket, the current sender window size is: 31 | receiver window size: 1
+[DEBUG] Sending the pkt with seqnum: 0
+[DEBUG] The pkt with seqnum: 0 has timeout
+[DEBUG] Sending the pkt with seqnum: 0
+[DEBUG] The sender is reading from the socket.
+[DEBUG] The ACK with the seqnum: 1 has been received
+[DEBUG] The sender is cumulatively acknowledging [0 : 1[ (place in the buffer) | [0, 1[ (seqnum)
+[DEBUG] The sender will send a pkt on the socket, the current sender window size is: 31 | receiver window size: 30
+[DEBUG] Sending the pkt with seqnum: 1
+[DEBUG] The sender will send a pkt on the socket, the current sender window size is: 30 | receiver window size: 29
+[DEBUG] The LAST PTYPE_DATA is being sent !
+[DEBUG] Sending the pkt with seqnum: 2
+[DEBUG] The sender is reading from the socket.
+[DEBUG] The ACK with the seqnum: 3 has been received
+[DEBUG] The sender is cumulatively acknowledging [1 : 3[ (place in the buffer) | [1, 3[ (seqnum)
+[DEBUG] The sender will send a pkt on the socket, the current sender window size is: 31 | receiver window size: 29
+[DEBUG] The CLOSING pkt is being sent !
+[DEBUG] Sending the pkt with seqnum: 3
+[DEBUG] A timer of -> 30000ms <- has started after sending the last PTYPE_DATA pkt !
+[DEBUG] The sender will send a pkt on the socket, the current sender window size is: 30 | receiver window size: 28
+[DEBUG] Sending LAST FEC pkt with seqnum: 0
+[DEBUG] A timer of -> 30000ms <- has started after sending the last PTYPE_DATA pkt !
+[DEBUG] The pkt with seqnum: 3 has timeout
+[DEBUG] Sending the pkt with seqnum: 3
+[DEBUG] The sender is reading from the socket.
+[DEBUG] The ACK with the seqnum: 4 has been received
+[DEBUG] The sender is cumulatively acknowledging [3 : 4[ (place in the buffer) | [3, 4[ (seqnum)
+[DEBUG] Sender disconnected
+[DEBUG] Wrote the transfer statistics to tests_logs/advanced_tests/long_message/with_FEC/long_message_sender_stats.csv.
diff --git a/tests_logs/advanced_tests/long_message/with_FEC/adv_valgrind_long_message_receiver.log b/tests_logs/advanced_tests/long_message/with_FEC/adv_valgrind_long_message_receiver.log
index bf0bb35748ff9284fe845989e526b0e4352254b6..e33dcc9d5071b1fb89012488786ca485b22f3d70 100644
--- a/tests_logs/advanced_tests/long_message/with_FEC/adv_valgrind_long_message_receiver.log
+++ b/tests_logs/advanced_tests/long_message/with_FEC/adv_valgrind_long_message_receiver.log
@@ -1,6 +1,15 @@
-==16542== Memcheck, a memory error detector
-==16542== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
-==16542== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
-==16542== Command: ./receiver ::1 65181 -s tests_logs/advanced_tests/long_message/with_FEC/long_message_receiver_stats.csv
-==16542== Parent PID: 16512
-==16542== 
+==31160== Memcheck, a memory error detector
+==31160== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
+==31160== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
+==31160== Command: ./receiver ::1 65119 -s tests_logs/advanced_tests/long_message/with_FEC/long_message_receiver_stats.csv
+==31160== Parent PID: 31130
+==31160== 
+==31160== 
+==31160== HEAP SUMMARY:
+==31160==     in use at exit: 0 bytes in 0 blocks
+==31160==   total heap usage: 20 allocs, 20 frees, 13,568 bytes allocated
+==31160== 
+==31160== All heap blocks were freed -- no leaks are possible
+==31160== 
+==31160== For lists of detected and suppressed errors, rerun with: -s
+==31160== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
diff --git a/tests_logs/advanced_tests/long_message/with_FEC/adv_valgrind_long_message_sender.log b/tests_logs/advanced_tests/long_message/with_FEC/adv_valgrind_long_message_sender.log
index 08b7dd96b33a156aede883ddd9ad3c55392edbe6..bc649bf3e52313dcc275a0978ce700dbc01fecfc 100644
--- a/tests_logs/advanced_tests/long_message/with_FEC/adv_valgrind_long_message_sender.log
+++ b/tests_logs/advanced_tests/long_message/with_FEC/adv_valgrind_long_message_sender.log
@@ -1,35 +1,15 @@
-==16543== Memcheck, a memory error detector
-==16543== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
-==16543== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
-==16543== Command: ./sender -f tests_files/long_message.txt ::1 65173 -c -s tests_logs/advanced_tests/long_message/with_FEC/long_message_sender_stats.csv
-==16543== Parent PID: 16512
-==16543== 
-==16543== 
-==16543== Process terminating with default action of signal 2 (SIGINT)
-==16543==    at 0x49890A5: write (write.c:26)
-==16543==    by 0x4909EBC: _IO_file_write@@GLIBC_2.2.5 (fileops.c:1181)
-==16543==    by 0x490A7D7: new_do_write (fileops.c:449)
-==16543==    by 0x490A7D7: _IO_new_file_xsputn (fileops.c:1255)
-==16543==    by 0x490A7D7: _IO_file_xsputn@@GLIBC_2.2.5 (fileops.c:1197)
-==16543==    by 0x48F4F82: buffered_vfprintf (vfprintf-internal.c:2395)
-==16543==    by 0x48F1D53: __vfprintf_internal (vfprintf-internal.c:1346)
-==16543==    by 0x49A9152: __fprintf_chk (fprintf_chk.c:33)
-==16543==    by 0x10B1CA: send_pkt (in /mnt/datalinux/Documents/BAC-SINF/bac3/Q2/reseaux/projet/project_trtp/sender)
-==16543==    by 0x10BBF4: read_and_send (in /mnt/datalinux/Documents/BAC-SINF/bac3/Q2/reseaux/projet/project_trtp/sender)
-==16543==    by 0x109694: main (in /mnt/datalinux/Documents/BAC-SINF/bac3/Q2/reseaux/projet/project_trtp/sender)
-==16543== 
-==16543== HEAP SUMMARY:
-==16543==     in use at exit: 2,756 bytes in 5 blocks
-==16543==   total heap usage: 7 allocs, 2 frees, 2,836 bytes allocated
-==16543== 
-==16543== LEAK SUMMARY:
-==16543==    definitely lost: 0 bytes in 0 blocks
-==16543==    indirectly lost: 0 bytes in 0 blocks
-==16543==      possibly lost: 0 bytes in 0 blocks
-==16543==    still reachable: 2,756 bytes in 5 blocks
-==16543==         suppressed: 0 bytes in 0 blocks
-==16543== Reachable blocks (those to which a pointer was found) are not shown.
-==16543== To see them, rerun with: --leak-check=full --show-leak-kinds=all
-==16543== 
-==16543== For lists of detected and suppressed errors, rerun with: -s
-==16543== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+==31161== Memcheck, a memory error detector
+==31161== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
+==31161== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
+==31161== Command: ./sender -f tests_files/long_message.txt ::1 65022 -c -s tests_logs/advanced_tests/long_message/with_FEC/long_message_sender_stats.csv
+==31161== Parent PID: 31130
+==31161== 
+==31161== 
+==31161== HEAP SUMMARY:
+==31161==     in use at exit: 0 bytes in 0 blocks
+==31161==   total heap usage: 13 allocs, 13 frees, 6,004 bytes allocated
+==31161== 
+==31161== All heap blocks were freed -- no leaks are possible
+==31161== 
+==31161== For lists of detected and suppressed errors, rerun with: -s
+==31161== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
diff --git a/tests_logs/advanced_tests/long_message/with_FEC/long_message_receiver_stats.csv b/tests_logs/advanced_tests/long_message/with_FEC/long_message_receiver_stats.csv
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..032a883990951c8e5be2b3c48ba01f5a1fe99fdf 100644
--- a/tests_logs/advanced_tests/long_message/with_FEC/long_message_receiver_stats.csv
+++ b/tests_logs/advanced_tests/long_message/with_FEC/long_message_receiver_stats.csv
@@ -0,0 +1,12 @@
+data_sent:0
+data_received:5
+data_truncated_received:0
+fec_sent:0
+fec_received:0
+ack_sent:3
+ack_received:0
+nack_received:0
+packet_ignored:0
+throughput:2916.465576
+packet_duplicated:1
+packet_recovered:0
diff --git a/tests_logs/advanced_tests/long_message/with_FEC/long_message_sender_stats.csv b/tests_logs/advanced_tests/long_message/with_FEC/long_message_sender_stats.csv
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0d3bb5adec8897f1308b0350916ead8b0e01c787 100644
--- a/tests_logs/advanced_tests/long_message/with_FEC/long_message_sender_stats.csv
+++ b/tests_logs/advanced_tests/long_message/with_FEC/long_message_sender_stats.csv
@@ -0,0 +1,13 @@
+data_sent:6
+data_received:0
+data_truncated_received:0
+fec_sent:1
+fec_received:0
+ack_sent:0
+ack_received:3
+nack_received:0
+packet_ignored:0
+throughput:2001.657104
+min_rtt:1997
+max_rtt:2026
+packet_retransmitted:2