如何在linux中激活TCP Fast Open

如何在linux中激活TCP Fast Open,linux,bash,sockets,tcp,Linux,Bash,Sockets,Tcp,我有两台linux电脑(PC1:kernel 3.13.0-37和PC2:kernel 3.11.0-12) 从PC1,我发送一个tcp数据包,其中包含tcp快速打开(快速打开Cookie请求) 我希望通过TCP选项(Fast Open Cookie:xxxxxxx)从服务器上得到如下回答: 但是我得到了一个没有tcp选项的tcp数据包(FastOpencookie:xxxxxxx) 我想知道在我的PC2(linux)上是否需要配置一些东西来激活TCP Fastt Open选项 对于TCP服

我有两台linux电脑(PC1:kernel 3.13.0-37和PC2:kernel 3.11.0-12)

从PC1,我发送一个tcp数据包,其中包含tcp快速打开(快速打开Cookie请求)

我希望通过TCP选项(Fast Open Cookie:xxxxxxx)从服务器上得到如下回答:

但是我得到了一个没有tcp选项的tcp数据包(FastOpencookie:xxxxxxx)

我想知道在我的PC2(linux)上是否需要配置一些东西来激活TCP Fastt Open选项

对于TCP服务器,我正在运行一个php脚本:

$sock = socket_create(AF_INET, SOCK_STREAM, 0);

// Bind the socket to an address/port
socket_bind($sock, "0.0.0.0", 4410) or die('Could not bind to address');
for(;;) {
    // Start listening for connections
    socket_listen($sock);
    ...
}

您必须在服务器的侦听套接字中使用以下命令启用TFO:

int qlen = 5;
setsockopt(fd, SOL_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen));

()

我认为这将是sysctl-w net.ipv4.tcp_fastopen=3的一个简单例子。由于不是这样,我删除了我的答案以帮助吸引其他回答者。此外,您必须为侦听套接字启用TFO:
sysctl-w net.ipv4.tcp\u fastopen=3
int qlen = 5;
setsockopt(fd, SOL_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen));