Network protocol-based data transmission method, system, device and storage medium
Patent Information
- Application Number
- CN202310818235.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-05
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2043-07-05
AI Technical Summary
[0003]为解决上述问题,本发明提供了基于网络协议的数据传输方法、系统、设备和存储介质,以克服现有技术中存在的因数据格式混乱而导致的网络传输效率低下和网络协议出错的问题
[0027] This invention employs extended CMD commands and RPC remote procedure calls to optimize data, and uses a new unified data structure type to transform the data. By compressing and formatting message content, it significantly reduces the size of transmitted data and lowers network transmission latency, thereby improving network transmission efficiency and game performance. This solves the problem of low network transmission efficiency caused by chaotic data formats in existing technologies. Furthermore, the new data structure of this invention can use a unified interface, eliminating the need to determine which protocol to use based on business requirements, thus reducing the possibility of network protocol errors.
Smart Images

Figure CN116846973B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data transmission technology, and in particular to data transmission methods, systems, devices, and storage media based on network protocols. Background Technology
[0002] In game development, network protocol design is a crucial aspect, determining the efficiency and reliability of network transmission and significantly impacting user traffic and developer compliance. Current technical solutions rely heavily on traditional network architectures, which often lack data compression and formatting, directly handling data transmission and logic generalization. However, in actual game development, developers may use incorrect data formats, such as using int instead of byte, resulting in excessively large message sizes, inefficient network transmission, and network protocol errors. Summary of the Invention
[0003] To address the aforementioned problems, this invention provides a data transmission method, system, device, and storage medium based on network protocols, thereby overcoming the issues of low network transmission efficiency and network protocol errors caused by chaotic data formats in the prior art.
[0004] The present invention adopts the following technical solution:
[0005] The data transmission method based on network protocols includes the following steps:
[0006] S1. Aggregate data from CMD commands and RPC remote procedure calls;
[0007] S2. Perform conversions on different data types, including: for basic data, directly perform range-based rationalization of data types at the network architecture level and convert them into byte data; for floating-point data, convert floating-point data into integers while retaining predetermined data precision; for vector data, split the value of ternary vector3 into x, y, z, and then convert it into float or string type; for quaternions, convert the quaternion into uint type and compress it into the corresponding rotation parameters.
[0008] S3, Data Serialization: Convert all transformed data into binary format;
[0009] S4. Data Compression: Pass binary format data into a compression algorithm to remove unnecessary bits;
[0010] S5. Differential Transmission: For high-frequency data, the entire data is transmitted initially, and if the data changes subsequently, only the difference in the data is transmitted.
[0011] Furthermore, the basic data includes any one or more of the following data types: bool, int, ulnt, long, ulong, and float.
[0012] Furthermore, the floating-point data includes any one or more of the following data types: short, ushort, double, string, and vector2.
[0013] Furthermore, the predetermined precision of the floating-point data is to retain 1 to 3 decimal places.
[0014] Furthermore, in step S3, the converted data is converted into binary format by a byteBuffer data parser.
[0015] Furthermore, in step S4, the unnecessary bits refer to bits in binary format data that are all represented by 0.
[0016] Furthermore, in step S5, the high-frequency data includes data on movement and / or rotation.
[0017] A data transmission system based on network protocols, the system comprising an aggregation module, a conversion module, a sequence compression module, and a difference transmission module;
[0018] The aggregation module is used to aggregate data from CMD commands and RPC remote procedure calls.
[0019] The conversion module is used to convert the different data types after aggregation to form corresponding data types;
[0020] The sequence compression module is used to convert all the converted data into binary format and pass it into a compression algorithm to remove unnecessary bits;
[0021] The compressed data from the differential transmission module is transmitted differentially. Specifically, the differential transmission involves initially transmitting the entire data, and if the data changes subsequently, only the difference in the data is transmitted.
[0022] Computer equipment, the computer equipment including memory and processor;
[0023] The memory is used to store computer programs;
[0024] The processor is used to record and execute the computer program to implement the steps of the network protocol-based data transmission method as described above.
[0025] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the network protocol-based data transmission method as described above.
[0026] By adopting the above technical solution, the present invention has the following advantages compared with the prior art:
[0027] This invention employs extended CMD commands and RPC remote procedure calls to optimize data, and uses a new unified data structure type to transform the data. By compressing and formatting message content, it significantly reduces the size of transmitted data and lowers network transmission latency, thereby improving network transmission efficiency and game performance. This solves the problem of low network transmission efficiency caused by chaotic data formats in existing technologies. Furthermore, the new data structure of this invention can use a unified interface, eliminating the need to determine which protocol to use based on business requirements, thus reducing the possibility of network protocol errors. Attached Figure Description
[0028] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0030] Example
[0031] The primary objective of this invention is to provide a data transmission method based on network protocols, such as... Figure 1 As shown, the method includes the following steps:
[0032] S1. Aggregate the data from CMD commands and RPC remote procedure calls. This embodiment utilizes the hijacking and integration of business communication logic. Specifically, we removed the scale parameter in NetworkTransform and split the CmdClientToServerSync function. By aggregating the data, we can optimize network transmission efficiency.
[0033] S2. Convert different data types separately, including:
[0034] For basic data, the data type is rationalized within a range at the underlying network architecture level and converted into byte data. This basic data includes types such as bool, int, ulnt, long, ulong, and float. For example, using int for data that can be represented by bytes will slow down transmission efficiency; therefore, we convert int data to byte type data to reduce the amount of data sent in each message.
[0035] For floating-point data, the data is converted to integers and retained to two decimal places. The floating-point data includes data of types such as short, ushort, double, string, and vector2. In this embodiment, the data precision is to retain two decimal places; for example, 0.234234 is converted to 0.23. Of course, one or three decimal places can also be retained as needed, which can reduce the data size and ensure the accuracy of the data during network transmission.
[0036] For vector data, the values of the ternary vector3 are split into x, y, and z, and then converted into float or string types.
[0037] For quaternions, converting the quaternion to a uint type and compressing it into the corresponding rotation parameters is also to reduce the data size and ensure the accuracy of the data during network transmission.
[0038] In this invention, the old data structure was adjusted and a new data structure was adopted. After testing, compared with the untransformed data, the new data structure can reduce the size of each data from a fixed 24 bytes to an average of 15 bytes, a reduction of 37%.
[0039] S3. Data Serialization: All converted data is converted into binary format through a self-encoded byteBuffer data parser; thereby achieving automatic and efficient serialization conversion, reducing the size of the serialized data, and further improving network transmission efficiency.
[0040] S4. Data Compression: Binary format data is passed to a compression algorithm to remove unnecessary bits. Unnecessary bits refer to bits in the binary format data that are all represented by 0s. For example, 1 int is 4 bits, displayed as 0000000000000001 in binary data. Before data serialization, if the value of 1 is less than 255, the data is transmitted as bytes, thus changing 0000000000000001 to 0001. This further compresses the data to its maximum, ensuring network transmission efficiency.
[0041] Compared to uncompressed data, the size of each data item after compression in this invention is reduced from a fixed 18 bytes to an average of 15 bytes, a reduction of 16%.
[0042] S5. Differential Transmission: For high-frequency data involving movement or rotation, the entire data is initially transmitted. If the data changes subsequently, only the differences are transmitted. For example, if the initial movement coordinates are x = 33943.23, y = 43243.23, z = 34322.43, and the position later changes to x = 33343.43, y = 43043.25, z = 34342.45, we only need to upload the differences between them: x = -559.8, y = -199.98, z = 20.02. This significantly reduces the size of the transmitted data and lowers network latency.
[0043] A second objective of this invention is to provide a data transmission system based on a network protocol, the system comprising an aggregation module, a conversion module, a sequence compression module, and a difference transmission module;
[0044] The aggregation module is used to aggregate data from CMD commands and RPC remote procedure calls.
[0045] The conversion module is used to convert the different data types after aggregation to form corresponding data types;
[0046] The sequence compression module is used to convert all the converted data into binary format and pass it into a compression algorithm to remove unnecessary bits;
[0047] The compressed data from the differential transmission module is transmitted differentially. Specifically, the differential transmission involves initially transmitting the entire data, and if the data changes subsequently, only the difference in the data is transmitted.
[0048] The implementation process of the functions and roles of each module in the above system can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0049] A third object of the present invention is to provide a computer device, the computer device including a memory and a processor;
[0050] The memory is used to store computer programs;
[0051] The processor is used to record and execute the computer program to implement the steps of the network protocol-based data transmission method described above.
[0052] A fourth objective of the present invention is to provide a computer-readable storage medium on which a computer program is stored, which, when executed by a processor, implements the steps of the network protocol-based data transmission method as described above.
[0053] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program goods. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program good implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. Computer-usable storage media include permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to: phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.
[0054] This invention is described with reference to flowchart illustrations of methods, systems, and computer program products according to embodiments of the invention. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the process. Figure 1 A device for a function specified in one or more processes.
[0055] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 The function specified in one or more processes.
[0056] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 Steps of a specified function in one or more processes.
[0057] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0058] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
[0059] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A data transmission method based on network protocols, characterized in that: Includes the following steps: S1. Aggregate data from CMD commands and RPC remote procedure calls; S2. Perform conversions on different data types, including: For basic data, directly perform range-based rationalization of the data type at the network architecture layer and convert it into byte data. The basic data includes any one or more of the following types: bool, int, ulnt, long, ulong; For floating-point data, convert the floating-point data to integers while retaining a predetermined data precision. The floating-point data includes any one or more of the following types: short, ushort, double, string, vector2; For vector data, split the ternary vector3 value into x, y, z, and then convert it into float or string type; For quaternions, convert the quaternion into uint type and compress it into the corresponding rotation parameters. S3, Data Serialization: Convert all transformed data into binary format; S4. Data Compression: Pass binary format data into a compression algorithm to remove unnecessary bits; S5. Differential Transmission: For high-frequency data, the entire data is transmitted initially, and if the data changes subsequently, only the difference in the data is transmitted.
2. The data transmission method based on network protocols as described in claim 1, characterized in that: The predetermined precision of the floating-point data is to retain 1 to 3 decimal places.
3. The data transmission method based on network protocols as described in claim 2, characterized in that: In step S3, the converted data is converted into binary format by a byteBuffer data parser.
4. The data transmission method based on network protocols as described in claim 3, characterized in that: In step S4, the unnecessary bits refer to bits in binary format data that are all represented by 0.
5. The data transmission method based on network protocols as described in claim 4, characterized in that: In step S5, the high-frequency data includes data on movement and / or rotation.
6. A computer device, characterized in that: The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is used to record and execute the computer program to implement the steps of the data transmission method based on a network protocol as described in any one of claims 1 to 5.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the data transmission method based on a network protocol as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Data transmission method and device, electronic equipment and medium
CN115630614A