Automated approach to optimizing network performance
By detecting multiple network parameters and automatically adjusting operating system parameters, the problem of network performance optimization in public network environments is solved, efficient network adaptability and stability of the equipment in complex environments is achieved, and the device's user experience is improved.
Patent Information
- Application Number
- CN202411562375.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-11-05
AI Technical Summary
The existing technology cannot automatically optimize network performance in complex public network environments, resulting in poor user experience in multiple network environments, and cannot effectively solve problems such as packet loss and network disconnection.
By detecting multiple network parameters, such as CPU load, socket status and TCP/IP protocol stack status, automatically adjusting operating system parameters, such as turning on GRO and GSO, modifying sysctl parameters, expanding the receiving and sending queue length, etc., network performance is achieved, etc. automation optimization.
The device can quickly adapt to complex network environments and automatically deal with problems such as bandwidth limitations, high packet loss rate and unstable socket connections, improving network quality and device usage experience, ensuring automatic recovery of default parameters after network recovery, ensuring stability.
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of network monitoring, and in particular to a method for automatically optimizing network performance. Background Art
[0002] With the localization of equipment and operating systems, more and more equipment uses domestic Linux operating systems, such as the Kylin operating system. These devices are not only deployed in intranet environments, but more often in public network environments. Due to the complexity of the public network environment and the difficulty in ensuring network bandwidth, devices deployed in the public network often encounter problems such as packet loss and network disconnection, which seriously affect the user experience of the equipment. As an operating system manufacturer, it is necessary to improve the network fluency in various network environments. Since the operating system in the device cannot be modified without important reasons after the device leaves the factory, the operating system cannot be adjusted according to the actual situation, and can only be adjusted automatically according to most foreseeable network fluency problems. That is, there is currently no technology that can automatically optimize network performance and achieve the purpose of improving network fluency in a complex public network environment. Summary of the invention
[0003] In order to enable the operating system to automatically adjust system parameters for various common network problems in various complex public network environments, improve network fluency, reduce the probability of network disconnection, and improve the user experience of the device, the present invention provides a method for automatically optimizing network performance, using the following technical solutions:
[0004] Automated methods to optimize network performance, including:
[0005] S1: When the boot is detected, the default parameters corresponding to multiple detection types of the current operating system are recorded, and the default parameters are stored in the form of a file;
[0006] S2: Start the scheduled task 1, detect multiple detection types of the operating system at a predetermined period, determine whether the corresponding preset adjustment conditions are met, and if so, make adjustments and set adjustment flags for the detection types;
[0007] S3: Start timing task 2, and detect whether there is an adjustment mark for each detection type in timing task 1 at a predetermined period. If so, re-detect the preset adjustment condition corresponding to the adjustment mark: if the preset adjustment condition is no longer met, restore the data of the detection type corresponding to the adjustment mark to the data before adjustment, and delete the corresponding adjustment mark until the data of the detection type is the default parameter.
[0008] In another possible implementation, multiple detection types include: whether the CPU that processes the network card receiving and sending packets has reached full load, whether the half connection has overflowed, whether the full connection has overflowed, whether the network port is insufficient, whether there are multiple socket timeouts and disconnections, whether the ring buffer has overflowed, whether the soft interrupt receiving buffer has overflowed, whether flow control packet loss occurs, whether the receiving buffer overflows, and whether the zero window overflows. The preset adjustment conditions corresponding to each detection type are: the CPU that processes the network card receiving and sending packets has reached full load, half connection overflows, full connection overflows, network ports are insufficient, multiple socket timeouts and disconnections occur, the ring buffer has overflowed, the soft interrupt receiving buffer overflows, flow control packet loss occurs, the receiving buffer overflows, and the zero window overflows.
[0009] In another possible implementation, when the detection type is whether the CPU for processing the network card receiving and sending packets has reached full load, S2 includes:
[0010] Use top to view the load of CPU0. If it is higher than 85%, it is determined that the CPU that processes the network card's sent and received packets has reached full load. Record the current status of the network card's GRO and GSO, open GRO and GSO through ethtool, and set the CPU full load status adjustment flag.
[0011] In another possible implementation, when the detection type is whether the semi-join overflows, S2 includes:
[0012] Check the number of SYN_RECV through netstat. If it continues to increase, it is determined that the half-connection overflows. Record the current status of the tcp_syncookies parameter, modify tcp_syncookies to 1 through sysctl, and set the half-connection overflow status adjustment flag.
[0013] In another possible implementation, when the detection type is whether the full connection overflows, S2 includes:
[0014] Check the LISTEN line of the status bit through ss-antlp. If the Recv-Q column is greater than the Send-Q column, the full connection overflow is determined. Record the current values of the protocol stack tcp_max_syn_backlog and somaxconn parameters. Set the above values to twice their current values through sysctl, and set the full connection overflow status adjustment flag.
[0015] In another possible implementation, when the detection type is whether the network port is insufficient, S2 includes:
[0016] Check the number of TCP ports in use through netstat. If the number of TCP ports in use is greater than the private reserved ports, it is determined that the network ports are insufficient. Record the current value of ip_local_port_range, expand the range of ip_local_port_range through sysctl, enable the timeout reuse mechanism through sysctl, reduce the MSL value through sysctl, and set the port shortage status adjustment flag.
[0017] In another possible implementation, when the detection type is whether the socket has timed out and disconnected multiple times, S2 includes:
[0018] By checking the socket error status in the system log, if there are multiple timeout logs, it is determined that the socket has timed out and disconnected multiple times. Record the number of SYN and SYNACK retransmissions, set the number of SYN and SYNACK retransmissions to 10 through sysctl, and set the socket timeout status adjustment flag.
[0019] In another possible implementation, when the detection type is whether there is an overflow in the ring buffer, S2 includes:
[0020] Check the overruns value through ifconfig. If it increases, it is determined that the ring buffer has overflowed. Get the receive and send ring queue lengths of the network card through ethtool. Set the receive and send wake-up queue lengths of the network card through ethtool to twice their own values, and set the ring buffer status adjustment flag.
[0021] In another possible implementation, when the detection type is whether the soft interrupt receiving buffer overflows, S2 includes:
[0022] By checking the third column of / proc / net / softnet_stat, if there is an increase, it is determined that the soft interrupt receive buffer overflows, and the current values of netdev_max_backlog, netdev_budget, and netdev_budget_usecs are recorded. Through sysctl, netdev_max_backlog, netdev_budget, and netdev_budget_usecs are expanded to twice their own values, and the soft interrupt buffer status adjustment flag is set.
[0023] In another possible implementation, when the detection type is whether flow control packet loss occurs, whether the receiving buffer overflows, and whether the zero window overflows, S2 includes:
[0024] Check dropped through ifconfig. If there is an increase, it is determined that flow control packet loss occurs. Get the txqueuelen value through ifconfig, set the txqueuelen value to twice its own value through ifconfig, set dev_weight to twice its own value through sysctl, set gro_normal_batch to twice its own value through sysctl, and set the flow control status adjustment flag;
[0025] By checking TCPRcvQDrop in / proc / net / netstat, if there is an increase, determine whether the receive buffer overflows, record the current values of tcp_rmem and rmem_max, set tcp_rmem to twice its own value through sysctl, set rmem_max to twice its own value through sysctl, and set the receive buffer adjustment flag;
[0026] By checking TCPZeroWindowDrop in / proc / net / netstat, if there is an increase, it is determined that the zero window overflows, and the current values of tcp_rmem and rmem_max are recorded. Then, tcp_rmem is set to twice its own value through sysctl, rmem_max is set to twice its own value through sysctl, and the zero window adjustment flag is set.
[0027] In summary, this application includes the following beneficial technical effects:
[0028] By adopting the above solution, the device can quickly adapt to complex network environments, automatically handle common problems such as limited bandwidth, high packet loss rate, unstable socket connection, etc., and automatically restore modified content after the network quality is restored. While ensuring stability, it greatly improves the user experience of the device in a variety of complex network environments and improves the adaptability of the operating system. DETAILED DESCRIPTION
[0029] The present application is described in further detail below.
[0030] After reading this specification, those skilled in the art may make non-creative modifications to this embodiment as needed, but such modifications are protected by patent law as long as they are within the scope of the claims of this application.
[0031] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application are described clearly and completely below. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.
[0032] In addition, the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article, unless otherwise specified, generally means that the associated objects before and after are in an "or" relationship.
[0033] The embodiments of the present application are described in further detail below.
[0034] Methods for automating and optimizing network performance include:
[0035] When the boot is detected, the default parameters corresponding to multiple detection types of the current operating system are recorded and stored in the form of a file;
[0036] Start the scheduled task 1, detect multiple detection types of the operating system at a predetermined period, determine whether the corresponding preset adjustment conditions are met, and if so, make adjustments and set the detection type as an adjustment flag.
[0037] For the embodiment of the present application, the predetermined period is 5 seconds, and multiple detection types include: whether the CPU processing the network card receiving and sending packets has reached full load, whether the half connection overflows, whether the full connection overflows, whether the network port is insufficient, whether there are multiple socket timeout disconnections, whether there is an overflow in the ring buffer, whether the soft interrupt receiving buffer overflows, whether flow control packet loss occurs, whether the receiving buffer overflows, and whether the zero window overflows; the preset adjustment conditions corresponding to each detection type are: the CPU processing the network card receiving and sending packets has reached full load, half connection overflows, full connection overflows, network ports are insufficient, multiple socket timeout disconnections occur, the ring buffer overflows, the soft interrupt receiving buffer overflows, flow control packet loss occurs, the receiving buffer overflows, and the zero window overflows. If the data format corresponding to the detection type is a switch format, the specific adjustment means is switch or close, and if the data format is a numerical format, the specific adjustment means is to increase the numerical value (in most scenarios, the numerical value is adjusted to twice its own numerical value).
[0038] Specifically, taking the Feiteng E2000 chip and installing the Kylin embedded operating system V10 SP1 as an example, the method of automatically optimizing network performance includes:
[0039] 1. Obtaining default parameters
[0040] After powering on, read and record the following data:
[0041] The network card delay fragmentation status (the network card delay fragmentation status represents the status of the network card GRO and GSO);
[0042] The semi-connection overflow status (reflected by the tcp_syncookies parameter) and the full connection queue numerical parameters (including the protocol stack tcp_max_syn_backlog and somaxconn parameters);
[0043] IP port range (represented by the value of ip_local_port_range);
[0044] The number of half-connection and full-connection retransmissions (i.e., the number of SYN and SYNACK retransmissions);
[0045] Send and receive ring buffer sizes (represented by the length of the network card's receive and send ring queues);
[0046] The length of the device receive queue (represented by netdev max backlog), the number of network packets processed by each soft interrupt (represented by netdev budget) and the processing interval (represented by netdev budget usecs);
[0047] NIC send queue length (characterized by txqueuelen), NIC device weight (characterized by dev weight), GRO batch number (characterized by gonormal batch)
[0048] TCP receive buffer size (characterized by tcp_rmem) and receive buffer maximum value (characterized by rmem_max).
[0049] 2. Testing Phase
[0050] 1. Is the CPU processing the NIC sending and receiving packets at full capacity?
[0051] Use top to check the load of CPU0. If it is higher than 85%, it means that the CPU processing the NIC's sent and received packets has reached full load. Record the current status of the NIC's GRO and GSO. Use ethtool to open GRO and GSO, and set the CPU full load status adjustment flag.
[0052] 2. Whether the semi-join overflows
[0053] Check the number of SYN_RECV through netstat. If it continues to grow, it means that the half-connection overflows. Record the current status of the tcp_syncookies parameter, modify tcp_syncookies to 1 through sysctl, and set the half-connection overflow status adjustment flag.
[0054] Among them, netstat is a commonly used tool for viewing network status under Linux system.
[0055] SYN_RECV is one of the nine common states of Linux system sockets. This state indicates that the server enters this state after receiving the SYN message from the client and waits for the client's confirmation.
[0056] The tcp_syncookies parameter indicates turning on SYN Cookies to defend against SYN Flood attacks. 0 means turning off SYN Cookies; the default value 1 means turning on SYN Cookies when the connection queue is full, and 2 means always using SYN Cookies.
[0057] 3. Whether the full connection overflows
[0058] Check the status bit LISTEN row through ss-antlp. If the Recv-Q column is greater than the Send-Q column, the full connection overflow is determined. Record the current values of the protocol stack tcp_max_syn_backlog and somaxconn parameters. Set the above values to twice their current values through sysctl, and set the full connection overflow status adjustment flag.
[0059] Among them, ss is a tool for viewing socket status in Linux system. It has similar functions to netstat, but describes the results from a different angle.
[0060] LISTEN is one of the nine common states of Linux system sockets, which means that the server-side socket is waiting for the client's connection request.
[0061] Recv-Q indicates the number of bytes in the receive queue.
[0062] Send-Q indicates the number of bytes in the send queue.
[0063] tcp_max_syn_backlog specifies the maximum number of clients that can accept SYN synchronization packets.
[0064] somaxconn indicates the maximum number of clients that the server can accept or process data.
[0065] Sysctl is a tool for reading and setting system parameters in Linux system.
[0066] 4. Are there insufficient network ports?
[0067] Check the number of TCP ports in use through netstat. If the number of TCP ports in use is greater than the private reserved ports, it is determined that the network ports are insufficient. Record the current value of ip_local_port_range, expand the range of ip_local_port_range through sysctl, enable the timeout reuse mechanism through sysctl, reduce the MSL value through sysctl, and set the port shortage status adjustment flag;
[0068] Among them, ip_local_port_range indicates the minimum and maximum values of the TCP / UDP port numbers that can be used by local applications. For example, the default value is [32768,60999], which means that the number of available ports is 60999-32768=29231.
[0069] MSL means Maximum Segment Lifetime, which is the longest time a data segment (message) can survive in the network. Since the data sent from computer A to computer B needs to pass through several network switches or routers, it takes some time. If the sending time exceeds MSL, the router or switch will automatically discard it.
[0070] 5. Are there multiple socket timeouts and disconnections?
[0071] Check the socket error status in the system log. If there are multiple timeout logs, it is determined that the socket has timed out and disconnected multiple times. Record the number of SYN and SYNACK retransmissions. Set the number of SYN and SYNACK retransmissions to 10 through sysctl and set the socket timeout status adjustment flag.
[0072] Among them, SYN and SYNACK are the message types sent in the socket three-way handshake.
[0073] 6. Is there an overflow in the ring buffer?
[0074] Check the overruns value through ifconfig. If it increases, it means that the ring buffer overflows. Get the length of the network card's receive and send ring queues through ethtool. Set the length of the network card's receive and send wake-up queues to twice their own values through ethtool. Set the ring buffer status adjustment flag.
[0075] Among them, ifconfig is a common tool for viewing network card status in Linux system.
[0076] overruns indicates that an overflow has occurred.
[0077] 7. Whether the soft interrupt receiving buffer overflows
[0078] By checking the third column of / proc / net / softnet_stat, if there is an increase, it is determined that the soft interrupt receive buffer overflows, and the current values of netdev_max_backlog, netdev_budget, and netdev_budget_usecs are recorded. Through sysctl, netdev_max_backlog, netdev_budget, and netdev_budget_usecs are expanded to twice their own values, and the soft interrupt buffer status adjustment flag is set;
[0079] Among them, netdev_max_backlog represents the maximum number of packets allowed to be sent to the queue when the rate at which each network interface receives packets is faster than the rate at which the kernel processes these packets.
[0080] netdev_budget indicates the number of packets to be processed in one batch.
[0081] The time period for netdev_budget_usecs batch processing.
[0082] 8. Whether flow control packet loss occurs
[0083] Check dropped through ifconfig. If there is an increase, it is determined that flow control packet loss occurs. Get the txqueuelen value through ifconfig, set the txqueuelen value to twice its own value through ifconfig, set dev_weight to twice its own value through sysctl, set gro_normal_batch to twice its own value through sysctl, and set the flow control status adjustment flag;
[0084] Among them, dropped is the number of discarded data packets.
[0085] txqueuelen send queue length.
[0086] gro_normal_batch accumulates a certain number of packets and searches them for processing in the TCP / IP protocol stack at one time.
[0087] dev_weight is the maximum number of packets the kernel can handle on a NAPI interrupt.
[0088] 9. Whether the receiving buffer overflows
[0089] By checking TCPRcvQDrop in / proc / net / netstat, if there is an increase, determine whether the receive buffer overflows, record the current values of tcp_rmem and rmem_max, set tcp_rmem to twice its own value through sysctl, set rmem_max to twice its own value through sysctl, and set the receive buffer adjustment flag;
[0090] Among them, TCPRcvQDrop counts the number of packets dropped due to system-wide or per-NIC memory pressure.
[0091] The tcp_rmem parameter has three values. The first value is the minimum number of bytes allocated for the socket receive buffer; the second value is the default value, the buffer can grow to this value when the system load is not heavy; the third value is the maximum number of bytes of the receive buffer space.
[0092] rmem_max The maximum TCP data receiving window.
[0093] 10. Does the zero window overflow?
[0094] By checking TCPZeroWindowDrop in / proc / net / netstat, if there is an increase, it is determined that the zero window overflows, and the current values of tcp_rmem and rmem_max are recorded. Through sysctl, tcp_rmem is set to twice its own value, and rmem_max is set to twice its own value, and the zero window adjustment flag is set;
[0095] TCPZeroWindowDrop is the number of packets lost when the receiving window is too small to receive packets.
[0096] 3. Subsequent monitoring stage
[0097] Start scheduled task 2 with a period of 5 seconds. Check whether there is an adjustment mark for each detection type in scheduled task 1. If so, re-check the preset adjustment condition corresponding to the adjustment mark: if the preset adjustment condition is no longer met, restore the data of the detection type corresponding to the adjustment mark to the data before adjustment, and delete the corresponding adjustment mark until the data of all detection types are restored to the default parameters.
[0098] This application monitors the CPU load, socket timeout and overflow of all processes in the TCP / IP protocol stack. When the established conditions are met, the core parameters of the operating system are automatically adjusted to ensure the smoothness of the network connection. When the established conditions are not met, the parameters are adjusted again until they are restored to the default parameters. This allows the device to quickly adapt to complex network environments and automatically handle common problems such as limited bandwidth, high packet loss rate, unstable socket connection, etc. After the network quality is restored, the modified content is automatically restored. Under the premise of ensuring stability, the user experience of the device in a variety of complex network environments is greatly improved, and the adaptability of the operating system is improved.
[0099] The above are only some implementation methods of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for automatically optimizing network performance, characterized in that: include: S1: When the boot is detected, the default parameters corresponding to multiple detection types of the current operating system are recorded, and the default parameters are stored in the form of a file; S2: Start the scheduled task 1, detect multiple detection types of the operating system at a predetermined period, determine whether the corresponding preset adjustment conditions are met, and if so, make adjustments and set adjustment flags for the detection types; S3: Start the timing task 2, and detect whether there is an adjustment mark for each detection type in the timing task 1 at a predetermined period. If there is, re-detect the preset adjustment condition corresponding to the adjustment mark: if the preset adjustment condition is no longer satisfied, restore the data of the detection type corresponding to the adjustment mark to the data before the adjustment, and delete the corresponding adjustment mark at the same time, until the data of the detection type is the default parameter; When the detection type is whether the CPU processing the network card receiving and sending packets has reached full load, S2 includes: Use top to check the load of CPU0. If it is higher than 85%, it means that the CPU processing the NIC's sent and received packets has reached full load. Record the current status of the NIC's GRO and GSO. Use ethtool to open GRO and GSO, and set the CPU full load status adjustment flag. When the detection type is whether the semi-join overflows, S2 includes: Check the number of SYN_RECV through netstat. If it continues to grow, it means that the half-connection overflows. Record the current status of the tcp_syncookies parameter, modify tcp_syncookies to 1 through sysctl, and set the half-connection overflow status adjustment flag. When the detection type is full connection overflow, S2 includes: Check the status bit LISTEN row through ss-antlp. If the Recv-Q column is greater than the Send-Q column, the full connection overflow is determined. Record the current values of the protocol stack tcp_max_syn_backlog and somaxconn parameters. Set the above values to twice their current values through sysctl, and set the full connection overflow status adjustment flag. When the detection type is whether the network port is insufficient, S2 includes: Check the number of TCP ports in use through netstat. If the number of TCP ports in use is greater than the private reserved ports, it is determined that the network ports are insufficient. Record the current value of ip_local_port_range, expand the range of ip_local_port_range through sysctl, enable the timeout reuse mechanism through sysctl, reduce the MSL value through sysctl, and set the port shortage status adjustment flag; When the detection type is whether the socket has timed out and disconnected multiple times, S2 includes: Check the socket error status in the system log. If there are multiple timeout logs, it is determined that the socket has timed out and disconnected multiple times. Record the number of SYN and SYNACK retransmissions. Set the number of SYN and SYNACK retransmissions to 10 through sysctl and set the socket timeout status adjustment flag. When the detection type is whether there is an overflow in the ring buffer, S2 includes: Check the overruns value through ifconfig. If it increases, it means that the ring buffer overflows. Get the length of the network card's receive and send ring queues through ethtool. Set the length of the network card's receive and send wake-up queues to twice their own values through ethtool. Set the ring buffer status adjustment flag. When the detection type is whether the soft interrupt receiving buffer overflows, S2 includes: By checking the third column of / proc / net / softnet_stat, if there is an increase, it is determined that the soft interrupt receive buffer overflows, and the current values of netdev_max_backlog, netdev_budget, and netdev_budget_usecs are recorded. Through sysctl, netdev_max_backlog, netdev_budget, and netdev_budget_usecs are expanded to twice their own values, and the soft interrupt buffer status adjustment flag is set; When the detection type is whether flow control packet loss occurs, whether the receiving buffer overflows, and whether the zero window overflows, S2 includes: Check dropped through ifconfig. If there is an increase, it is determined that flow control packet loss occurs. Get the txqueuelen value through ifconfig, set the txqueuelen value to twice its own value through ifconfig, set dev_weight to twice its own value through sysctl, set gro_normal_batch to twice its own value through sysctl, and set the flow control status adjustment flag; By checking TCPRcvQDrop in / proc / net / netstat, if there is an increase, determine whether the receive buffer overflows, record the current values of tcp_rmem and rmem_max, set tcp_rmem to twice its own value through sysctl, set rmem_max to twice its own value through sysctl, and set the receive buffer adjustment flag; By checking TCPZeroWindowDrop in / proc / net / netstat, if there is an increase, it is determined that the zero window overflows, and the current values of tcp_rmem and rmem_max are recorded. Then, tcp_rmem is set to twice its own value through sysctl, rmem_max is set to twice its own value through sysctl, and the zero window adjustment flag is set.
2. The method for automatically optimizing network performance according to claim 1, characterized in that: Multiple detection types include: whether the CPU processing the network card receiving and sending packets has reached full load, whether the half connection has overflowed, whether the full connection has overflowed, whether the network port is insufficient, whether there are multiple socket timeouts and disconnections, whether the ring buffer has overflowed, whether the soft interrupt receiving buffer has overflowed, whether flow control packet loss occurs, whether the receiving buffer overflows, and whether the zero window overflows. The preset adjustment conditions corresponding to each detection type are: the CPU processing the network card receiving and sending packets has reached full load, half connection overflows, full connection overflows, network ports are insufficient, multiple socket timeouts and disconnections occur, the ring buffer has overflowed, the soft interrupt receiving buffer overflows, flow control packet loss occurs, the receiving buffer overflows, and the zero window overflows.
Citation Information
Patent Citations
Design for computer performance self-adjusting system
CN103116538A
Network testing performance optimization method
CN105162657A