MQTT pressure measurement method, press machine, electronic equipment and storage medium

By registering multiple network cards on the MQTT stress testing press, and determining the number of newly occupied ports based on the number of free ports and weights, the problem of low MQTT stress testing efficiency is solved, a large number of long connections can be quickly established, and the stress testing efficiency is improved.

CN118842736AActive Publication Date: 2024-10-25CHINA UNITED NETWORK COMM GRP CO LTD +2

Patent Information

Application Number
CN202310449818.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-24
Publication Date
2024-10-25
Estimated Expiration
2043-04-24

AI Technical Summary

Technical Problem

MQTT stress testing efficiency is low. When the existing technology establishes a large number of long connections and the number of occupied network card ports is close to saturation, it takes a long time to expand the number of connections by adding new virtual IPs, resulting in low efficiency.

Method used

By registering multiple network cards on the MQTT stress testing press, the number of newly occupied ports in the next collection cycle is determined based on the number and weight of each network card, ensuring that the network card adds a corresponding number of occupied ports within a certain period of time until The preset number of test connections is reached.

Benefits of technology

It effectively saves the time to establish the number of MQTT long connections to reach the preset number of test connections, and improves the efficiency of MQTT stress testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118842736A_ABST
    Figure CN118842736A_ABST
Patent Text Reader

Abstract

The invention provides an MQTT pressure measurement method, a press machine, electronic equipment and a storage medium, and the method comprises the steps: obtaining the number of idle ports of each current network card when a collection cycle arrives; according to the number of idle ports of each network card, determining the number of newly-added occupied ports of each network card in the next acquisition period; wherein the number of newly-added occupied ports of the network card in the next collection period is the product of the proportion of the number of idle ports of the current network card, the weight of the network card and the total amount of target newly-added ports of all network cards in a preset single period; the ratio of the number of the idle ports of the network card is the ratio of the number of the idle ports of the network card to the sum of the number of the idle ports of all the network cards; and sending the number of newly-added occupied ports of the network card in the next acquisition period to each network card, so that the network card adds a corresponding number of occupied ports in the next acquisition period according to the number of newly-added occupied ports until the sum of the number of occupied ports of all network cards reaches a preset test connection number. According to the scheme, the efficiency of MQTT pressure measurement is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to communication technology, and in particular to an MQTT stress testing method, a stress testing machine, an electronic device and a storage medium. Background Art

[0002] At present, the scenarios of Message Queuing Telemetry Transport (MQTT) stress testing are mainly divided into: MQTT long connection stress testing, and throughput stress testing of publishing (Publish) and subscription (Subscribe).

[0003] Among them, MQTT long connection means that after the broker (Broker) and the client (Client) establish a connection, it is maintained for a certain period of time. MQTT long connection stress testing requires the establishment of a large number of long connections between the client and the broker. In actual applications, the broker can be simulated through the MQTT stress testing machine to establish MQTT long connections with multiple clients. Each MQTT long connection established requires the occupation of a port of the network card in the MQTT stress testing machine.

[0004] In the related technology, when the number of long connections established by the MQTT stress testing machine does not meet the preset number of test connections, and the number of port occupancy of the network card in the MQTT stress testing machine is close to saturation, more MQTT long connections are established by adding new virtual IPs. It takes a long time for the number of long connections established by the MQTT stress testing machine to reach the preset number of test connections, and the efficiency of MQTT stress testing is low. Summary of the invention

[0005] The present application provides an MQTT stress testing method, a stress machine, an electronic device and a storage medium, aiming to solve the problem of low efficiency of MQTT stress testing.

[0006] In a first aspect, the present application provides an MQTT stress testing method, which is applied to an MQTT stress testing machine, wherein the MQTT stress testing machine is registered with multiple network cards, and the method comprises: when a collection cycle arrives, obtaining the current number of free ports of each network card; determining the number of newly occupied ports of each network card in the next collection cycle according to the number of free ports of each network card; wherein the number of newly occupied ports of the network card in the next collection cycle is the product of the current proportion of the number of free ports of the network card, the weight of the network card, and the target total number of new ports of all network cards in a preset single cycle; the proportion of the number of free ports of the network card is the ratio of the number of free ports of the network card to the sum of the number of free ports of all network cards; and sending the number of newly occupied ports of the network card in the next collection cycle to each network card, so that the network card adds a corresponding number of occupied ports in the next collection cycle according to the newly occupied port number, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections.

[0007] In a possible implementation, after determining the number of newly occupied ports required for each network card per unit time in the next acquisition cycle based on the number of free ports of each network card, the method further includes: storing the number of newly occupied ports of each network card in the next acquisition cycle in a timing database in chronological order.

[0008] In a possible implementation, when the collection cycle arrives, the current number of free ports of each network card is obtained, including: when the collection cycle arrives, obtaining the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle from the timing database; calculating the sum of the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle to obtain the current number of occupied ports of each network card; calculating the difference between the number of ports of each network card and the current number of occupied ports of each network card to obtain the current number of free ports of each network card.

[0009] In a possible implementation, the multiple network cards include virtual network cards and fixed network cards; before determining the number of newly occupied ports of each network card in the next acquisition cycle according to the number of free ports of each network card, the method further includes: obtaining the index value of each virtual network card under each performance indicator, and normalizing the index value; wherein the performance indicators include latency, packet loss rate, transmission rate and jitter; for each performance indicator, calculating the proportion of the index value corresponding to each virtual network card in the index values ​​corresponding to all virtual network cards; for each performance indicator, calculating the entropy value of the performance indicator based on the proportion of the index value corresponding to each virtual network card in the index values ​​corresponding to all virtual network cards; and calculating the coefficient of variation of the performance indicator based on the entropy value of the performance indicator; wherein the performance indicator The difference coefficient of the target represents the degree of difference in the indicator value corresponding to each virtual network card under the performance indicator. The smaller the difference coefficient of the performance indicator, the greater the difference in the indicator value corresponding to each virtual network card under the performance indicator. Based on the difference coefficient of the performance indicator, the ratio of the difference parameter of the performance indicator to the sum of the difference parameters of all performance indicators is calculated to obtain the weight value of the performance indicator. For each virtual network card, the product result of the weight value of each performance indicator and the proportion of the indicator value of the virtual network card under the performance indicator in the indicator values ​​corresponding to all virtual network cards is calculated. The product results corresponding to all performance indicators are summed to obtain the weight value of the virtual network card. The sum of the largest weight value among the weight values ​​of all virtual network cards and the configuration parameters is used as the weight value of the fixed network card.

[0010] In a possible implementation, the method also includes: installing tunctl in a centos environment configured on the MQTT stress testing machine; determining the total number of network cards required for the test based on the preset number of test connections and the number of long connections that can be established by each network card; subtracting one from the total number of network cards to obtain the number of virtual network cards to be created; based on the tunctl, creating a corresponding number of virtual network cards, configuring IP addresses for the virtual network cards, and adding static routes of the virtual network cards in the routing table to complete the registration of the virtual network cards.

[0011] In a possible implementation, the method further includes: if the number of free ports of each network card is less than a preset threshold, registering a virtual network card for the MQTT stress testing machine.

[0012] In a second aspect, the present application provides an MQTT stress testing machine, which has multiple network cards registered, and the MQTT stress testing machine includes: an acquisition module, which is used to obtain the current number of free ports of each network card when a collection cycle arrives; a management module, which is used to determine the number of newly occupied ports of each network card in the next collection cycle according to the number of free ports of each network card; wherein the number of newly occupied ports of the network card in the next collection cycle is the product of the current proportion of the number of free ports of the network card and the weight of the network card and the target total number of new ports of all network cards in a preset single cycle; the proportion of the number of free ports of the network card is the ratio of the number of free ports of the network card to the sum of the number of free ports of all network cards; an allocation module, which is used to send the number of newly occupied ports of the network card in the next collection cycle to each network card, so that the network card adds a corresponding number of occupied ports in the next collection cycle according to the newly occupied ports, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections.

[0013] In a possible implementation, the MQTT stress testing machine further includes: a storage module, configured to store the number of newly occupied ports of each network card in the next collection cycle in a time series database in chronological order.

[0014] In a possible implementation, the acquisition module includes: a reading unit, which is used to obtain the number of newly occupied ports of each network card in the current acquisition cycle and the historical acquisition cycle from the timing database when the acquisition cycle arrives; a calculation unit, which is used to calculate the sum of the number of newly occupied ports of each network card in the current acquisition cycle and the historical acquisition cycle to obtain the current number of occupied ports of each network card; the calculation unit is also used to calculate the difference between the number of ports of each network card and the current number of occupied ports of each network card to obtain the current number of free ports of each network card.

[0015] In a possible implementation, the multiple network cards include virtual network cards and fixed network cards; the MQTT stress test press also includes: a weight determination module; the weight determination module is used to: obtain the index value of each virtual network card under each performance indicator, and normalize the index value; wherein the performance indicators include latency, packet loss rate, transmission rate and jitter; for each performance indicator, calculate the proportion of the index value corresponding to each virtual network card in the index values ​​corresponding to all virtual network cards; for each performance indicator, based on the proportion of the index value corresponding to each virtual network card in the index values ​​corresponding to all virtual network cards, calculate the entropy value of the performance indicator; and based on the entropy value of the performance indicator, calculate the difference coefficient of the performance indicator; wherein the difference coefficient of the performance indicator The number represents the degree of difference in the index value corresponding to each virtual network card under the performance index. The smaller the difference coefficient of the performance index, the greater the difference in the index value corresponding to each virtual network card under the performance index. Based on the difference coefficient of the performance index, the ratio of the difference parameter of the performance index to the sum of the difference parameters of all performance indicators is calculated to obtain the weight value of the performance index. For each virtual network card, the product result of the weight value of each performance indicator and the proportion of the index value of the virtual network card under the performance indicator in the index values ​​corresponding to all virtual network cards is calculated. The product results corresponding to all performance indicators are summed to obtain the weight value of the virtual network card. The sum of the largest weight value among the weight values ​​of all virtual network cards and the configuration parameters is used as the weight value of the fixed network card.

[0016] In a possible implementation, the MQTT stress testing machine also includes: a first registration module; the first registration module is used to: install tunctl in the centos environment configured on the MQTT stress testing machine; determine the total number of network cards required for the test based on the preset number of test connections and the number of long connections that each network card can establish; subtract one from the total number of network cards to obtain the number of virtual network cards to be created; based on the tunctl, create a corresponding number of virtual network cards, configure IP addresses for the virtual network cards, and add static routes of the virtual network cards in the routing table to complete the registration of the virtual network cards.

[0017] In a possible implementation, the MQTT stress testing machine further includes: a second registration module, configured to register a virtual network card for the MQTT stress testing machine if the number of free ports of each network card is less than a preset threshold.

[0018] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method as described above.

[0019] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to implement the method as described above when executed by a processor.

[0020] In the MQTT stress testing method, stress machine, electronic device and storage medium provided by the present application, when the collection cycle arrives, the number of free ports of each network card is obtained; the number of newly occupied ports of each network card in the next collection cycle is determined based on the number of free ports of each network card, the weight of the network card and the target total number of new ports of all network cards in a preset single cycle; each network card adds a corresponding number of occupied ports in the next collection cycle according to the number of newly occupied ports, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections. In the solution of the present application, the MQTT stress testing press is registered with multiple network cards, and the target total number of new ports for all network cards in a single cycle can be set. The weight of the network card is related to the actual network performance of the network card. The proportion of the number of free ports of the current network card represents the current idleness of the network card relative to other network cards. Therefore, based on the current number of free ports of each network card, the weight of the network card and the preset target total number of new ports for all network cards in a single cycle, the number of newly occupied ports of each network card in the next collection cycle is determined, which can effectively ensure that each network card adds a corresponding number of newly occupied ports in a certain period of time, saving the time for the number of established MQTT long connections to reach the preset number of test connections, thereby improving the efficiency of MQTT stress testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0022] Figure 1 Schematic diagram of the scenario of the MQTT stress testing method provided for this application;

[0023] Figure 2 A flowchart of an MQTT stress testing method provided in Example 1 of the present application;

[0024] Figure 3 A flowchart of an MQTT stress testing method provided in Example 2 of the present application;

[0025] Figure 4 A flowchart of an MQTT stress testing method provided in Example 3 of the present application;

[0026] Figure 5 A schematic diagram of the structure of an MQTT pressure testing press provided in Example 4 of the present application;

[0027] Figure 6This is a schematic diagram of the structure of an electronic device provided in Example 5 of the present application.

[0028] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0029] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0030] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.

[0031] The terms "first", "second", etc. in the specification and claims of this application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise indicated. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, for example, they can be implemented in an order other than those given in the diagrams or descriptions of the embodiments of this application.

[0032] In addition, the terms "including" and "having" and any variations thereof are intended to cover but not exclude inclusion, for example, a product or device comprising a series of components is not necessarily limited to those components explicitly listed, but may include other components not explicitly listed or inherent to these products or devices. The term "module" as used in this application refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic or combination of hardware and / or software code that can perform the functions associated with the element.

[0033] The term "Message Queue Telemetry Transport Protocol (MQTT)" used in each embodiment of the present application is a "lightweight" communication protocol based on the publish and subscribe mode, which is built on the Transmission Control Protocol (TCP) and the Internet Protocol (IP). During the communication process, MQTT includes three identities: publisher, subscriber, and broker. Among them, publishers and subscribers are clients, brokers can be servers, and publishers can also be subscribers. At present, the scenarios of MQTT stress testing are mainly divided into: MQTT long connection stress testing, and throughput stress testing of publishing (Publish) and subscription (Subscribe). Among them, MQTT long connection refers to the connection between the broker and the client, which is maintained for a certain period of time. MQTT long connection stress testing requires the establishment of a large number of long connections between the client and the broker.

[0034] Figure 1 This is a schematic diagram of the scenario of the MQTT stress testing method provided in this application. Figure 1 As shown, the MQTT stress test machine 101 simulates a proxy end and establishes an MQTT long connection with multiple clients in the system under test 100 . Each time an MQTT long connection is established, a port of the network card in the MQTT stress test machine 101 is occupied.

[0035] The MQTT stress test machine 101 can be obtained by installing an MQTT plug-in on a performance testing tool. Exemplarily, the performance testing tool can be jmeter or loadrunner. In actual applications, the MQTT stress test machine 101 simulates the proxy end and establishes MQTT long connections with multiple clients. Each time an MQTT long connection is established, a port of the network card in the MQTT stress test machine needs to be occupied.

[0036] In combination with the actual scenario description, when the number of MQTT long connections established by the MQTT stress test machine 101 does not meet the preset number of test connections, and the number of ports occupied by the network card in the MQTT stress test machine 101 is close to saturation, the number of MQTT long connections that can be established can be expanded by adding a new MQTT stress test machine or setting a virtual IP on the current MQTT stress test machine 101. Since adding a new MQTT stress test machine will increase the stress test cost, the number of long connections that can be established by the MQTT stress test machine 101 can be expanded by setting a virtual IP.

[0037] In actual applications, when the number of port occupancy of the network card in the MQTT stress test machine 101 is close to saturation, a virtual IP is set to establish more MQTT long connections. It takes a long time for the number of long connections established by the MQTT stress test machine to reach the preset number of test connections, and the efficiency of the MQTT stress test is low.

[0038] In an embodiment of the present application, the MQTT stress testing machine is registered with multiple network cards, and the target total number of new ports for all network cards in a single cycle can be set. The weight of the network card is related to the actual network performance of the network card. The proportion of the number of free ports of the current network card represents the current idleness of the network card relative to other network cards. Therefore, based on the current number of free ports of each network card, the weight of the network card and the preset target total number of new ports for all network cards in a single cycle, the number of newly occupied ports of each network card in the next collection cycle is determined, which can effectively ensure that each network card adds a corresponding number of newly occupied ports in a certain period of time, saving the time for the number of established MQTT long connections to reach the preset number of test connections, thereby improving the efficiency of MQTT stress testing.

[0039] The technical solutions of the present application and the technical solutions of the present application are described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. In the description of the present application, unless otherwise clearly specified and limited, each term should be understood in a broad sense in the art. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0040] Embodiment 1

[0041] Figure 2 A flow chart of an MQTT stress test method provided in the first embodiment of the present application is shown. The method of this embodiment is applied to an MQTT stress test machine. The MQTT stress test machine is registered with multiple network cards, such as Figure 2 As shown, the method comprises the following steps:

[0042] S201, when the collection cycle arrives, obtain the number of idle ports of each network card;

[0043] S202, determining the number of newly occupied ports of each network card in the next collection cycle according to the number of free ports of each network card;

[0044] S203. Send the number of newly occupied ports of the network card in the next collection cycle to each network card, so that the network card adds a corresponding number of occupied ports in the next collection cycle according to the number of newly occupied ports, until the sum of the number of occupied ports of all network cards reaches a preset number of test connections.

[0045] The number of free ports of the network card is the number of unoccupied ports of the network card. In practical applications, when the number of newly occupied ports of the network card in the next collection cycle is constant, the larger the number of free ports of the network card, the shorter the time for adding the corresponding number of occupied ports in the next collection cycle, that is, the larger the number of free ports of the network card, the faster the rate of newly occupied ports of the network card.

[0046] In this embodiment, the number of newly occupied ports of the network card in the next collection cycle is the product of the current idle port ratio of the network card, the weight of the network card, and the target total number of newly added ports of all network cards in a preset single cycle. Among them, the idle port ratio of the above network card is the ratio of the idle port number of the network card to the sum of the idle port numbers of all network cards.

[0047] Among them, the idle port ratio of the current network card represents the idleness of the current network card compared with other network cards. The larger the idle port ratio of the current network card, the more idle the current network card is compared with other network cards; the smaller the idle port ratio of the current network card, the smaller the idleness of the current network card is compared with other network cards. In practice, the larger the idle port ratio of the network card, the faster the rate of newly occupied ports of the network card is compared with the rate of other network cards; the smaller the idle port ratio of the network card, the slower the rate of newly occupied ports of the network card is compared with the rate of other network cards. For example, the MQTT stress test machine has registered network cards A, B, and C. When the collection cycle arrives, the number of free ports of the current network card A is 6000, the number of free ports of the current network card B is 5000, and the number of free ports of the current network card C is 8000; the sum of the number of free ports of all network cards is 19000, and the ratio of the number of free ports of each network card to the sum of the number of free ports of all network cards is calculated, and the proportion of free ports of the current network card A is 6 / 19, the proportion of free ports of the current network card B is 5 / 19, and the proportion of free ports of the current network card C is 8 / 19; the current network card C has the largest proportion of free ports, and the current network card C is more idle than network cards A and B.

[0048] Specifically, in S202, the number of newly occupied ports of each network card in the next collection cycle is determined according to the number of free ports of each network card. In one example, for each network card, the ratio of the number of free ports of the network card to the sum of the number of free ports of all network cards is calculated to obtain the proportion of the number of free ports of the network card; the product of the current proportion of the number of free ports of the network card, the weight of the network card, and the total number of target newly added ports of all network cards in a preset single cycle is calculated to obtain the number of newly occupied ports of the network card in the next collection cycle. For example, the target total number of new ports for all network cards in the next cycle is 190, the weight of network card A is 1.5, the weight of network card B is 0.8, and the weight of network card C is 0.75; the current idle port ratio of network card A is 6 / 19, the current idle port ratio of network card B is 5 / 19, and the current idle port ratio of network card C is 8 / 19; calculate the product of the current idle port ratio of network card A (6 / 19), the weight of the network card (1.5), and the target total number of new ports of all network cards in a preset single cycle (190), and get the next acquisition. The number of newly occupied ports of network card A in the collection cycle is 90; the product of the current idle port number ratio of network card B (5 / 19) and the network card weight (0.8) and the target total number of newly added ports (190) of all network cards in a single cycle is calculated, and the number of newly occupied ports of network card A in the next collection cycle is 40; the product of the current idle port number ratio of network card C (8 / 19) and the network card weight (0.75) and the target total number of newly added ports (190) of all network cards in a single cycle is calculated, and the number of newly occupied ports of network card A in the next collection cycle is 60.

[0049] Combined with the above example, the number of newly occupied ports of the network card in the next collection cycle is the product of the current proportion of the number of idle ports of the network card, the weight of the network card, and the total target number of newly added ports of all network cards in a preset single cycle. Among them, the weight of the network card is related to the network performance of the current network card. In a single collection cycle, the weight of the network card is constant; and in a collection cycle, the total target number of newly added ports of all network cards is constant; therefore, the number of newly occupied ports of the network card in the next collection cycle is positively correlated with the proportion of the number of idle ports of the current network card. The larger the proportion of the number of idle ports of the current network card, the larger the number of newly occupied ports of the network card in the next collection cycle.

[0050] It can be understood that when the proportion of the number of idle ports of the current network card is relatively small, the idle degree of the current network card is less than that of other network cards, and the rate of newly occupied ports of the network card is smaller than that of other network cards, that is, the number of newly occupied ports that can be added by the network card in the next collection cycle is smaller; therefore, sending a smaller number of newly occupied ports of the above-mentioned network card in the next collection cycle to the network card can ensure that the network card can efficiently add a corresponding number of newly occupied ports in the next collection cycle; when the proportion of the number of idle ports of the current network card is relatively large, the idle degree of the current network card is relatively large compared with other network cards, and the rate of newly occupied ports of the network card is larger than that of other network cards, that is, the number of newly occupied ports that can be added by the network card in the next collection cycle is larger; therefore, sending a larger number of newly occupied ports of the above-mentioned network card in the next collection cycle to the network card can ensure that the network card can efficiently add a corresponding number of newly occupied ports in the next collection cycle.

[0051] In actual applications, the target total number of new ports for all network cards in a single cycle is certain. When the MQTT stress test machine only registers a single network card, it takes a long time to add the corresponding number of new ports. When the MQTT stress test machine registers multiple network cards, the target total number of new ports for all network cards is allocated to multiple network cards for parallel processing, which can save the time for adding new ports and improve the efficiency of MQTT stress testing.

[0052] In this embodiment, for the network card with a relatively large number of idle ports, the rate of newly occupied ports of the current network card is relatively large relative to the rate of newly occupied ports of other network cards, and a relatively large number of newly occupied ports of the above network card in the next acquisition cycle is sent to the network card, which can also ensure that the establishment of the MQTT long connection is completed within a certain time; for the network card with a relatively small number of idle ports, the rate of newly occupied ports of the current network card is relatively small relative to the rate of newly occupied ports of other network cards, and a relatively small number of newly occupied ports of the above network card in the next acquisition cycle is sent to the network card, which can ensure that the establishment of the MQTT long connection is completed within a certain time. Therefore, this embodiment saves the time for the number of established MQTT long connections to reach the preset number of test connections, and improves the efficiency of MQTT stress testing.

[0053] It should be noted that during the MQTT stress test, the sum of the total number of target new ports for all network cards in all collection cycles is the preset number of test connections. For different collection cycles, the total number of target new ports for all network cards in a single cycle can be the same or different, and is not limited here. For example, for different collection cycles, the total number of target new ports for all network cards in a single cycle is set to be the same. Optionally, considering that the number of remaining ports for network cards is decreasing, the total number of target new ports for all network cards in a single cycle can be set to decrease.

[0054] Optionally, in a single cycle, a target total number of new ports for all network cards per unit time can be set; in one example, when a collection cycle arrives in S201, the number of free ports of each network card is obtained, specifically including: when a collection cycle arrives, the number of new ports per unit time of each network card is obtained, the product of the number of newly occupied ports per unit time of each network card is calculated and the duration of the current collection cycle is calculated to obtain the number of newly occupied ports of each network card in the current collection cycle; for each network card, the sum of the number of newly occupied ports in the current collection cycle and the number of newly occupied ports in the historical collection cycle is calculated to determine the current number of occupied ports of the network card; the difference between the total number of ports of the network card and the current number of occupied ports of the network card is calculated to obtain the current number of free ports of the network card.

[0055] Correspondingly, in S202, the number of newly occupied ports of each network card in the next collection cycle is determined according to the number of free ports of each network card, specifically including: for each network card, calculating the ratio of the number of free ports of the network card to the sum of the number of free ports of all network cards, to obtain the proportion of the number of free ports of the network card; calculating the product of the current proportion of the number of free ports of the network card, the weight of the network card and the preset target total number of new ports of all network cards per unit time, to obtain the number of newly occupied ports of the network card per unit time in the next cycle; it can be understood that the number of newly occupied ports of the network card per unit time in the next cycle can be determined by calculating the product of the number of newly occupied ports of the network card per unit time in the next cycle and the duration of the next collection cycle.

[0056] Correspondingly, in S203, the newly occupied ports of each network card in the next collection cycle are sent to each network card, so that the above-mentioned network card adds a corresponding number of occupied ports in the next collection cycle according to the number of newly occupied ports of each network card in the next collection cycle, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections, specifically including: sending the number of newly occupied ports of the network card per unit time in the next cycle to each network card, so that the network card adds a corresponding number of occupied ports per unit time in the next collection cycle according to the number of newly occupied ports of the network card per unit time in the next cycle, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections.

[0057] In addition, in an example, after the above S202, the method further includes:

[0058] The number of newly occupied ports of each network card in the next collection cycle is stored in the time series database in chronological order.

[0059] Among them, the time series database (TSDB) is a database used to store and process time series data, supporting efficient reading, writing and calculation of time series data. Exemplarily, the time series database can be DolphinDB, TimescaleDB, InfluxDB or TDengine. In practical applications, when each collection cycle arrives, the number of free ports of each network card is obtained, and based on the number of free ports of each network card, the number of newly occupied ports of each network card in the next collection cycle is determined. Therefore, in each collection cycle, the number of newly occupied ports of each network card is a series of data generated over time.

[0060] Exemplarily, the time when the number of newly occupied ports of each network card in the next collection cycle is determined is used as the timestamp of the number of newly occupied ports of each network card in the next collection cycle, and the number of newly occupied ports of each network card in the next collection cycle is stored in the time series database in the order of the timestamps. It can be understood that when the collection cycle arrives, the time series database stores the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle.

[0061] In this example, after determining the number of newly occupied ports of each network card in the next collection cycle, the number of newly occupied ports of each network card in the next collection cycle is stored in a time series database in chronological order. Based on the time series database, it is convenient to obtain the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle.

[0062] Optionally, in an example, the number of newly occupied ports of each network card in the next collection cycle is stored in a cache database in chronological order. For example, the cache database may be a remote dictionary server (Remote Dictionary Server, Redis for short).

[0063] In practical applications, the total number of occupied ports of the current network card can be determined by reading the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle in the time series database. In an example, the above S201 includes:

[0064] When the collection cycle arrives, the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle is obtained from the time series database;

[0065] Calculate the sum of the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle to obtain the current number of occupied ports of each network card;

[0066] The difference between the number of ports of each network card and the number of currently occupied ports of each network card is calculated to obtain the number of currently idle ports of each network card.

[0067] In this example, the current number of occupied ports of each network card is calculated based on the number of newly occupied ports of the network card in the current collection cycle and the historical collection cycle stored in the time series database; further, the number of free ports of each network card is obtained by calculating the difference between the number of ports of each network card and the current number of occupied ports of each network card.

[0068] Optionally, in an example, after S202 above, the method further includes: storing the number of newly occupied ports of each network card in the next acquisition cycle and the current number of occupied ports of each network card in a time series database in chronological order.

[0069] Optionally, in an example, the above S201 includes:

[0070] When the collection cycle arrives, the number of newly occupied ports of each network card in the current collection cycle and the number of occupied ports of each network card in the previous collection cycle are obtained from the time series database;

[0071] Calculate the sum of the number of newly occupied ports of each network card in the current collection cycle and the number of occupied ports of each network card in the previous collection cycle to obtain the current number of occupied ports of each network card;

[0072] The difference between the number of ports of each network card and the number of currently occupied ports of each network card is calculated to obtain the number of currently idle ports of each network card.

[0073] In the MQTT stress testing method provided in this embodiment, when the collection cycle arrives, the number of free ports of each network card is obtained; the number of newly occupied ports of each network card in the next collection cycle is determined according to the number of free ports of each network card, the weight of the network card and the target total number of newly added ports of all network cards in a preset single cycle; each network card adds a corresponding number of occupied ports in the next collection cycle according to the number of newly occupied ports, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections. In the process of MQTT stress testing in the embodiment of the present application, the MQTT stress testing press is registered with multiple network cards, and the target total number of new ports for all network cards in a single cycle can be set. The weight of the network card is related to the actual network performance of the network card. The proportion of the number of idle ports of the current network card represents the current idleness of the network card relative to other network cards. Therefore, based on the current number of idle ports of each network card, the weight of the network card and the preset target total number of new ports for all network cards in a single cycle, the number of newly occupied ports of each network card in the next collection cycle is determined, which can effectively ensure that each network card adds a corresponding number of newly occupied ports in a certain period of time, saves the time for the number of established MQTT long connections to reach the preset number of test connections, and improves the efficiency of MQTT stress testing.

[0074] Embodiment 2

[0075] Figure 3 A flow chart of an MQTT stress testing method provided in Embodiment 2 of the present application, wherein the multiple network cards include virtual network cards and fixed network cards; Figure 3 As shown, based on the above embodiment, before the above S202, the method further includes:

[0076] S301, obtaining the index value of each virtual network card under each performance index, and normalizing the above index values;

[0077] S302. For each performance indicator, calculate the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards;

[0078] S303. For each performance indicator, based on the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards, calculate the entropy value of the performance indicator; and based on the entropy value of the performance indicator, calculate the coefficient of variation of the performance indicator;

[0079] S304, based on the difference coefficient of the above performance indicator, calculate the ratio of the difference parameter of the above performance indicator to the sum of the difference parameters of all performance indicators to obtain the weight value of the above performance indicator;

[0080] S305. For each virtual network card, calculate the product of the weight value of each performance indicator and the proportion of the indicator value of the virtual network card under the above performance indicator in the indicator values ​​corresponding to all virtual network cards; add the above product results corresponding to all performance indicators to obtain the weight value of the virtual network card;

[0081] S306: The sum of the largest weight value among the weight values ​​of all virtual network cards and the configuration parameter is used as the weight value of the fixed network card.

[0082] Among them, the performance indicators include latency, packet loss rate, transmission rate and jitter, and the performance indicators characterize the performance of the network corresponding to the virtual network card. In practical applications, based on the impact of the performance indicators on the network corresponding to the virtual network card, the above performance indicators can be divided into positive performance indicators and negative performance indicators. The larger the indicator value under the positive performance indicator, the better the performance of the network corresponding to the virtual network card. The smaller the indicator value under the negative performance indicator, the better the performance of the network corresponding to the virtual network card. Exemplarily, the transmission rate belongs to the positive performance indicator; latency, packet loss rate and jitter belong to the negative performance indicators. In other examples, more performance indicators can be added or the above performance indicators can be reduced, and this application does not specifically limit the performance indicators.

[0083] Specifically, in S301, the indicator value of each virtual network card under each performance indicator is obtained. For example, the MQTT stress test machine is registered with virtual network card A, virtual network card B, and virtual network card C; performance indicator 1 is latency, performance indicator 2 is packet loss rate, performance indicator 3 is transmission rate, and performance indicator 4 is jitter. i ' j Indicates the index value of virtual network card i under the jth performance index.

[0084] In practical applications, since the performance indicators have different effects on the networks corresponding to the virtual network cards, they can be normalized. Specifically, in S301, the above indicator values ​​are normalized. Exemplarily, the normalization formula of the forward performance indicator can be expressed as:

[0085]

[0086] The normalization formula of negative performance indicators can be expressed as:

[0087]

[0088] Where n is the number of virtual network cards.

[0089] For ease of understanding, the normalized index values ​​of each virtual network card under each performance index are presented in a table. Table 1 shows the normalized index values ​​of each virtual network card under each performance index.ij It represents the normalized value of virtual network card i under the jth performance indicator.

[0090] Table 1

[0091] Virtual Network Card Delay(ms) Packet loss rate (%) Transmission speed (Mbps) Jitter(ms) Virtual Network Card A <![CDATA[x A1 ]]> <![CDATA[x A2 ]]> <![CDATA[x A3 ]]> <![CDATA[x A4 ]]> Virtual Network Card B <![CDATA[x B1 ]]> <![CDATA[x B2 ]]> <![CDATA[x B3 ]]> <![CDATA[x B4 ]]> Virtual Network Card C <![CDATA[x C1 ]]> <![CDATA[x C2 ]]> <![CDATA[x C3 ]]> <![CDATA[x C4 ]]>

[0092] In actual applications, for each performance indicator, the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards is: the ratio of the indicator value of the virtual network card under the performance indicator to the sum of the indicator values ​​of all virtual network cards under the performance indicator. Combined with Table 1, the indicator values ​​in the same column in the table are the indicator values ​​corresponding to different virtual network cards under the same performance indicator. Therefore, for each performance indicator, the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards is the ratio of the indicator value of the virtual network card under the performance indicator to the sum of all indicator values ​​in the corresponding column of the performance indicator. Exemplarily, under the jth performance indicator, the proportion of the indicator value corresponding to virtual network card i in the indicator values ​​corresponding to all virtual network cards can be expressed as:

[0093]

[0094] Specifically, for each performance indicator in S302, the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards is calculated. For example, for performance indicator 1 (latency), the indicator value x corresponding to virtual network card A is A1 The corresponding proportions of all virtual network cards are:

[0095] Optionally, in an example, after S301, an indicator matrix is ​​obtained, wherein the column vectors in the indicator matrix correspond to the performance indicators one-to-one, the row vectors in the indicator matrix correspond to the virtual network cards one-to-one, the column vectors of the indicator matrix include the indicator values ​​of all candidate network cards under the corresponding performance indicators, and the row vectors of the indicator matrix include the indicator values ​​of the corresponding virtual network cards under all performance indicators. For example, the indicator matrix R can be expressed as:

[0096]

[0097] Correspondingly, S302 specifically includes: for each performance indicator, calculating the ratio of the indicator value corresponding to each virtual network card to the sum of all indicator values ​​in the column vector corresponding to the performance indicator, and obtaining the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards.

[0098] In this embodiment, the difference coefficient of the above performance indicators represents the degree of difference of the indicator value corresponding to each virtual network card under the above performance indicators. The smaller the difference coefficient of the above performance indicators, the greater the difference of the indicator value corresponding to each virtual network card under the above performance indicators.

[0099] Specifically, in S303, for each performance indicator, the entropy value of the above performance indicator is calculated based on the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards; and based on the entropy value of the above performance indicator, the difference coefficient of the above performance indicator is calculated. Exemplarily, the entropy value of the j-th performance indicator can be expressed as:

[0100]

[0101] Where k>0, k=1 / ln(n), e j ≥0.

[0102] The coefficient of variation of the j-th performance indicator can be expressed as:

[0103]

[0104] Where m is the number of performance indicators,

[0105] Specifically, in S304, based on the difference coefficient of the above performance indicator, the ratio of the difference parameter of the above performance indicator to the sum of the difference parameters of all performance indicators is calculated to obtain the weight value of the above performance indicator. In combination with the above example, the weight value of the j-th performance indicator can be expressed as:

[0106]

[0107] Specifically, for each virtual network card in S305, the weight value of each performance indicator and the product of the proportion of the indicator value of the virtual network card under the above performance indicator in the indicator values ​​corresponding to all virtual network cards are calculated. j , the proportion of the index value corresponding to virtual network card i under the jth performance index in the index values ​​corresponding to all virtual network cards is p ij The product of the weight value of each performance indicator and the proportion of the indicator value of the above virtual network card under the above performance indicator in the indicator values ​​corresponding to all virtual network cards is w j ·p ij .

[0108] Specifically, in S305, the above product results corresponding to all performance indicators are summed to obtain the weight value of the above virtual network card. In combination with the above example, for virtual network card i, the weight value of virtual network card i can be expressed as:

[0109]

[0110] In actual applications, due to the performance difference between virtual network cards and fixed network cards, the weight value of fixed network cards is generally set higher than the weight value of virtual network cards. Therefore, the sum of the largest weight value among all virtual network cards and the configuration parameters can be used as the weight value of the fixed network card. The configuration parameters can be pre-set or calculated based on the difference between fixed network cards and virtual network cards in practice, and the impact on establishing MQTT long connections is not limited here.

[0111] In this embodiment, the index value of each virtual network card under each performance index is obtained, and the weight value of each virtual network card is obtained through a series of operations based on the index value of each virtual network card under each performance index; the weight value of the fixed network card is obtained by summing the weight value of the largest weight value among all virtual network cards and the configuration parameters; the weight values ​​of all network cards are obtained, and the weight values ​​of all network cards are related to the network performance of the network card. Therefore, based on the weight values ​​of all network cards, a more accurate number of newly occupied ports of the network card in the next collection cycle can be obtained, which can effectively improve the efficiency of MQTT stress testing.

[0112] Optionally, the number of ports of each can be determined, and a corresponding number of virtual network cards can be pre-set according to a preset number of test connections. In one example, the method further includes:

[0113] Install tunctl in the centos environment configured on the above MQTT stress test machine;

[0114] Based on the above preset number of test connections and the number of long connections that can be established by each network card, determine the total number of network cards required for the test; subtract one from the total number of network cards to obtain the number of virtual network cards to be created;

[0115] Based on the above tunctl, create a corresponding number of virtual network cards, configure IP addresses for the virtual network cards, and add static routes for the virtual network cards in the routing table to complete the registration of the virtual network cards.

[0116] In this example, tunctl is a command line tool for operating virtual network cards. In practice, the above MQTT stress test machine is configured with a centos environment. tunctl is installed in the centos environment, and virtual network cards can be registered by installing tunctl. Optionally, confirm whether tunctl is currently installed in the centos environment configured on the MQTT stress test machine. If tunctl is installed, a corresponding number of virtual network cards are directly created based on tunctl.

[0117] The number of long connections that can be established by the network card is the maximum number of ports that the network card can be allowed to occupy, and the number of long connections that can be established by each network card is not greater than the number of ports of the network card. In actual applications, if the number of ports currently occupied by the network card is less than the number of long connections that the network card can establish, the port of the network card can continue to be occupied to establish an MQTT long connection; if the number of ports currently occupied by the network card is greater than the number of long connections that the network card can establish, the port of the network card cannot continue to be occupied to establish an MQTT long connection.

[0118] It can be understood that the number of long connections that can be established by each network card can be the same or different, and the sum of the number of long connections of each network card is equal to the preset number of test connections. For example, the number of long connections that can be established by each network card is the same, and the total number of network cards required for the test can be determined by calculating the ratio of the preset number of test connections to the number of long connections that can be established by each network card. It should be noted that a fixed network card is registered on the MQTT stress test press. For example, the fixed network card can be eth0 (fiber Ethernet interface card). Therefore, after determining the total number of network cards required for the test, subtract one from the above total number of network cards to obtain the number of virtual network cards to be created.

[0119] In actual applications, after creating a corresponding number of virtual network cards, configure IP addresses for the virtual network cards, and add static routes for the virtual network cards in the routing table. The virtual network cards added to the routing table can communicate with the MQTT client network. It should be noted that there is no need to configure IP addresses for fixed network cards. When adding static routes for virtual network cards in the routing table, add the static routes for fixed network cards to the routing table. The fixed network cards added to the routing table can communicate with the MQTT client network.

[0120] Specifically, based on the above tunctl, create a corresponding number of virtual network cards, configure IP addresses for the virtual network cards, and add static routes of the virtual network cards in the routing table to complete the registration of the virtual network cards. Exemplarily, the number of virtual network cards to be created is 3, and virtual network card tap1, virtual network tap2, and virtual network tap3 are created through tunctl; class C IP addresses are configured for virtual network card tap1, virtual network tap2, and virtual network tap3 through tunctl; static routes of virtual network card tap1, virtual network tap2, and virtual network tap3 are added to the routing table to complete the registration of virtual network card tap1, virtual network tap2, and virtual network tap3.

[0121] In practice, other virtual network card command line tools can also be used to create virtual network cards. For example, a corresponding number of network cards can be created using the iptuntap tool. Optionally, other virtual network card command line tools can be combined with tunctl in this example to create virtual network cards, which is not limited here.

[0122] In this example, the number of virtual network cards to be created is determined based on the preset number of test connections and the number of long connections that can be established for each network card. The creation and registration of the corresponding number of virtual network cards are completed based on tunctl. By creating the corresponding number of virtual network cards, it can effectively avoid creating new virtual network cards when the number of ports occupied by the current network card is close to saturation, thereby improving the efficiency of MQTT stress testing.

[0123] Optionally, when the number of idle ports of each network card is less than a preset threshold, no new occupied ports will be allocated to the network card in the next collection cycle. In one example, the method further includes:

[0124] If the number of free ports of each network card is less than the preset threshold, a virtual network card is registered for the above MQTT stress test machine.

[0125] In actual applications, in order to ensure the rate at which each network card establishes a long connection, when the number of free ports of a network card is less than a preset threshold, no new occupied ports will be allocated to the network card in the next cycle, and new occupied ports will be allocated to network cards whose number of free ports is not less than the preset threshold. Therefore, when the number of free ports of each network card is less than the preset threshold, and the number of port occupancy of all current network cards does not reach the preset number of test connections, a virtual network card can be registered for the above-mentioned MQTT stress testing press.

[0126] Combined with the above example, the number of long connections that can be established by each network card is the difference between the number of ports of the network card and the preset threshold. In the above example, based on the above preset number of test connections and the number of long connections that can be established by each network card, the total number of network cards required for the test is determined; the number of virtual network cards to be created is obtained by subtracting one from the above total number of network cards. In practice, the ports in the network card may be unavailable or the establishment of a long connection may fail but the port is still occupied. When the number of free ports of all network cards is less than the preset threshold, the number of occupied ports of all network cards currently does not reach the preset number of test connections. A virtual network card can be registered for the above MQTT stress test press until the number of long connections established by the MQTT stress test press reaches the preset number of test connections, thereby achieving long connections without broken links and stress test results without abnormalities.

[0127] In this example, if the number of free ports of each network card is less than the preset threshold, registering a virtual network card for the above-mentioned MQTT stress test machine can effectively ensure that the number of long connections established by the MQTT stress test machine reaches the preset number of test connections, ensuring that the long connection is not broken, the stress test results are normal, and improving the reliability of MQTT.

[0128] In the MQTT stress testing method provided by the present application, the index value of each virtual network card under each performance index is obtained, and the weight value of each virtual network card and the weight value of the fixed network card are calculated based on the index value of each virtual network card under each performance index. In the scheme of the embodiment of the present application, the weight values ​​of all network cards are related to the network performance of the network card. Therefore, based on the weight values ​​of all network cards, a more accurate number of newly occupied ports of the network card in the next acquisition cycle can be obtained, which can effectively improve the efficiency of MQTT stress testing.

[0129] Embodiment 3

[0130] To facilitate understanding of the solution, the third embodiment of the present application will be exemplarily described below with reference to an example, wherein the MQTT stress testing machine is registered with three virtual network cards and one fixed network card. Figure 4 A flowchart of an MQTT stress testing method provided in Example 3 of the present application is shown in FIG. Figure 4 As shown, the process of the MQTT stress testing method of implementation three of this application includes the following steps:

[0131] Step 1: When the collection cycle arrives, the acquisition module obtains the number of idle ports of each network card;

[0132] Step 2: The weight determination module determines the weight value of each network card;

[0133] Step 3, the management module determines the number of newly occupied ports of each network card in the next collection cycle according to the number of free ports of each network card; wherein the number of newly occupied ports of the network card in the next collection cycle is the product of the current proportion of the number of free ports of the network card and the weight of the network card and the total target number of newly added ports of all network cards in a preset single cycle; the proportion of the number of free ports of the network card is the ratio of the number of free ports of the network card to the sum of the number of free ports of all network cards;

[0134] Step 4: The storage module stores the number of newly occupied ports of each network card in the next collection cycle in a time series database in chronological order;

[0135] Step 5: The allocation module obtains the number of newly occupied ports of each network card in the next collection cycle from the time series database, and sends the number of newly occupied ports of the network card in the next collection cycle to each network card;

[0136] Step 6: Each network card adds a corresponding number of occupied ports in the next collection cycle according to the corresponding number of newly occupied ports;

[0137] Step 7: If the sum of the number of occupied ports of all current network cards does not reach the preset number of test connections, execute step 1; if the sum of the number of occupied ports of all current network cards reaches the preset number of test connections, the MQTT stress test ends.

[0138] In the MQTT stress testing method provided in this embodiment, when the collection cycle arrives, the acquisition module obtains the number of free ports of each network card at present; the weight determination module determines the weight value of each network card; the management module determines the number of newly occupied ports of each network card in the next collection cycle according to the number of free ports of each network card; the storage module stores the number of newly occupied ports of each network card in the next collection cycle in a time series database in chronological order; the allocation module obtains the number of newly occupied ports of each network card in the next collection cycle from the time series database, and sends the number of newly occupied ports of the network card in the next collection cycle to each network card; each network card adds a corresponding number of occupied ports in the next collection cycle according to the corresponding number of newly occupied ports; until the sum of the number of occupied ports of all network cards reaches the preset number of test connections. In the process of MQTT stress testing in the embodiment of the present application, the MQTT stress testing press is registered with multiple network cards, and the target total number of new ports for all network cards in a single cycle can be set. The weight of the network card is related to the actual network performance of the network card. The proportion of the number of idle ports of the current network card represents the current idleness of the network card relative to other network cards. Therefore, based on the current number of idle ports of each network card, the weight of the network card and the preset target total number of new ports for all network cards in a single cycle, the number of newly occupied ports of each network card in the next collection cycle is determined, which can effectively ensure that each network card adds a corresponding number of newly occupied ports in a certain period of time, saves the time for the number of established MQTT long connections to reach the preset number of test connections, and improves the efficiency of MQTT stress testing.

[0139] Embodiment 4

[0140] Figure 5 A schematic diagram of the structure of an MQTT stress test press provided in the fourth embodiment of the present application, wherein the MQTT stress test press is registered with multiple network cards, such as Figure 5 As shown, the MQTT stress test machine includes:

[0141] The acquisition module 51 is used to acquire the number of idle ports of each network card when the collection cycle arrives;

[0142] The management module 52 is used to determine the number of newly occupied ports of each network card in the next collection cycle according to the number of free ports of each network card; wherein the number of newly occupied ports of the network card in the next collection cycle is the product of the current proportion of the number of free ports of the network card and the weight of the network card and the total target number of newly added ports of all network cards in a preset single cycle; the proportion of the number of free ports of the network card is the ratio of the number of free ports of the network card to the sum of the number of free ports of all network cards;

[0143] The allocation module 53 is used to send the number of newly occupied ports of the network card in the next collection cycle to each network card, so that the network card adds a corresponding number of occupied ports in the next collection cycle according to the newly occupied ports, until the sum of the occupied port numbers of all network cards reaches a preset test connection number.

[0144] The number of free ports of the network card is the number of unoccupied ports of the network card. In practical applications, when the number of newly occupied ports of the network card in the next collection cycle is constant, the larger the number of free ports of the network card, the shorter the time for adding the corresponding number of occupied ports in the next collection cycle, that is, the larger the number of free ports of the network card, the faster the rate of newly occupied ports of the network card.

[0145] Among them, the idle port ratio of the current network card represents the idleness of the current network card compared with other network cards. The larger the idle port ratio of the current network card, the more idle the current network card is compared with other network cards; the smaller the idle port ratio of the current network card, the smaller the idleness of the current network card is compared with other network cards. In practice, the larger the idle port ratio of the network card, the faster the rate of newly occupied ports of the network card is compared with the rate of other network cards; the smaller the idle port ratio of the network card, the slower the rate of newly occupied ports of the network card is compared with the rate of other network cards.

[0146] In one example, the management module 52 is specifically used to: for each network card, calculate the ratio of the number of free ports of the network card to the sum of the number of free ports of all network cards, and obtain the proportion of the number of free ports of the network card; calculate the product of the current proportion of the number of free ports of the network card and the weight of the network card and the target total number of new ports of all network cards in a preset single cycle, and obtain the number of newly occupied ports of the network card in the next collection cycle.

[0147] Combined with the above example, the number of newly occupied ports of the network card in the next collection cycle is the product of the current proportion of the number of idle ports of the network card, the weight of the network card, and the total target number of newly added ports of all network cards in a preset single cycle. Among them, the weight of the network card is related to the network performance of the current network card. In a single collection cycle, the weight of the network card is constant; and in a collection cycle, the total target number of newly added ports of all network cards is constant; therefore, the number of newly occupied ports of the network card in the next collection cycle is positively correlated with the proportion of the number of idle ports of the current network card. The larger the proportion of the number of idle ports of the current network card, the larger the number of newly occupied ports of the network card in the next collection cycle.

[0148] It can be understood that when the proportion of the number of idle ports of the current network card is relatively small, the idle degree of the current network card is less than that of other network cards, and the rate of newly occupied ports of the network card is smaller than that of other network cards, that is, the number of newly occupied ports that can be added by the network card in the next collection cycle is smaller; therefore, sending a smaller number of newly occupied ports of the above-mentioned network card in the next collection cycle to the network card can ensure that the network card can efficiently add a corresponding number of newly occupied ports in the next collection cycle; when the proportion of the number of idle ports of the current network card is relatively large, the idle degree of the current network card is relatively large compared with other network cards, and the rate of newly occupied ports of the network card is larger than that of other network cards, that is, the number of newly occupied ports that can be added by the network card in the next collection cycle is larger; therefore, sending a larger number of newly occupied ports of the above-mentioned network card in the next collection cycle to the network card can ensure that the network card can efficiently add a corresponding number of newly occupied ports in the next collection cycle.

[0149] In actual applications, the target total number of new ports for all network cards in a single cycle is certain. When the MQTT stress test machine only registers a single network card, it takes a long time to add the corresponding number of new ports. When the MQTT stress test machine registers multiple network cards, the target total number of new ports for all network cards can be allocated to multiple network cards for parallel processing, which can save the time for adding new ports and improve the efficiency of MQTT stress testing.

[0150] In this embodiment, for the network card with a relatively large number of idle ports, the rate of newly occupied ports of the current network card is relatively large relative to the rate of newly occupied ports of other network cards, and a relatively large number of newly occupied ports of the above network card in the next acquisition cycle is sent to the network card, which can also ensure that the establishment of the MQTT long connection is completed within a certain time; for the network card with a relatively small number of idle ports, the rate of newly occupied ports of the current network card is relatively small relative to the rate of newly occupied ports of other network cards, and a relatively small number of newly occupied ports of the above network card in the next acquisition cycle is sent to the network card, which can ensure that the establishment of the MQTT long connection is completed within a certain time. Therefore, this embodiment saves the time for the number of established MQTT long connections to reach the preset number of test connections, and improves the efficiency of MQTT stress testing.

[0151] It should be noted that during the MQTT stress test, the sum of the total number of target new ports for all network cards in all collection cycles is the preset number of test connections. For different collection cycles, the total number of target new ports for all network cards in a single cycle can be the same or different, and is not limited here. For example, for different collection cycles, the total number of target new ports for all network cards in a single cycle is set to be the same. Optionally, considering that the number of remaining ports for network cards is decreasing, the total number of target new ports for all network cards in a single cycle can be set to decrease.

[0152] Optionally, in a single cycle, the target total number of new ports for all network cards per unit time can be set; in one example, the acquisition module 51 is specifically used to: when the collection cycle arrives, obtain the number of new ports per unit time of each network card, calculate the product of the number of newly occupied ports per unit time of each network card and the duration of the current collection cycle, and obtain the number of newly occupied ports of each network card in the current collection cycle; for each network card, calculate the sum of the number of newly occupied ports in the current collection cycle and the number of newly occupied ports in the historical collection cycle to determine the current number of occupied ports of the network card; calculate the difference between the total number of ports of the network card and the current number of occupied ports of the network card to obtain the current number of free ports of the network card.

[0153] Correspondingly, the management module 52 is specifically used for: for each network card, calculating the ratio of the number of free ports of the network card to the sum of the number of free ports of all network cards, to obtain the proportion of the number of free ports of the network card; calculating the product of the current proportion of the number of free ports of the network card and the weight of the network card and the preset target total number of new ports of all network cards per unit time, to obtain the number of newly occupied ports of the network card per unit time in the next cycle; it can be understood that by calculating the product of the number of newly occupied ports of the network card per unit time in the next cycle and the duration of the next collection cycle, the number of newly occupied ports of the network card in the next collection cycle can be determined.

[0154] Correspondingly, the allocation module 53 is specifically used to send the number of newly occupied ports of the network card per unit time in the next cycle to each network card, so that the network card adds a corresponding number of occupied ports per unit time in the next collection cycle according to the number of newly occupied ports of the network card per unit time in the next cycle, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections.

[0155] In a possible implementation, the MQTT stress test press further includes:

[0156] The storage module is used to store the number of newly occupied ports of each network card in the next collection cycle in a time series database in chronological order.

[0157] Among them, the time series database is a database used to store and process time series data, supporting efficient reading, writing and calculation of time series data. Exemplarily, the time series database can be DolphinDB, TimescaleDB, InfluxDB or TDengine. In practical applications, when each collection cycle arrives, the number of free ports of each network card is obtained, and based on the number of free ports of each network card, the number of newly occupied ports of each network card in the next collection cycle is determined. Therefore, in each collection cycle, the number of newly occupied ports of each network card is a series of data generated over time.

[0158] Exemplarily, the time when the number of newly occupied ports of each network card in the next collection cycle is determined is used as the timestamp of the number of newly occupied ports of each network card in the next collection cycle, and the number of newly occupied ports of each network card in the next collection cycle is stored in the time series database in the order of the timestamps. It can be understood that when the collection cycle arrives, the time series database stores the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle.

[0159] In this example, after determining the number of newly occupied ports of each network card in the next collection cycle, the number of newly occupied ports of each network card in the next collection cycle is stored in a time series database in chronological order. Based on the time series database, it is convenient to obtain the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle.

[0160] Optionally, in an example, the number of newly occupied ports of each network card in the next collection cycle is stored in a cache database in chronological order. For example, the cache database may be a remote dictionary service.

[0161] In practical applications, the total number of occupied ports of the current network card can be determined by reading the number of newly occupied ports of each network card in the current acquisition cycle and the historical acquisition cycle in the time series database. In an example, the acquisition module 51 includes:

[0162] A reading unit, used for obtaining the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle from the time series database when the collection cycle arrives;

[0163] A calculation unit, used to calculate the sum of the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle, to obtain the current number of occupied ports of each network card;

[0164] The calculation unit is further used to calculate the difference between the number of ports of each network card and the number of currently occupied ports of each network card, so as to obtain the number of currently idle ports of each network card.

[0165] In this example, the current number of occupied ports of each network card is calculated based on the number of newly occupied ports of the network card in the current collection cycle and the historical collection cycle stored in the time series database; further, the number of free ports of each network card is obtained by calculating the difference between the number of ports of each network card and the current number of occupied ports of each network card.

[0166] Optionally, in an example, the storage module is also used to store the number of newly occupied ports of each network card in the next acquisition cycle and the current number of occupied ports of each network card in a time series database in chronological order.

[0167] Optionally, in one example, the acquisition module is also used to: when a collection cycle arrives, obtain from the timing database the number of newly occupied ports of each network card in the current collection cycle and the number of occupied ports of each network card in the previous collection cycle; calculate the sum of the number of newly occupied ports of each network card in the current collection cycle and the number of occupied ports of each network card in the previous collection cycle to obtain the current number of occupied ports of each network card; calculate the difference between the number of ports of each network card and the current number of occupied ports of each network card to obtain the current number of free ports of each network card.

[0168] In a possible implementation, the MQTT stress testing machine further includes: a weight determination module; the weight determination module is used to:

[0169] Obtain the index value of each virtual network card under each performance index, and normalize the above index values;

[0170] For each performance indicator, calculate the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards;

[0171] For each performance indicator, based on the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards, the entropy value of the above performance indicator is calculated; and based on the entropy value of the above performance indicator, the difference coefficient of the above performance indicator is calculated;

[0172] Based on the difference coefficient of the above performance indicators, the ratio of the difference parameter of the above performance indicators to the sum of the difference parameters of all performance indicators is calculated to obtain the weight value of the above performance indicators;

[0173] For each virtual network card, calculate the product of the weight value of each performance indicator and the proportion of the indicator value of the virtual network card under the above performance indicator in the indicator values ​​corresponding to all virtual network cards; add up the above product results corresponding to all performance indicators to obtain the weight value of the virtual network card;

[0174] The sum of the largest weight value among the weight values ​​of all virtual network cards and the configuration parameter is used as the weight value of the fixed network card.

[0175] Among them, the performance indicators include latency, packet loss rate, transmission rate and jitter, and the performance indicators characterize the performance of the network corresponding to the virtual network card. In practical applications, based on the impact of the performance indicators on the network corresponding to the virtual network card, the above performance indicators can be divided into positive performance indicators and negative performance indicators. The larger the indicator value under the positive performance indicator, the better the performance of the network corresponding to the virtual network card. The smaller the indicator value under the negative performance indicator, the better the performance of the network corresponding to the virtual network card. Exemplarily, the transmission rate belongs to the positive performance indicator; latency, packet loss rate and jitter belong to the negative performance indicators. In other examples, more performance indicators can be added or the above performance indicators can be reduced, and this application does not specifically limit the performance indicators.

[0176] In actual applications, for each performance indicator, the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards is: the ratio of the indicator value of the virtual network card under the performance indicator to the sum of the indicator values ​​of all virtual network cards under the performance indicator.

[0177] Optionally, in one example, the index value of each virtual network card under each performance indicator is obtained, and after the above index value is normalized, an index matrix is ​​obtained, wherein the column vectors in the index matrix correspond to the performance indicators one-to-one, the row vectors in the index matrix correspond to the virtual network cards one-to-one, the column vectors of the index matrix include the index values ​​of all candidate network cards under the corresponding performance indicators, and the row vectors of the index matrix include the index values ​​of the corresponding virtual network cards under all performance indicators. Correspondingly, for each performance indicator, the ratio of the index value corresponding to each virtual network card to the sum of all index values ​​in the column vector corresponding to the performance indicator is calculated to obtain the proportion of the index value corresponding to each virtual network card in the index values ​​corresponding to all virtual network cards.

[0178] In this implementation, the difference coefficient of the above performance indicators represents the degree of difference in the indicator values ​​corresponding to each virtual network card under the above performance indicators. The smaller the difference coefficient of the above performance indicators, the greater the difference in the indicator values ​​corresponding to each virtual network card under the above performance indicators.

[0179] In actual applications, due to the performance difference between virtual network cards and fixed network cards, the weight value of fixed network cards is generally set higher than the weight value of virtual network cards. Therefore, the sum of the largest weight value among all virtual network cards and the configuration parameters can be used as the weight value of the fixed network card. The configuration parameters can be pre-set or calculated based on the difference between fixed network cards and virtual network cards in practice, and the impact on establishing MQTT long connections is not limited here.

[0180] In this implementation, the index value of each virtual network card under each performance indicator is obtained, and the weight value of each virtual network card is obtained through a series of operations based on the index value of each virtual network card under each performance indicator; the weight value of the fixed network card is obtained by summing the weight value of the virtual network card with the largest weight value and the configuration parameter; the weight values ​​of all network cards are obtained, and the weight values ​​of all network cards are related to the network performance of the network card. Therefore, based on the weight values ​​of all network cards, a more accurate number of newly occupied ports of the network card in the next collection cycle can be obtained, which can effectively improve the efficiency of MQTT stress testing.

[0181] In addition, in an example, the MQTT stress test machine further includes: a first registration module; the first registration module is used to:

[0182] Install tunctl in the centos environment configured on the above MQTT stress test machine;

[0183] Based on the above preset number of test connections and the number of long connections that can be established by each network card, the total number of network cards required for the test is determined; the number of virtual network cards to be created is obtained by subtracting one from the total number of network cards;

[0184] Based on the above tunctl, create a corresponding number of virtual network cards, configure IP addresses for the virtual network cards, and add static routes for the virtual network cards in the routing table to complete the registration of the virtual network cards.

[0185] In this example, tunctl is a command line tool for operating virtual network cards. In practice, the above MQTT stress test machine is configured with a centos environment. tunctl is installed in the centos environment, and virtual network cards can be registered by installing tunctl. Optionally, confirm whether tunctl is currently installed in the centos environment configured on the MQTT stress test machine. If tunctl is installed, a corresponding number of virtual network cards are directly created based on tunctl.

[0186] The number of long connections that can be established by the network card is the maximum number of ports that the network card can be allowed to occupy, and the number of long connections that can be established by each network card is not greater than the number of ports of the network card. In actual applications, if the number of ports currently occupied by the network card is less than the number of long connections that the network card can establish, the port of the network card can continue to be occupied to establish an MQTT long connection; if the number of ports currently occupied by the network card is greater than the number of long connections that the network card can establish, the port of the network card cannot continue to be occupied to establish an MQTT long connection.

[0187] It can be understood that the number of long connections that can be established by each network card can be the same or different, and the sum of the number of long connections of each network card is equal to the preset number of test connections. For example, the number of long connections that can be established by each network card is the same, and the total number of network cards required for the test can be determined by calculating the ratio of the preset number of test connections to the number of long connections that can be established by each network card. It should be noted that a fixed network card is registered on the MQTT stress test press. For example, the fixed network card can be eth0 (fiber Ethernet interface card). Therefore, after determining the total number of network cards required for the test, subtract one from the above total number of network cards to obtain the number of virtual network cards to be created.

[0188] In actual applications, after creating a corresponding number of virtual network cards, configure IP addresses for the virtual network cards, and add static routes for the virtual network cards in the routing table. The virtual network cards added to the routing table can communicate with the MQTT client network. It should be noted that there is no need to configure IP addresses for fixed network cards. When adding static routes for virtual network cards in the routing table, add the static routes for fixed network cards to the routing table. The fixed network cards added to the routing table can communicate with the MQTT client network.

[0189] In practice, other virtual network card command line tools can also be used to create virtual network cards. For example, a corresponding number of network cards can be created using the iptuntap tool. Optionally, other virtual network card command line tools can be combined with tunctl in this example to create virtual network cards, which is not limited here.

[0190] In this example, the number of virtual network cards to be created is determined based on the preset number of test connections and the number of long connections that can be established for each network card. The creation and registration of the corresponding number of virtual network cards are completed based on tunctl. By creating the corresponding number of virtual network cards, it can effectively avoid creating new virtual network cards when the number of ports occupied by the current network card is close to saturation, thereby improving the efficiency of MQTT stress testing.

[0191] Optionally, when the number of free ports of each network card is less than a preset threshold, no new occupied ports will be allocated to the network card in the next collection cycle. In one example, the MQTT stress test machine further includes: a second registration module; the second registration module is used to:

[0192] If the number of free ports of each network card is less than the preset threshold, a virtual network card is registered for the above MQTT stress test machine.

[0193] In actual applications, in order to ensure the rate at which each network card establishes a long connection, when the number of free ports of a network card is less than a preset threshold, no new occupied ports will be allocated to the network card in the next cycle, and new occupied ports will be allocated to network cards whose number of free ports is not less than the preset threshold. Therefore, when the number of free ports of each network card is less than the preset threshold, and the number of port occupancy of all current network cards does not reach the preset number of test connections, a virtual network card can be registered for the above-mentioned MQTT stress testing press.

[0194] Combined with the above example, the number of long connections that can be established by each network card is the difference between the number of ports of the network card and the preset threshold. In the above example, based on the above preset number of test connections and the number of long connections that can be established by each network card, the total number of network cards required for the test is determined; the number of virtual network cards to be created is obtained by subtracting one from the above total number of network cards. In practice, the ports in the network card may be unavailable or the establishment of a long connection may fail but the port is still occupied. When the number of free ports of all network cards is less than the preset threshold, the number of occupied ports of all network cards currently does not reach the preset number of test connections. A virtual network card can be registered for the above MQTT stress test press until the number of long connections established by the MQTT stress test press reaches the preset number of test connections, thereby achieving long connections without broken links and stress test results without abnormalities.

[0195] In this example, if the number of free ports of each network card is less than the preset threshold, registering a virtual network card for the above-mentioned MQTT stress test machine can effectively ensure that the number of long connections established by the MQTT stress test machine reaches the preset number of test connections, ensuring that the long connection is not broken, the stress test results are normal, and improving the reliability of MQTT.

[0196] In the MQTT stress testing machine provided by the present embodiment, the acquisition module acquires the current number of free ports of each network card when the collection cycle arrives; the management module determines the number of newly occupied ports of each network card in the next collection cycle according to the current number of free ports of each network card, the weight of the network card and the target total number of newly added ports of all network cards in a preset single cycle; the allocation module sends the number of newly occupied ports of the network card in the next collection cycle to each network card, so that the network card adds a corresponding number of occupied ports in the next collection cycle according to the number of newly occupied ports, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections. In the process of MQTT stress testing in the embodiment of the present application, the MQTT stress testing machine is registered with multiple network cards. The target total number of new ports for all network cards in a single cycle can be set. The weight of the network card is related to the actual network performance of the network card. The proportion of the number of idle ports of the current network card represents the current idleness of the network card relative to other network cards. Therefore, based on the current number of idle ports of each network card, the weight of the network card and the preset target total number of new ports for all network cards in a single cycle, the number of newly occupied ports of each network card in the next collection cycle is determined, which can effectively ensure that each network card adds a corresponding number of newly occupied ports in a certain period of time, saves the time for the number of established MQTT long connections to reach the preset number of test connections, and improves the efficiency of MQTT stress testing.

[0197] Embodiment 5

[0198] Figure 6 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present application, such as Figure 6 As shown, the electronic device includes:

[0199] The processor 61 and the main control device also include a memory 62; they may also include a communication interface 63 and a bus 64. The processor 65, the memory 62, and the communication interface 63 may communicate with each other through the bus 64. The communication interface 63 may be used for information transmission. The processor 61 may call the logic instructions in the memory 62 to execute the method of the above embodiment.

[0200] In addition, the logic instructions in the memory 62 described above may be implemented in the form of software functional units and when sold or used as independent products, may be stored in a computer-readable storage medium.

[0201] The memory 62 is a computer-readable storage medium that can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the methods in the embodiments of the present application. The processor 61 executes functional applications and data processing by running the software programs, instructions, and modules stored in the memory 62, that is, implementing the methods in the above method embodiments.

[0202] The memory 62 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 62 may include a high-speed random access memory and may also include a non-volatile memory.

[0203] The present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the method in any embodiment is implemented. For example, the computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0204] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0205] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A MQTT stress testing method, It is characterized in that Applied to an MQTT stress test machine, the MQTT stress test machine is registered with multiple network cards, and the method includes: When the collection cycle arrives, obtain the number of idle ports of each network card; According to the number of free ports of each network card, the number of newly occupied ports of each network card in the next collection cycle is determined; wherein the number of newly occupied ports of the network card in the next collection cycle is the product of the current proportion of the number of free ports of the network card and the weight of the network card and the total target number of newly added ports of all network cards in a preset single cycle; the proportion of the number of free ports of the network card is the ratio of the number of free ports of the network card to the sum of the number of free ports of all network cards; The number of newly occupied ports of the network card in the next collection cycle is sent to each network card, so that the network card adds a corresponding number of occupied ports in the next collection cycle according to the newly occupied ports, until the sum of the occupied port numbers of all network cards reaches the preset test connection number.

2. The method according to claim 1, It is characterized in that After determining the number of newly occupied ports required per unit time of each network card in the next acquisition cycle according to the number of idle ports of each network card, the method further comprises: The number of newly occupied ports of each network card in the next collection cycle is stored in the time series database in chronological order.

3. The method according to claim 2, It is characterized in that When the collection period arrives, the number of idle ports of each network card is obtained, including: When the collection cycle arrives, the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle is obtained from the time series database; Calculate the sum of the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle to obtain the current number of occupied ports of each network card; The difference between the number of ports of each network card and the number of currently occupied ports of each network card is calculated to obtain the number of currently idle ports of each network card.

4. The method according to claim 1, It is characterized in that The multiple network cards include virtual network cards and fixed network cards; before determining the number of newly occupied ports of each network card in the next collection cycle according to the number of idle ports of each network card, the method further includes: Obtaining the index value of each virtual network card under each performance index, and normalizing the index value; wherein the performance index includes latency, packet loss rate, transmission rate and jitter; For each performance indicator, calculate the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards; For each performance indicator, based on the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards, the entropy value of the performance indicator is calculated; and based on the entropy value of the performance indicator, the difference coefficient of the performance indicator is calculated; wherein the difference coefficient of the performance indicator represents the degree of difference of the indicator value corresponding to each virtual network card under the performance indicator, and the smaller the difference coefficient of the performance indicator, the greater the difference of the indicator value corresponding to each virtual network card under the performance indicator; Based on the difference coefficient of the performance indicator, a ratio of the difference parameter of the performance indicator to the sum of the difference parameters of all performance indicators is calculated to obtain a weight value of the performance indicator; For each virtual network card, calculate the product of the weight value of each performance indicator and the proportion of the indicator value of the virtual network card under the performance indicator in the indicator values ​​corresponding to all virtual network cards; add up the product results corresponding to all performance indicators to obtain the weight value of the virtual network card; The sum of the largest weight value among the weight values ​​of all virtual network cards and the configuration parameter is used as the weight value of the fixed network card.

5. The method according to claim 4, It is characterized in that The method further comprises: Install tunctl in the centos environment configured on the MQTT stress test machine; Based on the preset number of test connections and the number of long connections that can be established by each network card, determine the total number of network cards required for the test; subtract one from the total number of network cards to obtain the number of virtual network cards to be created; Based on the tunctl, a corresponding number of the virtual network cards are created, IP addresses are configured for the virtual network cards, and static routes of the virtual network cards are added to the routing table to complete the registration of the virtual network cards.

6. The method according to any one of claims 1 to 5, It is characterized in that The method further comprises: If the number of free ports of each network card is less than a preset threshold, a virtual network card is registered for the MQTT stress testing machine.

7. A MQTT stress test press, It is characterized in that The MQTT stress test machine is registered with multiple network cards, and the MQTT stress test machine includes: The acquisition module is used to obtain the number of idle ports of each network card when the collection cycle arrives; A management module, used to determine the number of newly occupied ports of each network card in the next collection cycle according to the number of free ports of each network card; wherein the number of newly occupied ports of the network card in the next collection cycle is the product of the current proportion of the number of free ports of the network card and the weight of the network card and the total target number of newly added ports of all network cards in a preset single cycle; the proportion of the number of free ports of the network card is the ratio of the number of free ports of the network card to the sum of the number of free ports of all network cards; The allocation module is used to send the number of newly occupied ports of the network card in the next collection cycle to each network card, so that the network card adds a corresponding number of occupied ports in the next collection cycle according to the newly occupied ports, until the sum of the occupied port numbers of all network cards reaches a preset test connection number.

8. The MQTT pressure testing press according to claim 7, It is characterized in that The MQTT stress test machine also includes: The storage module is used to store the number of newly occupied ports of each network card in the next collection cycle in a time series database in chronological order.

9. The MQTT pressure testing press according to claim 8, It is characterized in that The acquisition module comprises: A reading unit, used for obtaining the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle from the time series database when the collection cycle arrives; A calculation unit, used to calculate the sum of the number of newly occupied ports of each network card in the current collection cycle and the historical collection cycle, to obtain the current number of occupied ports of each network card; The calculation unit is further used to calculate the difference between the number of ports of each network card and the number of currently occupied ports of each network card, so as to obtain the number of currently idle ports of each network card.

10. The MQTT stress testing press according to claim 7, It is characterized in that The multiple network cards include virtual network cards and fixed network cards; the MQTT stress test machine also includes: a weight determination module; the weight determination module is used to: Obtaining the index value of each virtual network card under each performance index, and normalizing the index value; wherein the performance index includes latency, packet loss rate, transmission rate and jitter; For each performance indicator, calculate the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards; For each performance indicator, based on the proportion of the indicator value corresponding to each virtual network card in the indicator values ​​corresponding to all virtual network cards, the entropy value of the performance indicator is calculated; and based on the entropy value of the performance indicator, the difference coefficient of the performance indicator is calculated; wherein the difference coefficient of the performance indicator represents the degree of difference of the indicator value corresponding to each virtual network card under the performance indicator, and the smaller the difference coefficient of the performance indicator, the greater the difference of the indicator value corresponding to each virtual network card under the performance indicator; Based on the difference coefficient of the performance indicator, a ratio of the difference parameter of the performance indicator to the sum of the difference parameters of all performance indicators is calculated to obtain a weight value of the performance indicator; For each virtual network card, calculate the product of the weight value of each performance indicator and the proportion of the indicator value of the virtual network card under the performance indicator in the indicator values ​​corresponding to all virtual network cards; add up the product results corresponding to all performance indicators to obtain the weight value of the virtual network card; The sum of the largest weight value among the weight values ​​of all virtual network cards and the configuration parameter is used as the weight value of the fixed network card.

11. The MQTT stress test press according to claim 10, It is characterized in that The MQTT stress test machine further includes: a first registration module; the first registration module is used to: Install tunctl in the centos environment configured on the MQTT stress test machine; Based on the preset number of test connections and the number of long connections that can be established by each network card, determine the total number of network cards required for the test; subtract one from the total number of network cards to obtain the number of virtual network cards to be created; Based on the tunctl, a corresponding number of the virtual network cards are created, IP addresses are configured for the virtual network cards, and static routes of the virtual network cards are added to the routing table to complete the registration of the virtual network cards.

12. The MQTT pressure testing press according to any one of claims 7 to 11, It is characterized in that The MQTT stress test machine also includes: The second registration module is used to register a virtual network card for the MQTT stress testing machine if the number of free ports of each network card is less than a preset threshold.

13. An electronic device, It is characterized in that include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6.

14. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.

Citation Information

Patent Citations

  • Message caching method and device

    CN109617832A

  • Data transmission method and device

    CN110460457A

  • Testing method, testing device and testing equipment for Ethernet ports of equipment

    CN111130924A

  • Pressure testing method, device and system

    CN111294250A

  • Parallel transmission method of pressure test data, pressure test tool and electronic equipment

    CN112463396A

Cited By

  • Network resource management method and device, storage medium and program product

    CN119996205A