l2udptest_client: Improve code readability; only count valid data in statistics
This commit is contained in:
parent
cea8145946
commit
176770eef5
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue