Network card function switch state adjustment method, device, electronic device and readable medium

By adjusting the peak number of packets that the network card can receive according to the network connection speed, and dynamically adjusting the switching status of the network card's packet reception function and interrupt function, the CPU performance degradation and stability threat caused by network storms are solved, and the CPU resources are realized Rational use and stability guarantee.

CN115604044BActive Publication Date: 2025-02-18INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211214593.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-30
Publication Date
2025-02-18
Estimated Expiration
2042-09-30

AI Technical Summary

Technical Problem

In the network, when there is a problem with the network topology design or connection, or when the nodes in the network form a loop, it is easy to cause a network storm, resulting in a surge in CPU usage, performance degradation, and even downtime, seriously threatening CPU stability.

Method used

By determining the network connection speed, the peak number of packets that the network card can receive is determined based on the network connection speed, and the switching status of the network card receiving packet function and/or the network card interrupt function is adjusted according to the number and number of packets received by the network card.

Benefits of technology

Dynamically adjust the switching status of network card receiving packet function and interrupt function, control the number of broadcast packets and multicast packets received and the number of interrupt reports, avoid excessive use of CPU resources, enable the CPU to handle normal services, and ensure the working efficiency and stability of the CPU. sex.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115604044B_ABST
    Figure CN115604044B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a method, device, electronic device and readable medium for adjusting the switch state of a network card function. The method includes: by determining the network connection speed and the number of data packets received by the network card, the peak number of data packets that the network card can receive can be determined according to the network connection speed, and the switch state of the network card receiving data packet function and / or the network card interruption function can be further adjusted according to the number of data packets received by the network card and the peak number. The peak number of data packets that the network card can receive is dynamically adjusted according to the network status, and then the number of data packets received by the network card and the peak number are used to dynamically adjust the switch state of the network card receiving data packet function and the network card interruption function, so as to control the reception amount of broadcast packets and multicast packets and the number of interruption reports, avoid excessive occupation of CPU resources, enable the CPU to process normal business, and ensure CPU work efficiency and stability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network communication technology, and in particular to a method for adjusting a network card function switch state, a device for adjusting a network card function switch state, an electronic device, and a computer-readable medium. Background Art

[0002] An existing network has many devices. Once there is a problem with the design or connection of the network topology, or a loop is formed in a node in a broadcast domain in the network, it is easy to form a network storm. The entire network traffic is occupied by multicast packets and broadcast packets, and other forwarding services cannot be carried out. Under normal circumstances, the hosts in the network need to respond to all multicast packets and broadcast packets. The influx of a large number of multicast packets and broadcast packets will cause the network card to report a large number of interrupts to the CPU. The CPU has to suspend the current task and call the network interrupt service program to respond to the interrupt. At the same time, the CPU constantly processes the protocol stack, causing the CPU occupancy rate to soar, and the superposition of interrupts will cause performance degradation or even downtime, which seriously threatens the stability of the CPU. Summary of the invention

[0003] In view of the above problems, embodiments of the present invention are proposed to provide a method for adjusting the state of a network card function switch, a device for adjusting the state of a network card function switch, an electronic device and a computer-readable medium that overcome the above problems or at least partially solve the above problems.

[0004] The embodiment of the present invention discloses a method for adjusting the state of a network card function switch, which is applied to a central processing unit and includes:

[0005] Determine the network connection speed;

[0006] Determining the peak value of the number of data packets that can be received by the network card according to the network connection speed; the data packets include multicast packets and / or broadcast packets;

[0007] Determine the number of packets received by the network card;

[0008] According to the number of data packets received by the network card and the peak value of the number, the switch state of the network card data packet receiving function and / or the network card interruption function is adjusted.

[0009] Optionally, the method further comprises:

[0010] According to a preset first corresponding relationship and the number of data packets received by the network card, the shutdown time of the network card data packet receiving function and / or the network card interruption function is determined; wherein the first corresponding relationship is the correspondence between the number of data packets received by the network card and the shutdown time of the network card data packet receiving function and / or the network card interruption function.

[0011] Optionally, the step of adjusting the switch state of the network card data packet receiving function and / or the network card interruption function according to the number of data packets received by the network card and the peak value of the number includes:

[0012] Determine whether the number of data packets received by the network card is greater than the peak number;

[0013] If the number of data packets received by the network card is greater than the peak number, shutting down the network card's data packet receiving function and / or the network card's interrupt function;

[0014] If the number of data packets received by the network card is less than or equal to the peak number, a function of receiving data packets and / or a function of interrupting the network card is enabled.

[0015] Optionally, if the number of data packets received by the network card is greater than the peak number, the step of disabling the network card data packet receiving function and / or the network card interruption function includes:

[0016] If the number of data packets received by the network card is greater than the peak number, and the number of data packets received by the network card is greater than the number of data packets received by the network card last time, adjusting the shutdown time of the network card data packet receiving function and / or the network card interruption function to be greater than the shutdown time of the network card data packet receiving function and / or the network card interruption function last time;

[0017] If the number of data packets received by the network card is greater than the peak number, and the number of data packets received by the network card is less than or equal to the number of data packets received by the network card last time, then the shutdown time of the network card data packet receiving function and / or the network card interruption function is adjusted to be less than or equal to the shutdown time of the network card data packet receiving function and / or the network card interruption function last time.

[0018] Optionally, the method further comprises:

[0019] If the number of data packets received by the network card is greater than the peak number, and the number of data packets received by the network card is less than or equal to the number of data packets received by the network card last time, the network card data packet receiving function is turned off, and the network card interrupt function is turned on.

[0020] Optionally, the method further comprises:

[0021] The peak value of the number of data packets that can be received by the network card is determined according to the processing capability of the central processor for interrupts and / or the processing capability of the protocol stack.

[0022] Optionally, the method further comprises:

[0023] According to a preset period, the number of data packets received by the network card is determined.

[0024] The embodiment of the present invention further discloses a network card function switch state adjustment device, which is applied to a central processing unit and includes:

[0025] A network connection speed determination module, used to determine the network connection speed;

[0026] A first peak quantity determination module, used to determine the peak quantity of data packets that can be received by the network card according to the network connection speed;

[0027] A first data packet quantity determination module, used to determine the quantity of data packets received by the network card;

[0028] The adjustment module is used to adjust the switch state of the network card receiving data packet function and / or the network card interruption function according to the number of data packets received by the network card and the peak value of the number.

[0029] Optionally, the device further comprises:

[0030] A shutdown time determination module is used to determine the shutdown time of the network card's data packet receiving function and / or the network card's interruption function based on a preset first corresponding relationship and the number of data packets received by the network card; wherein the first corresponding relationship is the correspondence between the number of data packets received by the network card and the shutdown time of the network card's data packet receiving function and / or the network card's interruption function.

[0031] Optionally, the adjustment module includes:

[0032] A judging submodule, used for judging whether the number of data packets received by the network card is greater than the peak number;

[0033] A closing submodule, used for closing a data packet receiving function and / or a network card interruption function of the network card if the number of data packets received by the network card is greater than the peak number;

[0034] The enabling submodule is used to enable the network card data packet receiving function and / or the network card interruption function if the number of data packets received by the network card is less than or equal to the peak number.

[0035] Optionally, the closing submodule includes:

[0036] A first adjustment unit is used to adjust the shutdown time of the network card receiving data packet function and / or the network card interruption function to be greater than the shutdown time of the network card receiving data packet function and / or the network card interruption function last time if the number of data packets received by the network card is greater than the peak number and the number of data packets received by the network card is greater than the number of data packets received by the network card last time;

[0037] The second adjustment unit is used to adjust the shutdown time of the network card's data packet receiving function and / or the network card's interruption function to be less than or equal to the shutdown time of the network card's data packet receiving function and / or the network card's interruption function last time if the number of data packets received by the network card is greater than the peak number and the number of data packets received by the network card is less than or equal to the number of data packets received by the network card last time.

[0038] Optionally, the device further comprises:

[0039] The switch module is used to turn off the network card's data packet receiving function and turn on the network card's interrupt function if the number of data packets received by the network card is greater than the peak number and the number of data packets received by the network card is less than or equal to the number of data packets received by the network card last time.

[0040] Optionally, the device further comprises:

[0041] The second peak quantity determination module is used to determine the peak quantity of data packets that can be received by the network card according to the processing capability of the central processor for interrupts and / or the processing capability of the protocol stack.

[0042] Optionally, the device further comprises:

[0043] The second data packet quantity determination module is used to determine the quantity of data packets received by the network card according to a preset period.

[0044] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0045] The memory is used to store computer programs;

[0046] The processor is used to implement the network card function switch state adjustment method as described in the embodiment of the present invention when executing the program stored in the memory.

[0047] The embodiment of the present invention further discloses one or more computer-readable media on which instructions are stored, and when executed by one or more processors, the processors execute the network card function switch state adjustment method as described in the embodiment of the present invention.

[0048] The embodiments of the present invention include the following advantages:

[0049] In the embodiment of the present invention, by determining the network connection speed and the number of data packets received by the network card, the peak number of data packets that the network card can receive can be determined according to the network connection speed, and the switch state of the network card receiving data packet function and / or the network card interruption function can be adjusted according to the number of data packets received by the network card and the peak number. The peak number of data packets that the network card can receive is dynamically adjusted according to the network status, and then the number of data packets received by the network card and the peak number are used to dynamically adjust the switch state of the network card receiving data packet function and the network card interruption function, thereby controlling the reception amount of broadcast packets and multicast packets and the number of interruption reports, avoiding excessive occupation of CPU resources, allowing the CPU to process normal business, and ensuring CPU work efficiency and stability. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 It is a flowchart of the steps of a method for adjusting the function switch state of a network card provided in an embodiment of the present invention;

[0051] Figure 2 is a flowchart of another method for adjusting the state of a network card function switch provided in an embodiment of the present invention;

[0052] Figure 3 It is a schematic diagram of a flow chart of adjusting the switch state of a network card function provided in an embodiment of the present invention;

[0053] Figure 4 It is a structural block diagram of a network card function switch state adjustment device provided in an embodiment of the present invention;

[0054] Figure 5 is a block diagram of an electronic device provided in an embodiment of the present invention;

[0055] Figure 6 is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0056] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0057] After the computer system is deployed into the network, when a large number of broadcast or multicast data packets are received, the network card will receive a large number of data packets, which will cause the network card to report a large number of interrupts to the CPU, forcing the CPU to stop the current processing task and call the network interrupt service program to respond to the interrupt. At the same time, the protocol stack's processing of a large number of data packets will consume a large amount of CPU resources, causing the CPU usage rate to soar. Responding to a large number of interrupts takes up a lot of resources, and the protocol stack consumes a lot of resources to process data packets, which will cause the CPU performance to decline or even crash, seriously threatening the CPU stability.

[0058] The present invention proposes a method for adjusting the state of a network card function switch, which is applied to a central processing unit. By sinking the processing of broadcast and multicast packets to the network card, the number of data packets processed by the CPU and the number of interruptions during a network storm are reduced, thereby reducing the workload of the CPU and ensuring the efficiency and stability of the CPU in processing normal business.

[0059] Reference Figure 1 , shows a flowchart of a method for adjusting the state of a network card function switch provided in an embodiment of the present invention, which may specifically include the following steps:

[0060] Step 101, determining the network connection speed;

[0061] Computers deployed in the network will generate data packets according to user needs. Data packets may include multicast packets and broadcast packets. When a large number of broadcast or multicast data packets are received, the network card will receive a large number of data packets, which will cause the network card to report a large number of interrupts to the CPU, forcing the CPU to stop the current processing tasks and call the network interrupt service program to respond to the interrupt. At the same time, the protocol stack's processing of a large number of data packets will consume a large amount of CPU resources, causing the CPU occupancy rate to soar. Therefore, it is necessary to control the amount of data packets received by the network card and the number of interrupt reports, that is, to control the opening and closing of the network card's data packet receiving function and interrupt function.

[0062] Based on this, the CPU can set a peak value for the number of packets that can be received by the network card. However, if a low upper limit is set on a high-speed network, this upper limit will be easily reached, and the multicast and broadcast packet receiving functions will be frequently closed, affecting normal multicast and broadcast. On the contrary, if a high upper limit is set on a low-speed network, this upper limit may never be reached, and the multicast and broadcast packet receiving functions will always be turned on. In this way, the influx of massive multicast and broadcast packets will occupy the resources of the network card and CPU, making the network card unable to send and receive other normal data packets, and thus making other services unable to be processed in time. Therefore, the CPU can set the peak value of the number of packets that the network card can receive according to the network connection speed.

[0063] In the embodiment of the present invention, in order to determine the peak value of the number of data packets that the network card can receive, the CPU can first determine the current network connection speed. Specifically, the CPU can set a monitoring tool to monitor the network connection speed in real time.

[0064] Step 102, determining the peak value of the number of data packets that can be received by the network card according to the network connection speed;

[0065] After the network connection speed is determined, the peak value of the number of data packets that the network card can receive can be determined according to the network connection speed. Specifically, the correspondence between the network connection speed and the peak value of the number of data packets that the network card can receive can be preset, so that after the network connection speed is determined, the peak value of the number of data packets that the network card can receive can be searched in the correspondence table between the two, thereby achieving the determination of the peak value of the number of data packets that the network card can receive.

[0066] In actual applications, the network connection speed per unit time can be monitored, and the peak value of the number of data packets that the network card can receive per unit time can be determined based on the network connection speed per unit time. The unit time can be set according to actual conditions, such as per millisecond or per second.

[0067] As an example, when the network connection speed is 10M / second, the peak value of the number of data packets that the network card can receive can be set to K; when the network connection speed is 100M / second, the peak value of the number of data packets that the network card can receive can be set to 10K; when the network connection speed is 1000M / second, the peak value of the number of data packets that the network card can receive can be set to 100K. Therefore, when the network connection speed is determined to be 10M / second, K can be used as the peak value of the number of data packets that the network card can receive; when the network connection speed is determined to be 100M / second, 10K can be used as the peak value of the number of data packets that the network card can receive; when the network connection speed is determined to be 1000M / second, 100K can be used as the peak value of the number of data packets that the network card can receive.

[0068] Step 103, determining the number of data packets received by the network card;

[0069] After determining the peak number of data packets that the network card can receive, in order to determine whether it is necessary to adjust the switch status of the network card's packet receiving function and interrupt function, the CPU can compare the peak number of data packets that the network card can receive with the number of data packets received by the network card, and adjust the switch status of the network card's packet receiving function and interrupt function according to the comparison result.

[0070] In the embodiment of the present invention, in order to compare the sizes of the two, the CPU can first determine the number of data packets received by the network card per unit time. Specifically, the CPU can set a monitoring tool to monitor and calculate the number of data packets received by the network card in real time.

[0071] Step 104: adjusting the switch state of the network card's data packet receiving function and / or the network card's interruption function according to the number of data packets received by the network card and the peak value of the number.

[0072] After determining the peak value of the number of data packets that the network card can receive and the number of data packets received by the network card, the peak value of the number of data packets that the network card can receive and the number of data packets received by the network card can be compared to obtain a comparison result, i.e., the number of data packets received by the network card is greater than the peak value of the number of data packets that the network card can receive, or the number of data packets received by the network card is less than or equal to the peak value of the number of data packets that the network card can receive. Then, according to the two comparison results, the network card data packet receiving function and / or the network card interruption function can be adjusted to on or off, thereby dynamically adjusting the switch state of the network card data packet receiving function and / or the network card interruption function according to the network status and the number of data packets received by the network card, reducing the number of data packets and the number of interruptions processed by the CPU during a network storm, thereby reducing the workload of the CPU and ensuring the efficiency and stability of the CPU in processing normal business.

[0073] Through the network card function switch state adjustment method of the embodiment of the present invention, the CPU can determine the peak value of the number of data packets that the network card can receive according to the network connection speed by determining the network connection speed and the number of data packets received by the network card, and can further adjust the switch state of the network card receiving data packet function and / or the network card interruption function according to the number of data packets received by the network card and the peak value of the number. The peak value of the number of data packets that the network card can receive is dynamically adjusted according to the network status, and then the number of data packets received by the network card and the peak value of the number are used to dynamically adjust the switch state of the network card receiving data packet function and the network card interruption function, thereby controlling the reception amount of broadcast packets and multicast packets and the number of interrupt reports, avoiding excessive occupation of CPU resources, allowing the CPU to process normal business, and ensuring CPU work efficiency and stability.

[0074] Reference Figure 2 , shows a flowchart of another method for adjusting the state of a network card function switch provided in an embodiment of the present invention, which may specifically include the following steps:

[0075] Step 201, determining the network connection speed;

[0076] In the embodiment of the present invention, in order to determine the peak value of the number of data packets that the network card can receive, the CPU can first determine the current network connection speed. Specifically, the CPU can set a monitoring tool to monitor the network connection speed in real time.

[0077] Step 202, determining the peak value of the number of data packets that can be received by the network card according to the network connection speed;

[0078] After the network connection speed is determined, the peak value of the number of data packets that the network card can receive can be determined according to the network connection speed. Specifically, the correspondence between the network connection speed and the peak value of the number of data packets that the network card can receive can be preset, so that after the network connection speed is determined, the peak value of the number of data packets that the network card can receive can be searched in the correspondence table between the two, thereby achieving the determination of the peak value of the number of data packets that the network card can receive.

[0079] In actual applications, the network connection speed per unit time can be monitored, and the peak value of the number of data packets that the network card can receive per unit time can be determined based on the network connection speed per unit time. The unit time can be set according to actual conditions, such as per millisecond or per second.

[0080] In one embodiment of the present invention, the method further comprises:

[0081] S11, determining a peak value of the number of data packets that can be received by the network card according to the processing capability of the central processor for interrupts and / or the processing capability of the protocol stack.

[0082] Different CPUs have different performances, so different CPUs have different capabilities for processing interrupts and / or processing protocol stacks. That is, even at the same network connection speed, different CPUs have different efficiencies for processing interrupts and data packets.

[0083] Therefore, in order to ensure the working efficiency and stability of the CPU, in addition to adjusting the peak number of data packets that the network card can receive according to the network connection speed, the peak number of data packets that the network card can receive can also be determined according to the central processor's processing capability for interrupts and / or the processing capability for the protocol stack, so as not to overestimate or underestimate the CPU's processing capability, and receive too many or too few broadcast packets and multicast packets, resulting in inappropriate use of CPU resources. Among them, the CPU's processing capability for interrupts can be the number of interrupts that the CPU can process per unit time; the CPU's processing capability for the protocol stack can be the number of data packets that the protocol stack can process by calling the CPU resources per unit time.

[0084] Specifically, the CPU model can be determined first, and the CPU's interrupt processing capability and / or protocol stack processing capability can be determined based on the CPU model. Then, the preset CPU interrupt processing capability and / or protocol stack processing capability can be compared with the peak value of the number of data packets that can be received by the network card. Therefore, after determining the CPU's interrupt processing capability and / or protocol stack processing capability, the peak value of the number of data packets that can be received by the network card can be determined based on the correspondence between the two.

[0085] In specific applications, the peak number of data packets that the network card can receive can be determined first according to the network connection speed, and then the peak number of data packets that the network card can receive can be determined according to the central processing unit's interrupt processing capability and / or the protocol stack processing capability. Finally, the average of these two respectively determined peak numbers is taken as the final peak number of data packets that the network card can receive. The peak number of data packets that the network card can receive is determined by taking into account both the network connection speed and the CPU performance, so that the determined peak number fits the actual situation and is more real and reliable, thereby ensuring the CPU's working efficiency and stability.

[0086] Optionally, two number peak values ​​N can be set according to the processing capability of the central processor for interrupts and the processing capability for the protocol stack. i and N g , where N i Greater than N g , when the number of packets received by the network card is less than N g When the number of packets received by the network card is greater than the peak value N, the network card packet receiving function and the network card interrupt function are turned on; when the number of packets received by the network card is greater than the peak value N g But less than the peak value N i When the number of packets received by the network card is greater than the peak value N, you can only turn off the network card's function of receiving packets; when the number of packets received by the network card is greater than the peak value N i You need to turn off the network card interrupt function.

[0087] Step 203, determining the number of data packets received by the network card according to a preset period;

[0088] After determining the peak number of data packets that the network card can receive, in order to determine whether it is necessary to adjust the switch status of the network card's packet receiving function and interrupt function, the CPU can compare the peak number of data packets that the network card can receive with the number of data packets received by the network card, and adjust the switch status of the network card's packet receiving function and interrupt function according to the comparison result.

[0089] In the embodiment of the present invention, in order to compare the sizes of the two, the CPU can first determine the number of data packets received by the network card per unit time. Specifically, the CPU can preset a period and access the network card according to the preset period to determine the number of multicast packets and / or broadcast packets received by the network card, so that the CPU does not need to frequently access the network card, thereby avoiding unnecessary consumption of resources.

[0090] In a specific application, the CPU may set a timer, and the timer is used to calculate time. When the calculated time reaches a preset period, the timer may remind the CPU to access the network card to obtain the number of data packets received by the network card within the period.

[0091] Step 204, determining whether the number of data packets received by the network card is greater than the peak number;

[0092] After determining the peak number of data packets that the network card can receive and the number of data packets received by the network card, it can be determined whether the number of data packets received by the network card is greater than the peak number. After comparison, a comparison result is obtained, that is, the number of data packets received by the network card is greater than the peak number of data packets that the network card can receive, or the number of data packets received by the network card is less than or equal to the peak number of data packets that the network card can receive. Then, according to the two comparison results, the network card data packet receiving function and / or the network card interruption function can be adjusted to be turned on or off, thereby dynamically adjusting the switch state of the network card data packet receiving function and / or the network card interruption function according to the network status and the number of data packets received by the network card, reducing the number of data packets and the number of interruptions processed by the CPU during a network storm, thereby reducing the workload of the CPU and ensuring the efficiency and stability of the CPU in processing normal business.

[0093] Step 205, if the number of data packets received by the network card is greater than the peak number, then turning off the network card data packet receiving function and / or the network card interruption function;

[0094] After comparison, if it is determined that the number of data packets received by the network card is greater than the peak number of data packets that the network card can receive, it can be explained that continuing to receive multicast packets and broadcast packets may reduce the CPU's working efficiency and affect the CPU's stability, and may even cause the CPU to crash. At this time, the network card's data packet receiving function and / or the network card's interrupt function can be turned off to ensure that the CPU can work normally.

[0095] Step 206: If the number of data packets received by the network card is less than or equal to the peak number, the network card data packet receiving function and / or the network card interruption function are enabled.

[0096] After comparison, if it is determined that the number of data packets received by the network card is less than or equal to the peak number of data packets that the network card can receive, it can be explained that the number of multicast packets and broadcast packets received within the period is relatively small, which will not reduce the CPU's work efficiency and affect the CPU's stability. At this time, the network card data packet receiving function and / or the network card interrupt function can be enabled to avoid missing normal multicast packets / broadcast packets.

[0097] In one embodiment of the present invention, the method further comprises:

[0098] S21, determining a shutdown time of a data packet receiving function and / or a network card interruption function of the network card according to a preset first corresponding relationship and the number of data packets received by the network card;

[0099] In order to avoid reducing the CPU's working efficiency and affecting the CPU's stability, when the number of packets received by the network card is greater than the peak number, the network card's packet receiving function and / or the network card's interrupt function can be turned off. However, if the turn-off time is too short, the packets and interrupts cannot be effectively shielded. If the turn-off time is too long, normal multicast packets and / or broadcast packets may be missed, resulting in the user's normal business not being processed in time. Therefore, the turn-off time of the network card's packet receiving function and / or the network card's interrupt function can be dynamically adjusted according to the number of packets actually received by the network card within a preset period.

[0100] Specifically, a first corresponding relationship may be preset, and the first corresponding relationship may be a corresponding relationship between the number of data packets received by the network card and the shutdown time of the network card data packet receiving function and / or the network card interruption function. Thus, after determining the number of data packets received by the network card, the shutdown time of the network card data packet receiving function and / or the network card interruption function may be searched according to the preset first corresponding relationship.

[0101] In one embodiment of the present invention, if the number of data packets received by the network card is greater than the peak number, the step of shutting down the network card data packet receiving function and / or the network card interruption function comprises:

[0102] S31, if the number of data packets received by the network card is greater than the peak number, and the number of data packets received by the network card is greater than the number of data packets received by the network card last time, adjusting the shutdown time of the network card data packet receiving function and / or the network card interruption function to be greater than the shutdown time of the network card data packet receiving function and / or the network card interruption function last time;

[0103] In the case that the number of data packets received by the network card in this cycle is greater than the peak number of data packets that the network card can receive, compared with the previous cycle, the number of data packets received by the network card in this cycle may be greater than the number of data packets received by the network card in the previous cycle, or may be less than or equal to the number of data packets received by the network card. Therefore, in the case that the number of data packets received by the network card in this cycle is greater than the peak number of data packets that the network card can receive, the number of data packets received by the network card in this cycle can be compared with the number of data packets received by the network card in the previous cycle. According to the comparison result, the shutdown time of the network card data packet receiving function and / or the network card interruption function can be controlled to adjust the shutdown time according to the actual situation to ensure the CPU working efficiency.

[0104] Specifically, when the number of data packets received by the network card in this cycle is greater than the peak number of data packets that the network card can receive, and the number of data packets received in this cycle increases compared to the number of data packets received in the previous cycle, the shutdown time of the network card receiving function and the interrupt reporting function can be extended to avoid continuing to receive multicast packets and / or broadcast packets due to the shutdown time being too short, thereby reducing the occupancy of CPU resources and ensuring the normal working efficiency and stability of the CPU.

[0105] As an example, when the peak number of data packets that the network card can receive is K, if the number of data packets received by the network card in this cycle is 100K, the number of data packets received by the network card in the previous cycle is 10K, and the shutdown time set in the previous cycle is T, since 100K>10K>K, it can be explained that the number of data packets received by the network card in this cycle is greater than the peak number of data packets that the network card can receive, and the number of data packets received in this cycle increases compared with the number of data packets received in the previous cycle, then the shutdown time can be set to be greater than T in this cycle. Specifically, the shutdown time can be set to 2T, 4T, 5T, 10T, and so on in this cycle.

[0106] S32, if the number of data packets received by the network card is greater than the peak number, and the number of data packets received by the network card is less than or equal to the number of data packets received by the network card last time, then the shutdown time of the network card data packet receiving function and / or the network card interruption function is adjusted to be less than or equal to the shutdown time of the network card data packet receiving function and / or the network card interruption function last time.

[0107] When the number of data packets received by the network card in this cycle is greater than the peak number of data packets that the network card can receive, and the number of received packets is reduced or unchanged compared with the previous cycle, the shutdown time of the network card receiving function and the interrupt reporting function can be shortened or not changed, thereby avoiding wasting CPU resources due to too long shutdown time, and avoiding missing normal multicast packets and / or broadcast packets.

[0108] As an example, when the peak number of data packets that the network card can receive is K, if the number of data packets received by the network card in this cycle is 10K, the number of data packets received by the network card in the previous cycle is 100K, and the shutdown time set in the previous cycle is T, since 100K>10K>K, it can be explained that the number of data packets received by the network card in this cycle is greater than the peak number of data packets that the network card can receive, and the received number is reduced compared with the previous cycle, then the shutdown time can be set to less than T in this cycle. Specifically, the shutdown time can be set to 1 / 2T, 1 / 4T, 1 / 5T, 1 / 10T, and so on in this cycle.

[0109] As an example, when the peak number of data packets that the network card can receive is K, if the number of data packets received by the network card in this cycle is 10K, the number of data packets received by the network card in the previous cycle is 10K, and the shutdown time set in the previous cycle is T, since 10K=10K>K, it can be explained that the number of data packets received by the network card in this cycle is greater than the peak number of data packets that the network card can receive, and the received number is equal to that in the previous cycle, then the shutdown time can be set to be equal to T in this cycle.

[0110] In one embodiment of the present invention, the method further comprises:

[0111] S41, if the number of data packets received by the network card is greater than the peak number, and the number of data packets received by the network card is less than or equal to the number of data packets received by the network card last time, then the network card data packet receiving function is turned off, and the network card interrupt function is turned on.

[0112] Since the peak number of data packets that the network card can receive is determined by the network connection speed and / or the CPU's interrupt processing capability and / or the protocol stack processing capability, when the number of data packets received by the network card is greater than the peak number, but the number of data packets received by the network card in this cycle is less than or equal to the number of data packets received by the network card in the previous cycle, it can be explained that the CPU resources are not excessively occupied and can work normally. At this time, the network card packet receiving function can be turned off and the network card interrupt function can be turned on, so that the CPU can handle the interrupt reported by the network card and further process the data packets, thereby reducing the waste of CPU resources.

[0113] Reference Figure 3 , shows a schematic diagram of a process for adjusting the switch state of a network card function provided in an embodiment of the present invention. The specific process is as follows:

[0114] 1. The CPU determines the peak number of data packets that the network card can receive according to the network connection speed and / or the CPU's processing capability for interrupts and / or the processing capability for the protocol stack;

[0115] 2. The timer calculates the time. When the preset period is reached, the CPU is reminded to access the network card to obtain the number of data packets received by the network card. The CPU accesses the network card to obtain the number of data packets received by the network card within the period.

[0116] 3. The CPU determines whether the number of data packets received by the network card during this period is greater than the peak number of data packets that the network card can receive;

[0117] 4. If the number of data packets received by the network card in this period is less than or equal to the peak number of data packets that the network card can receive, it means that the CPU resources are not excessively occupied and can continue to process data packets and interrupts reported by the network card. At this time, the switch state of the network card receiving data packet function and / or the network card interrupt function does not need to be adjusted. The CPU can wait for the next reminder of the timer to re-obtain the number of data packets received by the network card in the next period;

[0118] 5. If the number of data packets received by the network card in this cycle is greater than the peak number of receivable data packets, it means that the CPU resource usage is high. At this time, it can be further determined whether the number of data packets received by the network card in this cycle is greater than the number of data packets received by the network card in the previous cycle;

[0119] 6. If the number of data packets received by the network card in this cycle is less than or equal to the number of data packets received by the network card in the previous cycle, the data packet receiving function and the interruption function of the network card can be turned off, or only the data packet receiving function of the network card can be turned off and the interruption function of the network card can be turned on, and the shutdown time can be less than or equal to the shutdown time of the previous cycle;

[0120] 7. If the number of data packets received by the network card in this cycle is greater than the number of data packets received by the network card in the previous cycle, the data packet receiving function and interrupt function of the network card can be turned off, and the shutdown time can be greater than the shutdown time of the previous cycle;

[0121] 8. After the shutdown time is over, the network card's packet receiving function and interrupt function can be turned on; and the number of packets received by the network card can continue to be obtained to determine whether the network card's packet receiving function and interrupt function need to be turned on or off.

[0122] Through the network card function switch state adjustment method of the embodiment of the present invention, the CPU can determine the peak value of the number of data packets that the network card can receive according to the network connection speed by determining the network connection speed and the number of data packets received by the network card, and can further adjust the switch state of the network card receiving data packet function and / or the network card interruption function according to the number of data packets received by the network card and the peak value of the number. The peak value of the number of data packets that the network card can receive is dynamically adjusted according to the network status, and then the number of data packets received by the network card and the peak value of the number are used to dynamically adjust the switch state of the network card receiving data packet function and the network card interruption function, thereby controlling the reception amount of broadcast packets and multicast packets and the number of interrupt reports, avoiding excessive occupation of CPU resources, allowing the CPU to process normal business, and ensuring CPU work efficiency and stability.

[0123] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0124] Reference Figure 4 , shows a structural block diagram of a network card function switch state adjustment device provided in an embodiment of the present invention, which may specifically include the following modules:

[0125] The network connection speed determination module 401 is used to determine the network connection speed;

[0126] A first peak value determination module 402, configured to determine a peak value of the number of data packets that can be received by the network card according to the network connection speed;

[0127] A first data packet quantity determination module 403, used to determine the quantity of data packets received by the network card;

[0128] The adjustment module 404 is used to adjust the switch state of the network card data packet receiving function and / or the network card interruption function according to the number of data packets received by the network card and the peak value of the number.

[0129] In one embodiment of the present invention, the device further comprises:

[0130] A shutdown time determination module is used to determine the shutdown time of the network card's data packet receiving function and / or the network card's interruption function based on a preset first corresponding relationship and the number of data packets received by the network card; wherein the first corresponding relationship is the correspondence between the number of data packets received by the network card and the shutdown time of the network card's data packet receiving function and / or the network card's interruption function.

[0131] In one embodiment of the present invention, the adjustment module 404 includes:

[0132] A judging submodule, used for judging whether the number of data packets received by the network card is greater than the peak number;

[0133] A closing submodule, used for closing a data packet receiving function and / or a network card interruption function of the network card if the number of data packets received by the network card is greater than the peak number;

[0134] The enabling submodule is used to enable the network card data packet receiving function and / or the network card interruption function if the number of data packets received by the network card is less than or equal to the peak number.

[0135] In one embodiment of the present invention, the closing submodule includes:

[0136] A first adjustment unit is used to adjust the shutdown time of the network card receiving data packet function and / or the network card interruption function to be greater than the shutdown time of the network card receiving data packet function and / or the network card interruption function last time if the number of data packets received by the network card is greater than the peak number and the number of data packets received by the network card is greater than the number of data packets received by the network card last time;

[0137] The second adjustment unit is used to adjust the shutdown time of the network card's data packet receiving function and / or the network card's interruption function to be less than or equal to the shutdown time of the network card's data packet receiving function and / or the network card's interruption function last time if the number of data packets received by the network card is greater than the peak number and the number of data packets received by the network card is less than or equal to the number of data packets received by the network card last time.

[0138] In one embodiment of the present invention, the device further comprises:

[0139] The switch module is used to turn off the network card's data packet receiving function and turn on the network card's interrupt function if the number of data packets received by the network card is greater than the peak number and the number of data packets received by the network card is less than or equal to the number of data packets received by the network card last time.

[0140] In one embodiment of the present invention, the device further comprises:

[0141] The second peak quantity determination module is used to determine the peak quantity of data packets that can be received by the network card according to the processing capability of the central processor for interrupts and / or the processing capability of the protocol stack.

[0142] In one embodiment of the present invention, the device further comprises:

[0143] The second data packet quantity determination module is used to determine the quantity of data packets received by the network card according to a preset period.

[0144] Through the network card function switch state adjustment device of the embodiment of the present invention, the CPU can determine the peak value of the number of data packets that the network card can receive according to the network connection speed by determining the network connection speed and the number of data packets received by the network card, and can further adjust the switch state of the network card receiving data packet function and / or the network card interruption function according to the number of data packets received by the network card and the peak value of the number. The peak value of the number of data packets that the network card can receive is dynamically adjusted according to the network status, and then the number of data packets received by the network card and the peak value of the number are used to dynamically adjust the switch state of the network card receiving data packet function and the network card interruption function, thereby controlling the reception amount of broadcast packets and multicast packets and the number of interrupt reports, avoiding excessive occupation of CPU resources, allowing the CPU to process normal business, and ensuring CPU work efficiency and stability.

[0145] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0146] In addition, an embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, it includes a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.

[0147] Memory 503, used for storing computer programs;

[0148] The processor 501 is used to execute the program stored in the memory 503, and implements the following steps:

[0149] Determine the network connection speed;

[0150] Determining the peak value of the number of data packets that can be received by the network card according to the network connection speed; the data packets include multicast packets and / or broadcast packets;

[0151] Determine the number of packets received by the network card;

[0152] According to the number of data packets received by the network card and the peak value of the number, the switch state of the network card data packet receiving function and / or the network card interruption function is adjusted.

[0153] Optionally, the method further comprises:

[0154] According to a preset first corresponding relationship and the number of data packets received by the network card, the shutdown time of the network card data packet receiving function and / or the network card interruption function is determined; wherein the first corresponding relationship is the correspondence between the number of data packets received by the network card and the shutdown time of the network card data packet receiving function and / or the network card interruption function.

[0155] Optionally, the step of adjusting the switch state of the network card data packet receiving function and / or the network card interruption function according to the number of data packets received by the network card and the peak value of the number includes:

[0156] Determine whether the number of data packets received by the network card is greater than the peak number;

[0157] If the number of data packets received by the network card is greater than the peak number, shutting down the network card's data packet receiving function and / or the network card's interrupt function;

[0158] If the number of data packets received by the network card is less than or equal to the peak number, a function of receiving data packets and / or a function of interrupting the network card is enabled.

[0159] Optionally, if the number of data packets received by the network card is greater than the peak number, the step of disabling the network card data packet receiving function and / or the network card interruption function includes:

[0160] If the number of data packets received by the network card is greater than the peak number, and the number of data packets received by the network card is greater than the number of data packets received by the network card last time, adjusting the shutdown time of the network card data packet receiving function and / or the network card interruption function to be greater than the shutdown time of the network card data packet receiving function and / or the network card interruption function last time;

[0161] If the number of data packets received by the network card is greater than the peak number, and the number of data packets received by the network card is less than or equal to the number of data packets received by the network card last time, then the shutdown time of the network card data packet receiving function and / or the network card interruption function is adjusted to be less than or equal to the shutdown time of the network card data packet receiving function and / or the network card interruption function last time.

[0162] Optionally, the method further comprises:

[0163] If the number of data packets received by the network card is greater than the peak number, and the number of data packets received by the network card is less than or equal to the number of data packets received by the network card last time, the network card data packet receiving function is turned off, and the network card interrupt function is turned on.

[0164] Optionally, the method further comprises:

[0165] The peak value of the number of data packets that can be received by the network card is determined according to the processing capability of the central processor for interrupts and / or the processing capability of the protocol stack.

[0166] Optionally, the method further comprises:

[0167] According to a preset period, the number of data packets received by the network card is determined.

[0168] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0169] The communication interface is used for communication between the above terminal and other devices.

[0170] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0171] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0172] like Figure 6 As shown, in another embodiment provided by the present invention, a computer-readable storage medium 601 is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the network card function switch state adjustment method described in the above embodiment.

[0173] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the method for adjusting the network card function switch state described in the above embodiment.

[0174] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by 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 invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can 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.). The computer-readable storage medium can 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 can 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 hard disk Solid State Disk (SSD)), etc.

[0175] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0176] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0177] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A method for adjusting the function switch state of a network card, characterized in that: Applied to CPU, including: Determine the network connection speed; Determining the peak value of the number of data packets that can be received by the network card according to the network connection speed; the data packets include multicast packets and / or broadcast packets; Determining the model of the central processing unit, and determining the processing capability of the central processing unit for interrupts and / or the processing capability of the protocol stack according to the model; Determining a second peak number of data packets that can be received by the network card according to the processing capability of the central processor for interrupts and / or the processing capability of the protocol stack; Taking an average of the peak value of the quantity and the second peak value of the quantity to obtain a third peak value of the quantity; Determine the number of packets received by the network card; According to the number of data packets received by the network card and the third number peak value, adjusting the switch state of the network card data packet receiving function and / or the network card interruption function; The step of adjusting the switch state of the network card data packet receiving function and / or the network card interruption function according to the number of data packets received by the network card and the third number peak value includes: Determining whether the number of data packets received by the network card is greater than the third number peak value; If the number of data packets received by the network card is greater than the third number peak, shutting down the network card data packet receiving function and / or the network card interruption function; If the number of data packets received by the network card is less than or equal to the third peak number, a function of receiving data packets and / or a function of interrupting the network card is enabled.

2. The method according to claim 1, characterized in that: The method further comprises: According to a preset first corresponding relationship and the number of data packets received by the network card, the shutdown time of the network card data packet receiving function and / or the network card interruption function is determined; wherein the first corresponding relationship is the correspondence between the number of data packets received by the network card and the shutdown time of the network card data packet receiving function and / or the network card interruption function.

3. The method according to claim 1, characterized in that The step of disabling the network card data packet receiving function and / or the network card interruption function if the number of data packets received by the network card is greater than the third number peak value comprises: If the number of data packets received by the network card is greater than the third number peak value, and the number of data packets received by the network card is greater than the number of data packets received by the network card last time, adjusting the shutdown time of the network card data packet receiving function and / or the network card interruption function to be greater than the shutdown time of the network card data packet receiving function and / or the network card interruption function last time; If the number of data packets received by the network card is greater than the third peak number, and the number of data packets received by the network card is less than or equal to the number of data packets received by the network card last time, then the shutdown time of the network card data packet receiving function and / or the network card interruption function is adjusted to be less than or equal to the shutdown time of the network card data packet receiving function and / or the network card interruption function last time.

4. The method according to claim 1, characterized in that: The method further comprises: According to a preset period, the number of data packets received by the network card is determined.

5. A network card function switch state adjustment device, characterized in that: Applied to CPU, including: A network connection speed determination module, used to determine the network connection speed; A first peak quantity determination module, configured to determine a peak quantity of data packets that can be received by the network card according to the network connection speed; the data packets include multicast packets and / or broadcast packets; The device is also used to determine the model of the central processor, and determine the processing capability of the central processor for interrupts and / or the processing capability of the protocol stack according to the model; determine the second peak number of data packets that can be received by the network card according to the processing capability of the central processor for interrupts and / or the processing capability of the protocol stack; and average the peak number and the second peak number to obtain a third peak number; The device also includes: A first data packet quantity determination module, used to determine the quantity of data packets received by the network card; An adjustment module, used for adjusting a switch state of a network card data packet receiving function and / or a network card interruption function according to the number of data packets received by the network card and the third number peak value; The adjustment module is specifically used to determine whether the number of data packets received by the network card is greater than the third peak number; if the number of data packets received by the network card is greater than the third peak number, turning off the network card data packet receiving function and / or the network card interruption function; if the number of data packets received by the network card is less than or equal to the third peak number, turning on the network card data packet receiving function and / or the network card interruption function.

6. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the network card function switch state adjustment method as described in any one of claims 1-4 when executing the program stored in the memory.

7. One or more computer-readable media having instructions stored thereon, which, when executed by one or more processors, enable the processors to execute the method for adjusting the network card function switch state as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Control method for suppressing network storm and device thereof, storage medium and processor

    CN111464492A