Disclosure of Invention
In view of the above problems, the present invention provides an application-oriented interface communication protocol modeling method and apparatus, which achieve the purpose of improving the test efficiency of the application-oriented interface communication protocol by establishing a mathematical model of the application-oriented interface communication protocol.
In order to achieve the purpose, the invention provides the following technical scheme:
an application-oriented interface communication protocol modeling method comprises the following steps:
analyzing a serial interface communication protocol, extracting to obtain user application-oriented data, and recording the user application-oriented data as a communication data packet, wherein the serial interface communication protocol is a data transmission requirement for connecting a plurality of systems;
counting the communication data packet by taking bytes as units, and determining byte information of the communication data packet;
and establishing a mathematical model of the serial interface communication protocol according to the relation information of the communication data packets transmitted among the communication systems and the byte information of the communication data packets.
Preferably, the establishing a mathematical model of the communication data packet according to the relationship information of the communication data packet transmitted between the communication systems and the byte information of the communication data packet includes:
determining the number information of communication data packets transmitted among systems and the byte information of the communication data packets transmitted among the systems, and establishing a mathematical model of each communication data packet;
determining element information of each communication data packet according to byte information of each communication data packet, and establishing a mathematical model of element relation of the communication data packets according to the element information;
carrying out parameter content verification on the element information, and establishing an element verification relation model according to a verification result;
determining the value range of each system data, determining the question-answer relationship among the systems according to the value range, and establishing a question-answer relationship model of a communication data packet according to the question-answer relationship;
according to the received communication data packets of each system, determining data for distributing the element information in the received communication data packets according to a preset relationship, and establishing a decomposition and combination relationship model of the element information of the communication data packets, wherein the preset relationship comprises a decomposition relationship and a combination relationship.
Preferably, the method further comprises the following steps:
and checking the serial interface communication protocol according to the mathematical model of the serial interface communication protocol.
Preferably, before analyzing the serial interface communication protocol, extracting and obtaining data for the user application, and recording the data for the user application as a communication data packet, the method further includes:
analyzing the serial interface communication protocol, and determining the relation information between the system connected with the serial interface communication protocol and each system.
Preferably, before counting the communication data packets in units of bytes and determining byte information of the communication data packets, the method further includes:
and determining the composition form of the communication data packet, and performing byte statistics according to the composition galaxy, wherein the composition form comprises bytes, words and double words.
An application-oriented interface communication protocol modeling apparatus, comprising:
the system comprises an extraction module, a data transmission module and a data transmission module, wherein the extraction module is used for analyzing a serial interface communication protocol, extracting data for user application and recording the data for the user application as a communication data packet, and the serial interface communication protocol is a data transmission requirement for connecting a plurality of systems;
the determining module is used for counting the communication data packet by taking bytes as units and determining byte information of the communication data packet;
and the establishing module is used for establishing a mathematical model of the serial interface communication protocol according to the relation information of the communication data packets transmitted among the communication systems and the byte information of the communication data packets.
Preferably, the establishing module comprises:
the device comprises a first establishing unit, a second establishing unit and a third establishing unit, wherein the first establishing unit is used for determining the number information of communication data packets transmitted among systems and the byte information of the communication data packets transmitted among the systems and establishing a mathematical model of each communication data packet;
the second establishing unit is used for determining the element information of each communication data packet according to the byte information of each communication data packet and establishing a mathematical model of the element relation of the communication data packets according to the element information;
the third establishing unit is used for verifying the parameter content of the element information and establishing an element verification relation model according to a verification result;
the fourth establishing unit is used for determining the value range of each system data, determining the question-answer relationship among the systems according to the value range, and establishing a question-answer relationship model of the communication data packet according to the question-answer relationship;
and a fifth establishing unit, configured to determine, according to the received communication data packet of each system, data that distributes the element information in the received communication data packet according to a preset relationship, and establish a decomposition and combination relationship model of the element information in the communication data packet, where the preset relationship includes a decomposition relationship and a combination relationship.
Preferably, the method further comprises the following steps:
and the checking module is used for checking the serial interface communication protocol according to the mathematical model of the serial interface communication protocol.
Preferably, the method further comprises the following steps:
and the information determining module is used for analyzing the serial interface communication protocol and determining the relation information between the system connected with the serial interface communication protocol and each system.
Preferably, the method further comprises the following steps:
and the form determining module is used for determining the composition form of the communication data packet and carrying out byte statistics according to the composition form, wherein the composition form comprises bytes, words and double words.
Compared with the prior art, the method and the device have the advantages that the data and the interaction relation facing the user application in the serial interface communication protocol are analyzed, byte information is obtained through byte statistics, and various communication protocols can be analyzed according to a unified statistical method. And then establishing a mathematical model for completing description of various action relationships of the communication protocol based on the information obtained by analysis. And then, the system communication protocol described by the natural language can be converted into a machine language which can be identified by a computer based on the mathematical model, so that a universal representation mode of the communication protocol is obtained through the mathematical model, the communication protocol can be automatically tested according to the mathematical model, and the testing efficiency is improved.
The terms "first" and "second," and the like in the description and claims of the present invention and the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "comprising" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not set forth for a listed step or element but may include steps or elements not listed.
In an embodiment of the present invention, a method for modeling an application-oriented interface communication protocol is provided, and referring to fig. 1, the method may include the following steps:
s11, analyzing a serial interface communication protocol, extracting to obtain user application-oriented data, and recording the user application-oriented data as a communication data packet, wherein the serial interface communication protocol is a data transmission requirement for connecting a plurality of systems;
the serial interface communication protocol is suitable for the constraint of data transmission between systems and is also suitable for the constraint of data transmission between subsystems in a single system.
Before step S11 is performed, the serial interface communication protocol needs to be analyzed to determine the relationship information between the systems connected by the serial interface communication protocol and each system.
The purpose is to analyze the relationship between systems and data items agreed by the serial interface communication protocol. Then, the standard requirements of a physical layer and a data link layer of a serial interface communication protocol are eliminated, and only data which are oriented to user application are required. Since the communication protocol can implement the data building of the respective bus standards according to the prior art at the physical layer and the data link layer, it is not the research focus of the present invention, so that the data in the part needs to be excluded.
S12, counting the communication data packet by taking bytes as units, and determining the byte information of the communication data packet;
before executing step S12, the method may further include:
and determining the composition form of the communication data packet, and performing byte statistics according to the composition galaxy, wherein the composition form comprises bytes, words and double words.
The Data items involved in the communication protocol are analyzed and described, and whatever application layer protocol is, the Data items are composed of Data elements, the minimum element of the Data elements is binary bits (bit) of a computer, and bytes (Byte), words, double words and the like are formed by the bits, so that the most basic communication Data Packet (DP) is formed. In different bus protocol descriptions, the basic elements describing the data packets are different, for example, in the RS232/422/485/UART bus protocol, the basic elements are often described in bytes; in the MIL-STD-1553 bus protocol, a doubleword is often used as a basic element. In order to establish a unified specification, byte information of the communication data packets can be obtained by taking basic component element bytes as a statistical unit for all the communication data packets, wherein the byte information can include the number of bytes, the content of the bytes, and the like.
S13, establishing a mathematical model of the serial interface communication protocol according to the relation information of the communication data packets transmitted among the communication systems and the byte information of the communication data packets.
The method specifically comprises the following steps:
determining the number information of communication data packets transmitted among systems and the byte information of the communication data packets transmitted among the systems, and establishing a mathematical model of each communication data packet;
determining element information of each communication data packet according to byte information of each communication data packet, and establishing a mathematical model of element relation of the communication data packets according to the element information;
carrying out parameter content verification on the element information, and establishing an element verification relation model according to a verification result;
determining the value range of each system data, determining the question-answer relationship among the systems according to the value range, and establishing a question-answer relationship model of a communication data packet according to the question-answer relationship;
according to the received communication data packets of each system, determining data for distributing the element information in the received communication data packets according to a preset relationship, and establishing a decomposition and combination relationship model of the element information of the communication data packets, wherein the preset relationship comprises a decomposition relationship and a combination relationship.
It should be noted that, the modeling method for communication data packet adopts
Is represented by S
αThe system sends to S
βThe x-th data packet of the system, x is a data packet number, the data packet is composed of k bytes, the bytes are used as basic elements and are expressed according to the sequence of 0-N, equivalent expression is carried out according to the specific meaning of the data elements in application according to binary bits, N is a set of subsequent numbers of the bytes when the byte elements of the data packet are distinguished according to the practical application meaning, and if there are k elements in N, the mathematical model of each communication data packet is expressed as:
wherein x is more than or equal to 0, i is more than or equal to 0, j is more than or equal to 0, n is more than or equal to m is more than or equal to 0, alpha, beta belongs to (0,1, 2.), i, j, m, n, alpha and beta are system natural numbers.
The basic requirement that a communication data packet is identified is that the content of a particular byte satisfies a condition at the same time, so the mathematical model of the element relationship of the communication data packet can be expressed as:
the same error protection mechanism in the communication data packet usually adopts a specific checking method of parameter content, so the element checking relation model is expressed as:
assuming that the value range of certain meaning data of the S α system application layer is Q, the value range of certain meaning data fed back by the system S β making response according to the value of Q is A.R
kFor the question-answer relationship in a certain parameter pair value range,
indicates the x-th data packet sent from the S α system to the S β system
The value range of the parameter Bp to Q represented by the p-th to Q-th bytes in the (B) is Q
k,
The representation S β system feeds back to the S α system in the format of
S to t byte of the response parameter range a
k. The question-answer relationship model of the communication data packet represents:
a method for decomposing and combining element among data packets relates to m systems, wherein S is { S1, S2, …, Sm } is a system set, and the data packet x data DP of the S β system is received by the S α systemx(S β → S α), distribute some parameters in the data package to other system set ST according to the data meaning, which is oneThe decomposition and combination relation model of the communication data packet element information is expressed as follows:
in this way, mathematical models representing the communication protocol are obtained, and the communication protocol can be described accurately only through the mathematical models established above. If the communication protocol is relatively simple, some mathematical model may be selected to describe the communication protocol depending on the particular application.
By the application interface-oriented communication protocol modeling method disclosed by the embodiment of the invention, the data and interaction relation oriented to the user application in the serial interface communication protocol are analyzed, byte information is obtained by counting based on bytes, and various communication protocols can be analyzed according to a uniform counting method. And then establishing a mathematical model for completing description of various action relationships of the communication protocol based on the information obtained by analysis. And then, the system communication protocol described by the natural language can be converted into a machine language which can be identified by a computer based on the mathematical model, so that a universal representation mode of the communication protocol is obtained through the mathematical model, the communication protocol can be automatically tested according to the mathematical model, and the testing efficiency is improved.
In a specific application scenario, the application-oriented interface communication protocol modeling method provided by the present invention will be described below.
Referring to fig. 2, an aerospace system is illustrated as an example, and the system includes:
flight control system (flight control system for short) S0: the load control system S1 is connected through a CAN bus, and the data interaction is related to bidirectional data interaction, and the data interaction contents are shown in tables 1 and 2.
Load control system S1: the system is connected with a flight control system S0 through a CAN bus, and relates to bidirectional data interaction, and the data interaction contents are shown in tables 1 and 2; the image processing system S2 is connected through an RS422 bus, bidirectional data interaction is involved, and the data interaction content is shown in tables 3 and 4; the data exchange is connected with the servo control system S3 through an RS422 bus, and the data exchange is related to bidirectional data exchange, and the data exchange contents are shown in tables 5 and 6.
TABLE 1 flight control System data to load control System
TABLE 2 load control System to flight control System
Image processing system S2: the data interaction is related to bidirectional data interaction through RS422 bus connection with a load control system, and the data interaction contents are shown in tables 3 and 4.
Table 3 load control system to image processing system
Table 4 image processing system to load control system
Servo control system S3: the data interaction is related to bidirectional data interaction through RS422 bus connection with the load control system, and the data interaction contents are shown in tables 5 and 6.
TABLE 5 load control System to Servo control System
TABLE 6 Baud rate sent by the servo control system to the load control system
Modeling independent packets in a communication protocol (mathematical model of each communication packet):
DP1(S0→S1)={B0:1(b0:7,b0:7),B2:2(b0:7),B3:4(b8:15,b0:7),B5:6(b8:15,b0:7),B7:9(b16:23,b8:15,b0:7)} (1)
DP1(S1→S0)={B0:1(b0:7,b0:7),B2:2(b0:7),B3:3(b0:0,b1:1,b2:2,b3:3,b4:4,b5:5),B4:9(b0:7,b0:7,b0:7,b0:7,b0:7,b0:7)} (2)
DP1(S1→S2)={B0:1(b0:7,b0:7),B2:2(b0:7),B3:3(b0:7),B4:6(b16:23,b8:11,b12:15,b0:11),B7:7(b0:7)} (3)
DP1(S2→S1)={B0:1(b0:7,b0:7),B2:2(b0:7),B3:3(b4:4,b5:5),B4:4(b0:7)} (4)
DP1(S1→S3)={B0:1(b0:7,b0:7),B2:2(b0:7),B3:3(b0:7),B4:5(b8:15,b0:7),B6:7(b8:15,b0:7),B8:10(b16:24,b8:15,b0:7),B11:11(b0:7)} (5)
DP1(S3→S1)={B0:1(b0:7,b0:7),B2:2(b0:7),B3:3(b0:0,b1:1,b2:2,b3:3),B4:6(b16:24,b8:15,b0:7),B7:7(b0:7)} (6)
modeling the element relationship of each independent data packet in the communication protocol (mathematical model of the element relationship of the communication data packet):
DP1(S1→S2)(B7:7(b0:7))=DP1(S1→S2)(B3:3(b0:7)+B4:4(b0:7)+B5:5(b0:7)+B6:6(b0:7)) (7)
DP1(S2→S1)B4:4(b0:7)=DP1(S2→S1)B3:3(b0:7) (8)
DP1(S1→S3)(B11:11(b0:7))=DP1(S1→S3)(B3:3(b0:7)+B4:4(b0:7)+B5:5(b0:7)+B6:6(b0:7)+B7:7(b0:7)+B8:8(b0:7)+B9:9(b0:7)+B10:10(b0:7)) (9)
DP1(S3→S1)(B7:7(b0:7))=DP1(S3→S1)(B3:3(b0:7)+B4:4(b0:7)+B5:5(b0:7)+B6:6(b0:7)) (10)
DP1(S1→S2).H0:0.b0:7={0x7E}∩DP1(S1→S2).H1:1.b0:7={0x7E}∩DP1(S1→S2).B2:2.b0:7={0x99} (11)
DP1(S2→S1).H0:0.b0:7={0x7E}∩DP1(S2→S1).H1:1.b0:7={0x7E}∩DP1(S2→S1).B2:2.b0:7={0x99} (12)
DP1(S1→S3).H0:0.b0:7={0x7E}∩DP1(S1→S3).H1:1.b0:7={0x7E}∩DP1(S1→S3).B2:2.b0:7={0x99} (13)
establishing a model for the question-answer relationship of multiple data packets in a communication protocol (the question-answer relationship model of communication data packets):
R1={DP1(S0→S1)B2:2(b0:7∈(0x93,0xAA,0x6D,0x00,0xA6,0xFF),DP1(S1→S0)B2:2(b0:7∈(0x93,0xAA,0x6D,0x00,0xA6,0xFF)} (14)
R1={DP1(S1→S3),DP1(S3→S1)} (15)
R1={DP1(S1→S2),DP1(S2→S1)} (16)
establishing a model for the element decomposition and combination relation among the data packets in the communication protocol (the decomposition and combination relation model of the element information of the communication data packets):
DP1(S0→S1)(B2:2)=DP1(S1→S2)(B3:3)U DP1(S1→S3)(B3:3) (17)
DP1(S0→S1)(B3:4U B5:6U B7:9)=DP1(S1→S3)(B4:5U B6:7U B8:10) (18)
DP1(S3→S1)(B4:6)=DP1(S1→S2)(B4:6) (19)
DP1(S3→S1)(B3:3(b0:3))UDP1(S2→S1)(B3:3(b4:5))=DP1(S1→S0)(B3:3(b0:5)) (20)
the natural language description mode of the serial interface communication protocols among subsystems in the aerospace system can be converted into machine language through the established 20 small mathematical models, and then automatic testing of the serial interface communication protocols can be realized through a computer, so that testing efficiency is improved.
Corresponding to the application-oriented interface communication protocol modeling method provided by the embodiment of the present invention, the embodiment of the present invention further provides an interface communication protocol modeling apparatus, which, referring to fig. 3, includes:
the system comprises an extraction module 1, a data transmission module and a data transmission module, wherein the extraction module 1 is used for analyzing a serial interface communication protocol, extracting data for user application and recording the data for the user application as a communication data packet, and the serial interface communication protocol is a data transmission requirement for connecting a plurality of systems;
a determiningmodule 2, configured to count the communication data packets in units of bytes, and determine byte information of the communication data packets;
and the establishingmodule 3 is used for establishing a mathematical model of the serial interface communication protocol according to the relationship information of the communication data packets transmitted among the communication systems and the byte information of the communication data packets.
Specifically, the establishing module includes:
the device comprises a first establishing unit, a second establishing unit and a third establishing unit, wherein the first establishing unit is used for determining the number information of communication data packets transmitted among systems and the byte information of the communication data packets transmitted among the systems and establishing a mathematical model of each communication data packet;
the second establishing unit is used for determining the element information of each communication data packet according to the byte information of each communication data packet and establishing a mathematical model of the element relation of the communication data packets according to the element information;
the third establishing unit is used for verifying the parameter content of the element information and establishing an element verification relation model according to a verification result;
the fourth establishing unit is used for determining the value range of each system data, determining the question-answer relationship among the systems according to the value range, and establishing a question-answer relationship model of the communication data packet according to the question-answer relationship;
and a fifth establishing unit, configured to determine, according to the received communication data packet of each system, data that distributes the element information in the received communication data packet according to a preset relationship, and establish a decomposition and combination relationship model of the element information in the communication data packet, where the preset relationship includes a decomposition relationship and a combination relationship.
Optionally, the method further includes:
and the checking module is used for checking the serial interface communication protocol according to the mathematical model of the serial interface communication protocol.
Optionally, the method further includes:
and the information determining module is used for analyzing the serial interface communication protocol and determining the relation information between the system connected with the serial interface communication protocol and each system.
Optionally, the method further includes:
and the form determining module is used for determining the composition form of the communication data packet and carrying out byte statistics according to the composition form, wherein the composition form comprises bytes, words and double words.
According to the application-oriented interface communication protocol modeling device provided by the embodiment of the invention, the data and the interaction relation oriented to the user application in the serial interface communication protocol are analyzed, and byte information is obtained by counting based on bytes, so that various communication protocols can be analyzed according to a uniform counting method. And then establishing a mathematical model for completing description of various action relationships of the communication protocol based on the information obtained by analysis. And then, the system communication protocol described by the natural language can be converted into a machine language which can be identified by a computer based on the mathematical model, so that a universal representation mode of the communication protocol is obtained through the mathematical model, the communication protocol can be automatically tested according to the mathematical model, and the testing efficiency is improved.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.