CN112202798B - 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
- CN112202798B CN112202798B CN202011073525.XA CN202011073525A CN112202798B CN 112202798 B CN112202798 B CN 112202798B CN 202011073525 A CN202011073525 A CN 202011073525A CN 112202798 B CN112202798 B CN 112202798B
- Authority
- CN
- China
- Prior art keywords
- data
- protocol
- interface
- protocol conversion
- function
- 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.)
- Active
Links
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 OR CALCULATING; 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 successfully initialized, creating an interface data call function in the routing system, acquiring interface protocol data from an interface circuit by using the interface data call 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 chain technique, the protocol encapsulation data can be stored in block chain nodes. 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 and a system for protocol conversion of data, an electronic device, and a computer-readable storage medium.
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 call function to obtain the interface data call 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: 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 cause 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 is executed by a processor to implement the protocol conversion method of the data.
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 flowchart 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 method for protocol conversion of 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 diagram of an internal structure of an electronic device implementing a method for protocol conversion of 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.
An execution subject of the data protocol conversion method provided in the embodiment of the present application includes, but is not limited to, at least one of electronic devices that can be configured to execute the method provided in the embodiment of the present application, such as a server and a terminal. 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 is a detailed description of implementation details of the protocol conversion of the data of the present embodiment, and the following is provided only for facilitating understanding of the implementation details and is not necessary for implementing the present embodiment.
An 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 layer001The interface circuit is mainly used for realizing an interactive function with a user, for example, receiving the protocol conversion instruction input by the user, analyzing the protocol conversion instruction, and obtaining 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 presently disclosed TCP/IP protocolProtocols, an OSI protocol stack, a ZigBee protocol stack and the like, such as codes, function libraries and the like which are depended by the OSI protocol stack are encapsulated in a network layer, and an initialization protocol stack interface, a data protocol conversion interface and the like are provided.
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 method for protocol conversion of data, and as shown in fig. 2, in this embodiment, a flow of the method for protocol conversion of data includes:
and S1, initializing the protocol stack and the routing system according to the protocol conversion instruction input by the user.
In a preferred embodiment of the present invention, the protocol stack may use a currently disclosed TCP/IP protocol, OSI protocol stack, ZigBee protocol stack, and the like, for example, to encapsulate codes, function libraries, and the like that the OSI protocol stack depends on, and provide an automated initialization protocol stack interface, and when receiving a protocol conversion instruction input by a user, automatically trigger the initialization protocol stack interface, check whether the codes, function libraries, and the like that the protocol stack depends on are successfully encapsulated.
In addition, as can be known from the data interaction related to 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 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, therefore, 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.threading type in C + + programming language can be called, and after the calling is successful, the system garbage can be automatically recovered by running the Timer. In addition, a key system (such as Kerberos) is used for checking the security 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 successfully initialized, 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.
S2, when the protocol stack and the routing system are initialized successfully, an interface data call function is created 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 to enable the computer to test an original data call function, so as to ensure that the original data call function will not make errors 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 for example, 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 decapsulating 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.
For example, the interface protocol data struct _ 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
The MAC data and the IP data may be parsed from struct _ MAC _ FRAME _ HEADER in sequence, and so on, to obtain the protocol raw data.
And S5, according to the preset protocol rule and the protocol stack, encapsulating the protocol original data to obtain protocol encapsulation data, and according to the protocol conversion instruction, returning the protocol encapsulation 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 the interface data call function, obtain the interface protocol data from the interface circuit, and convert the data by using the conversion method in the protocol stack after obtaining the interface protocol data, so that the automation degree of the whole conversion process is high, the operating environment is not required to be separately configured for 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 be initialized, 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, the 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 interface data call functions within the 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 call function to obtain the interface data call function.
If the original data call function is:
Def API-call(Data-communication-protocol):
Data-communication-protocol=Telnet
wherein, "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 call function by using a compiler to obtain an assembly call function, and calling the assembler to change the assembly call function into the interface data call 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 to enable the computer to test an original data call function, so as to ensure that the original data call function will not make errors in the subsequent process. An Assembler (Assembler) is a program that translates assembly language into programming language.
As described above, in the embodiments 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.
For example, the interface protocol data struct _ 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
The MAC data and the IP data may be parsed from struct _ MAC _ FRAME _ HEADER in sequence, and so on, to obtain the protocol raw data.
In detail, after the protocol raw data is obtained, the protocol raw data is input into 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 translation program 12 of data, stored in the memory 11 and operable 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, e.g. 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 whole electronic device by using various interfaces and lines, and executes various functions of the electronic device 1 and processes data by running or executing programs or modules (for example, 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, among other things, for displaying information processed in the electronic device 1 and for displaying a visualized user interface.
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 several embodiments provided in 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 position, or may be distributed on multiple 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 reference to any claim 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 string of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, which is used for verifying the validity (anti-counterfeiting) of the information and generating 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 will be obvious that the term "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 intended to illustrate the technical solutions of the present invention and not to limit the same, 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 can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims (9)
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;
according to a preset protocol rule and the protocol stack, encapsulating the protocol original data to obtain protocol encapsulation data, and returning the protocol encapsulation data to a user according to the protocol conversion instruction;
wherein creating an interface data call function within the routing system comprises:
taking an interface circuit protocol as an input parameter of a pre-constructed data call API, and generating an original data call function;
compiling the original data calling function to obtain the interface data calling function;
the compiling the original data call function to obtain the interface data call function comprises:
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.
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 command 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.
And compiling the original data calling function to obtain the interface data calling function.
4. 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.
5. The method for protocol conversion of data according to claim 1, wherein the interface protocol data includes: 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.
6. A data protocol conversion system is characterized in that the system comprises a network layer, a system layer and a driving 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;
wherein creating an interface data call function within the routing system comprises:
taking an interface circuit protocol as an input parameter of a pre-constructed data call API, and generating an original data call function;
compiling the original data calling function to obtain the interface data calling function;
the compiling the original data calling function to obtain the interface data calling function comprises:
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.
7. The data protocol conversion system of claim 6, 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.
8. 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 5.
9. 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 5.
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 CN112202798A (en) | 2021-01-08 |
CN112202798B true 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 (4)
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 |
CN114968360A (en) * | 2022-06-02 | 2022-08-30 | 杭州东方通信软件技术有限公司 | API controller-based instruction issuing method |
CN115580665B (en) * | 2022-11-18 | 2023-03-10 | 中国信息通信研究院 | Block chain-based transport protocol conversion method, device, storage medium and equipment |
CN116647588B (en) * | 2023-04-26 | 2025-08-12 | 深圳开鸿数字产业发展有限公司 | Remote communication method, device, equipment and storage medium |
Citations (4)
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 |
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 (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
ATE323364T1 (en) * | 2001-08-24 | 2006-04-15 | Windmill Microsystems Holding | REMOTE DATA COLLECTION DEVICE WITH ELECTRONIC MAIL OVER PUBLIC AND PRIVATE NETWORKS AND METHOD AND COMPUTER PROGRAM THEREOF |
GB0919253D0 (en) * | 2009-11-03 | 2009-12-16 | Cullimore Ian | Atto 1 |
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 (4)
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 |
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 |
---|---|
CN112202798A (en) | 2021-01-08 |
WO2021189898A1 (en) | 2021-09-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112202798B (en) | Data protocol conversion method, system, electronic device and storage medium | |
US9348771B1 (en) | Cloud-based instrument driver system | |
CN113238929B (en) | Code testing method and device based on Mock data, electronic equipment and storage medium | |
CN112579452A (en) | Software automation test method, device, equipment and storage medium | |
CN112506779A (en) | Software interface testing method and device, electronic equipment and storage medium | |
CN113377661A (en) | Interface testing method and device, electronic equipment and storage medium | |
CN114035987A (en) | Data transmission method, device, electronic device and medium based on message queue | |
CN115037587B (en) | Automatic issuing method, device, equipment and storage medium for network equipment configuration | |
CN115002011A (en) | Flow bidirectional test method and device, electronic equipment and storage medium | |
CN114860252A (en) | Code unified compiling method and device, electronic equipment and readable storage medium | |
CN113312192A (en) | Data synchronization method and device based on window, electronic equipment and storage medium | |
CN115314570B (en) | Data issuing method, device, equipment and medium based on protocol development framework | |
CN113541929A (en) | Control method for system-on-chip quantum key distribution control system based on configuration | |
CN114019230B (en) | Intelligent electric energy meter design method and system | |
CN114237571A (en) | Code data conversion method, device, equipment and medium | |
CN113886244A (en) | Sql statement testing method, device, electronic device and readable storage medium | |
CN114844693A (en) | Lightweight communication data encryption method, device, equipment and storage medium | |
CN114721952A (en) | Synchronous deployment method, device, equipment and storage medium for multiple sets of test environments | |
CN114020414A (en) | Symbiotic method and device of Android system and bottom layer Linux, electronic equipment and storage medium | |
CN114389948A (en) | Whitelist-based function upgrade and verification method, device, device and medium | |
CN111865986A (en) | Information interaction method and system based on cloud platform | |
CN119149119B (en) | Network card driver installation method, device, equipment, medium and program product | |
CN119356662B (en) | Business execution method, device, equipment and medium | |
CN114564413B (en) | Synchronous equipment testing method and device | |
CN119743386B (en) | Ethernet physical layer multi-mode driving method, system, medium and driver |
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 |