Subject: [Taps] Summary of TCP Fast Open Interfaces

From: Tom Jones <[email-masked]>
Date: Mon, 30 Jul 2018 11:23:33 +0100

Hello TAPS,

In Montreal the topic of 0RTT and idempotent interfaces came up, I remember
there being interest in a summary of TCP Fast Open APIs. Michael Tuexen[1]
forwarded me a TFO test program for a different reason and this seemed like
a good starting point to attempt to summarise the APIs on different Operating
Systems.

I have included simplified APIs for Linux, FreeBSD, Mac Os and Windows[2][3].

I quickly searched for other Operating Systems none of the below had an easily
googlable API for TCP Fast Open:
	NetBSD
	OpenBSD
	Dragonfly BSD
	Haiku
	React OS
	Riot OS

If there are other platforms with TFO which I have missed I would
appreciate a pointer to documentation.

- Tom

A summary of TCP Fast Open Interfaces

Linux

	socket(IPPROTO_TCP)
	sendto(endpoint, MSG_FASTOPEN, data)

	Perform a sendto() call on the socket with a flag to indicate fast
	open and the idempotent data.

FreeBSD

	socket(IPPROTO_TCP)
	setsockopt(TCP_FASTOPEN)
	sendto(endpoint, data)

	Call setsockopt() to enable fast open. Call sendto() with the
	idempotent data.

Mac OS
	socket(IPPROTO_TCP)
	connectx(endpoints, data)

	Call to connectx() function with set of addresses and 
	idempotent data to send.

Windows
	socket(IPPROTO_TCP)
	setsockopt(TCP_FASTOPEN)
	bind(local_addr)
	ConnectEx(endpoint, data)

	Set the fast open options on the socket. 
	ConnectEx() must be called bound to a local address, bind() the socket
	to an address
	Start the connection with the ConnectEx() call, pass in the idempotent
	data.

Note:

This summary is deliberately a simplification of the API to aide comparison,
full details are in various platform documentation. All of these platforms
support binding to a local address before the call, the ConnectEx() API on
Windows requires it[2]. connectex() on Mac OS supports passing in a local
addresst to bind to.

[1]: https://github.com/nplab/test-programs/blob/master/tcp-fastopen.c
[2]: https://docs.microsoft.com/en-us/windows/desktop/api/mswsock/nc-mswsock-lpfn_connectex
[3]: https://gist.github.com/krrr/8b5fec3c93dc332bc8109641206529b5