I write a TCP client on a Linux 3.15 machine, which is able to use TCP Fast Open:
status = sendto(sd, (const void *) data, data_len, MSG_FASTOPEN,
(const struct sockaddr *) hostref->ai_addr,
sizeof(struct sockaddr_in));
if (status < 0) {
fprintf(stderr, "sendto: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
fprintf(stdout, "TFO connection successful to %s\n",
text_of(hostref->ai_addr));
Using tcpdump, I can check the sending of the TCP Fast Open option and that it does bypass the 3-way handshake (tested with Google's servers).
However, with servers which does not accept TCP fast open, sendto still succeeds, and the message "TFO connection successful" is displayed. Apparently, the Linux kernel code falls back to regular TCP if the server does not support TCP Fast Open (again, checked with tcpdump).
How to find out if my connection used TCP Fast Open or not?
send()
/sendto()
calls to account for TFO. There is no difference on the receiving end,recv()
/recvfrom()
will return whatever data was initially received and cached byaccept()
when TFO is enabled on the server side.