From 99a48af087b62638a74a1d6618ffde7e95de4e16 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sat, 22 Aug 2020 22:57:35 -0500 Subject: [PATCH] Stop Timer T2 when sending RR on k/2 unacked When handling I frames, stop Timer T2 if the number of unacknowledged frames has reached k/2 Other changes: * Provide annotations from the AX.25 v2.2 standards document * Improve implementation of I frame reception P/F procedure --- src/server.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/server.c b/src/server.c index 3838d80..325d457 100644 --- a/src/server.c +++ b/src/server.c @@ -1616,11 +1616,30 @@ static int handle_i(patty_ax25_server *server, } } - if (++sock->rx_pending == sock->n_window_rx / 2) { + if (frame->pf || ++sock->rx_pending == sock->n_window_rx / 2) { + /* + * AX.25 v2.2 Section 6.7.1.2 "Response Delay Timer T2" + * + * Timer T2, the Response Delay Timer, may optionally be implemented + * by the TNC to specify a maximum amount of delay to be introduced + * between the time an I frame is received and the time the resulting + * response frame is sent. This delay is introduced to allow a + * receiving TNC to wait a short period of time to determine if more + * than one frame is being sent to it. If more frames are received, + * the TNC can acknowledge them at once (up to seven), + * rather than acknowledging each individual frame. The use of Timer + * T2 is not required; it is simply recommended to improve channel + * efficiency. Note that to achieve maximum throughput on full-duplex + * channels, acknowledgements should not be delayed beyond k/2 + * frames. The k parameter is defined in Section 6.8.2.3. + */ sock->rx_pending = 0; patty_timer_stop(&sock->timer_t2); + /* + * AX.25 v2.2 Section 6.2 "Poll/Final (P/F) Bit Procedures" + */ return frame->pf? patty_ax25_sock_send_rr(sock, PATTY_AX25_FRAME_RESPONSE, 1): 0; } @@ -1628,13 +1647,6 @@ static int handle_i(patty_ax25_server *server, patty_timer_start(&sock->timer_t2); patty_timer_start(&sock->timer_t3); - /* - * AX.25 v2.2 Section 6.2 "Poll/Final (P/F) Bit Procedures" - */ - if (frame->pf == 1) { - return patty_ax25_sock_send_rr(sock, PATTY_AX25_FRAME_RESPONSE, 1); - } - return 0; error_handle_segment: