[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-devel] tcp_output does not force seg sent out
From: |
Simon Goldschmidt |
Subject: |
Re: [lwip-devel] tcp_output does not force seg sent out |
Date: |
Fri, 09 Mar 2012 08:08:30 +0100 |
narke <address@hidden> wrote:
> I found it's not always that the tcp_output() call can make a segment
> to be sent out. Sometimes it still accumulated data until TCP_MSS
> reached before output a segment.
That's the nagle algorithm (-> google). In short, it tries to limit the
overhead of ACK segments by sending as little segments as possible by combining
multiple calls to write() into a single segment.
> In what situation that tcp_output()
> does not output segment?
A segment is sent tcp_do_output_nagle() results in 1:
#define tcp_do_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \
((tpcb)->flags & (TF_NODELAY | TF_INFR)) || \
(((tpcb)->unsent != NULL) && (((tpcb)->unsent->next
!= NULL) || \
((tpcb)->unsent->len >= (tpcb)->mss))) || \
((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb)
>= TCP_SND_QUEUELEN)) \
) ? 1 : 0)
In other words, if there is unacked data, we wait for it to be acked or to send
a full segment (unless we are in fast retransmit or ran out of lwIP buffers).
> And, how do I ensure the output behavior
> really happen?
Call tcp_nagle_enable(pcb).
Simon
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de