WIP: Layer 2-Implementierung #6

Draft
thomas wants to merge 39 commits from layer2_dev into main
Showing only changes of commit 176770eef5 - Show all commits

View file

@ -408,10 +408,18 @@ int main(void)
bool tx_request_received = false; bool tx_request_received = false;
result_t result = connection_handle_packet(&l2conn, packetbuf, ret, &data_packet, &tx_request_received); result_t result = connection_handle_packet(&l2conn, packetbuf, ret, &data_packet, &tx_request_received);
may_tx = may_tx || tx_request_received;
// Switch to TX when a packet with tx_request=1 was decoded successfully.
// Note that this even triggers if the packet is out of sequence (but not for corrupted packets).
if(tx_request_received) {
may_tx = true;
}
switch(result) { switch(result) {
case OK: case OK:
// update statistics
m_rx_stats.successful_decodes++; m_rx_stats.successful_decodes++;
total_bytes += ret;
if(data_packet.payload_len != 0) { if(data_packet.payload_len != 0) {
rx_data_to_tun(&data_packet); rx_data_to_tun(&data_packet);
@ -436,8 +444,6 @@ int main(void)
break; break;
} }
total_bytes += ret;
uint64_t new = get_hires_time(); uint64_t new = get_hires_time();
if(new >= next_stats_print_time) { if(new >= next_stats_print_time) {
double rate = total_bytes * 1e9 / (new - old); double rate = total_bytes * 1e9 / (new - old);