Custom protocol generation method, data communication method, electronic device, readable medium, and program product
Through custom protocol generation methods, the protocol dictionary table and field order information are generated and encrypted, which solves the adaptability and security problems of traditional protocols in the fields of the Internet of Things and other fields, and realizes flexible configuration and efficient and secure data transmission.
Patent Information
- Application Number
- CN202510665180.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-22
- Publication Date
- 2025-07-18
AI Technical Summary
Traditional communication protocols are difficult to flexibly adapt to diversified application needs in fields such as the Internet of Things, resulting in low data transmission efficiency and insufficient security.
Through a custom protocol generation method, it receives a collection of protocol fields defined by the client and server, generates a protocol dictionary table and encrypts field order information, supports graphical interface configuration protocol fields, and realizes flexible configuration and encrypted transmission.
It improves the security and adaptability of data transmission, prevents the protocol from being illegally parsed or forged, and enhances the reliability of the communication process and the protection of the protocol.
Smart Images

Figure CN120343103A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of protocol configuration and data transmission in network communication, and particularly relates to a method for generating a custom protocol, a method for data communication, an electronic device, a computer-readable medium, and a computer program product. Background Art
[0002] In today's digital age, the demand for data transmission and communication continues to grow. Although traditional communication protocols are widely used, they have many limitations in specific industries or special application scenarios. General protocols often cannot precisely meet personalized requirements, resulting in low data transmission efficiency and high data security risks. Especially in the Internet of Things field, due to the diverse types of devices and complex data formats, traditional protocols are difficult to flexibly adapt to various application requirements. With the rapid expansion of the data scale, the problem of insufficient protocol scalability becomes more prominent. Therefore, there is an urgent need for a custom communication protocol that can be flexibly configured and adapted to different application scenarios to improve data transmission efficiency, enhance security, and meet the requirements of diversification and high efficiency in the modern communication environment. Summary of the Invention
[0003] Embodiments of the present disclosure provide a method for generating a custom protocol, a method for data communication, an electronic device, a computer-readable medium, and a computer program product.
[0004] In a first aspect, embodiments of the present disclosure provide a method for generating a custom protocol, including: receiving a set of protocol fields defined by a client and / or a target server; generating a protocol dictionary table based on the set of protocol fields, and pushing the protocol dictionary table to the client and the target server; defining the order of the protocol fields in the set of protocol fields to generate field order information; encrypting the field order information to generate encrypted field order information; and pushing the encrypted field order information to the client and the target server.
[0005] In some embodiments, receiving a set of protocol fields defined by a client and / or a target server includes: receiving, through a protocol customization interface, configuration parameters of each protocol field in the set of protocol fields configured by the client and / or the target server; and recording the configuration parameters to form the set of protocol fields.
[0006] In some embodiments, the configuration parameters include at least one of a field name, a field type, a field length, a field value range, whether the field is encrypted, and a field encryption method.
[0007] In some embodiments, when there are multiple target servers, receiving a set of protocol fields defined by the client and / or the target servers further includes: receiving configuration parameters of the protocol fields corresponding to each target server; respectively recording the configuration parameters of the protocol fields corresponding to each target server as the corresponding set of protocol fields, where the sets of protocol fields corresponding to each target server may be the same or configured as different sets of protocol fields according to business requirements.
[0008] In some embodiments, generating a protocol dictionary table based on the set of protocol fields and pushing the protocol dictionary table to the client and the target servers includes: for a single target server, respectively mapping each protocol field in the set of protocol fields to a corresponding entry in the protocol dictionary table, generating the protocol dictionary table, and pushing the protocol dictionary table to the client and the target servers; or for multiple target servers, respectively generating corresponding protocol dictionary tables for each target server based on the corresponding sets of protocol fields, and pushing the corresponding protocol dictionary tables to the client and the corresponding target servers.
[0009] In some embodiments, defining the order of the protocol fields in the set of protocol fields to generate field order information includes: determining the arrangement order of the protocol fields in the set of protocol fields based on conditions specified by the user or randomly generated; generating the field order information based on the arrangement order.
[0010] In some embodiments, encrypting the field order information to generate encrypted field order information includes: encrypting the field order information based on a preset encryption algorithm to generate the encrypted field order information.
[0011] In some embodiments, pushing the encrypted field order information to the client and the target servers includes: pushing the encrypted field order information to the client and the target servers; receiving receipt confirmations of the encrypted field order information from the client and the target servers.
[0012] In a second aspect, embodiments of the present disclosure provide a data communication method, including: the client establishing a communication connection with at least one target server; after the communication connection is established, the client and the target servers obtaining a protocol dictionary table and encrypted field order information corresponding to the target server generated by the custom protocol generation method according to the first aspect of the embodiments of the present disclosure; the client and the target servers respectively decrypting the encrypted field order information to obtain the field order information; and the client and the target servers performing data transmission according to the protocol dictionary table and the field order information.
[0013] In some embodiments, according to the protocol dictionary table and the field order information, data transmission between the client and the target server includes: the client encapsulates the data to be transmitted according to the protocol dictionary table and the field order information to generate encapsulated data, and sends it to the target server; after receiving the encapsulated data, the target server parses the encapsulated data based on the protocol dictionary table and the field order information.
[0014] In some embodiments, after receiving the encapsulated data, the target server parses the encapsulated data based on the protocol dictionary table and the field order information, including: if the parsing is successful, the target server receives the parsed data; if the parsing fails, the target server closes the communication connection with the client and discards the parsed data.
[0015] In a third aspect, embodiments of the present disclosure provide an electronic device, including: one or more processors; a memory storing one or more programs thereon, and when the one or more programs are executed by the one or more processors, the one or more processors implement the custom protocol generation method described in the first aspect of the embodiments of the present disclosure.
[0016] In a fourth aspect, embodiments of the present disclosure provide a computer-readable medium having a computer program stored thereon, and when the computer program is executed by a processor, the computer program implements the custom protocol generation method described in the first aspect of the embodiments of the present disclosure.
[0017] In a fifth aspect, embodiments of the present disclosure provide a computer program product including a computer program or instruction, and when the computer program or instruction is executed by a processor, the computer program or instruction implements the custom protocol generation method described in the first aspect of the embodiments of the present disclosure.
[0018] The present disclosure provides a method and application for customizing a data transmission protocol, which allows a client and a server to flexibly define protocol field parameters through a graphical interface, generating a unified protocol dictionary table and field order information. The system supports encrypting the field order information and pushing the encrypted configuration to both communication parties for subsequent data encapsulation and parsing. Through the dynamic configuration and encrypted transmission of the field order, the security of the protocol is effectively enhanced, preventing illegal parsing or forgery. This solution enhances the flexibility of protocol configuration and the reliability of the communication process, and is applicable to secure data synchronization in various network transmission scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 is a flowchart of a method for generating a custom protocol according to an embodiment of the present disclosure;
[0020] Figure 2It is a data communication network topology diagram between the client and multiple servers in the embodiments of the present disclosure;
[0021] Figure 3 It is a timing interaction diagram of a custom protocol device in the embodiments of the present disclosure;
[0022] Figure 4 It is a schematic diagram of the composition of an electronic device in the embodiments of the present disclosure;
[0023] Figure 5 It is a block diagram of a custom protocol generation device according to the embodiments of the present disclosure. Detailed implementation manners
[0024] To enable those skilled in the art to better understand the technical solutions of the present disclosure, the technical solutions of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0025] In the following, example embodiments will be described more fully with reference to the accompanying drawings. However, the example embodiments may be embodied in different forms and should not be construed as limited to the embodiments set forth herein. On the contrary, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0026] Without conflict, the various embodiments of the present disclosure and the features in the embodiments may be combined with each other.
[0027] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0028] The terms used herein are for the purpose of describing particular embodiments only and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include the plural forms unless the context clearly indicates otherwise. It will also be understood that when the terms "comprises" and / or "consists of" are used in this specification, it specifies the presence of the stated features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0029] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless expressly so defined herein.
[0030] In the present disclosure, unless otherwise specified, the following technical terms should be understood according to the following explanations:
[0031] Data encapsulation refers to encrypting the original service data to be transmitted according to a predefined format to generate data packets that meet the protocol.
[0032] Data parsing is a process of decrypting each field in the data packet according to a predefined protocol to restore it to the original service data.
[0033] A custom protocol refers to a communication protocol format independently defined by users according to specific communication requirements.
[0034] The present disclosure proposes a method and apparatus for generating a custom protocol.
[0035] The present disclosure aims to overcome the limitations existing in the prior art and mainly solve the following technical problems:
[0036] Improve the flexibility of protocol customization between the client and the server, realize the dynamic update of the protocol, avoid the need for the client and the server to jointly modify and synchronize every time the protocol changes, and improve the adaptability and maintenance efficiency of the system;
[0037] Enhance the data security and anti-counterfeiting ability of the custom protocol, prevent the data packet from being easily parsed or forged after being captured during transmission, and effectively improve the data security and anti-attack ability during the communication process.
[0038] The present disclosure provides a method for generating a custom protocol, providing a graphical interface, allowing the client and server users to jointly define a data transmission protocol (supporting Socket / TCP / UDP), and generating a unified transmission protocol dictionary table through flexible configuration of protocol fields.
[0039] Figure 1 It is a flowchart of a method for generating a custom protocol according to an embodiment of the present disclosure.
[0040] In a first aspect, referring to Figure 1 , an embodiment of the present disclosure provides a method for generating a custom protocol, including:
[0041] S11. Receive a set of protocol fields defined by the client and / or the target server;
[0042] S12. Generate a protocol dictionary table based on the set of protocol fields, and push the protocol dictionary table to the client and the target server;
[0043] S13. Define the order of the protocol fields in the set of protocol fields to generate field order information;
[0044] S14. Encrypt the field order information to generate encrypted field order information;
[0045] S15. Push the encrypted field order information to the client and the target server.
[0046] The present disclosure realizes the dynamic update of protocol content by enhancing the flexibility of protocol customization between the client and the server. At the same time, by encrypting the field order information, it effectively prevents the custom protocol data packet from being maliciously parsed or forged, thereby enhancing the data security and protocol protection capabilities during the communication process.
[0047] In some embodiments, receive a set of protocol fields defined by the client and / or the target server, including:
[0048] Through the protocol customization interface, receive the configuration parameters of each protocol field in the set of protocol fields configured by the client and / or the target server;
[0049] Record the configuration parameters to form the set of protocol fields.
[0050] In some embodiments, the configuration parameters include at least one of field name, field type, field length, field value range, whether the field is encrypted, and field encryption method.
[0051] In the embodiments of the present disclosure, the client and the server can log in to the custom protocol device and enter the protocol customization module. This module provides a graphical configuration interface, and users can perform custom configuration operations on protocol fields through interactive methods such as dragging, selecting, and inputting. Each protocol field consists of several configurable parameters, and the parameters include, but are not limited to: field name, field type, field length, field value range, field encryption configuration (such as whether to encrypt, encryption method), etc. Users can flexibly set field parameters according to business requirements, so as to generate a set of protocol fields that meet the transmission requirements.
[0052] In some embodiments, when there are multiple target servers, receiving the set of protocol fields defined by the client and / or the target server further includes:
[0053] Receive the configuration parameters of the protocol fields corresponding to each target server;
[0054] Record the configuration parameters of the protocol fields corresponding to each target server as the corresponding set of protocol fields respectively,
[0055] wherein, the sets of protocol fields corresponding to each target server can be the same or configured as different sets of protocol fields according to business requirements.
[0056] In an embodiment of the present disclosure, the custom protocol device supports generating corresponding protocol dictionary tables and field order information for multiple servers respectively. When the client establishes a communication connection with different servers, it can dynamically load the custom protocol configuration that matches the target server to ensure protocol compatibility and data transmission accuracy. The protocol field configuration supports differential definition, allowing different field sets and parameter combinations to be configured for different business systems, adapting to various data formats and device types, and is especially applicable to the multi-device data synchronization scenario in the Internet of Things environment. Thus, the client automatically selects the corresponding custom protocol configuration based on the target server for data encapsulation and communication, thereby supporting a highly compatible communication mechanism for multiple server nodes adopting different protocol schemes.
[0057] In some embodiments, generating a protocol dictionary table based on the protocol field set and pushing the protocol dictionary table to the client and the target server includes:
[0058] For a single target server, each protocol field in the protocol field set is respectively mapped to a corresponding entry in the protocol dictionary table to generate the protocol dictionary table, and the protocol dictionary table is pushed to the client and the target server; or
[0059] For multiple target servers, based on the corresponding protocol field sets respectively, corresponding protocol dictionary tables are generated for each target server, and the corresponding protocol dictionary tables are respectively pushed to the client and the corresponding target servers.
[0060] In an embodiment of the present disclosure, after the field configuration is completed, a "custom transmission protocol dictionary table" is generated from the field sets defined by the client user and the server user. This dictionary table serves as the structural basis of the custom protocol and supports management operations such as adding, editing, or deleting fields by the user to achieve fine-grained control of the data transmission structure.
[0061] In an embodiment of the present disclosure, the dictionary table is only used to define the basic structure and attributes of the protocol fields. Each field only needs to be defined once in the dictionary table, and it supports generating multiple field instances based on this definition during the data encapsulation process. For example, if the content of multiple server name fields needs to be transmitted during actual synchronization, only one "server name" field needs to be defined in the dictionary table. During data encapsulation and transmission, multiple instances can be generated according to this definition to meet specific data requirements, but there is no need to redefine this field in the dictionary table.
[0062] In an embodiment of the present disclosure, the system adopts a centralized protocol management mechanism. All protocol fields are uniformly managed and generated by a protocol definition device, and after the definition is completed, the standardized protocol dictionary table and configuration information such as the field order are pushed to the client and the server. The client and the server strictly share the same set of protocol definitions. If there are configuration conflicts (such as inconsistent parameter settings for the same field) during the process of the user customizing the protocol fields, the system does not automatically arbitrate, but the administrator coordinates uniformly during the protocol definition stage to form the final protocol dictionary table.
[0063] In an embodiment of the present disclosure, during the process of defining protocol fields, the custom protocol device supports configuring whether to enable encryption for each field separately; if encryption is enabled, the encryption method can be selected from a preset encryption algorithm, such as AES / ECB / PKCS5Padding, and custom extension of other algorithms is also supported. For example, if the field username is set as an encrypted field, its value will be encrypted when encapsulating the data packet, while other fields remain in plain text.
[0064] In an embodiment of the present disclosure, after the custom protocol device completes the definition of protocol fields, it pushes the generated protocol dictionary table to the client and the server, and the client and the server respectively confirm the dictionary table and respond with a successful addition.
[0065] In some embodiments, defining the order of the protocol fields in the protocol field set to generate field order information includes:
[0066] Receiving, through a protocol customization interface, the parameters of each protocol field in the protocol field set configured by the client and / or the server;
[0067] Generating the field order information based on the arrangement order.
[0068] In an embodiment of the present disclosure, during the custom protocol configuration process, the protocol device supports setting the arrangement order of protocol fields in the data packet, and this order can be either manually specified by the user or randomly generated by the system to enhance the flexibility and unpredictability of the protocol structure, thereby improving the security during the data synchronization process.
[0069] In some embodiments, encrypting the field order information to generate encrypted field order information includes:
[0070] Encrypting the field order information based on a preset encryption algorithm to generate encrypted field order information.
[0071] In an embodiment of the present disclosure, to prevent the protocol from being parsed after being illegally intercepted, the defined complete field order will be encrypted by a preset encryption algorithm. The default encryption algorithm is AES / ECB / PKCS5Padding, and the system also supports extending other encryption methods according to actual requirements. Users can flexibly select encryption strategies according to the data security level to improve the overall security of the system. By encrypting the field order information, the security and anti-tampering ability of the custom protocol during transmission are effectively guaranteed.
[0072] In some embodiments, pushing the encrypted field order information to the client and the server includes:
[0073] Pushing the encrypted field order information to the client and the server;
[0074] Receiving the reception confirmations of the encrypted field order information from the client and the server.
[0075] In an embodiment of the present disclosure, after the encrypted field order is pushed to the client and the server and both parties confirm successful reception, the configuration process of the custom protocol is completed.
[0076] In a second aspect, an embodiment of the present disclosure provides a data communication method, including:
[0077] The client establishes a communication connection with at least one target server;
[0078] After the communication connection is established, the client and the target server obtain a protocol dictionary table and encrypted field order information corresponding to the target server generated by the custom protocol generation method according to the first aspect of the embodiments of the present disclosure;
[0079] The client and the target server respectively decrypt the encrypted field order information to obtain the field order information;
[0080] According to the protocol dictionary table and the field order information, the client and the target server perform data transmission.
[0081] In some embodiments, according to the protocol dictionary table and the field order information, the client and the target server perform data transmission, including:
[0082] The client encapsulates the data to be transmitted according to the protocol dictionary table and the field order information to generate encapsulated data and sends it to the target server;
[0083] After receiving the encapsulated data, the target server parses the encapsulated data based on the protocol dictionary table and the field order information.
[0084] In some embodiments, after receiving the encapsulated data, the target server parses the encapsulated data based on the protocol dictionary table and the field order information, including:
[0085] If the parsing is successful, the target server receives the parsed data;
[0086] If the parsing fails, the target server closes the communication connection with the client and discards the parsed data.
[0087] In the embodiments of the present disclosure, the client establishes Socket connections with server A, server B, and server C respectively. After the communication connection is established, the client looks up the protocol dictionary table and the encrypted field order information corresponding to the target server locally according to the target server identifier. The protocol configuration can be independently generated for each of the multiple target servers or can be shared by multiple servers.
[0088] The client encapsulates the data to be transmitted into protocol data packets according to the field definition information in the custom protocol dictionary table and the received field order information. The field order information determines the arrangement order of the fields in the data packet, and the field definition information (such as field name, type, length, whether it is encrypted, etc.) determines the encapsulation method of each field.
[0089] After the encapsulation is completed, the data is sent to the corresponding server through the Socket channel.
[0090] After receiving the data packet, the server first decrypts the pushed field order information (by default, using the AES / ECB / PKCS5Padding algorithm). After decryption, the server combines the protocol dictionary table with the field order information to parse the data packet: that is, extracts and parses the encapsulated data field by field according to the field order. If the parsing is successful, the server confirms the reception of the data; if the parsing fails, the current connection is closed and the relevant data packet is discarded to ensure communication security and protocol integrity.
[0091] Those skilled in the art should understand that a custom protocol generation method provided by the present disclosure is applicable to various data transmission and synchronization scenarios, especially applicable to data interaction environments based on network communication. Preferably, it can be applied to data synchronization based on Socket communication (such as TCP, UDP connections), but is not limited thereto.
[0092] In an embodiment of the present disclosure, the custom protocol generates a field definition table, field order information, and a field encryption policy through graphical configuration, and can encapsulate and parse the transmitted data, having the advantages of flexible structure, high security, strong adaptability, etc. This protocol mechanism is independent of the specific transmission channel and can be widely applied to various communication methods such as HTTP / HTTPS, WebSocket, message queue (MQ), gRPC, and file offline transmission, supporting one-way or two-way data synchronization modes to meet the flexible, controllable, and secure data exchange requirements between heterogeneous systems.
[0093] Figure 2 It is a data communication network topology diagram between the client and multiple servers in an embodiment of the present disclosure. This diagram can implement a multi-node data synchronization mechanism.
[0094] In this architecture, the client can establish communication connections with multiple server nodes (including Server A, Server B, and Server C) respectively through, for example, Socket connections. This embodiment supports defining and using independent custom protocols for different server nodes, that is, each server node can configure the corresponding protocol field set, protocol dictionary table, and field order information. Before establishing communication with each target server, the client loads the protocol configuration of the corresponding server from the protocol definition device, including the protocol dictionary table and encrypted field order information corresponding to this server. The client encapsulates the data to be synchronized according to the custom protocol corresponding to the selected server (including the protocol dictionary table and field order information), generates a matching protocol data packet, and sends it to the corresponding target server.
[0095] After receiving the data packet, each server decrypts, parses, and processes the data packet according to its locally stored custom protocol configuration (including the protocol dictionary table and field order information). After the processing is completed, the server can return the synchronization result (such as the processing status, response data, etc.) to the client to achieve two-way data synchronization and status confirmation.
[0096] This multi-protocol mechanism improves the adaptability and flexibility of the system and is particularly suitable for scenarios with multiple data formats and security requirements in multi-business system integration, heterogeneous device interconnection, and the Internet of Things environment. By using different protocol configurations for different servers, the client can achieve data synchronization control for multiple types of servers, enhancing the customization ability and protocol compatibility of the communication system.
[0097] Figure 3 It is a timing interaction diagram of a custom protocol device in an embodiment of the present disclosure. Figure 3 It shows the timing interaction process of a custom protocol device according to an embodiment of the present disclosure, which is used to illustrate the typical interaction steps among the client, the custom protocol device, and the server in the process of constructing and using the custom data transmission protocol.
[0098] As Figure 3 shown, the process mainly includes the following steps:
[0099] The client and the server respectively send requests to the custom protocol device to add protocol fields, including configuration parameters such as field name, field type, field length, value range, whether to encrypt, and encryption method; after receiving, the custom protocol device respectively returns an "Add successful" response.
[0100] The custom protocol device generates a unified protocol dictionary table according to the protocol field configurations submitted by the client and the server. This dictionary table contains all protocol fields and their attribute information; after generation, the protocol device pushes the dictionary table to the client and the server respectively, and receives the "Add successful" confirmation feedback from them.
[0101] The custom protocol device sets the arrangement order of the protocol fields in the way specified by the user or randomly generated by the system to form field order information (for example: [field 3, field 1, field 2]). To ensure communication security, this field order information is encrypted using the default encryption algorithm (such as AES / ECB / PKCS5Padding) to form encrypted field order information, and is respectively pushed to the client and the server; the client and the server confirm successful reception.
[0102] After the protocol definition is completed, the client initiates a Socket communication connection request with the server. After the connection is successfully established, the client encapsulates the data to be transmitted according to the protocol dictionary table and the field order information, including field sorting and performing encryption operations on the encrypted fields. The encapsulated protocol data packet is sent to the server through the Socket channel.
[0103] After receiving the protocol data packet, the server parses the data packet field by field based on the protocol dictionary table and the field order information stored locally. If the field is encrypted, corresponding decryption processing is performed according to the field encryption method. If the parsing is successful, the server completes data reception and subsequent processing (such as storing in the database); if the parsing fails, the server closes the communication connection and discards the data packet to ensure communication security.
[0104] The above process effectively guarantees the protocol consistency between the client and the server and the security of data interaction, and realizes a custom protocol generation and application mechanism that supports custom configuration, centralized management, and high adaptability.
[0105] Figure 4 It is a schematic diagram of the composition of an electronic device according to an embodiment of the present disclosure.
[0106] In a third aspect, referring to Figure 4 , an embodiment of the present disclosure provides an electronic device, which includes:
[0107] One or more processors 401;
[0108] A memory 402, on which one or more programs are stored. When the one or more programs are executed by the one or more processors, the one or more processors implement the custom protocol generation method described in the first aspect of the embodiments of the present disclosure;
[0109] One or more I / O interfaces 403, connected between the processor and the memory, configured to implement information interaction between the processor and the memory.
[0110] Wherein, the processor 401 is a device with data processing capabilities, including but not limited to a central processing unit (CPU), etc.; the memory 402 is a device with data storage capabilities, including but not limited to a random access memory (RAM, more specifically such as SDRAM, DDR, etc.), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory (FLASH); the I / O interface (read / write interface) 403 is connected between the processor 401 and the memory 402 and can implement information interaction between the processor 401 and the memory 402, including but not limited to a data bus (Bus), etc.
[0111] In some embodiments, the processor 401, the memory 402, and the I / O interface 403 are interconnected through a bus 404 and are further connected to other components of the computing device.
[0112] Fourth aspect, the embodiments of the present disclosure provide a computer-readable medium, on which a computer program is stored. When the program is executed by a processor, the custom protocol generation method described in the first aspect of the embodiments of the present disclosure is implemented.
[0113] Fifth aspect, the embodiments of the present disclosure provide a computer program product, including a computer program or instruction. When the computer program or instruction is executed by a processor, the custom protocol generation method described in the first aspect of the embodiments of the present disclosure is implemented.
[0114] Figure 5 is a block diagram of a custom protocol generation device according to the embodiments of the present disclosure.
[0115] Sixth aspect, referring to Figure 5 , the embodiments of the present disclosure provide a custom protocol generation device, including:
[0116] A field receiving module 501, configured to receive a set of protocol fields defined by a client and / or a target server;
[0117] A dictionary generation module 502, generating a protocol dictionary table based on the set of protocol fields and pushing the protocol dictionary table to the client and the target server;
[0118] A sequential generation module 503, configured to define the order of protocol fields in the set of protocol fields to generate field order information;
[0119] An encryption module 504, configured to encrypt the field order information to generate encrypted field order information;
[0120] A push module 505, configured to push the encrypted field order information to the client and the target server.
[0121] In some embodiments, the field receiving module 501 includes:
[0122] A parameter configuration module, configured to receive configuration parameters of each protocol field in the set of protocol fields configured by the client and / or the target server through a protocol customization interface;
[0123] A field set generation module, configured to record the configuration parameters to form the set of protocol fields.
[0124] In some embodiments, the configuration parameters include at least one of a field name, a field type, a field length, a field value range, whether the field is encrypted, and a field encryption method.
[0125] In some embodiments, the field receiving module 501 further includes:
[0126] A target field parameter configuration module, configured to receive configuration parameters of protocol fields corresponding to each target server;
[0127] A field set recording module, configured to record the configuration parameters of protocol fields corresponding to each target server as corresponding sets of protocol fields respectively.
[0128] In some embodiments, the dictionary generation module 502 includes:
[0129] A field mapping module, configured to, for a single target server, map each protocol field in the set of protocol fields to a corresponding entry in the protocol dictionary table respectively, generate the protocol dictionary table, and push the protocol dictionary table to the client and the target server; or
[0130] A multi-dictionary generation sub-module, configured to, for multiple target servers, generate corresponding protocol dictionary tables for each target server respectively based on the corresponding sets of protocol fields, and push the corresponding protocol dictionary tables to the client and the corresponding target servers respectively.
[0131] In some embodiments, the sequential generation module 503 includes:
[0132] An order determination module configured to determine the arrangement order of the protocol fields in the set of protocol fields based on conditions specified by a user or randomly generated.
[0133] An order information generation module configured to generate the field order information based on the arrangement order.
[0134] In some embodiments, the encryption module 504 includes:
[0135] An encryption execution module configured to encrypt the field order information based on a preset encryption algorithm to generate encrypted field order information.
[0136] In some embodiments, the push module 505 includes:
[0137] An order information push module that pushes the encrypted field order information to the client and the target server;
[0138] A reception confirmation module configured to receive reception confirmations of the encrypted field order information from the client and the target server.
[0139] In a seventh aspect, an embodiment of the present disclosure provides a data communication device, including:
[0140] A connection establishment module configured to establish a communication connection between a client and at least one target server;
[0141] A protocol acquisition module. After the communication connection is established, the client and the target server acquire a protocol dictionary table and encrypted field order information corresponding to the target server, which are generated according to the custom protocol generation method described in the first aspect of the embodiments of the present disclosure;
[0142] A decryption module. The client and the target server respectively decrypt the encrypted field order information to obtain the field order information;
[0143] A data transmission module. The client and the target server perform data transmission according to the protocol dictionary table and the field order information.
[0144] In some embodiments, the data transmission module includes:
[0145] A data encapsulation module. The client encapsulates the data to be transmitted according to the protocol dictionary table and the field order information to generate encapsulated data and sends it to the target server;
[0146] A data parsing module. After receiving the encapsulated data, the target server parses the encapsulated data based on the protocol dictionary table and the field order information.
[0147] In some embodiments, the data parsing module includes:
[0148] A receiving module configured such that if the parsing is successful, the target server receives the parsed data;
[0149] A discarding module configured such that if the parsing fails, the target server closes the communication connection with the client and discards the parsed data.
[0150] To enable those skilled in the art to more clearly understand the technical solutions provided by the embodiments of the present disclosure, the following provides a detailed description of the custom protocol generation method provided by the embodiments of the present disclosure through specific embodiments:
[0151] Embodiment 1
[0152] The custom protocol generation method of the present disclosure can be applied to the scenario of data synchronization between a client and a server, and is particularly preferably applied to the file synchronization scenario based on the Socket communication method. It supports two modes: one-way synchronization and two-way synchronization, and has the characteristics of flexible protocol configuration, controllable field structure, and high security during the transmission process.
[0153] Taking the one-way synchronization of files from the client to the server as an example, its typical application process includes the following steps:
[0154] 1) The client C1 establishes a Socket connection with the server S1 to prepare a communication channel for subsequent data transmission;
[0155] 2) The client C1 encapsulates the file content to be synchronized based on the protocol dictionary table and the decrypted field order information. During the encapsulation process, the values of each field are arranged in the specified order, and the fields set to be encrypted are encrypted using a preset encryption algorithm (such as AES / ECB / PKCS5Padding) to construct a complete data packet;
[0156] 3) The client sends the encapsulated data packet to the server S1 through the Socket channel;
[0157] 4) After receiving the data packet, the server S1 parses the data packet based on the protocol dictionary table and the field order information saved locally. During the parsing process, the server extracts the data content item by item according to the field order and decrypts the encrypted fields;
[0158] 5) The server performs a validity check on the data. If the check is successful, the parsed data is written to a preset storage path to achieve data landing; if the check fails, the current connection is terminated and the corresponding data packet is discarded to ensure the correctness of data transmission and system security.
[0159] Example 2
[0160] This embodiment further expands the application of the custom protocol generation method of the present disclosure in a multi-server and multi-protocol environment, and is applicable to scenarios where the client needs to communicate with multiple server nodes separately, and each server uses different protocol configurations. This method is especially applicable to heterogeneous network environments such as the Internet of Things, distributed data collection, and multi-system integration.
[0161] Taking the example of the client synchronizing data to multiple servers respectively, its typical application process includes the following steps:
[0162] 1) The client C1 establishes Socket connections with multiple target servers (such as server A, server B, and server C) respectively to establish independent communication channels with each server;
[0163] 2) The client C1 and multiple target servers respectively generate corresponding protocol field sets and protocol dictionary tables for each target server by using the custom protocol device, and push their respective protocol dictionary tables and corresponding encrypted field sequence information to the client C1 and the corresponding target servers;
[0164] 3) Before communicating with each server, the client C1 dynamically loads the protocol dictionary table and field sequence information matching it according to the target server identifier, and decrypts the encrypted field sequence information;
[0165] 4) The client encapsulates the data to be transmitted based on the loaded target protocol configuration and constructs a data packet that conforms to the protocol structure of the target server;
[0166] 5) The client sends the encapsulated data to servers A, B, C, etc. respectively through the corresponding Socket connections;
[0167] 6) After each server receives the data packet from the client, it parses it based on the protocol dictionary table and field sequence information stored locally;
[0168] 7) The server performs validity verification on the data: if the verification passes, the data storage (such as warehousing) is completed; if the parsing or verification fails, it is regarded as an abnormal connection, the communication is disconnected, and the abnormal data packet is discarded.
[0169] Through the above process, this embodiment realizes flexible data synchronization between the client and multiple servers using different custom protocols, significantly improves the adaptability of the system in terms of multi-protocol support, protocol compatibility, and security, and is especially suitable for the actual application scenarios where multiple service systems coexist and the protocol requirements are diverse.
[0170] The protocol generation and synchronization mechanism provided by the present disclosure ensures a unified, flexible, and secure communication protocol configuration between the client and the server, thereby achieving efficient and stable data synchronization capabilities in heterogeneous systems or multi-node environments.
[0171] The present disclosure mainly aims at the file synchronization scenario in a cross-network environment and proposes a highly configurable custom protocol system, which has the following technical key points:
[0172] 1) The present disclosure supports dynamically generating protocol field configuration files according to user business requirements. Without modifying the source code of the communication protocol or recompiling the system, the flexible adjustment of the protocol structure can be achieved. This mechanism significantly improves the flexibility and configuration efficiency of protocol field customization, reduces development and maintenance costs, and is suitable for the rapid deployment requirements in variable scenarios.
[0173] 2) The present disclosure provides a verification function for the structural integrity, encryption consistency, and sequence correctness of custom fields in the protocol, ensuring the integrity and accuracy of protocol data and avoiding protocol communication failures and data errors caused by errors in custom fields.
[0174] 3) By providing a graphical interface for visual configuration of protocol fields, the configuration process is simplified and the user operation efficiency is improved. This method not only enhances the usability of the system but also provides good support for subsequent protocol extension and evolution.
[0175] The present disclosure provides a method for generating a custom protocol, which has the following technical effects:
[0176] 1) By supporting users to dynamically configure protocol fields (including parameters such as field names, types, lengths, and whether to encrypt), it can flexibly adapt to the diverse protocol requirements in different business systems or application scenarios, thereby significantly improving the scalability and adaptability of the protocol. At the same time, this method reduces system downtime and manual development workload caused by protocol field adjustment and improves system online efficiency.
[0177] 2) By introducing a graphical protocol field configuration interface, the operability and user experience of protocol customization are improved, the protocol development process is simplified, which is conducive to the consistent deployment and unified maintenance of the protocol on multiple servers, thereby improving the protocol configuration efficiency and the overall stability of the system.
[0178] 3) The present disclosure configures independent protocol field sets, corresponding protocol dictionary tables, and field sequence information for multiple target servers respectively, so that when the client establishes a communication connection with different servers, it can dynamically select and load the custom protocol configuration that matches the target server, thereby achieving highly compatible data communication in a cross-server, multi-protocol environment.
[0179] Those of ordinary skill in the art will understand that all or some of the steps in the methods disclosed above, and the functional modules / units in systems and devices, can be implemented as software, firmware, hardware, and appropriate combinations thereof. In the hardware implementation, the division between the functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, one physical component can have multiple functions, or one function or step can be executed by several physical components in cooperation. Some or all physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include a computer storage medium (or non-transitory medium) and a communication medium (or transitory medium). As is well known to those of ordinary skill in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable instructions, data structures, program modules, or other data. Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cassette, tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that a communication medium typically includes computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery medium.
[0180] Example embodiments have been disclosed herein, and although specific terms have been employed, they are used only and should be construed only for general illustrative purposes and not for purposes of limitation. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly stated, features, characteristics, and / or elements described in connection with a particular embodiment may be used singly or in combination with features, characteristics, and / or elements described in connection with other embodiments. Accordingly, those skilled in the art will understand that various forms and details may be changed without departing from the scope of the present disclosure as set forth by the appended claims.
Claims
1. A custom protocol generation method, comprising: Receiving a set of protocol fields defined by a client and / or a target server; Generating a protocol dictionary table based on the set of protocol fields, and pushing the protocol dictionary table to the client and the target server; Defining the order of the protocol fields in the set of protocol fields to generate field order information; Encrypting the field order information to generate encrypted field order information; Pushing the encrypted field order information to the client and the target server.
2. The custom protocol generation method according to claim 1, wherein, Receiving a set of protocol fields defined by a client and / or a target server, comprising: Receiving, through a protocol customization interface, configuration parameters of each protocol field in the set of protocol fields configured by the client and / or the target server; Recording the configuration parameters to form the set of protocol fields.
3. The custom protocol generation method according to claim 2, wherein The configuration parameters include at least one of a field name, a field type, a field length, a field value range, whether the field is encrypted, and a field encryption method.
4. The custom protocol generation method according to claim 3, wherein, When there are multiple target servers, receiving a set of protocol fields defined by a client and / or a target server further comprises: Receiving configuration parameters of protocol fields corresponding to each target server; Respectively recording the configuration parameters of the protocol fields corresponding to each target server as corresponding sets of protocol fields, wherein the sets of protocol fields corresponding to each target server may be the same or configured as different sets of protocol fields according to service requirements.
5. The custom protocol generation method according to any one of claims 1 to 4, wherein Generating a protocol dictionary table based on the set of protocol fields, and pushing the protocol dictionary table to the client and the target server, comprising: For a single target server, respectively mapping each protocol field in the set of protocol fields to a corresponding entry in the protocol dictionary table to generate the protocol dictionary table, and pushing the protocol dictionary table to the client and the target server; or For multiple target servers, respectively generating corresponding protocol dictionary tables for each target server based on the corresponding sets of protocol fields, and pushing the corresponding protocol dictionary tables to the client and the corresponding target servers.
6. The custom protocol generation method according to claim 5, wherein, Defining the order of the protocol fields in the set of protocol fields to generate field order information, comprising: Determining the arrangement order of the protocol fields in the set of protocol fields based on conditions specified by a user or randomly generated; Generating the field order information based on the arrangement order.
7. The custom protocol generation method according to claim 6, wherein, Encrypting the field order information to generate encrypted field order information, comprising: Encrypting the field order information based on a preset encryption algorithm to generate encrypted field order information.
8. The custom protocol generation method according to claim 7, wherein, Pushing the encrypted field order information to the client and the target server, comprising: Pushing the encrypted field order information to the client and the target server; Receiving a reception confirmation of the encrypted field order information from the client and the target server.
9. A data communication method, comprising: A client establishing a communication connection with at least one target server; After the communication connection is established, the client and the target server obtain a protocol dictionary table corresponding to the target server and encryption field order information generated by the custom protocol generation method according to any one of claims 1 to 8; The client and the target server respectively decrypt the encryption field order information to obtain the field order information; According to the protocol dictionary table and the field order information, the client and the target server perform data transmission.
10. The data communication method according to claim 9, wherein, According to the protocol dictionary table and the field order information, the client and the target server perform data transmission, including: The client encapsulates the data to be transmitted according to the protocol dictionary table and the field order information to generate encapsulated data, and sends it to the target server; After receiving the encapsulated data, the target server parses the encapsulated data based on the protocol dictionary table and the field order information.
11. The data communication method according to claim 10, wherein, After receiving the encapsulated data, the target server parses the encapsulated data based on the protocol dictionary table and the field order information, including: If the parsing is successful, the target server receives the parsed data; If the parsing fails, the target server closes the communication connection with the client and discards the parsed data.
12. An electronic device, comprising: One or more processors; A memory storing one or more programs, which when executed by the one or more processors cause the one or more processors to implement the custom protocol generation method according to any one of claims 1 to 8.
13. A computer-readable medium having stored thereon a computer program, which when executed by a processor implements the custom protocol generation method according to any one of claims 1 to 8.
14. A computer program product comprising a computer program or instruction, which when executed by a processor implements the custom protocol generation method according to any one of claims 1 to 8.