Layer 2: Added logging for retransmit handling

This commit is contained in:
Thomas Kolb 2024-07-20 00:26:53 +02:00
parent d449e31586
commit bcbcf5aeff
2 changed files with 17 additions and 0 deletions

View file

@ -4,6 +4,9 @@
#include <errno.h> #include <errno.h>
#define LOGGER_MODULE_NAME "l2rx"
#include "logger.h"
#include "layer2_rx.h" #include "layer2_rx.h"
#include "packet_structs.h" #include "packet_structs.h"
@ -44,6 +47,8 @@ result_t layer2_rx_handle_packet(layer2_rx_t *ctx, const uint8_t *buf, size_t bu
return ERR_INTEGRITY; return ERR_INTEGRITY;
} }
LOG(LVL_DEBUG, "Handling packet with rx_seq_nr %u, tx_seq_nr %u.", header.rx_seq_nr, header.tx_seq_nr);
ctx->last_acked_seq = header.rx_seq_nr; ctx->last_acked_seq = header.rx_seq_nr;
if(ctx->next_expected_seq != header.tx_seq_nr) { if(ctx->next_expected_seq != header.tx_seq_nr) {
@ -54,6 +59,8 @@ result_t layer2_rx_handle_packet(layer2_rx_t *ctx, const uint8_t *buf, size_t bu
ctx->next_expected_seq++; ctx->next_expected_seq++;
ctx->next_expected_seq &= 0xF; ctx->next_expected_seq &= 0xF;
LOG(LVL_INFO, "Received ACK for seq_nr %u in packet seq_nr %u.", header.rx_seq_nr, header.tx_seq_nr);
size_t header_size = layer2_get_encoded_header_size(&header); size_t header_size = layer2_get_encoded_header_size(&header);
// extract the payload and forward it to the tun device // extract the payload and forward it to the tun device

View file

@ -5,6 +5,9 @@
#include <poll.h> #include <poll.h>
#include <errno.h> #include <errno.h>
#define LOGGER_MODULE_NAME "l2tx"
#include "logger.h"
#include "layer2_tx.h" #include "layer2_tx.h"
#include "packet_structs.h" #include "packet_structs.h"
@ -76,6 +79,8 @@ result_t layer2_tx_fill_packet_queue(layer2_tx_t *ctx)
break; break;
} }
LOG(LVL_INFO, "Adding packet tx_seq %u to queue -> %zu entries",
header.tx_seq_nr, packet_queue_get_used_space(&ctx->packet_queue));
packet_queue_add(&ctx->packet_queue, &header, packetbuf, ret); packet_queue_add(&ctx->packet_queue, &header, packetbuf, ret);
ctx->next_seq_nr++; ctx->next_seq_nr++;
@ -104,6 +109,8 @@ size_t layer2_tx_encode_next_packet(layer2_tx_t *ctx, uint8_t ack_seq_nr, uint8_
header.rx_seq_nr = ack_seq_nr; header.rx_seq_nr = ack_seq_nr;
// encode the header // encode the header
LOG(LVL_DEBUG, "Encoding packet with rx_seq_nr %u, tx_seq_nr %u.", header.rx_seq_nr, header.tx_seq_nr);
size_t packet_size = layer2_encode_packet_header(&header, buf); size_t packet_size = layer2_encode_packet_header(&header, buf);
// add the payload data // add the payload data
@ -145,6 +152,9 @@ void layer2_tx_handle_ack(layer2_tx_t *ctx, uint8_t acked_seq)
} }
packet_queue_delete(&ctx->packet_queue, packets_to_remove); packet_queue_delete(&ctx->packet_queue, packets_to_remove);
LOG(LVL_DEBUG, "handling ack for seq_nr %u, removing %zu packets, %zu packets remaining.", acked_seq, packets_to_remove, packet_queue_get_used_space(&ctx->packet_queue));
} }