What does tcpi_rcv_mss mean?

Viewed 644

As we known, MSS is Maximum Segment Size of TCP data.

In Ipv4, MSS is 1460 in general, and in Ipv6, MSS is 1440 in general.

But the strange thing is: there are two types of MSS in struct tcp_info, which is tcpi_snd_mss and tcpi_rcv_mss.

I did a simple experiment, connect www.stackoverflow.com and output these two values.

#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <assert.h>

int main() {
    int fd = socket(AF_INET, SOCK_STREAM, 0);
    assert(fd >= 0);

    struct sockaddr_in server;
    server.sin_family = AF_INET;
    server.sin_port = htons(80);
    server.sin_addr.s_addr = inet_addr("151.101.193.69");

    int rc = connect(fd, (void*)&server, sizeof(server));
    assert(rc >= 0);

    struct tcp_info info;
    socklen_t len = sizeof(info);
    rc = getsockopt(fd, SOL_TCP, TCP_INFO, (void*)&info, &len);
    assert(rc >= 0);


    printf("%u\n", info.tcpi_snd_mss);
    printf("%u\n", info.tcpi_rcv_mss);
    return 0;
}
$ ./a.out
1440
536

The tcpi_rcv_mss is 536!!

But according to tcpdump, the MSS should be 1440(my MSS is 1460, stackoverflow'MSS is 1440).

$ sudo tcpdump -n host 151.101.193.69
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
18:39:52.690772 IP 10.101.25.77.14947 > 151.101.193.69.80: Flags [S], seq 548910783, win 29200, options [mss 1460,sackOK,TS val 3459919655 ecr 0,nop,wscale 8], length 0
18:39:52.797959 IP 151.101.193.69.80 > 10.101.25.77.14947: Flags [S.], seq 577830562, ack 548910784, win 28800, options [mss 1440,nop,nop,sackOK,nop,wscale 9], length 0
18:39:52.798000 IP 10.101.25.77.14947 > 151.101.193.69.80: Flags [.], ack 1, win 115, length 0
18:39:52.798333 IP 10.101.25.77.14947 > 151.101.193.69.80: Flags [F.], seq 1, ack 1, win 115, length 0
18:39:53.160527 IP 10.101.25.77.14947 > 151.101.193.69.80: Flags [F.], seq 1, ack 1, win 115, length 0
18:39:53.241597 IP 151.101.193.69.80 > 10.101.25.77.14947: Flags [F.], seq 1, ack 2, win 57, length 0
18:39:53.241657 IP 10.101.25.77.14947 > 151.101.193.69.80: Flags [.], ack 2, win 115, length 0

So i have two questions:

  1. What does tcpi_rcv_mss mean?
  2. Why is tcpi_rcv_mss 536 in my experiment?
1 Answers

Receive MSS is the maximum segment size you announce to the other peer you can accept, and Transmit MSS is the value announced by your peer and marks the maximum segment size you can send to it. Of course, there are two, yours doesn't have to be equal to your partner's.

Related