CN112202798A - Data protocol conversion method, system, electronic device and storage medium - Google Patents
Data protocol conversion method, system, electronic device and storage medium Download PDFInfo
- Publication number
- CN112202798A CN112202798A CN202011073525.XA CN202011073525A CN112202798A CN 112202798 A CN112202798 A CN 112202798A CN 202011073525 A CN202011073525 A CN 202011073525A CN 112202798 A CN112202798 A CN 112202798A
- Authority
- CN
- China
- Prior art keywords
- protocol
- data
- interface
- protocol conversion
- routing system
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000006243 chemical reaction Methods 0.000 title claims abstract description 134
- 238000000034 method Methods 0.000 title claims abstract description 62
- 238000005538 encapsulation Methods 0.000 claims abstract description 14
- 230000006870 function Effects 0.000 claims description 93
- 238000004590 computer program Methods 0.000 claims description 7
- 238000013519 translation Methods 0.000 claims description 6
- 238000012545 processing Methods 0.000 abstract description 5
- 239000002699 waste material Substances 0.000 abstract description 4
- 230000008569 process Effects 0.000 description 14
- 238000010586 diagram Methods 0.000 description 5
- 230000003993 interaction Effects 0.000 description 5
- 238000007726 management method Methods 0.000 description 5
- 238000012795 verification Methods 0.000 description 4
- 230000008859 change Effects 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 239000004973 liquid crystal related substance Substances 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000012360 testing method Methods 0.000 description 2
- 230000001960 triggered effect Effects 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/08—Protocols for interworking; Protocol conversion
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/541—Interprogram communication via adapters, e.g. between incompatible applications
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Communication Control (AREA)
Abstract
The invention relates to the field of data processing, and discloses a protocol conversion method of data, which comprises the following steps: initializing a protocol stack and a routing system according to a protocol conversion instruction input by a user, when the protocol stack and the routing system are initialized successfully, creating an interface data calling function in the routing system, acquiring interface protocol data from an interface circuit by using the interface data calling function, decapsulating the interface protocol data to obtain protocol original data, encapsulating the protocol original data according to a preset protocol rule and the protocol stack to obtain protocol encapsulated data, and returning the protocol encapsulated data to the user according to the protocol conversion instruction. The invention also relates to a block chaining technique, said protocol encapsulation data being storable in block chaining points. In addition, the invention also discloses a protocol conversion system of data, an electronic device and a storage medium. The invention can solve the problem of data waste caused by complicated configuration steps during protocol conversion.
Description
Technical Field
The present invention relates to the field of data processing, and in particular, to a method, a system, an electronic device, and a computer-readable storage medium for converting a protocol of data.
Background
With the rapid development of science and technology, the requirement for interactivity of various devices is also increased, but because protocols on which different devices depend are different, protocol data of the devices need to be unified before interaction.
The protocol data conversion commonly used at present comprises a characteristic keyword protocol conversion method, a bit type fixed format conversion method and the like, although the protocol conversion function can be completed, the configuration steps for configuring each protocol conversion method are complicated due to the independent existence of different protocol conversion methods and different operation environments, and further, the data waste is caused.
Disclosure of Invention
The invention provides a method, a system, electronic equipment and a computer readable storage medium for converting a data protocol, and mainly aims to solve the problem that data is wasted due to complicated configuration steps during conversion of each protocol.
In order to achieve the above object, the present invention provides a method for converting a protocol of data, including:
initializing a protocol stack and a routing system according to a protocol conversion instruction input by a user;
when the protocol stack and the routing system are initialized successfully, an interface data calling function is established in the routing system;
calling a function by using the interface data to acquire interface protocol data from an interface circuit;
decapsulating the interface protocol data to obtain protocol original data;
and encapsulating the protocol original data according to a preset protocol rule and the protocol stack to obtain protocol encapsulation data, and returning the protocol encapsulation data to a user according to the protocol conversion instruction.
Optionally, before initializing the protocol stack and the routing system according to the protocol conversion instruction, the method further includes:
and receiving the protocol conversion instruction input by the user, and analyzing the protocol conversion instruction to obtain the interface information of one or more interface circuits corresponding to the protocol conversion instruction.
Optionally, the initializing, according to the protocol conversion instruction, the protocol stack and the routing system includes:
initializing the routing system, and when the routing system fails to initialize, re-receiving a protocol conversion instruction input by a user;
and when the routing system is initialized successfully, acquiring one or more interface circuit protocols supported by the interface circuit, and initializing the protocol stack according to the interface circuit protocols.
Optionally, the creating an interface data call function in the routing system includes:
taking the interface circuit protocol as an input parameter of a pre-constructed data call API, and generating an original data call function;
and compiling the original data calling function to obtain the interface data calling function.
Optionally, the obtaining interface protocol data from the interface circuit by using the interface data call function includes:
calling a function by using the interface data, and starting a pre-constructed driver;
and acquiring the interface protocol data from the corresponding interface circuit by using the driver.
Optionally, the interface protocol data includes: the system comprises state interface protocol data, control interface protocol data, start-stop interface protocol data, rule issuing interface protocol data, updating interface protocol data and timing interface protocol data.
In order to solve the above problem, the present invention further provides a data protocol conversion system, which is characterized in that the system includes a network layer, a system layer and a driver layer, wherein:
the network layer is used for initializing a protocol stack and a routing system according to a protocol conversion instruction input by a user;
the system layer is used for creating an interface data call function in the routing system when the protocol stack and the routing system are initialized successfully;
the driving layer is used for calling a function by using the interface data and acquiring interface protocol data from an interface circuit;
the network layer is further configured to decapsulate the interface protocol data to obtain protocol raw data, encapsulate the protocol raw data according to a preset protocol rule and the protocol stack to obtain protocol encapsulated data, and return the protocol encapsulated data to a user according to the protocol conversion instruction.
Optionally, the system further comprises an application layer, wherein:
and the application layer is used for receiving the protocol conversion instruction input by the user, analyzing the protocol conversion instruction and obtaining the interface information of one or more interface circuits corresponding to the protocol conversion instruction.
In order to solve the above problem, the present invention also provides an electronic device, including: at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the protocol translation method for data described above.
In order to solve the above problem, the present invention further provides a computer-readable storage medium comprising a storage data area and a storage program area, wherein the storage data area stores created data, and the storage program area stores a computer program; wherein the computer program, when executed by a processor, implements the protocol translation method for data described above.
The embodiment of the invention firstly initializes a protocol stack and a routing system according to a protocol conversion instruction, wherein the protocol stack comprises each layer of protocol in a network and a conversion method which each layer of protocol depends on, and in order to ensure that the protocol stack operates without errors and initialize the protocol stack and the routing system which the protocol stack is positioned. The protocol stack depends on the routing system, and the routing system can support an interface data call function, obtain interface protocol data from an interface circuit, and convert the interface protocol data by using a conversion method in the protocol stack, so that the automation degree of the whole conversion process is high, an operation environment does not need to be configured independently due to different protocol conversion methods, and the problems of complicated configuration steps and data waste in data conversion are solved.
Drawings
Fig. 1 is a data interaction diagram of a protocol conversion method for data according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of a protocol conversion method for data according to an embodiment of the present invention;
fig. 3 is a detailed flowchart of S2 in the protocol conversion method for data according to an embodiment of the present invention;
fig. 4 is a detailed flowchart of S3 in the protocol conversion method for data according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a data protocol conversion system according to an embodiment of the present invention
Fig. 6 is a schematic internal structural diagram of an electronic device implementing a protocol conversion method for data according to an embodiment of the present invention;
the implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The execution subject of the protocol conversion method for data provided by the embodiment of the present application includes, but is not limited to, at least one of electronic devices, such as a server and a terminal, that can be configured to execute the method provided by the embodiment of the present application. In other words, the protocol conversion method of the data may be performed by software or hardware installed in the terminal device or the server device, and the software may be a block chain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like.
The core of the embodiment of the invention lies in that the constructed data protocol conversion system is utilized to acquire protocol data from an interface circuit and convert the protocol data into specified protocol data, thereby solving the problem of difficult interaction caused by different protocols of equipment where different interface circuits are positioned.
The following describes details of implementation of protocol conversion of data in the present embodiment, and the following is only provided for easy understanding and is not necessary for implementing the present embodiment.
The embodiment of the present invention is shown in fig. 1, which shows a data interaction process between the data protocol conversion system, the interface circuit and the user, and specifically includes:
1. a user sends a protocol conversion instruction to a data protocol conversion system;
2. the data protocol conversion system acquires interface protocol data from a pre-bound interface circuit according to the protocol conversion instruction;
3. and after the data protocol conversion system acquires the interface protocol data, carrying out protocol conversion on the interface protocol data in the data protocol conversion system.
Further, as shown in fig. 1, the data protocol conversion system includes an application layer, a network layer, a system layer, and a driver layer. Wherein:
application layer001Is mainly used for consolidatingAnd the current interactive function with the user is to receive the protocol conversion instruction input by the user, analyze the protocol conversion instruction and obtain one or more interface circuits corresponding to the protocol conversion instruction.
Network layer002The method is mainly used for realizing the function of a protocol stack, and is used for initializing the protocol stack and a routing system and decapsulating interface protocol data to obtain protocol original data according to a protocol conversion instruction, and encapsulating the protocol original data according to a preset protocol rule and the protocol stack to obtain protocol encapsulated data. The Protocol stack (also called Protocol stack) refers to a conversion method that is relied on by each layer Protocol in the sum of each layer Protocol in the network. Each layer of protocol comprises an upper layer protocol, a bottom layer protocol and the like, wherein the upper layer protocol is a protocol on which an application layer interacts with a user, and the bottom layer protocol is a protocol on which a driving layer interacts with an interface circuit. Further, the protocol stack of the present invention may use the currently disclosed TCP/IP protocol, OSI protocol stack, ZigBee protocol stack, etc., such as encapsulating codes, function libraries, etc. relied on by the OSI protocol stack in the network layer, and providing an initialization protocol stack interface, a data protocol conversion interface, etc.
System layer003The function of creating an interface data call function in the routing system is mainly realized. The system layer comprises operating systems such as a routing system for transmitting protocol data, a user operation application layer, a drive layer and an interface circuit, and the like, so that an interface data call function can be constructed by using the operating systems in the system layer. Preferably, the protocol stack runs on the routing system.
Drive layer004The interface data is mainly used for calling a function and acquiring interface protocol data from an interface circuit, the driving layer mainly comprises a driver, and the interface circuit is driven to send the interface protocol data by using the driver and the interface data calling function. The drivers include an RS232 driver, a ZigBee driver, a CAN driver, and the like.
Further, an embodiment of the present invention further provides a data protocol conversion method, and as shown in fig. 2, in this embodiment, a flow of the data protocol conversion method includes:
and S1, initializing the protocol stack and the routing system according to the protocol conversion instruction input by the user.
In the preferred embodiment of the invention, the protocol stack can use the currently disclosed TCP/IP protocol, OSI protocol stack, ZigBee protocol stack and the like, for example, codes, function libraries and the like which are depended on by the OSI protocol stack are packaged, an automatic initialization protocol stack interface is provided, when a protocol conversion instruction input by a user is received, the initialization protocol stack interface is automatically triggered, whether the codes and the function libraries which are depended on by the protocol stack are successfully packaged or not is checked, and the like.
In addition, as can be seen from the data interaction of the data protocol conversion system in fig. 1, the protocol conversion instruction is generally sent to the application layer by the user, and the data protocol conversion system generally binds to a plurality of interface circuits, so that it is necessary to determine which interface circuits the user needs to perform data protocol conversion according to the protocol conversion instruction sent by the user. In detail, the method includes, before the step S1:
and receiving a protocol conversion instruction input by a user, analyzing the protocol conversion instruction, and obtaining interface information of one or more interface circuits corresponding to the protocol conversion instruction.
In detail, in a preferred embodiment of the present invention, after receiving a protocol conversion command input by a user, a command line parser of the system layer, such as a CMD parser under Windows, is automatically invoked, a protocol conversion parsing script and an input protocol conversion command pre-constructed by a developer are sent to the command line parser, and the protocol conversion command is automatically parsed, so as to obtain interface information of one or more interface circuits.
Further, after obtaining one or more interface circuits corresponding to the protocol conversion instruction, the S1 includes:
step A, initializing the routing system, and when the routing system fails to initialize, re-receiving a protocol conversion instruction input by a user;
since the protocol stack runs on the routing system, the routing system needs to be initialized before the protocol stack is initialized, so that the problem of protocol stack initialization caused by the failure of the routing system is prevented.
Further, the initialization of the routing system includes clearing a cache of the routing system, checking a garbage collection timer, checking IP layer protocol security, and the like.
In the preferred embodiment of the invention, a Timer of system.thread class in C + + programming language can be called, and after the calling is successful, the system garbage can be automatically recovered by operating the Timer. In addition, a key system (such as Kerberos) is used for checking the safety of the IP layer protocol, a temporary encryption key is generated by the key system, a data packet transmitted by the routing system is temporarily encrypted, the encrypted data packet is read, modified and inserted for verification, and whether the IP layer protocol passes the verification is judged.
And step B, when the routing system is initialized successfully, acquiring one or more interface circuit protocols supported by the interface circuit, and initializing the protocol stack according to the interface circuit protocols.
In detail, initializing the protocol stack according to the interface circuit protocol includes:
starting a process of an initialization function corresponding to the interface circuit protocol by using the routing system; and sequentially initializing the protocol stack according to the process of the initialization function.
If a kernel named kernel _ thread is called in the routing system, a process for initializing the function is started, and a function named do _ basic _ setup is called by the process to initialize the entrance of the Internet packet switching protocol of the TCP/IP protocol stack.
And S2, when the protocol stack and the routing system are initialized successfully, creating an interface data call function in the routing system.
In the embodiment of the invention, after the routing system and the protocol stack are initialized successfully, the interface data call function is generated in the network layer. In detail, referring to fig. 3, the creating of the interface data call function in the routing system includes:
s21, taking the interface circuit protocol as an input parameter of a pre-constructed data call API, and generating an original data call function;
if the original data call function is:
Def API-call(Data-communication-protocol):
Data-communication-protocol=Telnet
among them, "Def API-call (Data-communication-protocol): "represents the calling function of the Data calling API, the function name is API-call, and the Data-communication-protocol needs to be assigned, so that the interface circuit protocol is assigned to the Data calling API by the Telnet protocol, and the original Data calling function is obtained.
And S22, compiling the original data calling function to obtain the interface data calling function.
In detail, compiling the raw data call function includes: compiling the original data calling function by using a compiler to obtain an assembly calling function, and calling the assembler to change the assembly calling function into the interface data calling function.
The compiler is a program for translating a high-level language, such as the C + + programming language, into a low-level language, which includes an assembly language in which a computer can directly operate, and the compiling is performed to allow the computer to test an original data call function, so as to ensure that the original data call function will not make an error in the subsequent process. An Assembler (Assembler) is a program that translates assembly language into programming language.
As described above, in the embodiment of the present invention, a protocol conversion instruction input by a user is analyzed to obtain one or more interface circuits corresponding to the protocol conversion instruction, and protocols corresponding to each interface circuit are different, for example, a protocol a corresponding to a first interface circuit, a protocol B corresponding to a second interface circuit, and the like, so that an interface data call function corresponding to each interface circuit needs to be constructed according to the interface circuit protocol corresponding to the interface circuit.
And S3, calling a function by using the interface data, and acquiring interface protocol data from the interface circuit.
In detail, referring to fig. 4, the S3 includes:
s31, calling a function by using the interface data, and starting a pre-constructed driver;
and S32, acquiring the interface protocol data from the corresponding interface circuit by using the driver.
As described above, in the embodiment of the present invention, the driver in the driver layer in the data protocol conversion system is started, and the driver is used to obtain the interface protocol data from the interface circuit.
In detail, the interface protocol data may be divided into device status interface protocol data, device control interface protocol data, device start/stop interface protocol data, device rule issuing interface protocol data, device update interface protocol data, device timing interface protocol data, and the like according to different interface circuits.
S4, decapsulating the interface protocol data to obtain protocol original data.
Preferably, in the embodiment of the present invention, the interface protocol data needs to be decapsulated correspondingly according to a data form, where the interface protocol data includes MAC data, IP data, TCP data, source data, and the like, where the source data includes run data of the interface circuit during running, the decapsulation includes splitting the interface protocol data into the MAC data, the IP data, the TCP data, the source data, and the like, and recording the source data as protocol raw data.
If the interface protocol data structure _ MAC _ FRAME _ HEADER is transmitted in the following order:
typedef struct_MAC_FRAME_HEADER
{char m_cDstMacAddress;
charm _ cSrcMAC address; // mac data
short m _ cType; // IP protocol and data } \\ u
Then the MAC data and the IP data can be parsed out from struct _ MAC _ FRAME _ HEADER according to the sequence, and so on, thereby obtaining the protocol raw data.
And S5, according to the preset protocol rule and the protocol stack, encapsulating the protocol original data to obtain protocol encapsulated data, and according to the protocol conversion instruction, returning the protocol encapsulated data to the user.
In detail, after the protocol raw data is obtained, the protocol raw data is input to the network layer for encapsulation by using an operating system in the system layer, the encapsulation methods are different, and if the protocol raw data is encapsulated in the head and the tail of a group of protocols, the encapsulation of the protocol raw data in the head and the tail of a group of protocols is called as a preset protocol rule. And then returning the obtained protocol encapsulation data to the user according to a protocol conversion instruction input by the user.
The embodiment of the invention firstly initializes a protocol stack and a routing system according to a protocol conversion instruction, wherein the protocol stack comprises each layer of protocol in a network and a conversion method which each layer of protocol depends on, and in order to ensure that the protocol stack operates without errors and initialize the protocol stack and the routing system which the protocol stack is positioned. The protocol stack depends on the routing system, and the routing system can support an interface data call function, obtain interface protocol data from an interface circuit, and convert the interface protocol data by using a conversion method in the protocol stack, so that the automation degree of the whole conversion process is high, an operation environment does not need to be configured independently due to different protocol conversion methods, and the problems of complicated configuration steps and data waste in data conversion are solved.
Fig. 5 is a block diagram of the data protocol conversion system according to the present invention.
The data protocol conversion system 100 according to the embodiment of the present invention may be installed in an electronic device. According to the implemented functions, the data protocol conversion system may include a network layer 101, a system layer 102, and a driver layer 103. A module according to the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and that can perform a fixed function, and that are stored in a memory of the electronic device.
In the embodiment of the present invention, the functions of the modules/units are as follows:
the network layer 101 is configured to initialize a protocol stack and a routing system according to a protocol conversion instruction input by a user.
In the preferred embodiment of the invention, the protocol stack can use the currently disclosed TCP/IP protocol, OSI protocol stack, ZigBee protocol stack and the like, for example, codes, function libraries and the like which are depended on by the OSI protocol stack are packaged, an automatic initialization protocol stack interface is provided, when a protocol conversion instruction input by a user is received, the initialization protocol stack interface is automatically triggered, whether the codes and the function libraries which are depended on by the protocol stack are successfully packaged or not is checked, and the like.
In detail, the data protocol conversion system further includes an application layer 104, configured to parse the protocol conversion instruction to obtain interface information of one or more interface circuits corresponding to the protocol conversion instruction.
The protocol conversion instruction is generally sent to the application layer 104 by a user, and the data protocol conversion system generally binds a plurality of interface circuits, so that it is necessary to determine which interface circuits the user needs to perform data protocol conversion according to the protocol conversion instruction sent by the user.
In detail, in a preferred embodiment of the present invention, after receiving a protocol conversion command input by a user, a command line parser of the system layer, such as a CMD parser under Windows, is automatically invoked, a protocol conversion parsing script and an input protocol conversion command pre-constructed by a developer are sent to the command line parser, and the protocol conversion command is automatically parsed, so as to obtain interface information of one or more interface circuits.
Further, after obtaining one or more interface circuits corresponding to the protocol conversion instruction, the initializing a protocol stack and a routing system according to the protocol conversion instruction input by the user includes:
step A, initializing the routing system, and when the routing system fails to initialize, re-receiving a protocol conversion instruction input by a user;
since the protocol stack runs on the routing system, the routing system needs to be initialized before the protocol stack is initialized, so that the problem of protocol stack initialization caused by the failure of the routing system is prevented.
Further, the initialization of the routing system includes clearing a cache of the routing system, checking a garbage collection timer, checking IP layer protocol security, and the like.
In the preferred embodiment of the invention, a Timer of system.thread class in C + + programming language can be called, and after the calling is successful, the system garbage can be automatically recovered by operating the Timer. In addition, a key system (such as Kerberos) is used for checking the safety of the IP layer protocol, a temporary encryption key is generated by the key system, a data packet transmitted by the routing system is temporarily encrypted, the encrypted data packet is read, modified and inserted for verification, and whether the IP layer protocol passes the verification is judged.
And step B, when the routing system is initialized successfully, acquiring one or more interface circuit protocols supported by the interface circuit, and initializing the protocol stack according to the interface circuit protocols.
In detail, initializing the protocol stack according to the interface circuit protocol includes:
starting a process of an initialization function corresponding to the interface circuit protocol by using the routing system; and sequentially initializing the protocol stack according to the process of the initialization function.
If a kernel named kernel _ thread is called in the routing system, a process for initializing the function is started, and a function named do _ basic _ setup is called by the process to initialize the entrance of the Internet packet switching protocol of the TCP/IP protocol stack.
The system layer 102 is configured to create an interface data call function in the routing system when the protocol stack and the routing system are initialized successfully.
In the embodiment of the invention, after the routing system and the protocol stack are initialized successfully, the interface data call function is generated in the network layer. In detail, the creating of the interface data call function within the routing system includes: taking the interface circuit protocol as an input parameter of a pre-constructed data call API, and generating an original data call function; and compiling the original data calling function to obtain the interface data calling function.
If the original data call function is:
Def API-call(Data-communication-protocol):
Data-communication-protocol=Telnet
among them, "Def API-call (Data-communication-protocol): "represents the calling function of the Data calling API, the function name is API-call, and the Data-communication-protocol needs to be assigned, so that the interface circuit protocol is assigned to the Data calling API by the Telnet protocol, and the original Data calling function is obtained.
In detail, compiling the raw data call function includes: compiling the original data calling function by using a compiler to obtain an assembly calling function, and calling the assembler to change the assembly calling function into the interface data calling function.
The compiler is a program for translating a high-level language, such as the C + + programming language, into a low-level language, which includes an assembly language in which a computer can directly operate, and the compiling is performed to allow the computer to test an original data call function, so as to ensure that the original data call function will not make an error in the subsequent process. An Assembler (Assembler) is a program that translates assembly language into programming language.
As described above, in the embodiment of the present invention, a protocol conversion instruction input by a user is analyzed to obtain one or more interface circuits corresponding to the protocol conversion instruction, and protocols corresponding to each interface circuit are different, for example, a protocol a corresponding to a first interface circuit, a protocol B corresponding to a second interface circuit, and the like, so that an interface data call function corresponding to each interface circuit needs to be constructed according to the interface circuit protocol corresponding to the interface circuit.
The driver layer 103 is configured to call a function using the interface data, and obtain interface protocol data from an interface circuit.
In detail, the obtaining interface protocol data from the interface circuit by using the interface data call function includes: calling a function by using the interface data, and starting a pre-constructed driver; and acquiring the interface protocol data from the corresponding interface circuit by using the driver.
As described above, in the embodiment of the present invention, the driver in the driver layer in the data protocol conversion system is started, and the driver is used to obtain the interface protocol data from the interface circuit.
In detail, the interface protocol data may be divided into device status interface protocol data, device control interface protocol data, device start/stop interface protocol data, device rule issuing interface protocol data, device update interface protocol data, device timing interface protocol data, and the like according to different interface circuits.
The network layer 101 is further configured to decapsulate the interface protocol data to obtain protocol raw data, encapsulate the protocol raw data according to a preset protocol rule and the protocol stack to obtain protocol encapsulated data, and return the protocol encapsulated data to a user according to the protocol conversion instruction.
Preferably, in the embodiment of the present invention, the interface protocol data needs to be decapsulated correspondingly according to a data form, where the interface protocol data includes MAC data, IP data, TCP data, source data, and the like, where the source data includes run data of the interface circuit during running, the decapsulation includes splitting the interface protocol data into the MAC data, the IP data, the TCP data, the source data, and the like, and recording the source data as protocol raw data.
If the interface protocol data structure _ MAC _ FRAME _ HEADER is transmitted in the following order:
typedef struct_MAC_FRAME_HEADER
{char m_cDstMacAddress;
charm _ cSrcMAC address; // mac data
short m _ cType; // IP protocol and data } \\ u
Then the MAC data and the IP data can be parsed out from struct _ MAC _ FRAME _ HEADER according to the sequence, and so on, thereby obtaining the protocol raw data.
In detail, after the protocol raw data is obtained, the protocol raw data is input to a network layer for encapsulation by using an operating system in the system layer, the encapsulation methods are different, if the protocol raw data is encapsulated in the head and the tail of a group of protocols, the protocol raw data is encapsulated in the head and the tail of the group of protocols, which is called as a preset protocol rule, and then the obtained protocol encapsulation data is returned to a user according to a protocol conversion instruction input by the user.
Fig. 6 is a schematic structural diagram of an electronic device implementing the protocol conversion method of data according to the present invention.
The electronic device 1 may comprise a processor 10, a memory 11 and a bus, and may further comprise a computer program, such as a protocol conversion program 12 of data, stored in the memory 11 and executable on the processor 10.
The memory 11 includes at least one type of readable storage medium, which includes flash memory, removable hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device 1, such as a removable hard disk of the electronic device 1. The memory 11 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device 1. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device 1. The memory 11 may be used not only to store application software installed in the electronic device 1 and various types of data, such as codes of the protocol conversion program 12 of the data, but also to temporarily store data that has been output or is to be output.
The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same or different functions, including one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the electronic device by using various interfaces and lines, and executes various functions and processes data of the electronic device 1 by running or executing programs or modules (e.g., a protocol conversion program for executing data, etc.) stored in the memory 11 and calling data stored in the memory 11.
The bus may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is arranged to enable connection communication between the memory 11 and at least one processor 10 or the like.
Fig. 6 only shows an electronic device with components, and it will be understood by a person skilled in the art that the structure shown in fig. 5 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than shown, or a combination of certain components, or a different arrangement of components.
For example, although not shown, the electronic device 1 may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 10 through a power management device, so as to implement functions of charge management, discharge management, power consumption management, and the like through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device 1 may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
Further, the electronic device 1 may further include a network interface, and optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), which are generally used for establishing a communication connection between the electronic device 1 and other electronic devices.
Optionally, the electronic device 1 may further comprise a user interface, which may be a Display (Display), an input unit (such as a Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable for displaying information processed in the electronic device 1 and for displaying a visualized user interface, among other things.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The protocol conversion program 12 of the data stored in the memory 11 of the electronic device 1 is a combination of a plurality of instructions, which when executed in the processor 10, can realize:
initializing a protocol stack and a routing system according to a protocol conversion instruction input by a user;
when the protocol stack and the routing system are initialized successfully, an interface data calling function is established in the routing system;
calling a function by using the interface data to acquire interface protocol data from an interface circuit;
decapsulating the interface protocol data to obtain protocol original data;
and encapsulating the protocol original data according to a preset protocol rule and the protocol stack to obtain protocol encapsulation data, and returning the protocol encapsulation data to a user according to the protocol conversion instruction.
Further, the integrated modules/units of the electronic device 1, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. The computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
Further, the computer usable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the blockchain node, and the like.
In the embodiments provided by the present invention, it should be understood that the disclosed apparatus, system, and method may be implemented in other ways. For example, the system embodiments described above are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any accompanying claims should not be construed as limiting the claim concerned.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims (10)
1. A method for protocol translation of data, the method comprising:
initializing a protocol stack and a routing system according to a protocol conversion instruction input by a user;
when the protocol stack and the routing system are initialized successfully, an interface data calling function is established in the routing system;
calling a function by using the interface data to acquire interface protocol data from an interface circuit;
decapsulating the interface protocol data to obtain protocol original data;
and encapsulating the protocol original data according to a preset protocol rule and the protocol stack to obtain protocol encapsulation data, and returning the protocol encapsulation data to a user according to the protocol conversion instruction.
2. The method for protocol conversion of data according to claim 1, wherein before initializing the protocol stack and the routing system according to the protocol conversion instruction, the method further comprises:
and receiving the protocol conversion instruction input by the user, and analyzing the protocol conversion instruction to obtain the interface information of one or more interface circuits corresponding to the protocol conversion instruction.
3. The method for protocol conversion of data according to claim 2, wherein initializing a protocol stack and a routing system according to the protocol conversion instruction comprises:
initializing the routing system, and when the routing system fails to initialize, re-receiving a protocol conversion instruction input by a user;
and when the routing system is initialized successfully, acquiring one or more interface circuit protocols supported by the interface circuit, and initializing the protocol stack according to the interface circuit protocols.
4. A method for protocol translation of data according to claim 3, wherein said creating an interface data call function within said routing system comprises:
taking the interface circuit protocol as an input parameter of a pre-constructed data call API, and generating an original data call function;
and compiling the original data calling function to obtain the interface data calling function.
5. The method for protocol conversion of data according to claim 1, wherein the obtaining interface protocol data from the interface circuit by using the interface data call function comprises:
calling a function by using the interface data, and starting a pre-constructed driver;
and acquiring the interface protocol data from the corresponding interface circuit by using the driver.
6. The method for protocol conversion of data according to claim 1, wherein the interface protocol data includes: the system comprises state interface protocol data, control interface protocol data, start-stop interface protocol data, rule issuing interface protocol data, updating interface protocol data and timing interface protocol data.
7. A data protocol conversion system, comprising a network layer, a system layer, and a driver layer, wherein:
the network layer is used for initializing a protocol stack and a routing system according to a protocol conversion instruction input by a user;
the system layer is used for creating an interface data call function in the routing system when the protocol stack and the routing system are initialized successfully;
the driving layer is used for calling a function by using the interface data and acquiring interface protocol data from an interface circuit;
the network layer is further configured to decapsulate the interface protocol data to obtain protocol raw data, encapsulate the protocol raw data according to a preset protocol rule and the protocol stack to obtain protocol encapsulated data, and return the protocol encapsulated data to a user according to the protocol conversion instruction.
8. The data protocol conversion system of claim 7, wherein the system further comprises an application layer, wherein:
and the application layer is used for receiving the protocol conversion instruction input by the user, analyzing the protocol conversion instruction and obtaining the interface information of one or more interface circuits corresponding to the protocol conversion instruction.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a protocol translation method for data according to any one of claims 1 to 7.
10. A computer-readable storage medium comprising a storage data area and a storage program area, wherein the storage data area stores created data, and the storage program area stores a computer program; wherein the computer program, when executed by a processor, implements a protocol translation method for data according to any of claims 1 to 7.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011073525.XA CN112202798B (en) | 2020-10-09 | 2020-10-09 | Data protocol conversion method, system, electronic device and storage medium |
PCT/CN2020/131975 WO2021189898A1 (en) | 2020-10-09 | 2020-11-26 | Protocol conversion method and system for data, and electronic device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011073525.XA CN112202798B (en) | 2020-10-09 | 2020-10-09 | Data protocol conversion method, system, electronic device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112202798A true CN112202798A (en) | 2021-01-08 |
CN112202798B CN112202798B (en) | 2022-07-15 |
Family
ID=74013792
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011073525.XA Active CN112202798B (en) | 2020-10-09 | 2020-10-09 | Data protocol conversion method, system, electronic device and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN112202798B (en) |
WO (1) | WO2021189898A1 (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114338448B (en) * | 2021-12-29 | 2024-02-20 | 北京天融信网络安全技术有限公司 | Performance test method and device, electronic equipment and storage medium |
CN115580665B (en) * | 2022-11-18 | 2023-03-10 | 中国信息通信研究院 | Block chain-based transport protocol conversion method, device, storage medium and equipment |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1728701A (en) * | 2004-07-30 | 2006-02-01 | 国家数字交换系统工程技术研究中心 | Method for treating protocol stack of route through one process |
US20110107357A1 (en) * | 2009-11-03 | 2011-05-05 | Ian Henry Stuart Cullimore | TCP/IP Stack-Based Operating System |
CN109857569A (en) * | 2018-11-08 | 2019-06-07 | 深圳壹账通智能科技有限公司 | Interface calling processing method and device, storage medium, computer equipment |
CN110166485A (en) * | 2019-06-14 | 2019-08-23 | 北京经纬恒润科技有限公司 | A kind of the scheduling application method and device of agreement |
CN111541688A (en) * | 2020-04-21 | 2020-08-14 | 深圳市高川自动化技术有限公司 | Embedded system compatible with multiple protocols, data processing method and device |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1419626B1 (en) * | 2001-08-24 | 2006-04-12 | Windmill Microsystems Holding B.V. | System for remote data acquisition based on e-mail message communication through public and private networks and corresponding method and computer program |
CN109672732B (en) * | 2018-12-18 | 2021-10-22 | 浩云科技股份有限公司 | Interface adaptation method, device and system |
-
2020
- 2020-10-09 CN CN202011073525.XA patent/CN112202798B/en active Active
- 2020-11-26 WO PCT/CN2020/131975 patent/WO2021189898A1/en active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1728701A (en) * | 2004-07-30 | 2006-02-01 | 国家数字交换系统工程技术研究中心 | Method for treating protocol stack of route through one process |
US20110107357A1 (en) * | 2009-11-03 | 2011-05-05 | Ian Henry Stuart Cullimore | TCP/IP Stack-Based Operating System |
CN109857569A (en) * | 2018-11-08 | 2019-06-07 | 深圳壹账通智能科技有限公司 | Interface calling processing method and device, storage medium, computer equipment |
CN110166485A (en) * | 2019-06-14 | 2019-08-23 | 北京经纬恒润科技有限公司 | A kind of the scheduling application method and device of agreement |
CN111541688A (en) * | 2020-04-21 | 2020-08-14 | 深圳市高川自动化技术有限公司 | Embedded system compatible with multiple protocols, data processing method and device |
Also Published As
Publication number | Publication date |
---|---|
CN112202798B (en) | 2022-07-15 |
WO2021189898A1 (en) | 2021-09-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9348771B1 (en) | Cloud-based instrument driver system | |
CN112202798B (en) | Data protocol conversion method, system, electronic device and storage medium | |
CN105005471A (en) | Method, device, server and system for modifying configuration parameters of BIOS | |
CN113238929B (en) | Code testing method and device based on Mock data, electronic equipment and storage medium | |
CN112506779A (en) | Software interface testing method and device, electronic equipment and storage medium | |
CN112528307A (en) | Service request checking method and device, electronic equipment and storage medium | |
CN104899085A (en) | Data processing method and apparatus | |
CN111294235A (en) | Data processing method, device, gateway and readable storage medium | |
CN113377661A (en) | Interface testing method and device, electronic equipment and storage medium | |
CN113761412A (en) | Application page display method and device, electronic equipment, medium and application system | |
CN114035987A (en) | Data transmission method and device based on message queue, electronic equipment and medium | |
CN111026439A (en) | Application program compatibility method, device, equipment and computer storage medium | |
CN113541929B (en) | Control method for system-on-chip quantum key distribution control system based on configuration | |
CN116450109A (en) | Modbus communication library adaptation method under MATLAB and CCS combined development mode | |
CN111459510A (en) | Cross-network operating system installation method and device, electronic equipment and medium | |
CN112764995B (en) | Server hardware resource monitoring method, device and medium | |
CN115002011A (en) | Flow bidirectional test method and device, electronic equipment and storage medium | |
CN110548285B (en) | Game communication control method and device, medium and electronic equipment | |
CN114020414A (en) | Symbiotic method and device of Android system and bottom layer Linux, electronic equipment and storage medium | |
CN114064033A (en) | Front-end component development method and device, electronic equipment and readable storage medium | |
CN114428702A (en) | Information physical test system containing general interface module | |
CN113312192A (en) | Data synchronization method and device based on window, electronic equipment and storage medium | |
CN114564413B (en) | Synchronous equipment testing method and device | |
CN113572851B (en) | Remote desktop connection method based on browser | |
CN114650436B (en) | Remote control method, device, equipment and medium based on background service |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |