A Ping delay simulation method, computing device and Ping delay simulation system
By simulating interrupt threading and preset program delay processing on the target processor, the problem of difficulty in accurately simulating the Ping delay caused by excessive processor load in the prior art is solved, and an efficient simulation method is realized and system performance is improved.
Patent Information
- Application Number
- CN202410119034.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-29
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-01-29
AI Technical Summary
The prior art is difficult to accurately simulate ping delays due to excessive load on the device processor, and conventional methods may affect system stability.
By calling the interrupt processing kernel thread on the target processor to process multiple TCP messages and creating a preset program delays processing the first Ping request message, thereby simulating the abnormal scheduling behavior of the processor being occupied by the task for a long time.
It realizes the ping delay caused by excessive processor load without modifying the kernel function code, which improves the flexibility and real-time performance of the system.
Smart Images

Figure CN117896269B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of server technology, and in particular to a Ping delay simulation method and computing device. Background Art
[0002] The Internet packet explorer (Ping) is a tool for checking the quality of the connection between computers or network devices. It tests the connection between devices by sending Internet control message protocol (ICMP) packets. After sending a packet, the Ping tool will record the time required from sending the packet to receiving a response. This time is the Ping delay. Ping delay is one of the indicators that reflect the quality of the network link. The smaller the Ping delay, the better the network link quality, and vice versa.
[0003] Generally, Ping latency is affected by many factors, such as network congestion, router response speed, packet size, and destination device load. One of the reasons for excessive Ping latency is that a real-time task or kernel task occupies the processor for a long time, which causes the destination device's processor to be overloaded.
[0004] In order to better study solutions for this scenario or invent debugging tools for this scenario, it is often necessary to artificially simulate the Ping delay caused by this reason during debugging. Summary of the invention
[0005] The embodiments of the present application provide a Ping delay simulation method, a computing device, and a Ping delay simulation system, which can simulate the Ping delay caused by excessive processor load of the device.
[0006] In the first aspect, an embodiment of the present application provides a Ping delay simulation method, which is applied to a first device, and the operating system kernel of the first device adopts a non-preemptive scheduling mechanism, and the method includes: in response to receiving multiple TCP messages from a second device, calling the interrupt processing kernel thread of the target processor to process the network message tasks corresponding to the multiple TCP messages; the target processor is a processor that processes the Ping request message from the second device; adding the first task corresponding to the preset program to the ready task queue of the target processor; in response to receiving the first Ping request message, adding the first network message processing task corresponding to the first Ping request message to the ready task queue after the first task; wherein the first Ping request message is a non-first Ping request message sent by the first device; the Ping delay of the first Ping request message is determined based on the execution time of the preset program.
[0007] Therefore, by performing network pressure on the second device to trigger the interrupt threading of the target processor, and then creating a preset program to delay the time for the target processor to process the first network message processing task corresponding to the first Ping request message, the Ping delay caused by the abnormal scheduling behavior of the target processor being occupied by the first task for a long time is simulated.
[0008] In a possible implementation, before responding to receiving a plurality of TCP messages from the second device, the method further includes: determining a target processor when receiving a Ping request message for the first time, and determining a corresponding relationship between the target processor and the Ping request message.
[0009] In a possible implementation, determining the correspondence between the target processor and the Ping request message includes: determining a first corresponding parameter based on the IP address of the first device, the IP address of the second device, and the Ping request message; and determining the target processor based on the first corresponding parameter.
[0010] In a possible implementation, the correspondence between the target processor and the Ping request message is determined based on the identification number of the target processor and the first corresponding parameter. Exemplarily, the identification number of the target processor may be the serial number of the target processor.
[0011] In one possible implementation, after adding the first network message processing task corresponding to the first Ping request message to the first task in the ready task queue, the method also includes: based on the correspondence between the target processor and the Ping request message, calling the target processor to execute the first network message processing task corresponding to the first Ping request message.
[0012] Thus, the Ping request message from the IP address of the second device can be received and processed by the target processor to speed up the processing of the Ping request message.
[0013] In a possible implementation, before adding the first task corresponding to the preset program to the ready task queue of the target processor, the method further includes: determining the target processor based on a kernel tracking mechanism in response to a user query instruction.
[0014] Thus, the user can determine the serial number of the target processor that processes the Ping request message, so as to bind the preset program using the user control instruction.
[0015] In one possible implementation, adding a first task corresponding to a preset program to a ready task queue of a target processor includes: in response to a user instruction, binding the preset program to the target processor and creating a first task corresponding to the preset program; adding the first task to the ready task queue of the target processor.
[0016] In a possible implementation, the first task includes executing an infinite loop for a target duration; the target duration is set according to the size of the Ping delay to be simulated.
[0017] Therefore, the target processor is bound to execute the first task corresponding to the preset program, so as to delay the time for the target processor to process the first network message processing task.
[0018] In a possible implementation, receiving a plurality of TCP messages from the second device includes: receiving a plurality of TCP messages of a preset size at a preset frequency, wherein the preset frequency and the preset size are set according to a network bandwidth of a network link.
[0019] Thus, network pressure can be applied through the second device to trigger the target processor in the first device to perform interrupt threading.
[0020] In a second aspect, an embodiment of the present application provides a computing device, the computing device comprising: a memory and a processor; the memory and the processor are coupled; wherein,
[0021] A memory for storing program instructions;
[0022] A processor is used to execute program instructions to perform the method described in the first aspect or any possible implementation manner of the first aspect.
[0023] In a third aspect, an embodiment of the present application provides a simulated Ping delay simulation system, characterized in that the system includes a first device and a second device; the first device and the second device are communicatively connected; wherein the first device is the computing device described in the second aspect.
[0024] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the Ping delay simulation method of the first aspect.
[0025] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which is used to implement the Ping delay simulation method of the first aspect when the computer program is executed by a processor.
[0026] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0028] Figure 1 This is the working principle diagram of the Ping tool based on the ICMP protocol;
[0029] Figure 2 A schematic diagram of a Ping delay simulation scenario provided in an embodiment of the present application;
[0030] Figure 3 A flowchart of a Ping delay simulation method provided in an embodiment of the present application;
[0031] Figure 4 A schematic diagram of a scenario for implementing interrupt threading provided in an embodiment of the present application;
[0032] Figure 5 A schematic diagram of another scenario of Ping delay simulation provided in an embodiment of the present application;
[0033] Figure 6 A flowchart of another Ping delay simulation method provided in an embodiment of the present application;
[0034] Figure 7 A schematic diagram of the structure of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] 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 will be described below in conjunction with the accompanying drawings.
[0036] In the description of the embodiments of the present application, any embodiment or design scheme of "exemplary", "for example" or "for example" should not be understood as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "for example" or "for example" is intended to present related concepts in a specific way.
[0037] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized. "At least one" can be one or more, where a plurality is two or more.
[0038] Ping is a detection tool that works at the application layer in the TCP / IP network architecture. The Ping tool sends ICMP messages based on the ICMP protocol. The ICMP messages are encapsulated in IP data packets, and the IP data packets are forwarded at the network layer in the TCP / IP network architecture.
[0039] ICMP messages based on the ICMP protocol can be roughly divided into two categories: one is the query message used for network diagnosis, that is, the query message type. The other is the error message that notifies the cause of the network error, that is, the error message type. Among them, the query message type includes the ICMP echo request message (echo request), that is, the Ping request message sent by the Ping tool, and the ICMP echo reply message (echo reply), that is, the Ping reply message received by the Ping tool. The query message type is used to determine whether the IP data packet sent between the communicating hosts or routers has successfully reached the other end.
[0040] For example, Figure 1 The figure shows the working principle of the Ping tool based on ICMP protocol. Figure 1 As shown in the figure, a network link is established between the source device and the destination device through n routers. Where n≥1. The source device and the destination device are hardware devices such as PCs, servers, mobile terminals, and smart wearable devices that support the ICMP protocol. First, the Ping tool on the source device sends ①ICMP echo request message to the destination device to test whether the destination is reachable. Next, the destination device sends ②ICMP echo reply message in response to the received ICMP echo request message. Finally, the Ping tool of the source device receives the lCMP echo request message to complete the network quality query of the communication link. In this process, the ICMP echo request message and the ICMP echo reply message are respectively encapsulated into different IP data packets, and the header of the IP data packet includes the IP address information of the source device and the destination device. One or more routers complete the transmission of IP data packets between the source device and the destination device at the network layer.
[0041] The Ping tool can be used to perform the above network quality detection operation to calculate various round-trip time delays (RTT). For example, according to the process of sending requests and receiving responses by the Ping tool multiple times, the average round-trip time delay (average RTT), minimum delay (minimum RTT), maximum delay (maximum RTT) and other statistical data are calculated. The above round-trip time delays are collectively referred to as Ping delays. These statistical data are used to evaluate the quality of the network link, that is, Ping delay is one of the indicators reflecting the quality of the network link. It can be understood that the smaller the Ping delay, the better the network link quality, and vice versa.
[0042] Since the Ping tool tests the reachability and latency of a network link by sending and receiving ICMP messages, its measurement results are affected by the network environment and the target device. Network congestion, router load, and the responsiveness of the target device may all lead to an increase in Ping latency.
[0043] One of the reasons for the long Ping latency is that the processor of the destination device is overloaded due to a real-time task or kernel task of the destination device occupying the processor for a long time. Therefore, in the operation and maintenance process of the network environment and the destination device, it is valuable and meaningful to artificially simulate such abnormal scheduling behavior of the processor.
[0044] However, due to the various reasons for excessive Ping latency, it is difficult for users to accurately simulate the scenario where the Ping latency is too large due to excessive processor load on the target device. On the one hand, the operating system kernel of the device usually does not provide an external debugging interface for the Ping processing process; on the other hand, the Ping tool sends and receives ICMP messages that are processed by the device kernel network protocol stack, making it difficult for users to modify the kernel program.
[0045] In the related technology, the extended Berkeley Packet Filter (eBPF) technology can be used to insert a stub in the Ping processing flow of the kernel protocol stack of the destination device to increase the latency, but it cannot simulate the abnormal scheduling behavior of the processor being occupied by other tasks for a long time. Alternatively, since Ping requests are generally processed in the soft interrupt context, the latency can be artificially increased in the soft interrupt context of the kernel of the destination device, but this will also increase the processing time of the soft interrupt for other kernel tasks, affecting the overall stability of the system.
[0046] In view of this, an embodiment of the present application provides a Ping delay simulation method, which adopts a non-preemptive scheduling mechanism based on the operating system kernel of the first device, triggers the interrupt threading of the target processor in the first device by performing network pressure on the second device, and then creates a preset program to delay the time for the target processor to process the first network message processing task corresponding to the first Ping request message, thereby simulating the Ping delay caused by the abnormal scheduling behavior of the target processor being occupied by the first task for a long time.
[0047] Since the scenario of excessive Ping delay caused by excessive processor load of the first device can be simulated without modifying the kernel function code, the simulation method is simple and efficient. On this basis, solutions for such scenarios can be studied or debugging tools for such scenarios can be invented.
[0048] It can be understood that the first device can run different operating systems to execute the kernel's non-preemptive scheduling mechanism, such as Unix, Linux, etc. The following will take the Linux system as an example to explain in detail the solution involved in this application.
[0049] For example, Figure 2 FIG. 1 shows a schematic diagram of a Ping delay simulation scenario provided by an embodiment of the present application. Figure 2 As shown, the scenario is completed by the first device and the second device executing steps 201 to 207. Specifically, it includes:
[0050] Step 201: The second device sends a Ping request message to the first device for the first time.
[0051] In this embodiment, the second device is a source device that sends a Ping request message, the first device is a destination device that sends a Ping response message, and the operating system kernel of the first device adopts a non-preemptive scheduling mechanism. The Ping request message is an echo request message based on the ICMP protocol. The Ping request message is encapsulated in an IP data packet, and the IP data packet is forwarded at the network layer in the TCP / IP network architecture. The header of the IP data packet includes the IP address information of the source device and the destination device.
[0052] A network link is established between the first device and the second device in advance through a network device such as a router. For example, a TCP connection can be established using a three-way handshake process. The network device is responsible for forwarding various IP data packets between the first device and the second device, and the IP data packets are transmitted using the TCP protocol at the transport layer.
[0053] Optionally, the first device is a server in the network, and the second device is one of multiple clients managed by the server. The second device can use client software or an application such as a browser to initiate a data or service request to the first device. Before, after, or during the execution of the application, the second device can detect the quality of the network link between the second device and the first device by sending a Ping request message.
[0054] Step 202: The first device processes the Ping request message sent for the first time.
[0055] Step 203: Send a Ping response message corresponding to the Ping request message sent for the first time to the second device.
[0056] In this embodiment, the first device includes multiple processors, which can exchange data with each other and work independently. Multiple processors are assigned to different processes to perform parallel processing of multiple tasks. The Ping reply message is an echo reply message based on the ICMP protocol.
[0057] In the Linux kernel, interrupts are an asynchronous event processing mechanism used to improve the concurrent processing capabilities of the system. The occurrence of an interrupt event triggers the execution of the interrupt handler, which is divided into two parts: the upper half and the lower half. The upper half corresponds to hard interrupts and is used to quickly handle interrupts; the lower half corresponds to soft interrupts and is used to asynchronously handle unfinished work in the upper half. Soft interrupts in Linux include various types such as network message sending and receiving, timing, scheduling, RCU locks, etc.
[0058] For example, when the network card notifies the processor to receive a network IP data packet through a hardware interrupt, the processor will call the registered interrupt function according to the interrupt table to process the reception of the IP data packet. During the processing, the interrupt function will call the corresponding function in the network card driver to temporarily disable the interrupt of the network card, thereby preventing the processor from being interrupted continuously. Since the hard interrupt handler cannot be interrupted during execution, if it executes for too long, it will cause the processor to be unable to respond to other hardware interrupts. Therefore, the Linux kernel introduces soft interrupts, so that the time-consuming part of the hard interrupt handler function can be moved to the soft interrupt handler function for slow processing.
[0059] Therefore, the first device can use the soft interrupt processing function to process the Ping request message sent by the second device for the first time. The network card driver will trigger an interrupt when receiving a network message, and specify the target processor (such as CPU X) that responds to this interrupt according to the information carried in the message header of the network message, so that the kernel allocates the target processor from multiple processors to execute this soft interrupt, and generates a Ping response message corresponding to the Ping request message sent for the first time and sends it to the second device.
[0060] When it is not the first time to receive a Ping request message from the IP address of the second device, since the second device has a fixed IP address in the established network link, the information carried in the message header of the network message will not change. Therefore, the processor that the system subsequently assigns to process the Ping request message from the second device is basically fixed, that is, the first device will also assign the Ping request message received from the second device subsequently to the target processor for processing.
[0061] Step 204: The second device continuously sends multiple TCP messages and multiple Ping request messages to the first device.
[0062] In this embodiment, the second device continuously sends multiple TCP messages to the first device through a network stress testing tool. The content of the TCP messages does not involve the implementation of specific services and is used to increase the network load of the first device.
[0063] The second device also continuously sends multiple Ping request messages to the first device through the Ping tool.
[0064] The timing when the Ping tool starts sending multiple Ping request messages can be the same as the timing when the network stress testing tool starts sending multiple TCP messages, or it can be before or after the network stress testing tool starts sending multiple TCP messages, which is not limited here.
[0065] The frequency (e.g., 1 time / s) at which the Ping tool continuously sends multiple Ping request messages is independent of the frequency at which the network stress testing tool continuously sends multiple TCP messages. For example, the network stress testing tool can send multiple TCP messages at a preset frequency to quickly increase the network load of the first device.
[0066] It can be understood that in this embodiment, the types of network packet messages include TCP messages and Ping request messages.
[0067] Usually, the interrupt handler function that processes network message runs directly in the soft interrupt context. However, when the network load is too large, the frequency of soft interrupts being triggered will be very high. If this operation method is continued, some problems will occur: the interrupt context cannot be preempted, and the long interrupt processing may cause the user space task to not get enough processor time, thus reducing the real-time performance and response speed of the system.
[0068] Therefore, in this embodiment, the Linux kernel will start some interrupt processing kernel threads according to the number of processors when it is started, and each processor corresponds to an interrupt processing kernel thread. The names of these threads are all called ksoftirqd / Xthread, where X is an integer starting from 0, indicating the number of the processor. The system can set the processor to call the ksoftirqd / X thread corresponding to the processor to process the network message task corresponding to the network message message when there are too many soft interrupts in the kernel and it cannot handle them. In this way, when the network load is too large, the system can trigger the processor in the kernel to interrupt threading, and use the interrupt processing kernel thread to process the network message task corresponding to the network message message. After the processor is interrupt threaded, the operating system uniformly schedules various network message processing tasks and user tasks in the processor ready task queue, which can greatly improve the real-time performance and response performance of the system.
[0069] Typically, a system can choose to set up one or more processors to support interrupt threading.
[0070] Optionally, one or more processors (including the target processor) included in the first device are set to support interrupt threading. The size and frequency of sending multiple TCP messages are set in the network stress testing tool deployed on the second device to adjust the data transmission rate of sending TCP messages. And TCP messages are sent to the first device based on the set data transmission rate. For example, the data transmission rate of sending TCP messages can be increased to the maximum bandwidth supported by the network card in the first device to quickly trigger the interrupt threading of one or more processors (including the target processor) in the first device.
[0071] Step 205: Bind the target processor to execute a preset program.
[0072] In this embodiment, the preset program is a kernel code pre-written in the kernel, which does not involve the implementation of a specific kernel function and is only used to occupy the processor resources of the target duration. The target duration is set according to the size of the Ping delay to be simulated.
[0073] As described in step 202-step 203, the first device will also assign the Ping request message from the second device that is not received for the first time to the target processor for processing. In step 204, a network stress test tool is used to send multiple TCP messages to the first device to trigger the interrupt threading of one or more processors (including the target processor) in the first device. Therefore, the kernel will call the interrupt processing kernel thread of the target processor to process the network message tasks corresponding to the multiple Ping messages.
[0074] As described in step 202, the operating system kernel of the first device adopts a non-preemptive scheduling mechanism, that is, there is no priority relationship between the tasks in the ready task queue of the processor, and each task is scheduled and executed in order in the ready task queue. The operating system implements the scheduling rotation of tasks through the non-preemptive scheduling mechanism. During the execution of the current task, other tasks can only wait in the ready task queue of the processor. When the current task is executed, the task scheduling function is used to schedule the task switching, and the next task in the ready task queue is arranged to start execution.
[0075] Exemplarily, since the preset program is pre-written in the kernel, the preset program can be executed by binding the target processor to occupy the target processor resources for the target duration. In the ready task queue of the target processor, for the network message processing task corresponding to the Ping request message arranged after the task corresponding to the preset program, its execution time will be delayed. It can be understood that the time increased by the Ping delay corresponding to these Ping request messages due to the execution time delay is less than or equal to the target duration that the preset program occupies the target processor, wherein the maximum value of the time increased by the Ping delay is equal to the target duration. Among them, the Ping delay is the time between the second device sending the Ping request message and receiving the corresponding Ping response message.
[0076] Optionally, by repeatedly executing a preset program periodically / irregularly, the processing time of some network message processing tasks corresponding to some Ping request messages in the ready task queue of the target processor can be delayed.
[0077] Step 206: Use the target processor to process the first Ping request message among the multiple Ping request messages.
[0078] Step 207: Send a first response message corresponding to the first Ping request message to the second device.
[0079] In this embodiment, after processing the task corresponding to the preset program, the target processor processes the first network message processing task corresponding to the first Ping request message arranged after the task corresponding to the preset program, and sends a first response message corresponding to the first Ping request message to the second device.
[0080] Since the task corresponding to the preset program occupies the target processor for a long time, in the ready task queue of the target processor, the execution time of the network message processing task corresponding to the first Ping request message arranged after the task corresponding to the preset program will be delayed.
[0081] In this way, the target processor processes the multiple Ping request messages sent in step 204, the target processor or other processors in the first device processes the multiple TCP messages sent in step 204, and sends response messages corresponding to these TCP messages or Ping request messages to the second device.
[0082] Optionally, due to the influence of periodic / irregular repeated execution of a preset program, the target processor may have a large delay when sending corresponding Ping response messages for some Ping request messages.
[0083] Therefore, without modifying the kernel process or mechanism, the ping delay caused by the abnormal scheduling behavior of the target processor being occupied by other tasks for a long time can be simulated, thereby improving the utilization efficiency of the system. By utilizing the feature that the operating system kernel of the first device adopts a non-preemptive scheduling mechanism, the unreasonable execution of the kernel thread but the logic allowed by the kernel is simulated, thereby improving the flexibility of the system.
[0084] Based on the description in the above embodiment, a method for simulating Ping delay provided in an embodiment of the present application is introduced below.
[0085] For example, Figure 3 A flowchart of a Ping delay simulation method provided by an embodiment of the present application is shown in FIG. Figure 2 In the first device shown, the operating system kernel of the first device adopts a non-preemptive scheduling mechanism. Figure 3 As shown, the method is completed by steps 301 to 303:
[0086] Step 301, in response to receiving multiple TCP messages from a second device, calling an interrupt processing kernel thread of a target processor to process network message tasks corresponding to the multiple TCP messages; wherein the target processor is a processor for processing Ping request messages from the second device.
[0087] In this embodiment, the first device includes one or more processors, and the operating system kernel of the first device adopts a non-preemptive scheduling mechanism. Figure 2 The web link shown.
[0088] Optionally, the first device is a server in the network, corresponding to the destination device. The second device is one of the multiple clients managed by the server, corresponding to the source device. The second device has a fixed IP address during data transmission. It is understood that the IP data packet transmitted between the first device and the second device includes the IP addresses of the source device and the destination device. It is understood that the types of network message messages include TCP messages and Ping request messages.
[0089] As described in step 203, in the first device, for an IP data packet from a fixed IP address, the processor that receives and processes the Ping request message included in the IP data packet is basically fixed. Therefore, in the first device, the target processor has a corresponding relationship with the Ping request message from the second device.
[0090] Exemplarily, when the first device receives the Ping request message sent by the second device for the first time, it can use the soft interrupt context for processing. The network card driver triggers an interrupt when receiving a network message, and specifies the target processor (such as CPU X) that responds to the interrupt according to the information carried in the message header of the network message, so that the kernel allocates the target processor from multiple processors to execute the soft interrupt, and generates a Ping response message corresponding to the Ping request message sent for the first time and sends it to the second device.
[0091] Exemplarily, when the network card driver receives a Ping request message from the IP address of the second device for the first time, the target processor can be selected by a preset scheduling algorithm. Specifically, when the Ping request message from the IP address of the second device is received for the first time, the network card driver performs a hash operation based on the source address information (the IP address of the second device), the target address information (the IP address information of the first device) carried in the message header of the IP data packet, and the protocol type (Ping request message) of the data carried to obtain a hash value (the first corresponding parameter), and obtains the processor serial number according to the hash value and the preset algorithm to determine the target processor, and determines the correspondence between the target processor and the first corresponding parameter.
[0092] In one achievable manner, the preset algorithm may be a modulo operation, in which a modulo operation is performed on the acquired hash value to obtain a corresponding operation result, and a processor having the sequence number (the modulo operation result of the hash value) is used as the target processor.
[0093] Optionally, the correspondence between the hash value and the processor serial number is saved in the network configuration table of the network card.
[0094] When it is not the first time to receive a Ping request message from the IP address of the second device, first, the network card driver also obtains the above hash value through hash operation. Next, according to the network card configuration, the processor serial number can be obtained by performing another operation according to the scheduling algorithm based on the hash value to determine the target processor, or the processor serial number corresponding to the above hash value can be queried from the network configuration table of the network card to determine the target processor. The specific method is not limited here.
[0095] Thus, the Ping request message from the IP address of the second device can be received and processed by the target processor to speed up the processing of the Ping request message.
[0096] Exemplarily, the first device includes multiple processors, and the Linux kernel will start an interrupt processing kernel thread named ksoftirqd / X thread for each processor when it is started, where X is an integer starting from 0, indicating the number of the processor. The system can set one or more processors to call the ksoftirqd / X thread corresponding to one or more processors (including the target processor) to process the network message task when there are too many soft interrupts in the kernel and they cannot be processed.
[0097] The contents of the multiple TCP messages sent by the second device do not involve the implementation of specific services and are used to increase the network load of the first device.
[0098] In one implementation, a network stress testing tool deployed on the second device sends multiple TCP messages to the first device to create a sufficiently large network load for the first device. In response to receiving multiple TCP messages from the second device, an interrupt processing kernel thread of one or more processors (including the target processor) included in the first device is called to process network message tasks corresponding to the multiple TCP messages.
[0099] A plurality of TCP messages of a preset size can be sent by presetting the preset frequency of the network stress testing tool deployed by the second device, so as to call the interrupt processing kernel thread of one or more processors (including the target processor) included in the first device as soon as possible to perform the network message processing task. The preset frequency and the preset size are set according to the network bandwidth of the network link. It can be understood that the performance parameters of each hardware device (such as a router, a network card, etc.) that constitutes the network link may cause a network bandwidth bottleneck. Since the purpose of using the network stress testing tool to send multiple TCP messages is to increase the network load of the first setting, when setting the preset frequency and the preset size, the maximum network bandwidth supported by the network card in the first device can be referred to first.
[0100] Optionally, when sending multiple TCP messages through the network stress testing tool deployed by the second device, multiple Ping request messages can be sent through the Ping tool deployed by the second device to speed up the speed of calling the interrupt processing kernel thread of one or more processors (including the target processor) included in the first device.
[0101] Optionally, when sending multiple TCP messages through the network stress testing tool deployed by the second device, all network interruptions from the IP address of the second device by the first device can be bound to the target processor for processing, so as to speed up the calling of the interrupt processing kernel thread of the target processor included in the first device. For example, by executing the following user operation instruction in the first device: ifname = "enol", cpu_list = "3", the operation of binding the network message task generated by receiving the network IP data packet of the second device to the processor represented by the number "3" is implemented. Among them, "enol" represents the network card address in the second device, and "3" represents the number of a processor in the first device.
[0102] Optionally, you can also Figure 2 In the Ping delay simulation scenario diagram shown, a UDP connection is established between the first device and the second device at the transport layer, and a network stress testing tool deployed on the second device is used to send multiple UDP messages to complete the solution executed in step 301, and the details are not repeated here.
[0103] Thus, network pressure can be applied through the second device to trigger the target processor in the first device to perform interrupt threading.
[0104] Exemplarily, in response to executing a user query instruction in the first device, the ftrace kernel function can be used to trace the processing process of the Ping request message so that the user can obtain the information of the target processor. For example, the user query instruction is executed: echo′p:icmp_rcvicmp_rcv′> / sys / kernel / debug / tracing / kprobe_events, and the kernel processing interface icmp_rcv that responds to the Ping request message is traced through the kprobe_event mechanism of ftrace. After receiving the Ping request message, trace will print the traced function name and processor number in the first device, for example, the feedback traced function name is icmp_rcv, and the target processor number is CPU X.
[0105] Thus, the user can determine the serial number of the target processor that processes the Ping request message, so as to use the user control instruction to bind the preset program in step 302.
[0106] Step 302: Add the first task corresponding to the preset program to the ready task queue of the target processor.
[0107] In this embodiment, the preset program is a kernel code pre-written in the kernel. Such code does not involve the implementation of a specific kernel function and is only used to occupy the processor resources of the target duration. The target duration is set according to the size of the Ping delay that needs to be constructed. When the preset program is loaded, a first task corresponding to the preset program is created, and the first task is added to the ready task queue of the processor allocated to the preset program.
[0108] For a processor, the tasks in its ready task queue are tasks that have the running conditions (not suspended or blocked), but have other tasks running and need to wait. If the task in the ready state is determined by the scheduler to obtain the right to use the processor, the task will enter the running state from the waiting state. It can be understood that for a processor, there can only be one task in the running state at any time in its ready task queue, and there can be multiple tasks in the waiting state.
[0109] In one implementation, by executing a user control instruction in the first device, a preset program is bound to a target processor for loading to create a first task, and the first task is added to a ready task queue of the target processor.
[0110] Specifically, a preset program named do_delay_on_cpu.c can be pre-written in the kernel, and the preset program can be compiled into a module file with a suffix of ko. In the ko module file loading stage, the module file can be loaded by binding the target processor, a kworker task corresponding to the module file can be created, and the corresponding kworker task can be added to the ready task queue of the target processor to wait for scheduling by the scheduler. For example, after executing a user query instruction in the first device to allow the user to determine that the target processor number X is 3; by executing the user control instruction: insmod do_delay_on_cpu.ko cpu=3, the preset program can be bound to a target processor numbered 3, and the kworker task corresponding to the do_delay_on_cpu.ko module file can be created using the target processor numbered 3.
[0111] The preset program is the kernel code pre-written in the kernel. This type of code does not involve the implementation of a specific kernel function and is only used to occupy the processor resources of the target duration. The target duration is set according to the size of the Ping delay to be simulated.
[0112] In one implementation, the preset program is written as an infinite loop that executes the target duration to occupy the processor resources for the target duration. In this way, the kworker task corresponding to the do_delay_on_cpu.ko module file is used to execute an infinite loop of the user-specified target duration mdelay. This target duration mdelay represents the duration of occupying the target processor. Assuming that the task after the kworker task in the ready task queue of the target processor is ksoftirqd / X thread, it means that ksoftirqd / X thread will not be scheduled for mdelay. Generally speaking, the setting of mdelay cannot exceed 20s (system default value), otherwise it will trigger the system to have a softlockup panic problem and cause the kernel to crash.
[0113] Therefore, by binding the target processor to execute the first task corresponding to the preset program, the time for the target processor to process the first network message processing task corresponding to the first Ping request message is delayed in step 303 .
[0114] Step 303, in response to receiving the first Ping request message, add the first network message processing task corresponding to the first Ping request message to the ready task queue after the first task. The first Ping request message is not the first Ping request message sent by the first device. The Ping delay of the first Ping request message is determined based on the execution time of the preset program.
[0115] In this embodiment, based on the correspondence between the target processor and the Ping request message sent by the second device, in response to receiving the first Ping request message, a corresponding first network message processing task is created for the first Ping request message, and the first network message processing task is added after the first task in the ready task queue of the target processor.
[0116] In one implementation, the operating system kernel of the first device adopts a non-preemptive scheduling mechanism and executes a preset program by binding a target processor, thereby delaying the time for the target processor to process the first network message processing task.
[0117] It can be understood that in the ready task queue of the target processor, the first network message processing task corresponding to the first Ping request message is ranked after the first task corresponding to the preset program. Therefore, after the target processor processes the first task corresponding to the preset program, it processes the first network message processing task corresponding to the first Ping request message according to the scheduler, and sends a Ping response message corresponding to the first Ping request message to the second device. For the second device, the round-trip time of sending the first Ping request message and receiving the first Ping response message is the Ping delay caused by the excessive network load of the target processor of the first device.
[0118] For example, Figure 4 A schematic diagram of a scenario for implementing interrupt threading provided by an embodiment of the present application is shown in FIG. Figure 4 As shown, a network link is pre-established between the first device as the server and the second device as the client. Optionally, the two parties transmit IP data packets based on the TCP connection established in the three-way handshake process. And the second device uses the method in step 201 to send a Ping request message to the first device for the first time. As described in step 202, the processor in the first device that processes the Ping request message sent for the first time is the target processor. The target processor has a corresponding relationship with the Ping request message from the IP address of the second device.
[0119] The first device includes multiple processors (such as CPU X, CPU X+1, etc.), and the multiple processors can exchange data with each other and work independently. Multiple tasks are processed in parallel by allocating multiple processors to different processes. The operating system kernel of the first device adopts a non-preemptive scheduling mechanism.
[0120] The IP address of the network card NIC in the second device is 192.168.1.2, and the IP address of the network card NIC in the first device is 192.168.1.1. It can be understood that the IP data packet encapsulating the Ping request message sent by the second device includes the IP address of the destination device: 192.168.1.1.
[0121] Optionally, a Ping tool is used in the second device to send multiple Ping request messages to the first device. Also, a network stress test tool netperf (network stress test client) is used in the second device to send multiple TCP messages to the first device at a preset frequency and preset size. For example, the user stress test instruction: . / netperf-tTCP_STREAM-H server_IP can be executed in the second device to send multiple TCP messages to the first device. Among them, server_IP is the IP address of the network card NIC in the first device.
[0122] Accordingly, the first device has deployed the netserver (network stress test server) service corresponding to the network stress test tool netperf. It can be understood that the excessive network burden caused by receiving multiple Ping request messages and multiple TCP messages triggers multiple processors (including the target processor) of the first device to interrupt threading.
[0123] Furthermore, by binding the target processor to execute the preset program, the first task corresponding to the preset program is added to the ready task queue of the target processor. Figure 4 As shown, the first task can be set as a dead loop task with a target execution duration.
[0124] Furthermore, according to the setting of the network configuration table of the first device, a ksoftirqd / X thread is created for receiving the Ping request message from the second device, and the ksoftirqd / X thread is added to the ready task queue of the target processor CPU X after the first task. The multiple ksoftirqd / X threads created for the TCP message are added to the ready task queues of multiple processors (including the target processor). For example, the ksoftirqd / X+1thread and ksoftirqd / ...thread created for the TCP message are added to the ready task queues of CPU X+1 and CPU... respectively. The processing process for a TCP message includes: first calling the kernel packet receiving entry napi_gro_receive to receive the IP data packet, then calling the TCP message receiving entry tcp_v4_rcv to receive the TCP message, and finally calling the processing interface recv to process the TCP message.
[0125] Since the operating system kernel of the first device adopts a non-preemptive scheduling mechanism, for the target processor CPU X, when the current thread kthread task is used to process the first task, the ksoftirqd / X thread needs to wait in the ready task queue of the target processor. Therefore, the time for the target processor to process the ksoftirqd / X thread can be delayed.
[0126] For example, Figure 5 FIG. 4 shows another scenario schematic diagram of Ping delay simulation provided by an embodiment of the present application. Figure 5 As shown, when the first device receives the Ping request message NET_RX and generates an interrupt irq, the target processor CPU X has performed the following operations in the network system: Figure 4The interrupt threading shown, that is, the network stress test tool deployed by the second device is used to perform network stress, triggering the network packet receiving process of the first device to be transferred from the soft interrupt softirq to the interrupt processing kernel thread (ksoftirqd / X thread) to process the network message task. Since the operating system kernel of the first device has the non-preemptive scheduling feature, the preset file do_delay_on_cpu.c can be written and compiled to obtain the do_delay_on_cpu.ko module file, and the do_delay_on_cpu.ko module file can be bound to the target processor for loading to create a corresponding kworker task and occupy the time resources of the target processor for a long time.
[0127] like Figure 5 As shown in the left figure, the target processor is bound to execute the preset program, and a kworker task is created for the preset program. When the kworker task is scheduled as the running kthread (or RT) task of the target processor CPU X, the target processor CPUX is used to execute a dead loop with a target duration specified by the user. The target duration indicates the time that the target processor is occupied without being released, which means that the ksoftirqd / X thread that is behind the kworker task in the ready task queue of the target processor will not be scheduled for the target duration. The final result is that the target processor cannot respond to the Ping request message corresponding to the ksoftirqd / X thread in a timely manner.
[0128] like Figure 5 As shown in the figure on the right, after a period of time, since the kthread (or RT) task on the target processor CPU X actively releases the kworker task, the scheduler schedules the ksoftirqd / X thread for execution. At the same time, the ready task queue of the target processor CPU X is also updated to other tasks waiting for scheduling. For example, the processing process for a Ping request message includes: first calling the kernel packet receiving entry napi_gro_receive to receive the IP data packet, then calling the icmp data packet receiving entry icmp_rcv to receive the Ping request message, and finally calling the processing interface icmp_echo to generate the Ping response message corresponding to the Ping request message.
[0129] In summary, due to the influence of executing the preset program, the target processor CPU X will have a large delay when executing the network message processing task corresponding to the Ping request message after the first task (kworker task) in the ready task queue. It can be understood that the execution time of the loop function in the preset program is set according to the size of the Ping delay to be simulated. For example, the user setting instruction: dms=2000 can be executed in the first device to set the execution time of the infinite loop function in the first task to 2000ms.
[0130] Optionally, since the pre-written preset program will occupy the time resources of the target processor of the target time and then release them when loaded, the preset program loading behavior can be repeated continuously to make the target processor have a larger delay when sending corresponding Ping response messages for some Ping request messages.
[0131] For example, by executing the Ping request message command in the second device: ping 192.168.1.1 (192.168.1.1) 56 (84) bytes of data., the following trace can be seen in the second device: 64 bytes from 192.168.1.1: icmp_seq = 1 ttl = 64 time = 2328 ms, where icmp_seq = 1 indicates the sequence number of the response message, and time = 2328 ms indicates the Ping delay between the Ping request message and the corresponding Ping response message. Generally speaking, if the Ping delay is within 10-50 ms, it means that the network link quality is good.
[0132] Therefore, the embodiment of the present application adopts a non-preemptive scheduling mechanism based on the operating system kernel of the first device, triggers the interrupt threading of the target processor in the first device by performing network pressure on the second device, and then creates a preset program to delay the time for the target processor to process the first network message processing task corresponding to the first Ping request message, thereby simulating the Ping delay caused by the abnormal scheduling behavior of the target processor being occupied by the first task for a long time.
[0133] The solution used in the embodiment of the present application has the following advantages: 1. It can simulate the ping delay caused by abnormal scheduling behavior of the processor being occupied by other tasks for a long time without modifying the kernel process or mechanism. 2. It can simulate the unreasonable execution of kernel threads but logic allowed by the kernel by taking advantage of the feature that the operating system kernel of the first device adopts a non-preemptive scheduling mechanism.
[0134] Next, another Ping delay simulation method provided in the embodiment of the present application is introduced. The Ping delay simulation method is applied to Figure 2 The second device shown. Figure 6 As shown, the method is completed by step 601-step 602:
[0135] Step 601: Send multiple TCP messages to the first device to call the interrupt processing kernel thread of the target processor to process the network message tasks corresponding to the multiple TCP messages. The target processor is the processor that processes the Ping request message of the second device.
[0136] In this embodiment, a network link is provided between the second device and the first device. The second device sends a Ping request message to the first device so as to determine an available processor from among multiple processors of the first device as a target processor.
[0137] The network pressure is applied by sending a plurality of TCP messages to the first device, so as to call the interrupt processing kernel thread of the target processor included in the first device to process the network message tasks corresponding to the plurality of TCP messages.
[0138] Optionally, the second device uses the network stress testing tool netperf to send multiple TCP messages to the first device to exert network stress. Accordingly, the first device has started the netserver service corresponding to the netperf tool. The first device senses the network stress, interrupts the multiple processors (including the target processor) included, and creates and executes multiple network message processing tasks for the processor to improve the real-time performance and response performance of the system.
[0139] Step 602: Send a first Ping request message to the first device.
[0140] Step 603: Receive a first Ping response message.
[0141] The first Ping response message is a response message corresponding to the first Ping request message.
[0142] Step 604, determine the Ping delay.
[0143] The Ping delay is the time between the second device sending the first Ping request message and receiving the first Ping response message.
[0144] In this embodiment, in the first device, the first network message processing task is a network message processing task created for receiving the first Ping request message. The processing time of the first network message processing task is delayed because the target processor processes the first task corresponding to the preset program.
[0145] Optionally, in the first device, based on the characteristics of the processor adopting a non-preemptive kernel mechanism, by creating a preset program and binding the target processor, the processing time of the target processor can be occupied according to the set target time, so as to delay the time for the target processor to process the first network message processing task corresponding to the first Ping request message. The first network message processing task is arranged after the first task in the ready task queue of the target processor.
[0146] For the second device, the round trip time between sending the first Ping request message and receiving the first Ping response message is the Ping delay, which is the Ping delay caused by the excessive load of the target processor of the first device.
[0147] It is understandable that the size of the sequence number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. In addition, in some possible implementations, each step in the above embodiment can be selectively executed according to actual conditions, and can be partially executed or fully executed, which is not limited here.
[0148] Based on the method in the above embodiment, the present application embodiment provides a computing device. Figure 7 As shown, the computing device 700 includes: a bus 702, a processor 704, a memory 706, and a communication interface 708. The processor 704, the memory 706, and the communication interface 708 communicate through the bus 702. The computing device 700 can be a server or a terminal device. It should be understood that the embodiment of the present application does not limit the number of processors and memories in the computing device 700.
[0149] The bus 702 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 The bus 704 is represented by only one line, but does not mean that there is only one bus or one type of bus. The bus 704 may include a path for transmitting information between various components of the computing device 700 (eg, the memory 706, the processor 704, and the communication interface 708).
[0150] The processor 704 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0151] The memory 706 may include a volatile memory, such as a random access memory (RAM). The processor 704 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0152] The memory 706 stores executable program codes, and the processor 704 executes the executable program codes to respectively implement the aforementioned Figure 2 The functions of the first device or the second device in the embodiment are implemented to realize all or part of the steps of the method in the above embodiment. That is, the memory 706 stores instructions for executing all or part of the steps in the method in the above embodiment.
[0153] Alternatively, the memory 706 stores executable codes, and the processor 704 executes the executable codes to respectively implement the aforementioned Figure 2 The memory 706 can be used to implement the functions of the first device or the second device in the embodiment, thereby implementing all or part of the steps in the method of the above embodiment. That is, the memory 706 stores instructions for executing all or part of the steps in the method of the above embodiment.
[0154] The communication interface 708 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 700 and other devices or communication networks.
[0155] Based on the method in the above embodiment, the embodiment of the present application provides another computing device. The computing device includes: a memory and a processor; the memory and the processor are coupled; wherein the memory is used to store program instructions; and the processor is used to execute the program instructions to execute the method in the above embodiment.
[0156] Based on the method in the above embodiment, an embodiment of the present application provides a simulated Ping delay simulation system, characterized in that the system includes a first device and a second device; the first device and the second device are communicatively connected; wherein the first device is any of the above computing devices.
[0157] The method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, CD-ROMs, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC.
[0158] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.
[0159] It should be understood that the various numerical numbers involved in the embodiments of the present application are only used for the convenience of description and are not used to limit the scope of the embodiments of the present application.
Claims
1. A Ping delay simulation method, characterized in that: Applied to a first device, the operating system kernel of the first device adopts a non-preemptive scheduling mechanism, and the method includes: In response to receiving a plurality of TCP messages from a second device, calling an interrupt processing kernel thread of a target processor to process network message tasks corresponding to the plurality of TCP messages; the target processor is a processor for processing Ping request messages from the second device; Adding a first task corresponding to a preset program to a ready task queue of the target processor; In response to receiving a first Ping request message, a first network message processing task corresponding to the first Ping request message is added after the first task in the ready task queue; wherein, the first Ping request message is not the first Ping request message sent by the first device; and the Ping delay of the first Ping request message is determined based on the execution time of the preset program.
2. The method according to claim 1, characterized in that: Prior to responding to receiving the plurality of TCP messages from the second device, the method further comprises: When the Ping request message is received for the first time, a target processor is determined.
3. The method according to claim 2, characterized in that When the Ping request message is received for the first time, determining the target processor includes: Determine a first corresponding parameter based on the IP address of the first device, the IP address of the second device, and the Ping request message: A target processor is determined based on the first corresponding parameter.
4. The method according to claim 3, characterized in that The method further comprises: The corresponding relationship between the target processor and the Ping request message is determined based on the identification number of the target processor and the first corresponding parameter.
5. The method according to claim 4, characterized in that After adding the first network message processing task corresponding to the first Ping request message to the first task in the ready task queue, the method further includes: Based on the correspondence between the target processor and the Ping request message, the target processor is called to execute the first network message processing task corresponding to the first Ping request message.
6. The method according to any one of claims 1 to 5, characterized in that: Before adding the first task corresponding to the preset program to the ready task queue of the target processor, the method further includes: In response to a user query instruction, the target processor is determined based on a kernel tracing mechanism.
7. The method according to any one of claims 1 to 6, characterized in that: The step of adding the first task corresponding to the preset program to the ready task queue of the target processor includes: In response to a user instruction, binding the preset program to the target processor and creating a first task corresponding to the preset program; The first task is added to the ready task queue of the target processor.
8. The method according to any one of claims 1 to 7, characterized in that: The first task includes executing an infinite loop of a target duration; the target duration is set according to the size of the Ping delay to be simulated.
9. A computing device, characterized in that The computing device comprises: a memory and a processor; the memory and the processor are coupled; wherein, The memory is used to store program instructions; The processor is used to execute the program instructions to perform the method according to any one of claims 1-8.
10. A Ping delay simulation system, characterized in that: The system includes a first device and a second device; The first device and the second device are communicatively connected; wherein the first device is the computing device as claimed in claim 9.
Citation Information
Patent Citations
Power business edge computing task allocation method and device
CN110570075A
Network simulation system and network test method
CN111092648A