如何在Linux上验证TCP保持活动状态 [英] How to verify TCP keep alive on Linux
问题描述
我想在我的Linux机器上设置tcp keep live.所以我正在做的是运行脚本
I want to set tcp keep alive on my linux machine. So what I am doing is running a script
if [ `/sbin/sysctl -n net.ipv4.tcp_keepalive_time` != 200 ] ; then
/sbin/sysctl -w net.ipv4.tcp_keepalive_time=200;
但是我仍然与亚马逊的红移有关.有人可以帮忙给我看看,我如何检查tcp keep live是否已设置?
But I still have issues with connections to amazon's redshift. Can someone please help and show me how I can check if tcp keep alive is actually set or not?
推荐答案
要检查保持活动状态是否为活动,请打开连接,请勿交换任何数据,并使用tcpdump或类似方法验证数据包是否在连接中定期交换,甚至如果没有实际数据交换.
To check if keep alive is active open a connection, don't exchange any data and verify with tcpdump or similar that packets gets regularly exchanged on the connection, even if no real data get exchanged.
但是也许您只是将keep-alive与超时混淆了:
But maybe you just confuse keep-alive with timeout:
- 保持活动状态:检测连接是否仍处于活动状态,例如必要时可以交换数据.这将检测到网络连接等的丢失.保持活动在TCP层上完成.
- 超时:一些不活动后,连接将关闭.这是在应用程序层完成的.
在两种情况下,除非尝试在套接字上进行读写,否则您都不会检测到问题.
In both cases you will not detect the problem until you try to read or write on the socket.
这篇关于如何在Linux上验证TCP保持活动状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!