connection: do not send ACKs for empty packets

This commit is contained in:
Thomas Kolb 2024-09-22 15:56:43 +02:00
parent 307fdc657d
commit 02a2afbc5b
2 changed files with 5 additions and 5 deletions

View file

@ -115,7 +115,7 @@ result_t connection_handle_packet(connection_ctx_t *ctx, const uint8_t *buf, siz
case L2_MSG_TYPE_EMPTY: case L2_MSG_TYPE_EMPTY:
LOG(LVL_DEBUG, "Empty packet: accepted ACK for %u.", ctx->last_acked_seq); LOG(LVL_DEBUG, "Empty packet: accepted ACK for %u.", ctx->last_acked_seq);
// handle the acknowledgement internally // handle the acknowledgement internally
connection_handle_ack(ctx, header.rx_seq_nr); connection_handle_ack(ctx, header.rx_seq_nr, false);
return OK; // do not ACK and call back return OK; // do not ACK and call back
case L2_MSG_TYPE_CONN_MGMT: case L2_MSG_TYPE_CONN_MGMT:
@ -142,7 +142,7 @@ result_t connection_handle_packet(connection_ctx_t *ctx, const uint8_t *buf, siz
LOG(LVL_INFO, "Received ACK for seq_nr %u in packet seq_nr %u.", header.rx_seq_nr, header.tx_seq_nr); LOG(LVL_INFO, "Received ACK for seq_nr %u in packet seq_nr %u.", header.rx_seq_nr, header.tx_seq_nr);
// handle the acknowledgement internally // handle the acknowledgement internally
connection_handle_ack(ctx, header.rx_seq_nr); connection_handle_ack(ctx, header.rx_seq_nr, true);
size_t header_size = layer2_get_encoded_header_size(&header); size_t header_size = layer2_get_encoded_header_size(&header);
@ -332,7 +332,7 @@ void connection_tx_clean_empty_packet(connection_ctx_t *ctx)
} }
void connection_handle_ack(connection_ctx_t *ctx, uint8_t acked_seq) void connection_handle_ack(connection_ctx_t *ctx, uint8_t acked_seq, bool do_ack)
{ {
// check the connection state // check the connection state
switch(ctx->conn_state) { switch(ctx->conn_state) {
@ -369,7 +369,7 @@ void connection_handle_ack(connection_ctx_t *ctx, uint8_t acked_seq)
LOG(LVL_DEBUG, "handling ack for seq_nr %u, removing %zu packets, %zu packets remaining.", acked_seq, packets_to_remove, packets_available); LOG(LVL_DEBUG, "handling ack for seq_nr %u, removing %zu packets, %zu packets remaining.", acked_seq, packets_to_remove, packets_available);
if(packets_available == 0) { if(do_ack && packets_available == 0) {
// no packets left in queue, but an acknowledgement must be // no packets left in queue, but an acknowledgement must be
// transmitted. Add an empty packet to do that. // transmitted. Add an empty packet to do that.
result_t res = connection_add_empty_packet(ctx, false); result_t res = connection_add_empty_packet(ctx, false);

View file

@ -123,7 +123,7 @@ void connection_tx_clean_empty_packet(connection_ctx_t *ctx);
* \param acked_seq The acknowledged (= next expected) sequence number. * \param acked_seq The acknowledged (= next expected) sequence number.
* \param do_ack Whether an empty packet shall be generated if the queue is empty. * \param do_ack Whether an empty packet shall be generated if the queue is empty.
*/ */
void connection_handle_ack(connection_ctx_t *ctx, uint8_t acked_seq); void connection_handle_ack(connection_ctx_t *ctx, uint8_t acked_seq, bool do_ack);
/*!\brief Check if there are packets queued for transmission. /*!\brief Check if there are packets queued for transmission.
*/ */