Communication message automatic checking method and device
Through automated communication message inspection methods and devices, the target function runs the inspection expression, the problem of low efficiency of SOME/IP communication message consistency inspection is solved, and efficient automatic inspection is achieved.
Patent Information
- Application Number
- CN202411819542.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-03-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, the consistency checking of SOME/IP communication packets is inefficient and requires manual inspection, which takes a long time.
Provides automatic inspection methods and devices for communication packets. By obtaining the message to be checked and the expression to be checked, the actual value is assigned to the expression, and the inspection expression is run using the objective function (such as Python's eval() function), to automatically determine whether the actual value of the message field is consistent with the expected value.
Automatic consistency inspection of communication messages is realized, which significantly improves inspection efficiency and reduces the time and labor intensity of manual inspection.
Smart Images

Figure CN119629085A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of communication message protocols, and in particular to a communication message automatic checking method and device. Background Art
[0002] The SOME / IP protocol is a middleware communication protocol based on Ethernet, mainly used for internal vehicle communication. Abnormal communication messages based on the SOME / IP protocol may cause problems in internal vehicle communication. To ensure normal vehicle communication, it is necessary to perform consistency checks on the SOME / IP communication messages, specifically to check whether the actual values of each field of each layer protocol of the SOME / IP communication message are consistent with the expected values in the protocol specification.
[0003] Generally, the consistency of SOME / IP communication messages is checked manually, that is, the messages to be checked are manually selected one by one to check whether the actual value of the corresponding field is the same as the expected value. Due to the large number of SOME / IP communication messages, manual checking is inefficient and it takes a long time to complete all checks. Summary of the invention
[0004] The present invention solves the technical problem of how to improve the efficiency of communication message consistency checking by providing a communication message automatic checking method and device.
[0005] On the one hand, the present invention provides the following technical solutions:
[0006] A communication message automatic checking method, comprising:
[0007] Acquire a communication message to be checked and a check expression corresponding to the communication message to be checked; the check expression includes a check object and an expected value of the check object;
[0008] Acquire the actual value of the inspection object in the communication message to be inspected, and assign the actual value of the inspection object to the inspection object in the inspection expression;
[0009] Passing the check expression as a parameter to a target function and running the target function to obtain a first running result of the target function;
[0010] Among them, the first operating result is the first result or the second result; the first operating result is the first result, which means that the value of the inspection object in the inspection expression is the expected value; the first operating result is the second result, which means that the value of the inspection object in the inspection expression is not the expected value.
[0011] Optionally, before obtaining the actual value of the inspection object in the communication message to be inspected and assigning the actual value of the inspection object to the inspection object in the inspection expression, the method further includes:
[0012] Convert the check expression into an expression executable by Python language.
[0013] Optionally, the converting the check expression into an expression executable by Python language includes at least one of the following:
[0014] Modify the name of the inspection object to the name corresponding to the inspection object in the preset name comparison table;
[0015] Replace the target field in the check expression with a preset field corresponding to the target field, wherein the format of the preset field is a Python language format;
[0016] Single quotation marks are added around the expected values of the IP address and MAC address in the inspection object.
[0017] Optionally, the step of obtaining the communication message to be checked includes:
[0018] Acquire a plurality of communication messages to be screened and a screening expression corresponding to the inspection expression; the screening expression includes a screening object and an expected value of the screening object;
[0019] Acquire the actual value of the screening object in the communication message to be screened, and assign the actual value of the screening object to the screening object in the screening expression;
[0020] Passing the screening expression as a parameter to the objective function and running the objective function to obtain a second running result of the objective function, where the second running result is the first result or the second result;
[0021] Using the communication message to be screened whose second operation result is the first result as the communication message to be checked;
[0022] Among them, the second running result is the first result, which means that the value of the screening object in the screening expression is the expected value; the second running result is the second result, which means that the value of the screening object in the screening expression is not the expected value.
[0023] Optionally, before obtaining the actual value of the screening object in the communication message to be screened and assigning the actual value of the screening object to the screening object in the screening expression, the method further includes:
[0024] The filter expression is converted into an expression executable by the Python language.
[0025] Optionally, the step of converting the filter expression into an expression executable by Python language includes at least one of the following:
[0026] Modify the name of the screening object to the name corresponding to the screening object in the preset name comparison table;
[0027] Replace the target field in the filter expression with a preset field corresponding to the target field, wherein the format of the preset field is a Python language format;
[0028] Single quotation marks are added around the expected values of the IP address and MAC address in the screening object.
[0029] Optionally, the target function is Python's eval() function.
[0030] On the other hand, the present invention also provides the following technical solutions:
[0031] A communication message automatic checking device, comprising:
[0032] An acquisition module, used to acquire a communication message to be checked and an inspection expression corresponding to the communication message to be checked; the inspection expression includes an inspection object and an expected value of the inspection object;
[0033] and for obtaining the actual value of the inspection object in the communication message to be inspected, and assigning the actual value of the inspection object to the inspection object in the inspection expression;
[0034] An operation module, used for passing the inspection expression as a parameter to an objective function and running the objective function to obtain a first operation result of the objective function;
[0035] Among them, the first operating result is the first result or the second result; the first operating result is the first result, which means that the value of the inspection object in the inspection expression is the expected value; the first operating result is the second result, which means that the value of the inspection object in the inspection expression is not the expected value.
[0036] On the other hand, the present invention also provides the following technical solutions:
[0037] A computer device comprises a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of any one of the above communication message automatic checking methods.
[0038] On the other hand, the present invention also provides the following technical solutions:
[0039] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of any one of the above-mentioned methods for automatically checking communication messages.
[0040] One or more technical solutions provided by the present invention have at least the following technical effects or advantages:
[0041] The present invention first assigns the actual value of the inspection object in the communication message to be inspected to the inspection object in a preconfigured inspection expression, and then passes the inspection expression as a parameter to the objective function and runs the objective function to obtain a first running result of the objective function. The first running result can reflect whether the value of the inspection object in the inspection expression is an expected value, that is, whether the actual value of the inspection object in the communication message to be inspected is the expected value. By assigning the inspection expression and running the inspection expression, automatic inspection of the communication message is realized, thereby improving the inspection efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings in the following description are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0043] Figure 1 Schematic diagram of the screening interface of the wireshark software in an embodiment of the present invention;
[0044] Figure 2 Flow chart of the method for automatically checking communication messages in an embodiment of the present invention;
[0045] Figure 3 A schematic diagram of a check expression written according to Wireshark rules in an embodiment of the present invention;
[0046] Figure 4 A schematic diagram of a preset name comparison table in an embodiment of the present invention;
[0047] Figure 5 A schematic diagram of a portion of a screening expression and a portion of a checking expression written according to Wireshark rules in an embodiment of the present invention;
[0048] Figure 6 Schematic diagram of a communication message automatic inspection device in an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The embodiment of the present invention solves the technical problem of how to improve the efficiency of communication message consistency checking by providing a communication message automatic checking method and device.
[0050] In order to better understand the technical solution of the present invention, the technical solution of the present invention will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0051] As shown in Table 1, SOME / IP (Scalable service-Oriented MiddlewarE over IP) communication message has a layered architecture, including Ethernet layer, IP layer, TCP (Transmission Control Protocol) or UDP (User Data Protocol) transport layer, SOME / IP layer, SOMEIP-SD (Service Discovery) layer and other layer protocols. The SOMEIP-SD layer includes Entry (entry) sub-element and Option (supplementary information) sub-element. Each layer of protocol and each sub-element include multiple protocol fields that need to be checked. Each row in Table 1 is an inspection object. For example, the inspection object in row 1 is the Destination (eth.dst) of the Ethernet layer.
[0052] Table 1
[0053]
[0054]
[0055]
[0056] Generally, before checking the communication messages, you need to record the communication messages. The recorded message files are in .pcap or .pcapng format, and the message files include various types of communication messages. When checking manually, you need to filter out the communication messages that need to be checked first. You can use the network packet analysis software wireshark to filter them. For example, if you want to filter out SD messages, you can enter "someipsd" in the wireshark filter and press the Enter key. The wireshark message panel will only display the filtered SD messages. Figure 1As shown; then use the mouse to select each SD message in turn, and check in turn whether the actual value of the inspection object in each SD message is the expected value. For example, if the inspection object is the Sourceport of the transport layer, and the expected value of the Source port is 30490, it is necessary to check whether the Source port of each SD message is 30490. If the Source port of all SD messages is 30490, the inspection passes. If the Source port of at least one SD message is not 30490, the inspection fails. It can be seen that manual inspection requires manually clicking on each communication message to be inspected, manually checking the actual value of the inspection object in each communication message to be inspected, and manually judging whether the actual value of the inspection object in each communication message to be inspected is the expected value, and the inspection efficiency is low.
[0057] like Figure 2 As shown, the communication message automatic inspection method of the embodiment of the present invention includes:
[0058] Step S1, obtaining a communication message to be checked and a check expression corresponding to the communication message to be checked; the check expression includes a check object and an expected value of the check object;
[0059] The communication messages to be checked are the communication messages that need to be checked, and can be screened out from the recorded communication messages in advance, for example, by Figure 1 Each row in Table 1 corresponds to a check expression. For example, the check expression corresponding to the first row in Table 1 can be eth.dst=='01:00:5e:05:01:02', the check object is eth.dst, and the expected value is 01:00:5e:05:01:02; the check expression corresponding to the 24th row in Table 1 can be someip.session_id==0x00ce, the check object is someip.session_id, and the expected value is 0x00ce; all the check expressions corresponding to Table 1 can be configured in the configuration table in advance, and each check expression can be obtained by parsing the configuration table through the pandas library of the Python language;
[0060] Each inspection expression corresponds to a plurality of communication messages to be inspected, and steps S1-S3 may be performed once for each communication message to be inspected, and the next inspection expression and the corresponding communication message to be inspected may be automatically obtained to continue inspection after all the communication messages to be inspected corresponding to the current inspection expression have been inspected;
[0061] Step S2, obtaining the actual value of the inspection object in the communication message to be inspected, and assigning the actual value of the inspection object to the inspection object in the inspection expression;
[0062] In some implementations, the actual value of the inspection object in the communication message to be inspected may be obtained by running a preset update program, and part of the code of the preset update program may be as follows:
[0063]
[0064] In the update program, the actual value of each field of each layer protocol can be obtained by obtaining the protocol object of each layer. For the SOMEIP-SD layer, the actual value of each field in the sub-element entry and option of the SOMEIP-SD layer can also be obtained by obtaining the SOMEIP-SD layer object; for example, if the inspection object is someip.session_id, the actual value of someip.session_id can be obtained after obtaining the SOMEIP layer object; then the actual value of someip.session_id is assigned to someip.session_id in the inspection expression someip.session_id==0x00ce;
[0065] Step S3, passing the check expression as a parameter to the target function and running the target function to obtain a first running result of the target function;
[0066] The first operation result is the first result or the second result; the first operation result is the first result, which means that the value of the inspection object in the inspection expression is the expected value; the first operation result is the second result, which means that the value of the inspection object in the inspection expression is not the expected value;
[0067] In some embodiments, the target function may be Python's eval() function, and the eval() function may return a Boolean running result, for example, the first result may be True and the second result may be False. Returning True indicates that the value of the check object in the check expression is the expected value, and returning False indicates that the value of the check object in the check expression is not the expected value. For example, if the check expression is someip.session_id==0x00ce, then eval(someip.session_id==0x00ce) is run. If eval(someip.session_id==0x00ce)==True, it means that the value of someip.session_id is the expected value 0x00ce, that is, the actual value of the Session ID of the someip layer in the current communication message to be checked is 0x00ce, and the check passes. If eval(someip.session_id==0x00ce)==False, it means that the value of someip.session_id is not the expected value 0x00ce, that is, the actual value of the Session ID of the someip layer in the current communication message to be checked is not 0x00ce, and the check fails.
[0068] As can be seen from the above, the automatic inspection method of communication messages in the embodiment of the present invention first assigns the actual value of the inspection object in the communication message to be inspected to the inspection object in the pre-configured inspection expression, and then passes the inspection expression as a parameter to the objective function and runs the objective function to obtain the first running result of the objective function. The first running result can reflect whether the value of the inspection object in the inspection expression is the expected value, that is, whether the actual value of the inspection object in the communication message to be inspected is the expected value. By assigning the inspection expression and running the inspection expression, the automatic inspection of the communication message is realized, and the inspection efficiency is improved.
[0069] The check expressions eth.dst=='01:00:5e:05:01:02' and someip.session_id==0x00ce in the above examples are actually expressions that can be run by Python. However, the check expressions configured in practice may not be directly run by Python. For example, the check expressions eth.dst==01:00:5e:05:01:02 and someip.sessionid==0x00ce written according to Wireshark rules may not be run directly by Python. Figure 3 In order to obtain a check expression executable by Python language in the above case, in some embodiments, before step S2, the communication message automatic check method may further include:
[0070] Convert the check expression into an expression that can be executed in Python language.
[0071] In some embodiments, converting the check expression into an expression executable by the Python language may include at least one of the following: modifying the name of the check object to the name corresponding to the check object in the preset name comparison table; replacing the target field in the check expression with the preset field corresponding to the target field, and the format of the preset field is the Python language format; adding single quotes at both ends of the expected values of the IP address and MAC address in the check object. Among them, the target field may include a field corresponding to the logical "and" (such as "&&") and a field corresponding to the logical "or"; the preset field corresponding to the logical "and" is the string "and", that is, "and" is replaced with "&&"; the preset field corresponding to the logical "or" is the string "or".
[0072] The preset name comparison table can be as follows Figure 4 As shown. Exemplarily, if the check expression written according to the Wireshark rule is eth.dst == 01:00:5e:05:01:02, the name of the check object eth.dst is the same as the corresponding name in the preset name comparison table and does not need to be modified, but the check object eth.dst is a MAC address, and single quotes need to be added at both ends of the expected value 01:00:5e:05:01:02 to form a check expression eth.dst == '01:00:5e:05:01:02' that can be executed in the Python language. Exemplarily, if the check expression written according to the Wireshark rule is someip.sessionid == 0x00ce, the name of the check object someip.sessionid corresponds to the name someip.session_id in the preset name comparison table, then a check expression someip.session_id == 0x00ce that can be executed in the Python language is formed.
[0073] Some of the code for format conversion of expressions is as follows:
[0074]
[0075]
[0076] As mentioned above, you can Figure 1 The method shown screens out the communication messages to be checked, but the efficiency of manual screening is low. To improve the screening efficiency of the communication messages to be checked, in some embodiments, in step S1, the step of obtaining the communication messages to be checked may include:
[0077] Obtaining a plurality of communication messages to be filtered and a filter expression corresponding to the check expression; the filter expression includes a filter object and an expected value of the filter object;
[0078] Obtaining the actual value of the filter object in the communication message to be filtered, and assigning the actual value of the filter object to the filter object in the filter expression;
[0079] Passing the screening expression as a parameter to the target function and running the target function to obtain a second running result of the target function, where the second running result is the first result or the second result;
[0080] The communication message to be screened whose second operation result is the first result is used as the communication message to be checked;
[0081] Among them, the second running result is the first result, which means that the value of the screening object in the screening expression is the expected value; the second running result is the second result, which means that the value of the screening object in the screening expression is not the expected value.
[0082] In some embodiments, a recorded .pcap message file can be loaded in Python's scapy library to obtain multiple communication messages to be filtered in the .pcap message file. Each filter expression corresponds to a check expression, and each filter expression can be pre-configured in a configuration table, and each filter expression can be obtained by parsing the configuration table through Python's pandas library. For example, in the filter expression someipsd.entry_array.type==0x00 and someipsd.entry_array.srv_id==0x4003and ip.src=='172.16.113.90', the filter objects include someipsd.entry_array.type, someipsd.entry_array.srv_id and ip.src, and the expected values are 0x00, 0x4003, and 172.16.113.90, respectively, and the corresponding check expression is eth.dst=='01:00:5e:05:01:02'. For example, in the filter expression someip.msg_type==0x2 and someip.srv_id==0xffff and ip.src=='172.16.113.90'and ip.dst=='239.5.1.2', the filter objects include someip.msg_type, someip.srv_id and ip.src, and the expected values are 0x2, 0xffff, and 172.16.113.90 respectively. The corresponding check expression is someip.session_id==0x00ce.
[0083] Each filter expression corresponds to multiple communication messages to be filtered, and each communication message to be filtered can be filtered once. After all the communication messages to be filtered corresponding to the current filter expression are filtered, the next filter expression and the corresponding communication message to be filtered can be automatically obtained to continue filtering.
[0084] In some implementations, the actual value of the screening object in the communication message to be screened can also be obtained by running the update program described above. For example, if the screening object includes someip.msg_type, the actual value of someip.msg_type can be obtained after obtaining the SOMEIP layer object; then the actual value of someip.msg_type is assigned to the someip.msg_type in the screening expression someip.msg_type==0x2 and someip.srv_id==0xffff and ip.src=='172.16.113.90'and ip.dst=='239.5.1.2'.
[0085] For example, if the filter expression is someip.msg_type==0x2 and someip.srv_id==0xffff and ip.src=='172.16.113.90'and ip.dst=='239.5.1.2', then run eval(someip.msg_type==0x2 and someip.srv_id==0xffff and ip.src=='172.16.113.90'). someip.srv_id==0xffffandip.src=='172.16.113.90')==True, which means that the value of someip.msg_type is the expected value 0x2, the value of someip.srv_id is the expected value 0xffff and the value of ip.src is the expected value 172.16.113.90, that is, the actual value of the Message Type of the someip layer in the current communication message to be filtered is the expected value 0x2, the actual value of the Service ID is the expected value 0xffff and the actual value of the Source Address of the IP layer is the expected value 172.16.113.90, the current communication message to be filtered is used as the communication message to be checked; if eval(someip.msg_type==0x2 and someip.srv_id==0xffff and ip.src == '172.16.113.90') == False, indicating that the value of someip.msg_type is not the expected value 0x2, the value of someip.srv_id is not the expected value 0xffff, or the value of ip.src is not the expected value 172.16.113.90, and the current communication message to be filtered does not need to be checked for the current item.
[0086] In this way, the actual value of the screening object in the communication message to be screened is first assigned to the screening object in the pre-configured screening expression, and then the screening expression is passed as a parameter to the target function and the target function is run to obtain a second running result of the target function. The second running result can reflect whether the value of the screening object in the screening expression is the expected value, that is, whether the actual value of the screening object in the communication message to be screened is the expected value. By assigning the screening expression and running the screening expression, automatic screening of the communication message is achieved, thereby improving the screening efficiency.
[0087] Similarly, the filter expressions in the examples above are actually expressions that can be run by Python language, but the filter expressions configured in practice may not be directly run by Python language. For example, the filter expression someipsd.entry.type==0x00&&someipsd.entry.serviceid==0x4003&&ip.src==172.16.113.90 may be written according to Wireshark rules. Figure 5 In order to obtain a filter expression executable by Python language in the above case, in some embodiments, before obtaining the actual value of the filter object in the communication message to be filtered and assigning the actual value of the filter object to the filter object in the filter expression, the communication message automatic inspection method may further include:
[0088] Convert the filter expression into an expression executable by Python.
[0089] In some embodiments, converting the screening expression into an expression executable by the Python language may include at least one of the following: modifying the name of the screening object to the name corresponding to the screening object in the preset name comparison table; replacing the target field in the screening expression with the preset field corresponding to the target field, and the format of the preset field is the Python language format; adding single quotes at both ends of the expected values of the IP address and MAC address in the screening object. Among them, the target field may include a field corresponding to the logical "and" (such as "&&") and a field corresponding to the logical "or"; the preset field corresponding to the logical "and" is the string "and", that is, "and" is replaced with "&&"; the preset field corresponding to the logical "or" is the string "or".
[0090] For example, if the filter expression written according to the Wireshark rule is someipsd.entry.type==0x00&&someipsd.entry.serviceid==0x4003&&ip.src==172.16.113.90, the filter objects someipsd.entry.type, someipsd.entry.serviceid, ip.src are in Figure 4The corresponding names in the preset name comparison table are someipsd.entry_array.type, someipsd.entry_array.srv_id, and ip.src. Replace the logical AND "&&" with the string "and". Add single quotes at both ends of the expected value 172.16.113.90 of the IP address ip.src in the filter object to form a filter expression someipsd.entry_array.type == 0x00and someipsd.entry_array.srv_id == 0x4003and ip.src == '172.16.113.90' that can be executed in the Python language.
[0091] In some embodiments, the embodiments of the present invention can also record whether there are messages that fail each check, the number of messages that pass the screening expression, the number of messages that pass the check expression, the number of messages that fail the check expression, and the sequence numbers and timestamps corresponding to the communication messages that fail each check, to facilitate the subsequent locating of the corresponding messages in the original message file.
[0092] like Figure 6 As shown, the embodiment of the present invention also provides a communication message automatic inspection device, including:
[0093] An acquisition module, used to acquire the communication message to be checked and the inspection expression corresponding to the communication message to be checked; the inspection expression includes an inspection object and an expected value of the inspection object;
[0094] and for obtaining the actual value of the inspection object in the communication message to be inspected, and assigning the actual value of the inspection object to the inspection object in the inspection expression;
[0095] A running module, used for passing the check expression as a parameter to the target function and running the target function to obtain a first running result of the target function;
[0096] Among them, the first running result is the first result or the second result; the first running result is the first result, which means that the value of the inspection object in the inspection expression is the expected value; the first running result is the second result, which means that the value of the inspection object in the inspection expression is not the expected value.
[0097] In some implementations, the communication message automatic inspection device may further include:
[0098] The conversion module is used to convert the check expression into an expression that can be executed in Python language.
[0099] In some implementations, the conversion module may be specifically used for at least one of the following:
[0100] Change the name of the inspection object to the name corresponding to the inspection object in the preset name comparison table;
[0101] Replace the target field in the check expression with the preset field corresponding to the target field. The format of the preset field is Python language format.
[0102] Put single quotation marks around the expected values of the IP address and MAC address in the check object.
[0103] In some implementations, the acquisition module may be specifically used to:
[0104] Obtaining a plurality of communication messages to be filtered and a filter expression corresponding to the check expression; the filter expression includes a filter object and an expected value of the filter object;
[0105] Obtaining the actual value of the filter object in the communication message to be filtered, and assigning the actual value of the filter object to the filter object in the filter expression;
[0106] Passing the screening expression as a parameter to the target function and running the target function to obtain a second running result of the target function, where the second running result is the first result or the second result;
[0107] The communication message to be screened whose second operation result is the first result is used as the communication message to be checked;
[0108] Among them, the second running result is the first result, which means that the value of the screening object in the screening expression is the expected value; the second running result is the second result, which means that the value of the screening object in the screening expression is not the expected value.
[0109] In some implementations, the communication message automatic inspection device may further include:
[0110] The conversion module is used to convert the filter expression into an expression that can be executed in Python.
[0111] In some implementations, the conversion module may be specifically used for at least one of the following:
[0112] Change the name of the filter object to the name corresponding to the filter object in the preset name comparison table;
[0113] Replace the target field in the filter expression with the preset field corresponding to the target field. The format of the preset field is Python language format.
[0114] Add single quotation marks around the expected values of the IP address and MAC address in the filter object.
[0115] In some implementations, the target function may be Python's eval() function.
[0116] Based on the same inventive concept as the above-mentioned method for automatically checking communication messages, an embodiment of the present invention also provides a computer device, including a memory, a processor and a computer program stored in the memory, and the processor executes the computer program to implement the steps of any one of the above-mentioned methods for automatically checking communication messages.
[0117] Since the computer device introduced in the embodiment of the present invention is a computer device used to implement the communication message automatic inspection method in the embodiment of the present invention, based on the communication message automatic inspection method introduced in the embodiment of the present invention, a person skilled in the art can understand the specific implementation of the computer device in the embodiment of the present invention and its various variations, so how the computer device implements the method in the embodiment of the present invention is not described in detail here. As long as a person skilled in the art implements the computer device used in the communication message automatic inspection method in the embodiment of the present invention, it belongs to the scope of protection of the present invention.
[0118] Based on the same inventive concept as the above-mentioned method for automatically checking communication messages, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of any of the above-mentioned methods for automatically checking communication messages when executed by a processor.
[0119] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0120] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0121] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0122] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0123] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for automatically checking communication messages, characterized in that: include: Acquire a communication message to be checked and a check expression corresponding to the communication message to be checked; the check expression includes a check object and an expected value of the check object; Acquire the actual value of the inspection object in the communication message to be inspected, and assign the actual value of the inspection object to the inspection object in the inspection expression; Passing the check expression as a parameter to a target function and running the target function to obtain a first running result of the target function; Among them, the first operating result is the first result or the second result; the first operating result is the first result, which means that the value of the inspection object in the inspection expression is the expected value; the first operating result is the second result, which means that the value of the inspection object in the inspection expression is not the expected value.
2. The communication message automatic checking method according to claim 1, characterized in that: Before obtaining the actual value of the inspection object in the communication message to be inspected and assigning the actual value of the inspection object to the inspection object in the inspection expression, the method further includes: Convert the check expression into an expression executable by Python language.
3. The communication message automatic checking method according to claim 2, characterized in that: The step of converting the check expression into an expression executable by Python language includes at least one of the following: Modify the name of the inspection object to the name corresponding to the inspection object in the preset name comparison table; Replace the target field in the check expression with a preset field corresponding to the target field, wherein the format of the preset field is a Python language format; Single quotation marks are added around the expected values of the IP address and MAC address in the inspection object.
4. The communication message automatic checking method according to claim 1, characterized in that: The step of obtaining the communication message to be checked includes: Acquire a plurality of communication messages to be screened and a screening expression corresponding to the inspection expression; the screening expression includes a screening object and an expected value of the screening object; Acquire the actual value of the screening object in the communication message to be screened, and assign the actual value of the screening object to the screening object in the screening expression; Passing the screening expression as a parameter to the objective function and running the objective function to obtain a second running result of the objective function, where the second running result is the first result or the second result; Using the communication message to be screened whose second operation result is the first result as the communication message to be checked; Among them, the second running result is the first result, which means that the value of the screening object in the screening expression is the expected value; the second running result is the second result, which means that the value of the screening object in the screening expression is not the expected value.
5. The communication message automatic checking method according to claim 4, characterized in that: Before obtaining the actual value of the screening object in the communication message to be screened and assigning the actual value of the screening object to the screening object in the screening expression, the method further includes: The filter expression is converted into an expression executable by the Python language.
6. The communication message automatic checking method according to claim 5, characterized in that: The step of converting the screening expression into an expression executable by Python language includes at least one of the following: Modify the name of the screening object to the name corresponding to the screening object in the preset name comparison table; Replace the target field in the filter expression with a preset field corresponding to the target field, wherein the format of the preset field is a Python language format; Single quotation marks are added around the expected values of the IP address and MAC address in the screening object.
7. The method for automatically checking communication messages according to any one of claims 1 to 6, characterized in that: The target function is Python's eval() function.
8. A communication message automatic inspection device, characterized in that: include: An acquisition module, used to acquire a communication message to be checked and an inspection expression corresponding to the communication message to be checked; the inspection expression includes an inspection object and an expected value of the inspection object; and for obtaining the actual value of the inspection object in the communication message to be inspected, and assigning the actual value of the inspection object to the inspection object in the inspection expression; An operation module, used for passing the inspection expression as a parameter to a target function and running the target function to obtain a first operation result of the target function; Among them, the first operating result is the first result or the second result; the first operating result is the first result, which means that the value of the inspection object in the inspection expression is the expected value; the first operating result is the second result, which means that the value of the inspection object in the inspection expression is not the expected value.
9. A computer device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Request recording method and device, equipment and storage medium
CN114003784A
Service interface test method, device and equipment
CN116866239A
Python-based interface test result automatic generation method
CN117370217A
Automatic interface testing method and device, equipment and storage medium
CN117421222A
Vehicle-mounted Ethernet communication behavior test method and system, electronic equipment and medium
CN119011430A