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

Intercepting FEC packets

parent d3ed91a0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -74,7 +74,7 @@ pkt_status_code pkt_decode_data_fec(const char *data, const size_t len, pkt_t *p
if ( length > 0 )
expected_len += CRC_SIZE;
if ( len != expected_len )
if ( len != expected_len && type != PTYPE_FEC)
return E_UNCONSISTENT;
// We set the TR to 0 in order to calculcate the CRC on the header
......
......@@ -210,6 +210,13 @@ int prepare_ack_to_send(receiver_state_t * state)
int handle_fec_pkt(receiver_state_t * state, const pkt_t * pkt)
{
ASSERT(state != NULL && pkt != NULL);
if (state->last_received_in_order > pkt_get_seqnum(pkt))
{
DEBUG("Received FEC with seqnum %d but wasn't used since last received in order is %d", pkt_get_seqnum(pkt), state->last_received_in_order);
return 0;
}
// Add FEC to state buffer of fec
// See if there's FEC that can be used and update buffer
return 0;
}
......@@ -224,6 +231,9 @@ int handle_fec_pkt(receiver_state_t * state, const pkt_t * pkt)
*/
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);
if (update_buffer_upon_new_data(state, pkt) != 0) return -1;
if (prepare_ack_to_send(state) != 0) return -1;
......@@ -297,9 +307,6 @@ int handle_truncated_pkt(receiver_state_t * state, const pkt_t * pkt)
*/
int handle_valid_pkt(receiver_state_t * state, const pkt_t * pkt)
{
// Feck - Not handled for now
if (pkt_get_type(pkt) != PTYPE_DATA) return 0;
// Is it in the receive_window ?
uint8_t seqnum = pkt_get_seqnum(pkt);
int in_window = (seqnum >= state->recv_window_start);
......@@ -318,15 +325,16 @@ int handle_valid_pkt(receiver_state_t * state, const pkt_t * pkt)
uint8_t tr = pkt_get_tr(pkt);
if (tr == 1)
{ /* If truncated */
{ /* If truncated */
return handle_truncated_pkt(state, pkt);
} else if (pkt_get_type(pkt) == PTYPE_DATA)
{ /* Not */
{ /* Type DATA */
return handle_data_pkt(state, pkt);
} else if (pkt_get_type(pkt) == PTYPE_FEC)
{
{ /* Type FEC */
return handle_fec_pkt(state, pkt);
}
return 0;
}
......@@ -355,14 +363,11 @@ int handle_incoming(struct pollfd * pfd, receiver_state_t * state)
pkt_status_code pkt_status = pkt_decode(buffer, read_bytes, pkt);
if (pkt_status == 0)
{
DEBUG("Received 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);
if (handle_valid_pkt(state, (const pkt_t *) pkt) != 0) return -1;
} else
{
/* If the packet has been damaged we can discuss if it's better to send a ACK
or not but for now we just ignore it */
DEBUG("Received a damaged packet with %d status.", pkt_status);
// See if there's a FEC that can be used and update buffer
pkt_del(pkt);
return prepare_ack_to_send(state);
}
......
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