Linux command lines for TCP variables
Last Updated :
27 Apr, 2022
In this article, we will discuss the Linux command lines for TCP variables.
Find default TCP used in the Linux
- Checking the default TCP in the Linux Kernel
$ sysctl net.ipv4.tcp_congestion_control
Output:
$ net.ipv4.tcp_congestion_control = cubic
- Changing the default TCP in the Linux Kernel to Reno
$ sudo sysctl -w net.ipv4.tcp_congestion_control=reno
Output:
$ net.ipv4.tcp_congestion_control = reno tcp_congestion_control
Switching back to CUBIC as the default TCP in the Linux Kernel
$ sudo sysctl -w net.ipv4.tcp_congestion_control=cubic
Output:
$ net.ipv4.tcp_congestion_control = cubic

Enable TCP Fastopen
- Checking the default setting of TFO in the Linux Kernel
$ sysctl net.ipv4.tcp_fastopen
Output
$ net.ipv4.tcp_fastopen = 1
- Enabling TFO if your machine is a Server
$ sudo sysctl -w net.ipv4.tcp_fastopen=2
Output:
$ net.ipv4.tcp_fastopen = 2
- Enabling TFO if your machine is a Client as well as a Server
$ sudo sysctl -w net.ipv4.tcp_fastopen=3
Output
$ net.ipv4.tcp_fastopen = 3
$ sudo sysctl -w net.ipv4.tcp_fastopen=0
Output
$ net.ipv4.tcp_fastopen = 0

Enable Slow Start Restart congestion control algorithm
- Checking the default setting of SSR in the Linux Kernel
$ sysctl net.ipv4.tcp_slow_start_after_idle
Output
$ net.ipv4.tcp_slow_start_after_idle = 1
- Disable Slow Start Restart (important for Servers, not so much for Clients)
$ sudo sysctl -w net.ipv4.tcp_slow_start_after_idle=0
Output:
$ net.ipv4.tcp_slow_start_after_idle = 0

Enable window scaling
- Checking the default setting of TCP Window Scaling in the Linux Kernel
$ sysctl net.ipv4.tcp_window_scaling
Output
$ net.ipv4.tcp_window_scaling = 1
- Disable TCP Window Scaling (not recommended, but try it to learn and re-enable)
$ sudo sysctl -w net.ipv4.tcp_window_scaling=0
Output:
$ net.ipv4.tcp_window_scaling = 0

How to find default window scaling in Linux kernel
Checking the default value of Window Scaling Factor in the Linux Kernel
$ sysctl net.ipv4.tcp_adv_win_scale
Output
net.ipv4.tcp_adv_win_scale = 1
This is shift.cnt=1, scaling factor=2shift.cnt = 2
tcp_adv_win_scaleEnable the SACK option
- Checking the default setting of SACK in the Linux Kernel
$ sysctl net.ipv4.tcp_sack
Output:
net.ipv4.tcp_sack=1
- Disabling the default setting of SACK in the Linux Kernel
$ sudo sysctl -w net.ipv4.
Output:
net.ipv4.tcp_sack=0 tcp_sack


Check timestamp setting
- Check the default setting of TIMESTAMPS in the Linux kernel
$ sysctl net.ipv4.tcp_timestamps
Output
net.ipv4.tcp_timestamps=1
- Disable the TIMESTAMPS in the Linux kernel
$ sudo sysctl -w net.ipv4.tcp_timestamps=0
Output
net.ipv4.tcp_timestamps=0

Check Low Latency setting:
- Check the default setting of Low Latency in the Linux kernel
$ sysctl net.ipv4.tcp_low_latency
Output
net.ipv4.tcp_low_latency=1
- Disable Low Latency in the Linux kernel
$ sudo sysctl -w net.ipv4.tcp_low_latency=0
Output
net.ipv4.tcp_low_latency=0

Check the default Buffer Size
- Check the default setting of Buffer Size in the Linux kernel
$ sysctl net.ipv4.tcp_rmem
Output
net.ipv4.tcp_rmem=4096 131072 6291456
Values are in the order: min default max. 131072 Bytes = 128 KB, is the default buffer size.
default buffer sizeCheck the available and allowed TCP in the Linux kernel:
- To see the available TCPs:
sysctl net.ipv4.tcp_available_congestion_control
Output
net.ipv4.tcp_allowed_congestion_control= reno cubic
sysctl net.ipv4.tcp_allowed_congestion_control
Output
net.ipv4.tcp_allowed_congestion_control= reno cubic

Check the default base MSS in the Linux kernel
- To see the default base MSS value:
sysctl net.ipv4.tcp_base_mss
Output
net.ipv4.tcp_base_mss = 1024
tcp_base_mssCheck the default value of DUP-ACK for fast retransmit of the lost packet
- To see the default value of DUP-ACK:
sysctl net.ipv4.tcp_early_retrans
Output
net.ipv4.tcp_early_retrans = 3

See the default timeout for blackholing the TFO
- Blackhole timeout for TFO:
sysctl net.ipv4.tcp_fastopen_blackhole_timeout_sec
Output
net.ipv4.tcp_fastopen_blackhole_timeout_sec = 3600
tcp_fastopen_blackhole_timeout_secNumber of retransmissions
- The number of packet retransmission without involving the network layer:
sysctl net.ipv4.tcp_retries1
Output
net.ipv4.tcp_retries1 = 3
- The maximum number of retransmissions of a lost packet before giving up:
sysctl net.ipv4.tcp_retries2
Output
sysctl net.ipv4.tcp_retries2 = 15

Default KeepAlive parameters in Linux kernel
- Default keepalive timeout value:
sysctl net.ipv4.tcp_keepalive_time
Output
net.ipv4.tcp_keepalive_time=7200
When a client is not actively sending the request to the server, then the server waits for 7200 seconds. If no response is coming from the client then it sends the confirmatory packets to the client. For 7200 seconds server just waits and does not disconnect the connection.
- The default frequency of keepalive probes:
sysctl net.ipv4.tcp_keepalive_probes
Output
net.ipv4.tcp_keepalive_probes=9
When 7200 seconds are over, the server sends the first probe message to see whether the client is still connected or not. If no response comes before the second probe is sent then the server again sends the probe message. When all 9 probes are sent and no confirmation is received from the client. Then server disconnects the client and the socket is available for other clients to use.
- The default time interval of each keepalive probe:
sysctl net.ipv4.tcp_keepalive_intvl
Output
net.ipv4.tcp_keepalive_intvl=75
The server will send the next probe after an interval of 75 seconds. Thus, the total time of inactivity to disconnect the connection by the server is:- 7200+9*75 = 7875 seconds.

Similar Reads
ss command in linux Linux is celebrated for its versatility and robust command-line utilities. One such utility is the 'ss' command, which stands for "Socket Statistics." It is a potent tool for inspecting and displaying detailed information about network sockets on a Linux system. The 'ss' command is an indispensable
4 min read
Practical Uses of nc(netcat) command in Linux Netcat is one of the most powerful networking tools, security tools, and network monitoring tools. It is even considered a Swiss army knife of networking tools. It acts like a cat command over a network. It is generally used for the following reasons:Operation related to TCP, UDP, or UNIX-domain soc
7 min read
Netstat command in Linux The netstat command is like a special tool in Linux that helps you understand and check things about how your computer connects to the internet. It can tell you about the connections your computer is making, the paths it uses to send information, and even some technical details like how many packets
7 min read
hping3 Command in Linux Hello there, fellow tech enthusiasts! Today, we're going to delve into the world of network manipulation using the powerful hping3 command in Linux. Whether you're a seasoned network administrator or just curious about how networking works, hping3 is a tool you'll want to add to your toolkit. In thi
4 min read
'IPCS' command in Linux with examples ipcs shows information on the inter-process communication facilities for which the calling process has read access. By default, it shows information about all three resources: shared memory segments, message queues, and semaphore arrays. Without options, the information shall be written in short for
3 min read
iptables command in Linux with Examples The iptables command in Linux is a powerful tool that is used for managing the firewall rules and network traffic. It facilitates allowing the administrators to configure rules that help how packets are filtered, translated, or forwarded. On using this iptables, you can set up security policies to c
7 min read
TCP flow Analyze and Debug Network Traffic in Linux TCPflow is a completely free and open-source tool used for the analysis of network traffic on Linux and Unix systems. The data which is transferred during the connection is stored in a file by TCPflow in a systematic format for later study. TCPflow is almost the same as its counterparts such as Wire
5 min read
Ways to Find Out List of All Open Ports in Linux In this guide, we'll explore how to identify the comprehensive list of open ports in Linux, crucial endpoints for communication within computer networks. Ports, serving as gateways for network communication, are represented by 16-bit numbers ranging from 0 to 65535. These ports play a pivotal role i
4 min read
Netcat - Basic Usage and Overview Netcat is a versatile Unix utility that facilitates reading and writing data across network connections using either TCP or UDP protocols. Often referred to as the "Swiss Army knife" of networking, Netcat can perform a wide range of tasks, including connecting to remote servers, listening for incomi
4 min read
Iperf Command to Test Speed, Performance and Bandwidth of Network in Linux There is a great degree of flex in how the packets are delivered and overall bit rate and packet payload size can be controlled. iperf is a tool that is used to perform network performance measurement and tuning. iperf is an open-source software which is written in C language. Jperf is a GUI version
2 min read