connection: do not send ACKs for empty packets
Some checks failed
/ build-hamnet70 (push) Failing after 27s
/ build-doc (push) Successful in 15s
/ deploy-doc (push) Has been skipped

This commit is contained in:
Thomas Kolb 2024-09-22 15:56:43 +02:00
parent dedad8b81f
commit 8c3eca658c
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:
LOG(LVL_DEBUG, "Empty packet: accepted ACK for %u.", ctx->last_acked_seq);
// 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
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);
// 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);
@ -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
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);
if(packets_available == 0) {
if(do_ack && packets_available == 0) {
// no packets left in queue, but an acknowledgement must be
// transmitted. Add an empty packet to do that.
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 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.
*/