lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] Purpose of undocumented piece of code in tcp_output_seg


From: Leon Woestenberg
Subject: Re: [lwip-devel] Purpose of undocumented piece of code in tcp_output_segments()?
Date: Fri, 18 Oct 2024 23:32:15 +0200



On Fri, Oct 18, 2024 at 4:38 PM Leon Woestenberg <leon@sidebranch.com> wrote:
What is the purpose of this piece of code in tcp_output_segments()?
(i.e. the code that is going to transmit a TCP segment).

  len = (u16_t)((u8_t *)seg->tcphdr - (u8_t *)seg->p->payload);
  if (len == 0) {
    /** Exclude retransmitted segments from this count. */
    MIB2_STATS_INC(mib2.tcpoutsegs);
  }
  seg->p->len -= len;
  seg->p->tot_len -= len;
  seg->p->payload = seg->tcphdr;

So answering my own question, it seems to have to do with the approach that the first time the TCP segments get sent, the lower layers (IP and typically Ethernet) extend the payload towards the front.

This code seems to undo that in case the segments get retransmitted again. (As the newly sent segments have slightly different IP headers, these need to be re-generated.)

Regards,

Leon.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]