A method for simulating massive devices

By creating abstract devices and performing authentication and regular data reporting, the problem of unstable connection of simulated devices in the existing technology is solved, stable and efficient simulation of massive devices is achieved, and resource usage is reduced.

CN114840399BActive Publication Date: 2025-09-26HANGZHOU INSTRUCTION SET INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210361522.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-07
Publication Date
2025-09-26
Estimated Expiration
2042-04-07

AI Technical Summary

Technical Problem

When software simulates devices in the existing technology, the connection is unstable, it is difficult to simulate massive devices, and the cost is high.

Method used

By creating abstract devices, performing authentication and regularly triggering data reporting, and adopting device response methods of different communication types, CPU resource usage is reduced and stable connections are achieved.

Benefits of technology

Effectively simulate network interactions of massive devices, reduce CPU thread resource usage, and make connections more stable.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114840399B_ABST
    Figure CN114840399B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for simulating a large number of devices, comprising the following steps: Step 1, reading operating parameters / configuration files; Step 2, creating an abstract device based on the configuration files read in Step 1; Step 3, authenticating the abstract device created in Step 2. If authentication fails, the process terminates immediately; if authentication passes, a thread is bound to the device and data reporting is triggered according to a configuration timer. The present invention's method for simulating a large number of devices effectively creates abstract devices through the three steps, and then implements stress testing using the abstract devices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a device simulation method, and more particularly to a method for simulating massive devices. Background Art

[0002] The device access platform needs to be tested to its extreme carrying capacity. Therefore, a large number of devices need to be connected during the test process. However, in the actual test process, a large number of devices are not available. Therefore, it is difficult to achieve the desired test effect by using actual devices, or the test cost is very high. Therefore, software simulation is often used in the existing technology to implement testing.

[0003] JMeter is a Java-based stress testing tool developed by the Apache organization and primarily used for software stress testing. JMeter only supports HTTP stress testing; other communication methods must be integrated via plugins. When simulating large amounts of data, each connection handle corresponds to a single thread, leading to unstable device connections and frequent disconnections. Summary of the Invention

[0004] In view of the shortcomings of the existing technology, the purpose of the present invention is to provide a method for realizing analog massive devices that can withstand large analog quantities and has more stable connections.

[0005] To achieve the above object, the present invention provides the following technical solution: a method for simulating massive devices, comprising the following steps:

[0006] Step 1: Read the operating parameters / configuration file;

[0007] Step 2: Create an abstract device based on the configuration file read in step 1;

[0008] Step 3: Authenticate the abstract device created in step 2. If the authentication fails, the process ends immediately. If the authentication passes, the thread is bound to the device and data reporting is triggered according to the configuration schedule.

[0009] As a further improvement of the present invention, the specific steps of creating an abstract device in step 2 are as follows:

[0010] Step 21: Analyze the device attributes and event reporting methods based on the configuration file;

[0011] Step 22: uniformly write the attribute and command control processing rules based on the device attributes obtained in step 21;

[0012] Step 23: Expand the rules written in step 22, and build in a random number function, an accumulation loop function, and an echo function;

[0013] Step 24: Determine the communication type of the abstract device, determine the abstract method for the device to respond back to the platform based on the communication type, and determine the abstract method for stopping the device from working.

[0014] As a further improvement of the present invention, the communication types in step 24 include HTTP devices, TCP devices, MQTT devices and CoAP devices. The abstract method of the device responding back to the platform is specifically: the HTTP device assembles the request header and request body according to the protocol, the TCP device and MQTT device encode and assemble the message, and the CoAP device sends it through the UDP protocol;

[0015] The abstract method for stopping the device is as follows:

[0016] The TCP device and the MQTT device disconnect the TCP connection and release the local handle resources. The HTTP device and the CoAP device do not perform any operation.

[0017] As a further improvement of the present invention, the specific steps of timing triggering data reporting in step 3 are as follows: step 31, determining whether the scheduled task has been triggered, if the task has been triggered, proceeding to the next step, if the task has not been triggered, the CPU rejects the task and ends;

[0018] Step 32: Determine whether the number of available threads is less than the number of CPU cores. If so, select an available thread to execute the task and then terminate. If not, proceed to the next step.

[0019] Step 33: Determine whether the task queue of the available thread is full. If the task queue is not full, add the task to the blocking queue and wait for the available thread to execute it. If the task queue is full, proceed to the next step.

[0020] Step 3 and 4: Determine whether the number of available threads is less than 2 times the number of CPU cores. If the number of available threads is less than 2 times the number of CPU cores, create a thread and execute the task before ending. If the number of available threads is not less than 2 times the number of CPU cores, the CPU rejects the task and ends.

[0021] The beneficial effect of the present invention is that, through the settings of step one and step two, an abstract device can be effectively created according to the parameters / configuration file, and then through the settings of step three, the created abstract device is authenticated, and after the authentication is passed, it is confirmed as a simulated device, and then the configuration therein is used to trigger data reporting at a fixed time, which well simulates the interaction of real devices in network communication, and there is no need to simulate the operating logic of the device itself, thereby greatly reducing the occupation of CPU thread resources and making the connection more stable. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 is a flow chart of the method of the present invention;

[0023] Figure 2 Schematic diagram of thread binding device;

[0024] Figure 3 This is a flowchart for timing triggered data reporting. DETAILED DESCRIPTION

[0025] The present invention will be further described below with reference to the embodiments shown in the accompanying drawings.

[0026] Reference Figures 1 to 3 As shown, a method for simulating massive devices in this embodiment includes the following steps:

[0027] Step 1: Read the operating parameters / configuration file;

[0028] Step 2: Create an abstract device based on the configuration file read in step 1;

[0029] In step three, the abstract device created in step two is authenticated. If the authentication fails, the process ends directly. If the authentication passes, the thread is bound to the device and data reporting is triggered according to the configuration. In the process of using the method of this embodiment, it is only necessary to execute steps one, two and three in sequence. In this way, an abstract device that only simulates the interaction mode of the device on the Internet can be effectively created, and the method of triggering data reporting at a time is adopted, which greatly reduces the occupancy of the CPU thread and realizes the large-scale simulation of the abstract device.

[0030] As a specific implementation method of the improvement, the specific steps of creating the abstract device in step 2 are as follows: step 21, the device attributes and event reporting method parsed according to the configuration file;

[0031] Step 22: uniformly write the attribute and command control processing rules based on the device attributes obtained in step 21;

[0032] Step 23: Expand the rules written in step 22, and build in a random number function, an accumulation loop function, and an echo function;

[0033] In step 24, determine the communication type of the abstract device. Based on the communication type, determine the abstract method for the device to respond back to the platform and also determine the abstract method for stopping the device. By setting the above steps, the internal rules of the abstract device can be used to simulate the input and feedback of the real device, thereby achieving the effect of simulating the real device and minimizing the use of computing resources.

[0034] As an improved specific implementation method, the communication types in step 24 include HTTP devices, TCP devices, MQTT devices, and CoAP devices. The abstract method for the devices to respond back to the platform is as follows: the HTTP device assembles the request header and request body according to the protocol, the TCP device and MQTT device encode and assemble the message, and the CoAP device sends it through the UDP protocol;

[0035] The abstract method for stopping the device is as follows:

[0036] TCP devices and MQTT devices disconnect the TCP connection and release local handle resources. HTTP devices and CoAP devices do not perform any operations. Devices of different communication types need to be handled differently. For example, HTTP devices need to assemble the request header and request body according to the protocol, TCP devices need to encode and assemble the message, and CoAP devices need to send it through the UDP protocol.

[0037] An abstract method for stopping a device. Devices with different communication types have different processing methods. Devices with long connections such as TCP and MQTT need to disconnect the TCP connection and release local handle resources, while devices such as HTTP and CoAP do not need to be processed.

[0038] As an improved specific implementation method, the specific steps of timing triggering data reporting in step 3 are as follows:

[0039] Step 31: Determine whether the scheduled task has been triggered. If the task has been triggered, proceed to the next step. If the task has not been triggered, the CPU rejects the task and ends.

[0040] Step 32: Determine whether the number of available threads is less than the number of CPU cores. If so, select an available thread to execute the task and then terminate. If not, proceed to the next step.

[0041] Step 33: Determine whether the task queue of the available thread is full. If the task queue is not full, add the task to the blocking queue and wait for the available thread to execute it. If the task queue is full, proceed to the next step.

[0042] Steps 3 and 4 determine whether the number of available threads is less than 2 times the number of CPU cores. If the number of available threads is less than 2 times the number of CPU cores, create a thread and execute the task before ending. If the number of available threads is not less than 2 times the number of CPU cores, the CPU rejects the task and ends. By setting the above steps, it is possible to reduce the use of CPU resources by reusing thread technology when the scheduled task is triggered.

[0043] In summary, the method of this embodiment uses an abstract device to simulate an existing real device, can withstand a large amount of simulation, and has a more stable connection.

[0044] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiment. All technical solutions based on the concept of the present invention are within the scope of protection of the present invention. It should be noted that for those skilled in the art, various improvements and modifications that do not depart from the principles of the present invention should also be considered within the scope of protection of the present invention.

Claims

1. A method for simulating massive devices, characterized by: The steps include: Step 1: Read the operating parameters / configuration file; Step 2, create an abstract device according to the configuration file read in step 1, the specific steps are as follows: step 21, device attributes and event reporting methods parsed according to the configuration file; step 22, unified write attribute and command control processing rules according to the device attributes obtained in step 21; step 23, expand the rules written in step 22, and build in random number function, cumulative loop function and echo function; step 24, determine the communication type of the abstract device, determine the abstract method for the device to respond back to the platform according to the communication type, and determine the abstract method for stopping the device, wherein the abstract method for the device to respond back to the platform is specifically: the http device assembles the request header and request body according to the protocol, the tcp device and the mqtt device encode and assemble the message, and the coap device sends it through the udp protocol, and the abstract method for stopping the device is specifically: the tcp device and the mqtt device disconnect the tcp connection and release the local handle resources, and the http device and the coap device do not perform any operation; use the rules inside the abstract device to simulate the input feedback of the real device to achieve the effect of simulating the real device and minimize the computing resource usage; Step 3: Authenticate the abstract device created in step 2. If the authentication fails, the process ends immediately. If the authentication passes, the thread is bound to the device and data reporting is triggered according to the configuration timer. Execute steps 1, 2, and 3 in sequence to create an abstract device that only simulates the way devices interact on the Internet. Use a timed trigger data reporting method to reduce CPU thread usage and achieve large-scale simulation of abstract devices.

2. The method for simulating massive devices according to claim 1, wherein: The communication types in step 24 include http equipment, tcp equipment, mqtt equipment and coap equipment.

3. The method for simulating massive devices according to claim 1 or 2, characterized in that: The specific steps for timing triggering data reporting in step 3 are as follows: Step 31: Determine whether the scheduled task has been triggered. If the task has been triggered, proceed to the next step. If the task has not been triggered, the CPU rejects the task and ends. Step 32: Determine whether the number of available threads is less than the number of CPU cores. If so, select an available thread to execute the task and then terminate. If not, proceed to the next step. Step 33: Determine whether the task queue of the available thread is full. If the task queue is not full, add the task to the blocking queue and wait for the available thread to execute it. If the task queue is full, proceed to the next step. Step 3 and 4: Determine whether the number of available threads is less than 2 times the number of CPU cores. If the number of available threads is less than 2 times the number of CPU cores, create a thread and execute the task before ending. If the number of available threads is not less than 2 times the number of CPU cores, the CPU rejects the task and ends.

Citation Information

Patent Citations

  • Stability test method for equipment cloud management platform system

    CN111382080A

  • Simulation test method, device, equipment and medium

    CN114116356A