search
HomeOperation and MaintenanceLinux Operation and MaintenanceHow to optimize TCP/IP performance and network performance of Linux systems

How to optimize TCP/IP performance and network performance of Linux systems

Nov 07, 2023 am 11:15 AM
load balancingwindow sizeTCP acceleration that optimizes TCP/IP performancecongestion control

How to optimize TCP/IP performance and network performance of Linux systems

In the field of modern computers, the TCP/IP protocol is the basis for network communication. As an open source operating system, Linux has become the preferred operating system used by many businesses and organizations. However, as network applications and services become more and more critical components of business, administrators often need to optimize network performance to ensure fast and reliable data transfer.

This article will introduce how to improve the network transmission speed of Linux systems by optimizing TCP/IP performance and network performance of Linux systems. This article will explore some necessary TCP parameters and how to change them to optimize network performance. This article will also introduce how to use some common CLI and kernel tools to check network performance in the system, and provide readers with some code examples.

1. Understand tcp tw_reuse

TCP connection is a connection-oriented transmission protocol, so the IP address and port combination must be different to create a new connection. After the client and server have been closed, but Linux is still waiting for a period of time when the connection may have been recently created, an attempt is made to establish a tcp connection. This period of time is called the "TIME_WAIT" state, and connections in this state cannot be reused. This behavior can slow down the server's TCP/IP performance.

To avoid this situation, we can use the tw_reuse parameter. Enabling tw_reuse allows exited connections to be reused without waiting for a certain period of time. This parameter can be enabled through the following command:

echo 1 >/proc/sys/net/ipv4/tcp_tw_reuse

2. Adjust the TCP keepalive parameters appropriately

TCP keepalive is a mechanism that can detect whether the connection is still active and prevent problems due to network congestion. Causes connection loss. TCP keepalive periodically checks the connection status to determine whether the connection is still active and closes the connection if not.

Adjusting TCP keepalive parameters can improve transmission performance. The following are three important TCP parameters:

1.tcp_keepalive_time

The tcp_keepalive_time parameter defines the time interval between sending keep-alive messages. If a node in the network becomes unresponsive, the keepalive mechanism attempts to reestablish the connection.

The default value is 7200 seconds (i.e. 2 hours)

2.tcp_keepalive_intvl

The tcp_keepalive_intvl parameter defines the retry interval after sending a keep-alive message.

The default value is 75 seconds

3.tcp_keepalive_probes

tcp_keepalive_probes defines how many TCP probes are performed before sending a keepalive message.

The default value is 9 times

These parameters can be changed to improve TCP performance. The following is the command to change the above three parameters:

echo 600 >/proc/sys/net/ipv4/tcp_keepalive_time
echo 30 >/proc/sys/net/ipv4/tcp_keepalive_intvl
echo 5 >/proc/sys/net/ipv4/tcp_keepalive_probes

3. Enable TCP window scaling option

TCP Window Scaling (TCP Window Scaling) is an option to extend the TCP header to support High speed internet. By default, the Linux kernel automatically enables the TCP window extension option, but if you are using an older version of the kernel, you may need to enable this option.

The following is the command to enable the TCP window extension option:

echo 1 >/proc/sys/net/ipv4/tcp_window_scaling

4. Use ifconfig to adjust the MTU and MRU values ​​

MTU (Maximum Transmission Unit) is the data packet that can be transmitted Maximum size, while MRU (Maximum Receive Unit) is the maximum packet size that the receiving end can receive.

Changing the MTU and MRU values ​​can improve the network performance of the system. We can use the ifconfig command to change these values. The following are the commands to change MTU and MRU:

ifconfig eth0 mtu 9000
ifconfig eth0 mru 9000

5. Use iperf3 to test network performance

iperf3 is a traffic detection and network service quality testing tool. It helps administrators measure the system's network performance and check network congestion. Use iperf3 to quickly discover network bottlenecks for tuning.

First, start iperf3 on the server side. The following command can start a TCP server listening on the default port:

iperf3 -s

Then, run iperf3 on the client to test the broadcast speed of network information. For TCP testing, you can run the following command:

iperf3 -c <server-ip>

6. Use the netstat command to monitor network performance

The netstat command is a commonly used command line tool that can be used to check network connections in Linux systems and transmission performance.

You can use the following command to check the number and status of TCP connections in a Linux system:

netstat -nat | grep -i "tcp.*established"

This command will return the number of TCP connections currently established. The higher the number of connections established, the lower the TCP/IP performance of the system will be.

7. Use sysctl to view TCP/IP parameters

sysctl is a CLI utility that manages kernel parameters. You can use it to view and change TCP/IP parameters.

The following is the command to view the TCP/IP parameters:

sysctl -a | grep tcp

We can change these parameters as needed by using the following command:

sysctl -w <parameter=value>

For example, the following command will change The maximum memory compression size of the TCP stack:

sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'

8. Use tcpdump to monitor network traffic

tcpdump is a command line utility tool for capturing network data packets. You can use it to monitor network traffic to find network faults or bottlenecks.

The following is the command to capture inbound and outbound TCP traffic using the tcpdump command:

tcpdump -i eth0 -vv tcp

Its output can be redirected to a file and then viewed using wireshark:

tcpdump -i eth0 -vv tcp -w <filename>
wireshark <filename>

in conclusion

The network performance of Linux systems can be improved by appropriately configuring TCP/IP and network parameters. Through the CLI and kernel tools provided in this article, administrators can better understand the network performance of the system and optimize it. This article provides code examples to help administrators better understand how to optimize TCP/IP performance and network performance.

The above is the detailed content of How to optimize TCP/IP performance and network performance of Linux systems. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Building Blocks of Linux: Key Components ExplainedThe Building Blocks of Linux: Key Components ExplainedApr 30, 2025 am 12:26 AM

The core components of the Linux system include the kernel, file system, and user space. 1. The kernel manages hardware resources and provides basic services. 2. The file system is responsible for data storage and organization. 3. Run user programs and services in the user space.

Using Maintenance Mode: Troubleshooting and Repairing LinuxUsing Maintenance Mode: Troubleshooting and Repairing LinuxApr 29, 2025 am 12:28 AM

Maintenance mode is a special operating level entered in Linux systems through single-user mode or rescue mode, and is used for system maintenance and repair. 1. Enter maintenance mode and use the command "sudosystemctlisolaterscue.target". 2. In maintenance mode, you can check and repair the file system and use the command "fsck/dev/sda1". 3. Advanced usage includes resetting the root user password, mounting the file system in read and write mode and editing the password file.

Linux Maintenance Mode: Understanding the PurposeLinux Maintenance Mode: Understanding the PurposeApr 28, 2025 am 12:01 AM

Maintenance mode is used for system maintenance and repair, allowing administrators to work in a simplified environment. 1. System Repair: Repair corrupt file system and boot loader. 2. Password reset: reset the root user password. 3. Package management: Install, update or delete software packages. By modifying the GRUB configuration or entering maintenance mode with specific keys, you can safely exit after performing maintenance tasks.

Linux Operations: Networking and Network ConfigurationLinux Operations: Networking and Network ConfigurationApr 27, 2025 am 12:09 AM

Linux network configuration can be completed through the following steps: 1. Configure the network interface, use the ip command to temporarily set or edit the configuration file persistence settings. 2. Set up a static IP, suitable for devices that require a fixed IP. 3. Manage the firewall and use the iptables or firewalld tools to control network traffic.

Maintenance Mode in Linux: A System Administrator's GuideMaintenance Mode in Linux: A System Administrator's GuideApr 26, 2025 am 12:20 AM

Maintenance mode plays a key role in Linux system management, helping to repair, upgrade and configuration changes. 1. Enter maintenance mode. You can select it through the GRUB menu or use the command "sudosystemctlisolaterscue.target". 2. In maintenance mode, you can perform file system repair and system update operations. 3. Advanced usage includes tasks such as resetting the root password. 4. Common errors such as not being able to enter maintenance mode or mount the file system, can be fixed by checking the GRUB configuration and using the fsck command.

Maintenance Mode in Linux: When and Why to Use ItMaintenance Mode in Linux: When and Why to Use ItApr 25, 2025 am 12:15 AM

The timing and reasons for using Linux maintenance mode: 1) When the system starts up, 2) When performing major system updates or upgrades, 3) When performing file system maintenance. Maintenance mode provides a safe and controlled environment, ensuring operational safety and efficiency, reducing impact on users, and enhancing system security.

Linux: Essential Commands and OperationsLinux: Essential Commands and OperationsApr 24, 2025 am 12:20 AM

Indispensable commands in Linux include: 1.ls: list directory contents; 2.cd: change working directory; 3.mkdir: create a new directory; 4.rm: delete file or directory; 5.cp: copy file or directory; 6.mv: move or rename file or directory. These commands help users manage files and systems efficiently by interacting with the kernel.

Linux Operations: Managing Files, Directories, and PermissionsLinux Operations: Managing Files, Directories, and PermissionsApr 23, 2025 am 12:19 AM

In Linux, file and directory management uses ls, cd, mkdir, rm, cp, mv commands, and permission management uses chmod, chown, and chgrp commands. 1. File and directory management commands such as ls-l list detailed information, mkdir-p recursively create directories. 2. Permission management commands such as chmod755file set file permissions, chownuserfile changes file owner, and chgrpgroupfile changes file group. These commands are based on file system structure and user and group systems, and operate and control through system calls and metadata.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment