lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Getting the server to use an MSS larger than 536


From: Mason
Subject: Re: [lwip-users] Getting the server to use an MSS larger than 536
Date: Wed, 21 Mar 2012 17:28:04 +0100
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20120216 Firefox/10.0.2 SeaMonkey/2.7.2

Simon Goldschmidt wrote:

> Mason wrote:
>
>> Note that Google sends only 590-byte frames. How do I get lwip
>> to advertize larger MSS?
>>
>> NB: I have the following TCP-related definitions in my lwipopts.h
>>
>> #define TCP_MSS 1460
>> #define TCP_WND (40*TCP_MSS)
>> #define TCP_SND_BUF (8*TCP_MSS)
>> #define TCP_SND_QUEUELEN 16
>>
>> There's relevant code in src/core/tcp.c
>>
>>   pcb->snd_wnd = TCP_WND;
>>   /* As initial send MSS, we use TCP_MSS but limit it to 536.
>>      The send MSS is updated when an MSS option is received. */
>>   pcb->mss = (TCP_MSS > 536) ? 536 : TCP_MSS;
>> #if TCP_CALCULATE_EFF_SEND_MSS
>>   pcb->mss = tcp_eff_send_mss(pcb->mss, ipaddr);
>> #endif /* TCP_CALCULATE_EFF_SEND_MSS */
>>
>> [..]
>>
>> (My MTU is 1500, I'm using Ethernet.)
> 
> In that case (if you have set netif->mtu to 1500), tcp_eff_send_mss()
> should return 1460 (1500 - IP_HLEN - TCP_HLEN). If it doesn't,
> possible problems could be that ip_route() doesn't return your netif
> or that netif->mtu isn't set to 1500.

tcp_eff_send_mss will never return 1460 if it is called with
536 as the first parameter, since it returns the minimum of
first parameter and MTU (minus headers).

  pcb->mss = (TCP_MSS > 536) ? 536 : TCP_MSS;
  pcb->mss = tcp_eff_send_mss(pcb->mss, ipaddr);

First statement is equivalent to pcb->mss = LWIP_MIN(536, TCP_MSS);
and sets pcb->mss to 536.
Second statement calls tcp_eff_send_mss(536, ipaddr);

Why is the MSS being clipped in the first statement?

/**
 * Calcluates the effective send mss that can be used for a specific IP address
 * by using ip_route to determin the netif used to send to the address and
 * calculating the minimum of TCP_MSS and that netif's mtu (if set).
 */
u16_t
tcp_eff_send_mss(u16_t sendmss, ip_addr_t *addr)
{
  u16_t mss_s;
  struct netif *outif;

  outif = ip_route(addr);
  if ((outif != NULL) && (outif->mtu != 0)) {
    mss_s = outif->mtu - IP_HLEN - TCP_HLEN;
    /* RFC 1122, chap 4.2.2.6:
     * Eff.snd.MSS = min(SendMSS+20, MMS_S) - TCPhdrsize - IPoptionsize
     * We correct for TCP options in tcp_write(), and don't support IP options.
     */
    sendmss = LWIP_MIN(sendmss, mss_s);
  }
  return sendmss;
}

NB: the comment does not match the code. We're not dealing with
TCP_MSS, but a clipped value of TCP_MSS.

> You should check the MSS option in the SYN packet sent to the Google server.

I did! (cf. trace) lwip advertizes a 536-byte MSS.

-- 
Regards.



reply via email to

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