Data testing method and device based on relay node, electronic equipment and medium
By identifying devices in the network and establishing communication connections, data transmission, monitoring and testing are implemented, which solves the problem that traditional tools are difficult to test while maintaining the network structure, and improves the stability and flexibility of data testing.
Patent Information
- Application Number
- CN202510331899.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2045-03-20
AI Technical Summary
Traditional network packet capture tools are difficult to test while maintaining the existing network structure, and cannot maintain the original data communication status, cannot interfere with the data field values in real time, and cannot flexibly modify the data field types, which limits the efficiency and accuracy of data testing.
The relay node identifies the data sending device and the receiving device, establishes a communication connection, and forwards data in the relay mode to realize data transmission, monitoring and testing, and maintains the connection status regularly through the heartbeat monitoring port.
Without interfering with the original network, the stability and flexibility of data testing are achieved, the consistency of data transmission and reception rate and transmission methods are maintained, network traffic and processing delays are avoided, and network communication performance and reliability are ensured.
Smart Images

Figure CN119853835A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to technical fields such as data monitoring and data testing. Specifically, the present disclosure relates to a data testing method, device, electronic device and medium based on a relay node. Background Art
[0002] In modern network environments, it is essential to test and monitor the accuracy and performance of data transmission, especially without interfering with normal business operations. Ensuring the stability and real-time performance of data communication is key in the software development and testing phase. Regardless of the network data communication protocol used, the reliability of network communication is the basis for normal function operation and accurate data transmission.
[0003] However, although traditional network packet capture and monitoring software can provide data monitoring functions, on the one hand, traditional network packet capture mainly realizes direct communication between device A and device B or device B and device A. This mode is difficult to test under the premise of maintaining the existing network structure, which not only limits the efficiency of development and testing, but may also affect the stability of key business systems. On the other hand, traditional network packet capture generally has the shortcomings of being unable to maintain the original data communication status, unable to intervene in the data field value in real time, and unable to flexibly modify the data field type.
[0004] In view of the above problems, a flexible and accurate data testing solution is urgently needed. Summary of the invention
[0005] The embodiments of the present disclosure provide a data testing method, device, electronic device and medium based on a relay node. Through the relay node, the network can be automatically accessed and seamlessly intervened in the network without interfering with the original network to perform data transmission, data monitoring and data testing, which not only reduces the impact on the original network, but also improves the stability and flexibility of data testing. The technical solutions provided by the present disclosure are as follows: In a first aspect, an embodiment of the present disclosure provides a data testing method based on a relay node, the method being performed by the relay node, the method comprising: Identify a data sending device and a data receiving device based on the relay node; Based on the heartbeat monitoring port of the relay node, receiving the handshake data sent by the data sending device and the data receiving device respectively, and establishing a communication connection between the relay node and the data sending device, and between the relay node and the data receiving device based on the handshake data; In the case where the data receiving device switches the original IP address to the test IP address, the IP address of the relay node is switched to the original IP address of the data receiving device to enter the relay mode, wherein the test IP address is a predefined IP address for data testing. In the relay mode, the relay node forwards the data sent by the data sending device to the data receiving device, and the relay node forwards the data sent by the data receiving device to the data sending device. The relay node is also used to periodically send a first heartbeat data packet to the data sending device and the data receiving device through the heartbeat monitoring port to ensure the connection status between the relay node and the data sending device, and between the relay node and the data receiving device. In the above relay mode, data transmission, data monitoring, and data testing are performed.
[0006] In a second aspect, an embodiment of the present disclosure provides a data testing device based on a relay node, the device comprising a relay node, and the device comprises: An identification module, used to identify a data sending device and a data receiving device based on the above relay node; A first processing module, configured to receive handshake data sent by the data sending device and the data receiving device respectively based on the heartbeat monitoring port of the relay node, and to establish a communication connection between the relay node and the data sending device, and between the relay node and the data receiving device based on the handshake data; a second processing module, configured to switch the IP address of the relay node to the original IP address of the data receiving device to enter a relay mode when the data receiving device switches the original IP address to a test IP address, wherein the test IP address is a predefined IP address for data testing, and in the relay mode, the relay node forwards the data sent by the data sending device to the data receiving device, and the relay node forwards the data sent by the data receiving device to the data sending device, and the relay node is further configured to periodically send a first heartbeat data packet to the data sending device and the data receiving device through the heartbeat monitoring port to ensure the connection status between the relay node and the data sending device, and between the relay node and the data receiving device; The third processing module is used to perform data transmission, data monitoring, and data testing in the above relay mode.
[0007] In a third aspect, an embodiment of the present disclosure provides an electronic device, including a processor and a memory, wherein the processor and the memory are connected to each other; The memory is used to store computer programs; The processor is configured to execute the method provided in the first aspect when calling the computer program.
[0008] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the method provided in the first aspect above.
[0009] In a fifth aspect, an embodiment of the present disclosure provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in the first aspect above.
[0010] In the disclosed embodiment, a data sending device and a data receiving device are identified through a relay node, and based on the heartbeat monitoring port of the relay node, a communication connection is established between the relay node and the data sending device through the received handshake data sent by the data sending device, and a communication connection is established between the relay node and the data receiving device through the received handshake data sent by the data receiving device; when the data receiving device and the relay node establish a communication connection, the data receiving device switches its own original IP address to a test IP address, and switches the IP address of the relay node to the original IP address of the data receiving device, and then enters the relay mode; in the relay mode, the data sending device sends data to the relay node, the relay node forwards the data sent by the data sending device to the data receiving device, the data receiving device sends data to the relay node, and the relay node forwards the data sent by the data receiving device to the data sending device, and the relay node is also used to periodically send a first heartbeat data packet to the data sending device and the data receiving device through the heartbeat monitoring port to ensure the connection status of the relay node and the data sending device, and the relay node and the data receiving device; in the relay mode, data transmission, data monitoring and data testing are performed. Through the embodiments of the present disclosure, the relay node can automatically access the original network and seamlessly intervene in the network without interfering with the original network. In the relay mode, it can perform data transmission, data monitoring and data testing, and can maintain the consistency of data reception and transmission rates and transmission methods, avoiding the introduction of additional network traffic and processing delays due to data packet mirroring or interception, ensuring that network communication performance and reliability are not affected, and improving the stability, flexibility and reliability of data testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for describing the embodiments of the present disclosure are briefly introduced below.
[0012] Figure 1 A schematic diagram of a flow chart of a data testing method based on a relay node provided in an embodiment of the present disclosure; Figure 2 A schematic diagram of a communication structure based on a relay node provided in an embodiment of the present disclosure; Figure 3 A flowchart of another data testing method based on a relay node provided in an embodiment of the present disclosure; Figure 4 A schematic diagram of a data packet parsing code provided by an embodiment of the present disclosure; Figure 5 A schematic diagram of a process of exiting a relay mode provided in an embodiment of the present disclosure; Figure 6 A schematic diagram of the structure of a data testing device based on a relay node provided in an embodiment of the present disclosure; Figure 7 A schematic diagram of the structure of an electronic device for a data testing method for a relay node provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0013] The embodiments of the present disclosure are described below in conjunction with the drawings in the present disclosure. It should be understood that the implementation methods described below in conjunction with the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present disclosure and do not constitute a limitation on the technical solutions of the embodiments of the present disclosure.
[0014] In order to make the objectives, technical solutions and advantages of the present disclosure more clear, the embodiments of the present disclosure will be further described in detail below with reference to the accompanying drawings.
[0015] At present, traditional solutions generally use general packet capture software for data testing. Although these technical solutions can meet the requirements of network data monitoring to a certain extent, they generally have the shortcomings of being unable to maintain the original data communication status, unable to intervene in the data field values in real time, and unable to flexibly modify the data field type.
[0016] Among them, the traditional general packet capture solution has the following main disadvantages: 1. Unable to maintain the original data communication status: Traditional packet capture tools cannot completely avoid interfering with the original network structure and the normal flow of data when monitoring data. These tools often capture data by mirroring ports or intercepting data packets, which may introduce additional network traffic and processing delays, thereby affecting the performance and reliability of normal network communications.
[0017] 2. Inability to manually intervene in the test field values: Traditional tools can only perform passive monitoring and lack the ability to intervene and replace data in real time. This limitation makes it impossible to actively adjust the field values in the data stream during the test, making it difficult to simulate various complex network conditions and abnormal situations, affecting the flexibility and effectiveness of the test.
[0018] 3. Unable to modify data field types: Traditional packet capture tools have limitations in monitoring and analyzing data packets, and cannot flexibly modify field types within data packets. This limits testers’ ability to set and control data of specific interest bits, making it difficult to meet the needs of accurate testing.
[0019] In order to solve the above problems, further improved and innovative technical methods are necessary. The data testing method based on relay nodes in the embodiment of the present disclosure can meet higher testing flexibility and accuracy requirements. Figure 1 , Figure 1 A schematic diagram of a data testing method based on a relay node provided in an embodiment of the present disclosure, such as Figure 1 As shown, the method includes: Step S101, identifying a data sending device and a data receiving device based on the above relay node; Step S102, based on the heartbeat monitoring port of the relay node, receiving the handshake data sent by the data sending device and the data receiving device respectively, and establishing a communication connection between the relay node and the data sending device, and between the relay node and the data receiving device based on the handshake data; Step S103, in the case where the data receiving device switches the original IP address to the test IP address, the IP address of the relay node is switched to the original IP address of the data receiving device to enter the relay mode, wherein the test IP address is a predefined IP address for data testing, and in the relay mode, the relay node forwards the data sent by the data sending device to the data receiving device, and the relay node forwards the data sent by the data receiving device to the data sending device, and the relay node is further used to periodically send a first heartbeat data packet to the data sending device and the data receiving device through the heartbeat monitoring port to ensure the connection status of the relay node and the data sending device, and the relay node and the data receiving device; Step S104, performing data transmission, data monitoring, and data testing in the above relay mode.
[0020] Optionally, for the convenience of description, the data sending device can be recorded as device A, and the data receiving device can be recorded as device B. By inserting a relay node between device A and device B, or inserting a relay node between device B and device A, a communication architecture of "device A-relay node-device B" or "device B-relay node-device A" is formed. Figure 2 , Figure 2 A schematic diagram of a communication structure based on relay nodes is provided for an embodiment of the present disclosure, wherein the relay nodes are responsible for bridging and monitoring communication data flows, while supporting dynamic data packet intervention.
[0021] The disclosed embodiment provides an online test data communication replacement protocol based on a relay node. When the protocol is applied, in addition to creating a normal data transceiver port during programming, a heartbeat monitoring port needs to be created. It is necessary to ensure that the relay node, device A, and device B are in the same test network. When the relay node is connected to the network, it will automatically detect and identify the target device in the network, namely device A and device B. In other words, the data sending device and the data receiving device can be automatically identified based on the relay node.
[0022] In an optional embodiment, the identifying of the data sending device and the data receiving device based on the relay node includes: The heartbeat monitoring port is monitored via the User Datagram Protocol (UDP) and a third heartbeat signal is sent periodically. If a target heartbeat data packet based on the third heartbeat signal feedback is received, the target heartbeat data packet is parsed to obtain identification information of the target heartbeat data packet; Determine the sending device corresponding to the target heartbeat data according to the identification information; If the sending device corresponding to the identification information is the data sending device, determining that the relay node recognizes the data sending device; Alternatively, if the sending device corresponding to the identification information is the data receiving device, it is determined that the relay node recognizes the data receiving device.
[0023] Optionally, the relay node can continuously monitor the heartbeat monitoring port through the User Datagram Protocol (UDP) communication method, and send a heartbeat signal (i.e., the third heartbeat signal) periodically. When receiving a feedback heartbeat packet (i.e., the target heartbeat data packet), the packet_id value (i.e., the identification information) in the heartbeat packet is parsed to confirm which target device fed back the heartbeat packet. If the packet_id value belongs to device A, it is determined that the relay node has identified device A. If the packet_id value belongs to device B, it is determined that the relay node has identified device B. Among them, the unique identity document (ID) that identifies device A and device B is identified by packet_id.
[0024] After identifying device A and device B, it is necessary to confirm the connection status between the relay node and device A and device B. The connection status between the relay node and device A and device B can be confirmed in the following manner.
[0025] In an optional embodiment, the heartbeat monitoring port based on the relay node receives handshake data sent by the data sending device and the data receiving device respectively, and establishes a communication connection between the relay node and the data sending device, and between the relay node and the data receiving device based on the handshake data, including: Performing data monitoring based on the heartbeat monitoring port, and in the case of monitoring the handshake data, performing data identification on the handshake data to obtain a data identifier of the handshake data; If the data identifier belongs to the data sending device, confirm whether the first handshake signal and the first heartbeat signal contained in the handshake data are in a confirmation state, and if so, send first confirmation handshake information to the data sending device, and the data sending device receives the first confirmation handshake information to establish a communication connection between the relay node and the data sending device; If the above-mentioned data identifier belongs to the above-mentioned data receiving device, confirm whether the second handshake signal and the second heartbeat signal contained in the above-mentioned handshake data are in a confirmation state. If so, send second confirmation handshake information to the above-mentioned data receiving device, and the above-mentioned data receiving device receives the above-mentioned second confirmation handshake information to establish a communication connection between the above-mentioned relay node and the above-mentioned data receiving device.
[0026] Optionally, device A and device B establish a communication connection by sending a handshake signal (i.e., the handshake data) to the heartbeat monitoring port of the relay node. The relay node is responsible for monitoring the heartbeat monitoring port and parsing the received packet (i.e., the handshake data) to obtain the ID (packet_id) of the corresponding device in the packet, i.e., the data identifier of the handshake data. If the ID (packet_id) belongs to device A, it is confirmed whether the first handshake signal and the first heartbeat signal contained in the handshake data are both in the confirmation state, i.e., whether the handshake data sent by device A contains the "handshake" field and its state is "True", and whether the handshake data sent by device A contains the "heartbeat" field and its state is "True". If both are in the confirmation state, i.e., "True", the relay node will return a heartbeat confirmation packet to device A to establish a handshake and connection between the relay node and device A.
[0027] Similarly, if the ID (packet_id) of the corresponding device in the packet obtained by the relay node belongs to device B, then it confirms whether the second handshake signal and the second heartbeat signal contained in the handshake data are both in the confirmation state, that is, confirms whether the handshake data sent by device B contains the "handshake" field and its state is "True", and confirms whether the handshake data sent by device B contains the "heartbeat" field and its state is "True". If both are in the confirmation state, that is, "True", the relay node will return a heartbeat confirmation packet to device B to establish a handshake and connection between the relay node and device B.
[0028] After the relay node successfully shakes hands with the data sending device (i.e. device A) and the data receiving device (i.e. device B), the relay node will record the detected IP address of device B, where the IP address refers to the Internet Protocol Address (IP for short). Once device B establishes a connection with the relay node, device B will switch the data receiving address (i.e. the original IP address mentioned above) to the test mode IP address (i.e. the test IP address mentioned above), and the data port remains unchanged. At this time, the relay node creates a new connection and automatically matches, and the data receiving address of the relay node (i.e. the IP address of the relay node) will switch to the original IP address of device B.
[0029] By changing the address, the original direct communication between device A and device B is changed to device A sending data to the relay node, and then the relay node forwards the data to device B. In addition, the original direct communication between device B and device A is changed to device B sending data to the relay node, and then the relay node forwards the data to device A, thus entering the relay mode. The relay node also regularly sends heartbeat packets to device A and device B through the heartbeat monitoring port to ensure the connection status between the relay node and device A, and between the relay node and device B.
[0030] In the relay mode, data transmission, data monitoring, and data testing are performed. When data transmission, data monitoring, and data testing are completed, the relay mode is exited, and the data sending device and the data receiving device will return to the original communication mode.
[0031] Through the disclosed embodiments, in relay mode, by modifying the IP address of the data receiving device, the relay node can seamlessly intervene in the original communication link and implement full-process data packet monitoring and intervention. When the test is completed, the system can automatically restore the device to its original state, thereby ensuring that the impact of the test process on the network topology and performance is minimized.
[0032] In an optional embodiment, in the above relay mode, performing data monitoring includes: Parsing the received unparsed data according to the data packet parsing code to obtain the parsed actual data, wherein the data packet parsing code is determined according to a predefined data packet format specification table, the data packet format specification table is used to define at least one specific character, the type of each of the specific characters, the meaning of each of the specific characters and the number of bytes occupied by each of the specific characters, and the unparsed data includes the data sent by the data sending device and the data sent by the data receiving device; The actual data after analysis is displayed on the data monitoring interface of the relay node, so that the target user can monitor the data in real time.
[0033] Optionally, the relay node may define a data packet format specification table according to the data packet format, and use characters in a specific format to accurately define the structure of the data packet. The characters defined in the data packet format specification table include but are not limited to the characters shown in Table 1: Among them, each character listed in the character column in Table 1 is the at least one specific character mentioned above, and Table 1 defines the type, meaning and number of bytes occupied by the character (ie, the specific character).
[0034] According to the data packet format specification table shown in Table 1, the tester generates a data packet parsing code by manually combining these characters, so that the structure of the data packet can be flexibly adjusted according to different test scenarios, data types and data lengths, thereby achieving efficient test data communication replacement.
[0035]
[0036] Table 1 In actual applications, similar to traditional data communication protocols, the relay node puts the received data packet (i.e., unparsed data) into a buffer, and splits and parses the data in the buffer according to the above-mentioned data packet parsing code, thereby obtaining the actual value of each variable of the data in the buffer (i.e., actual data), which is used for data monitoring (i.e., data monitoring) and super control. For details about super control, please refer to the following description.
[0037] Then, the actual data after parsing is displayed on the data monitoring interface of the relay node, so that the target user (i.e., the tester) can monitor the data in real time.
[0038] Through the embodiments of the present disclosure, network data can be monitored efficiently and flexibly in real time, and the impact on network topology and performance is effectively reduced, which greatly facilitates network data testing and helps to improve network performance and data transmission accuracy.
[0039] In an optional embodiment, in the above relay mode, performing data testing includes: Receive test data sent by the target user through the data control interface; If the data field of the data sending device is in an overriding state, sending the test data to the data receiving device through the relay node to implement a test on the data sending device; If the data field of the data receiving device is in an overriding state, the test data is sent to the data sending device via the relay node to implement a test on the data receiving device.
[0040] Optionally, in relay mode, the tester (i.e., the target user mentioned above) can monitor the data packet content parsed by the relay node, which is sent by the data sending device and the data receiving device. During the monitoring process, the tester can override the interest bit.
[0041] When performing over-control of the interest bit, the tester can input test data through the data control interface of the relay node. If the data field of the data sending device is in the over-control state, the relay node can send the test data to the data receiving device, thereby realizing the test of the data sending device; if the data field of the data receiving device is in the over-control state, the relay node can send the test data to the data sending device, thereby realizing the test of the data receiving device.
[0042] Through the embodiments of the present disclosure, real-time data intervention and monitoring are achieved, and testers can flexibly set interest bit test data, monitor data transmission in real time, obtain data packet status and content, and achieve instant intervention and adjustment.
[0043] In an optional embodiment, in the above relay mode, performing data transmission includes: receiving and buffering the command data sent by the data sending device, and sending the command data to the data receiving device; When the data receiving device receives the command data and sends feedback data to the relay node according to the command data, the feedback data is received and buffered, and the feedback data is sent to the data sending device so that the data sending device receives the feedback data.
[0044] Optionally, in relay mode, the data sending device sends command data to the relay node. After receiving the command data, the relay node caches the command data and sends the command data to the data receiving device. After receiving the command data, the data receiving device obtains feedback data based on the content of the command data and sends the feedback data to the relay node. After receiving the feedback data, the relay node caches the feedback data and sends the feedback data to the data sending device. The data sending device receives the feedback data.
[0045] Through the embodiments of the present disclosure, when data is transmitted in relay mode, the interactive data between the data sending device and the data receiving device can be forwarded via the relay node. The consistency of the data transmission and reception rate and the transmission method can be maintained through the relay node, avoiding the introduction of additional network traffic and processing delays due to data packet mirroring or interception, thereby ensuring that the network communication performance and reliability are not affected.
[0046] In an optional embodiment, the above relay mode is exited in the following manner: If the relay node does not receive the second heartbeat data packet sent by the data sending device within a preset time, it is determined that the relay node and the data sending device have not established a communication connection; If the relay node does not receive the third heartbeat data packet sent by the data receiving device within the preset time, it is determined that the relay node and the data receiving device have not established a communication connection; When the relay node and the data sending device do not establish a communication connection, and the relay node and the data receiving device do not establish a communication connection, exit the relay mode; Alternatively, receiving a connection stop command sent by the target user through the data control interface; Sending the connection stop command to the data sending device and the data receiving device respectively, wherein the connection stop command is used to instruct the data sending device and the data receiving device to disconnect the communication connection with the relay node; When receiving the disconnection confirmation messages respectively sent by the data sending device and the data receiving device based on the connection stop command, the relay mode is exited.
[0047] Optionally, when the test is finished, exit relay mode by: Method 1: The tester sends a connection stop command through the data control interface. The connection stop command can be triggered by clicking Disconnect on the data control interface. At this time, the relay node sends the connection stop command to the data sending device and the data receiving device respectively. The connection stop command contains a heartbeat data packet handshake signal, and the "handshake" field in the signal is "False". After the data sending device and the data receiving device receive the connection stop command, they return a heartbeat confirmation data packet to the relay node (that is, the above-mentioned confirmation disconnection message). At this time, the system will trigger the relay node to exit the relay mode. After exiting the relay mode, the relay node will stop monitoring and intervening in the data packet and restore the original data transmission path.
[0048] Mode 2: If the relay node does not detect the second heartbeat data packet sent by the data sending device within a preset time (such as 30 seconds), it is confirmed that the data sending device and the relay node are disconnected; if the relay node does not detect the third heartbeat data packet sent by the data receiving device within a preset time (such as 30 seconds), it is confirmed that the data receiving device and the relay node are disconnected. When it is confirmed that the data sending device and the relay node are disconnected, and the data receiving device and the relay node are disconnected, the relay mode is exited.
[0049] After exiting the relay mode, the data sending device and the data receiving device will restore the original data transmission path and communicate directly without passing through the relay node. The system will ensure that the network topology and performance are restored to the state before the test, greatly reducing the impact of the test process on the network. Since the software program of the relay node is simple and efficient, it occupies very few resources and has extremely low latency, the impact of the entire process on the original network topology and performance can be ignored.
[0050] Through the embodiments of the present disclosure, when exiting the relay mode, the impact of the test process on the network can be greatly reduced, and the impact on the performance of the original network topology can be reduced.
[0051] In an optional embodiment, the above method further includes: In the case of exiting the relay mode, the data receiving device switches the test IP address of the data receiving device to the original IP address according to a preset logic; Alternatively, in the case of exiting the relay mode, the data receiving device receives a recovery instruction and switches the test IP address of the data receiving device to the original IP address.
[0052] Optionally, the above pre-set logic is: when the data receiving device establishes a communication connection with the relay node, the data receiving device uses the test IP address for data transmission; when the data receiving device is disconnected from the relay node, the data receiving device uses the original IP address for data transmission.
[0053] If the relay mode is exited through the above method 2, the data receiving device and the relay node are disconnected. At this time, the data receiving device will switch the test IP address to the original IP address for communication according to the pre-set logic.
[0054] If the relay mode is exited through the above method 1, the data receiving device can switch the test IP address to the original IP address for data transmission by receiving the recovery instruction.
[0055] Through the disclosed embodiment, after exiting the relay mode, the data sending device will switch to the original IP address for data transmission, ensuring that the original data transmission path can be restored, reducing the impact of data testing on the original data transmission.
[0056] The data testing method based on the relay node in the embodiment of the present disclosure is described in detail below in conjunction with an embodiment. For the convenience of description, the data sending device is recorded as device A, and the data receiving device is recorded as device B.
[0057] 1. The communication link example is as follows: In this embodiment, device A sends a command data packet to device B every second (the command data packet corresponds to the command data sent by the above-mentioned data sending device), which is defined as follows. After receiving the data packet, device B returns an identical feedback data packet to A (the feedback data packet corresponds to the feedback data sent by the above-mentioned data receiving device): Struct dataPackage { Float dataTest1; Int dataTest2; Char dataTest3; Bool dataTest4; } The data packet contains four types of data, namely floating point, integer, character and Boolean, and each data packet is 10 bytes long.
[0058] 2. Communication port and address description: (1) Device A: Data receiving port: 5000; Data sending port: 5001; Heartbeat monitoring port: 6000 IP address 192.168.1.10; (2) Relay Node: Heartbeat monitoring port: 6000; Data receiving / sending port: automatically set according to the data port of device A and device B when establishing a handshake (in this embodiment, the receiving / sending port will be automatically set to 5001 / 5000 when establishing a connection) IP address 192.168.1.20; (3) Device B: Heartbeat monitoring port: 6000; Data receiving port: 5001; Data sending port: 5000; IP address 192.168.1.11 (corresponds to the original IP address above); Test IP address: 192.168.1.1.
[0059] three, Figure 3 A flow chart of another method based on relay node data testing provided by an embodiment of the present disclosure, such as Figure 3 As shown, the steps for device A and device B to establish communication connections with the relay node are: Among them, device A and device B establish a communication connection by sending handshake data to the relay node respectively. The handshake data is a heartbeat data packet. The definition of the heartbeat data packet is as follows in Table 2:
[0060] Table 2 The embodiments of the present disclosure do not impose any limitation on the fields included in the heartbeat data packet. In actual applications, fields can be added according to test requirements.
[0061] Step S301: Device A sends data content to device B (i.e. Figure 3 In the send command data packet (IP: 192.168.1.11, port: 5001), at the same time, device A sends the handshake and heartbeat request fields handshake=True, heartbeat=True to relay node C. The data packet (i.e., handshake data) sent by device A to relay node C contains the fields shown in Table 3:
[0062] Table 3 Step S302: Device B sends data content to device A (i.e. Figure 3 In the return feedback data packet (IP: 192.168.1.10, port: 5000), at the same time, device B sends the handshake and heartbeat request fields handshake=True, heartbeat=True to relay node C. The data packet (i.e., handshake data) sent by device B to relay node C contains the fields shown in Table 4:
[0063] Table 4 Step S303: Relay node C receives data packets (i.e. the above handshake data) from device A and device B respectively and processes: 1. Relay node C listens on port 6000 and receives heartbeat packets from device A and device B. Here, the packet ID (packet_id) is identified to distinguish which device sent the packet.
[0064] 2. Relay node C identifies the packet ID (packet_id) to distinguish which device sent the data packet, and checks the handshake field and heartbeat field in the data packet. If both the handshake and heartbeat fields are True, it means this is a handshake and heartbeat request.
[0065] 3. When the identified data packet ID=01, it indicates a heartbeat data packet sent from device A. When the handshake field (corresponding to the above-mentioned first handshake signal) and the heartbeat field (corresponding to the above-mentioned first heartbeat signal) in the received data packet are parsed to be True (i.e., in a confirmed state), relay node C generates a handshake confirmation packet (corresponding to the above-mentioned first handshake confirmation information) and sends it to port 5000 of device A to establish a communication connection between the relay node and device A.
[0066] 4. When the identified data packet ID=02, it indicates a heartbeat data packet sent from device B. When the handshake field (corresponding to the above-mentioned second handshake signal) and the heartbeat field (corresponding to the above-mentioned second heartbeat signal) in the received data packet are parsed to be True (i.e., in a confirmed state), relay node C generates a handshake confirmation packet (corresponding to the above-mentioned second handshake confirmation information) and sends it to port 5001 of device B to establish a communication connection between the relay node and device B.
[0067] 5. At this point, the receiving end of device B will use the test IP address (192.168.1.1) to receive data; relay node C creates a new connection and uses the actual IP address of device B (192.168.1.11) (that is, the original IP address of device B) and port (5001) for communication.
[0068] 6. Once relay node C has established a handshake connection with both device A and device B, the communication mode is switched from "device A-device B, device B-device A" to "device A-relay node-device B, device B-relay node-device A", and the relay mode is entered.
[0069] Step S304: Data monitoring (ie data surveillance) and data testing: According to the above data packet format specification table, the tester can set the data packet parsing code to "fic?", where the data packet parsing code can refer to Figure 4 , Figure 4 A schematic diagram of a data packet parsing code provided for an embodiment of the present disclosure. After the relay node receives a data packet sent by device A or device B (i.e., the unparsed data mentioned above), it caches the received data, parses it according to the definition of "fic?", and splits each data packet of length 10 into a floating point type, an integer type, a character type, and a Boolean type, thereby obtaining the actual data value of each variable (i.e., the actual data mentioned above), which can be used for data monitoring (i.e., data monitoring).
[0070] If the tester wants to override the value of a data variable (for example, he wants to modify the value of dataTest1), he can directly modify the value of the "f" field in the "fic?" field before sending the data out, and then send it out to achieve override of the data.
[0071] The process of data monitoring based on relay nodes is as follows: Step S3041, device A sends a command data packet to the relay node; Step S3042, device B sends a feedback data packet to the relay node; Step S3043, the tester sets the data packet parsing code of device A and device B to the relay node through the data control interface; In step S3044, the relay node parses and caches the command data packet sent by device A (ie, the command data) and the feedback data packet sent by device B (ie, the feedback data) according to the data packet parsing code.
[0072] The process of data testing (override control) based on relay nodes is as follows: Step S3045, the tester can monitor the data packet contents of device A and device B parsed by the relay node and can perform overriding of the interest bit, mainly by sending overriding command (feedback) data to the relay node; Step S3046, the relay node sends the command data packet of the device A after the control to the device B; Step S3047: The feedback data packet of the device B after the supervising is sent to the device A by the relay node.
[0073] Through the embodiments of the present disclosure, efficient, flexible and automated online data testing can be achieved, which not only realizes real-time monitoring and intervention of network data, but also effectively reduces the impact on network topology and performance, provides great convenience for network data testing, and helps to improve network performance and data transmission accuracy. The main technical effects are as follows: 1. No interference with the original network structure: The automatic access and exit of relay nodes are realized through the replacement protocol, which allows seamless access to the network without affecting the original network topology; 2. Maintain data communication consistency: In relay mode, the relay node can maintain the consistency of data transmission and reception rate and transmission method, avoiding the introduction of additional network traffic and processing delays due to data packet mirroring or interception, ensuring that network communication performance and reliability are not affected; 3. Real-time data intervention and monitoring: Testers can flexibly set test data of interest, monitor data transmission in real time, obtain data packet status and content, and implement immediate intervention and adjustment; 4. Flexible generation of data packet parsing codes: Relay nodes can define the data packet structure through specific format string characters according to the data packet format specification table. Testers can freely combine these characters to generate data packet parsing codes as needed to adapt to different test requirements and scenarios.
[0074] After completing data monitoring and data testing, you can exit the relay mode and restore the original network transmission mode. Figure 5 , Figure 5 A schematic diagram of a process of exiting a relay mode provided in an embodiment of the present disclosure, such as Figure 5 As shown, the main process is as follows: The relay node detects heartbeat data through the heartbeat monitoring port. If it does not receive heartbeat packets (heartbeat=True) from device A and device B for more than 30 seconds, the relay node automatically disconnects. At this time, device A and device B exit the relay node, restore the original IP address (192.168.1.11) of the receiving end of device B, and the transmission mode returns to direct transmission mode.
[0075] Alternatively, manually click on the disconnect button through the data control interface, and the relay node sends a disconnect message (handshake=False, heartbeat=False). Figure 5 The disconnection packet shown in (corresponding to the above connection stop command), device A and device B confirm receipt and return a disconnection message (i.e. Figure 5 The disconnection packet shown in Figure 1 is sent to the relay node to confirm the disconnection. The original IP address (192.168.1.11) of the receiving end of device B is restored, and the transmission mode is restored to direct transmission mode.
[0076] After exiting the relay mode, the system will ensure that the network topology and performance are restored to the state before the test, greatly reducing the impact of the test process on the network. Since the software program of the relay node is simple and efficient, it occupies very low resources and has extremely low latency, the impact of the entire process on the original network topology and performance can be ignored.
[0077] The present disclosure provides a data testing device based on a relay node, the device comprising a relay node, such as Figure 6 As shown, the device 60 may include: an identification module 601, a first processing module 602, a second processing module 603 and a third processing module 604, wherein: An identification module 601, configured to identify a data sending device and a data receiving device based on the above-mentioned relay node; The first processing module 602 is used to receive the handshake data sent by the data sending device and the data receiving device respectively based on the heartbeat monitoring port of the relay node, and establish a communication connection between the relay node and the data sending device, and between the relay node and the data receiving device based on the handshake data; The second processing module 603 is used for switching the IP address of the relay node to the original IP address of the data receiving device to enter the relay mode when the data receiving device switches the original IP address to the test IP address, wherein the test IP address is a predefined IP address for data testing. In the relay mode, the relay node forwards the data sent by the data sending device to the data receiving device, and the relay node forwards the data sent by the data receiving device to the data sending device. The relay node is also used for periodically sending a first heartbeat data packet to the data sending device and the data receiving device through the heartbeat monitoring port to ensure the connection status between the relay node and the data sending device, and between the relay node and the data receiving device. The third processing module 604 is used to perform data transmission, data monitoring, and data testing in the above relay mode.
[0078] In an optional embodiment, the third processing module 604 is specifically used for: Parsing the received unparsed data according to the data packet parsing code to obtain the parsed actual data, wherein the data packet parsing code is determined according to a predefined data packet format specification table, the data packet format specification table is used to define at least one specific character, the type of each of the specific characters, the meaning of each of the specific characters and the number of bytes occupied by each of the specific characters, and the unparsed data includes the data sent by the data sending device and the data sent by the data receiving device; The actual data after analysis is displayed on the data monitoring interface of the relay node, so that the target user can monitor the data in real time.
[0079] In an optional embodiment, the third processing module 604 is specifically used for: Receive test data sent by the target user through the data control interface; If the data field of the data sending device is in an overriding state, sending the test data to the data receiving device through the relay node to implement a test on the data sending device; If the data field of the data receiving device is in an overriding state, the test data is sent to the data sending device via the relay node to implement a test on the data receiving device.
[0080] In an optional embodiment, the third processing module 604 is specifically used for: receiving and buffering the command data sent by the data sending device, and sending the command data to the data receiving device; When the data receiving device receives the command data and sends feedback data to the relay node according to the command data, the feedback data is received and buffered, and the feedback data is sent to the data sending device so that the data sending device receives the feedback data.
[0081] In an optional embodiment, the first processing module 602 is specifically used for: Performing data monitoring based on the heartbeat monitoring port, and in the case of monitoring the handshake data, performing data identification on the handshake data to obtain a data identifier of the handshake data; If the data identifier belongs to the data sending device, confirm whether the first handshake signal and the first heartbeat signal contained in the handshake data are in a confirmation state, and if so, send first confirmation handshake information to the data sending device, and the data sending device receives the first confirmation handshake information to establish a communication connection between the relay node and the data sending device; If the above-mentioned data identifier belongs to the above-mentioned data receiving device, confirm whether the second handshake signal and the second heartbeat signal contained in the above-mentioned handshake data are in a confirmation state. If so, send second confirmation handshake information to the above-mentioned data receiving device, and the above-mentioned data receiving device receives the above-mentioned second confirmation handshake information to establish a communication connection between the above-mentioned relay node and the above-mentioned data receiving device.
[0082] In an optional embodiment, the apparatus further includes a fourth processing module, configured to exit the relay mode through the fourth processing module in the following manner: If the relay node does not receive the second heartbeat data packet sent by the data sending device within a preset time, it is determined that the relay node and the data sending device have not established a communication connection; If the relay node does not receive the third heartbeat data packet sent by the data receiving device within the preset time, it is determined that the relay node and the data receiving device have not established a communication connection; When the relay node and the data sending device do not establish a communication connection, and the relay node and the data receiving device do not establish a communication connection, exit the relay mode; Alternatively, receiving a connection stop command sent by the target user through the data control interface; Sending the connection stop command to the data sending device and the data receiving device respectively, wherein the connection stop command is used to instruct the data sending device and the data receiving device to disconnect the communication connection with the relay node; When receiving the disconnection confirmation messages respectively sent by the data sending device and the data receiving device based on the connection stop command, the relay mode is exited.
[0083] In an optional embodiment, the above device further includes a switching module, which is used to: In the case of exiting the relay mode, the data receiving device switches the test IP address of the data receiving device to the original IP address according to a preset logic; Alternatively, in the case of exiting the relay mode, the data receiving device receives a recovery instruction and switches the test IP address of the data receiving device to the original IP address.
[0084] In an optional embodiment, the identification module is specifically used for: The heartbeat monitoring port is monitored via the User Datagram Protocol (UDP) and a third heartbeat signal is sent periodically. If a target heartbeat data packet based on the third heartbeat signal feedback is received, the target heartbeat data packet is parsed to obtain identification information of the target heartbeat data packet; Determine the sending device corresponding to the target heartbeat data according to the identification information; If the sending device corresponding to the identification information is the data sending device, determining that the relay node recognizes the data sending device; Alternatively, if the sending device corresponding to the identification information is the data receiving device, it is determined that the relay node recognizes the data receiving device.
[0085] The device of the embodiment of the present disclosure can execute the method provided by the embodiment of the present disclosure, and its implementation principle is similar and has corresponding technical effects. The actions performed by each module in the device of each embodiment of the present disclosure correspond to the steps in the method of each embodiment of the present disclosure. For the detailed functional description of each module of the device, please refer to the description in the corresponding method shown in the previous text, which will not be repeated here.
[0086] An embodiment of the present disclosure provides an electronic device (computer device / equipment / system), including a memory, a processor, and a computer program stored in the memory, and the processor executes the above computer program to implement the steps of the method provided in any optional embodiment of the present disclosure.
[0087] In an alternative embodiment, an electronic device is provided, such as Figure 7 As shown, Figure 7 The electronic device 4000 shown includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, such as through a bus 4002. Optionally, the electronic device 4000 may also include a transceiver 4004, which may be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present disclosure.
[0088] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of the present invention. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0089] The bus 4002 may include a path to transmit information between the above components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0090] The memory 4003 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation herein.
[0091] The memory 4003 is used to store the computer program for executing the embodiment of the present disclosure, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the computer program stored in the memory 4003 to implement the steps shown in the above method embodiment.
[0092] An embodiment of the present disclosure provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented.
[0093] The embodiments of the present disclosure also provide a computer program product, including a computer program, which can implement the steps and corresponding contents of the aforementioned method embodiments when executed by a processor.
[0094] It should be understood that, although the flowchart of the embodiment of the present disclosure indicates each operation step by arrows, the implementation order of these steps is not limited to the order indicated by the arrows. Unless clearly stated herein, in some implementation scenarios of the embodiment of the present disclosure, the implementation steps in each flowchart can be executed in other orders according to demand. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage in these sub-steps or stages can also be executed at different times. In scenarios with different execution times, the execution order of these sub-steps or stages can be flexibly configured according to demand, and the embodiment of the present disclosure does not limit this.
[0095] The above is only an optional implementation method for some implementation scenarios of the present disclosure. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the scheme of the present disclosure, other similar implementation methods based on the technical ideas of the present disclosure are also within the protection scope of the embodiments of the present disclosure.
Claims
1. A data testing method based on relay nodes, characterized in that: The method is performed by a relay node, and the method includes: identifying a data sending device and a data receiving device based on the relay node; Based on the heartbeat monitoring port of the relay node, receiving the handshake data sent by the data sending device and the data receiving device respectively, and establishing a communication connection between the relay node and the data sending device, and between the relay node and the data receiving device based on the handshake data; In the case where the data receiving device switches the original IP address to the test IP address, the IP address of the relay node is switched to the original IP address of the data receiving device to enter the relay mode, wherein the test IP address is a predefined IP address for data testing, and in the relay mode, the relay node forwards the data sent by the data sending device to the data receiving device, and the relay node forwards the data sent by the data receiving device to the data sending device, and the relay node is further used to periodically send a first heartbeat data packet to the data sending device and the data receiving device through the heartbeat monitoring port to ensure the connection status of the relay node and the data sending device, and the connection status of the relay node and the data receiving device; In the relay mode, data transmission, data monitoring, and data testing are performed.
2. The method according to claim 1, characterized in that In the relay mode, data monitoring includes: Parsing the received unparsed data according to the data packet parsing code to obtain the parsed actual data, wherein the data packet parsing code is determined according to a predefined data packet format specification table, the data packet format specification table is used to define at least one specific character, the type of each of the specific characters, the meaning of each of the specific characters and the number of bytes occupied by each of the specific characters, and the unparsed data includes the data sent by the data sending device and the data sent by the data receiving device; The parsed actual data is displayed on the data monitoring interface of the relay node, so that the target user can perform real-time data monitoring.
3. The method according to claim 1, characterized in that In the relay mode, the data test includes: Receive test data sent by the target user through the data control interface; If the data field of the data sending device is in an overriding state, sending the test data to the data receiving device through the relay node to implement a test on the data sending device; If the data field of the data receiving device is in an overriding state, the test data is sent to the data sending device via the relay node to implement a test on the data receiving device.
4. The method according to claim 1, characterized in that In the relay mode, data transmission includes: receiving and buffering command data sent by the data sending device, and sending the command data to the data receiving device; When the data receiving device receives the command data and sends feedback data to the relay node according to the command data, the feedback data is received and buffered, and the feedback data is sent to the data sending device so that the data sending device receives the feedback data.
5. The method according to claim 1, characterized in that: The heartbeat monitoring port based on the relay node receives handshake data sent by the data sending device and the data receiving device respectively, and establishes a communication connection between the relay node and the data sending device, and between the relay node and the data receiving device based on the handshake data, including: Performing data monitoring based on the heartbeat monitoring port, and in the case of monitoring the handshake data, performing data identification on the handshake data to obtain a data identifier of the handshake data; If the data identifier belongs to the data sending device, confirm whether the first handshake signal and the first heartbeat signal contained in the handshake data are in a confirmation state, and if so, send a first confirmation handshake message to the data sending device, and the data sending device receives the first confirmation handshake message to establish a communication connection between the relay node and the data sending device; If the data identifier belongs to the data receiving device, confirm whether the second handshake signal and the second heartbeat signal contained in the handshake data are in a confirmation state. If so, send second confirmation handshake information to the data receiving device, and the data receiving device receives the second confirmation handshake information to establish a communication connection between the relay node and the data receiving device.
6. The method according to claim 1, characterized in that The method further includes exiting the relay mode by: If the relay node does not receive the second heartbeat data packet sent by the data sending device within a preset time, it is determined that the relay node and the data sending device have not established a communication connection; If the relay node does not receive the third heartbeat data packet sent by the data receiving device within the preset time, it is determined that the relay node and the data receiving device have not established a communication connection; When the relay node and the data sending device do not establish a communication connection, and the relay node and the data receiving device do not establish a communication connection, exit the relay mode; Alternatively, receiving a connection stop command sent by the target user through the data control interface; Sending the connection stop command to the data sending device and the data receiving device respectively, wherein the connection stop command is used to instruct the data sending device and the data receiving device to disconnect the communication connection with the relay node; When receiving the disconnection confirmation messages respectively sent by the data sending device and the data receiving device based on the connection stop command, the relay mode is exited.
7. The method according to claim 6, characterized in that The method further comprises: In the case of exiting the relay mode, the data receiving device switches the test IP address of the data receiving device to the original IP address according to a preset logic; Alternatively, in the case of exiting the relay mode, the data receiving device receives a recovery instruction and switches the test IP address of the data receiving device to the original IP address.
8. The method according to claim 1, characterized in that: The identifying of a data sending device and a data receiving device based on the relay node includes: Monitor the heartbeat monitoring port via the User Datagram Protocol UDP and periodically send a third heartbeat signal; If a target heartbeat data packet based on the third heartbeat signal feedback is received, the target heartbeat data packet is parsed to obtain identification information of the target heartbeat data packet; Determine a sending device corresponding to the target heartbeat data according to the identification information; If the sending device corresponding to the identification information is the data sending device, determining that the relay node recognizes the data sending device; Alternatively, if the sending device corresponding to the identification information is the data receiving device, it is determined that the relay node recognizes the data receiving device.
9. A data testing device based on a relay node, characterized in that: The device comprises a relay node, and the device includes: An identification module, used to identify a data sending device and a data receiving device based on the relay node; A first processing module, configured to receive handshake data sent by the data sending device and the data receiving device respectively based on the heartbeat monitoring port of the relay node, and to establish a communication connection between the relay node and the data sending device, and between the relay node and the data receiving device based on the handshake data; a second processing module, configured to switch the IP address of the relay node to the original IP address of the data receiving device to enter a relay mode when the data receiving device switches the original IP address to a test IP address, wherein the test IP address is a predefined IP address for data testing, and in the relay mode, the relay node forwards the data sent by the data sending device to the data receiving device, and the relay node forwards the data sent by the data receiving device to the data sending device, and the relay node is further configured to periodically send a first heartbeat data packet to the data sending device and the data receiving device through the heartbeat monitoring port to ensure the connection status between the relay node and the data sending device, and between the relay node and the data receiving device; The third processing module is used to perform data transmission, data monitoring, and data testing in the relay mode.
10. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Test data communication and test method and device, equipment and a storage medium
CN110069413A
Agent monitoring method of server and related product
CN110740078A
Router equipment testing method and system based on two-layer network
CN112235157A
Communication test method and device, and storage medium
CN116546532A
Bagging test method and device and storage medium
CN118802611A