A method and device for encapsulating data and parsing data in message transmission

By determining the encoding mode based on the attributes and transmission mode of the application data and encoding the data, the problem of low data transmission efficiency in the prior art is solved, and efficient resource utilization and improvement of application system performance are achieved.

CN119383226BActive Publication Date: 2025-06-27BEIJING YOYO TIANYU SYST TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411513482.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-06-27
Estimated Expiration
2044-10-28

AI Technical Summary

Technical Problem

In the prior art, it is difficult to efficiently transmit data blocks with uncertain data types and uncertain data lengths in data transmission, resulting in waste of resources and reduced transmission efficiency.

Method used

By determining the encoding mode according to the attributes and transmission mode of the application data, the data is encoded and the target message is generated. Different data types and transmission modes correspond to different encoding modes, rationally utilize resources and improve transmission efficiency.

Benefits of technology

It realizes flexible encoding of different data types and transmission modes, rational use of resources, improves transmission efficiency, and improves the performance of the application system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119383226B_ABST
    Figure CN119383226B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for encapsulating data in message transmission, which is applied to a message sender and includes the following steps: determining an encoding mode according to the attributes and transmission mode of application data; encoding the application data according to the encoding mode, variant data type and value of a custom encoding value to generate a target message; and transmitting the target message to a message receiver. By adopting different encoding modes for encoding application data according to the attributes and transmission mode of the application data, the present invention encodes different data types of the application data with different encodings, and the same data type can further adopt different encodings. After encoding, the largest data is represented by the smallest number of transmitted bytes, reasonably utilizing resources, improving the transmission efficiency and enhancing the performance of the application system. The present invention also discloses a method for parsing data in message transmission and a device for implementing the above method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electronics and computer data processing, and in particular to a method and device for encapsulating and parsing data in message transmission. Background Art

[0002] Computer network protocols, as the cornerstone of building a network communication system, are usually divided into seven layers. Among these seven layers, the transport layer plays a crucial role. It mainly relies on TCP / IP or UDP protocols and is dedicated to solving the problem of transmitting network packets. At this layer, the focus is not on the specific data type, but on how to efficiently and accurately complete the data transfer.

[0003] Generally speaking, when building business applications, most application layer systems are established on the basis of transport layer protocols. During the interaction process of the application layer, in order to ensure the accurate expression and efficient processing of data, a series of basic data types are usually defined, such as integer (int), double-precision floating-point type (double), single-precision floating-point type (float), string, and binary array, etc. These data types provide basic specifications for data exchange in the application layer. These basic types are usually of variable length, so generally a field is required to identify its length during transmission.

[0004] However, during data transmission, especially through a narrow-bandwidth transmission link, the transmission efficiency and quality of these basic data types often become a key issue to be considered. When defining common application protocols, a challenge is often faced, that is, how to effectively transmit a data block with an uncertain data type and variable length in a message, which is particularly common in the application layer. Although the key-value pair method can meet the basic transmission requirements, in today's pursuit of efficient transmission, it is not the most ideal choice. Using one encoding method for each message to transmit various data types, and the encoding methods for different data types are the same, which causes resource waste, leads to a decrease in transmission efficiency, and even affects the performance of the entire application system. Summary of the Invention

[0005] In order to solve the above problems existing in the prior art, the present invention provides a method and device for encapsulating and parsing data in message transmission. The technical problems to be solved by the present invention are realized through the following technical solutions:

[0006] The first aspect of the embodiments of the present invention provides a method and device for encapsulating and parsing data in message transmission, including the following steps:

[0007] Determine an encoding mode according to the attributes and transmission mode of the application data;

[0008] Encode the application data according to the encoding mode, variant data type, and value of the custom encoding value to generate a target message; wherein, the value of the custom encoding value indicates an empty string and its value or a non-empty value boolean type and its value; the target message includes the transmission mode;

[0009] Transmit the target message to the message recipient.

[0010] In an embodiment of the present invention, the determining the encoding mode according to the attributes of the application data and the transmission mode includes:

[0011] When the field type of the application data is String and it is an empty string, the encoding mode is the first string mode;

[0012] When the field type of the application data is String and the transmission mode is the first transmission mode NONE, the encoding mode is the second string mode;

[0013] When the field type of the application data is String, the transmission mode is the second transmission mode FAST, and the maximum actual length of the string is less than 21 bits, the encoding mode is the third string mode;

[0014] When the field type of the application data is String, the transmission mode is the second transmission mode FAST, and the minimum actual length of the string is 21 bits, the encoding mode is the fourth string mode;

[0015] When the field type of the application data is String, the transmission mode is the third transmission mode MAX, and the maximum actual length of the string is less than 21 bits, the encoding mode is the fifth string mode;

[0016] When the field type of the application data is String, the transmission mode is the third transmission mode MAX, and the minimum actual length of the string is 21 bits, the encoding mode is the sixth string mode;

[0017] The encoding the application data according to the encoding mode, variant data type, and value of the custom encoding value to generate a target message includes:

[0018] When the encoding mode is the first string mode, the value of the field type in the target message is 0x83, and the length is 1 byte; wherein, 0x83 is the custom encoding value, and 0x8 indicates that the field type is a string and it is an empty string;

[0019] When the encoding mode is the second string mode, the length of the field type in the target message is 1 byte, with a value of 0x03, the length of the string length is 4 bytes, with a value of the actual length of the string, the length of the string is the actual length of the string plus 1, and the value is a null-terminated string;

[0020] When the encoding mode is the third string mode, the length of the field type in the target message is 1 byte, with a value of 0x43, the maximum length of the string length is 3 bytes, with a value of the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value is a null-terminated string;

[0021] When the encoding mode is the fourth string mode, the length of the field type in the target message is 1 byte, with a value of 0x03, the length of the string length is 4 bytes, with a value of the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value is a null-terminated string;

[0022] When the encoding mode is the fifth string mode, the length of the field type in the target message is 1 byte, with a value of 0x43, the maximum length of the string length is 3 bytes, with a value of the actual length of the string, the length of the string is the actual length of the string, and the value is a string without a null;

[0023] When the encoding mode is the sixth string mode, the length of the field type in the target message is 1 byte, with a value of 0x03, the length of the string length is 4 bytes, with a value of the actual length of the string, the length of the string is the actual length of the string, and the value is a string without a null.

[0024] In an embodiment of the present invention, the determining the encoding mode according to the attributes and transmission mode of the application data includes:

[0025] When the field type of the application data is Int8, the encoding mode is the Int8 mode;

[0026] When the field type of the application data is Int16, the transmission mode is the first transmission mode NONE, and the minimum length of the value of the field is 7 bits, the encoding mode is the 16-bit integer first mode;

[0027] When the field type of the application data is Int16, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the value of the field is less than 7 bits, the encoding mode is the 16-bit integer second mode;

[0028] When the field type of the application data is Int32, the transmission mode is the first transmission mode NONE, and the minimum length of the value of the field is 21 bits, the encoding mode is the 32-bit integer first mode;

[0029] When the field type of the application data is Int32, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the value of the field is less than 21 bits, the encoding mode is the 32-bit integer second mode;

[0030] When the field type of the application data is Int64, the transmission mode is the first transmission mode NONE, and the minimum length of the value of the field is 49 bits, the encoding mode is the 64-bit integer first mode;

[0031] When the field type of the application data is Int64, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the value of the field is less than 49 bits, the encoding mode is the 64-bit integer second mode;

[0032] Encoding the application data according to the encoding mode, variant data type, and the value of the custom encoding value to generate a target message, including:

[0033] When the encoding mode is the Int8 mode, the length of the field type in the target message is 1 byte, the value is 0x07, the length of the value of the field is 1 byte, and the value is the actual value;

[0034] When the encoding mode is the 16-bit integer first mode, the value of the field type in the target message is 0x09, the length is 1 byte, the length of the value of the field is 2 bytes, and the value is the actual value;

[0035] When the encoding mode is the 16-bit integer second mode, the value of the field type in the target message is 0x49, the length is 1 byte, the length of the value of the field is 1 byte, and the value is the actual value;

[0036] When the encoding mode is the 32-bit integer first mode, the value of the field type in the target message is 0x0B, the length is 1 byte, the length of the value of the field is 4 bytes, and the value is the actual value;

[0037] When the encoding mode is the 32-bit integer second mode, the value of the field type in the target message is 0x4B, the length is 1 byte, the maximum length of the value of the field is 3 bytes, and the value is the actual value;

[0038] When the encoding mode is the 64-bit integer first mode, the value of the field type in the target message is 0x0D, the length is 1 byte, the length of the value of the field is 8 bytes, and the value is the actual value;

[0039] When the encoding mode is the 64-bit integer second mode, the value of the field type in the target message is 0x4D, the length is 1 byte, the maximum length of the value of the field is 7 bytes, and the value is the actual value.

[0040] In an embodiment of the present invention, the determining the encoding mode according to the attributes of the application data and the transmission mode includes:

[0041] When the field type of the application data is the boolean type and the transmission mode is the first transmission mode NONE, the encoding mode is the boolean first mode;

[0042] When the field type of the application data is the boolean type and the transmission mode is the fourth transmission mode not NONE, the encoding mode is the boolean second mode;

[0043] The encoding the application data according to the encoding mode, the variant data type, and the value of the custom encoding value to generate a target message includes:

[0044] When the encoding mode is the boolean first mode, the value of the field type in the target message is 0x11, the length is 1 byte, the length of the value of the field is 4 bytes, and the value is the actual value;

[0045] When the encoding mode is the boolean second mode, the value of the field type in the target message is 0xD1 or 0x51, and the length is 1 byte; wherein, 0xD1 and 0x51 are custom encoding values, 0xD1 indicates that the type of the field is boolean and the value is true, and 0x51 indicates that the type of the field is boolean and the value is false.

[0046] In an embodiment of the present invention, the determining the encoding mode according to the attributes of the application data and the transmission mode includes:

[0047] When the field type of the application data is an object and the transmission mode is the first transmission mode NONE or the minimum length of the object is 21, the encoding mode is the object first mode;

[0048] When the field type of the application data is an object, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the object is less than 21 bits, the encoding mode is the object second mode;

[0049] The encoding the application data according to the encoding mode, the variant data type, and the value of the custom encoding value to generate a target message includes:

[0050] When the encoding mode is the object - type first mode, the value of the field type in the target message is 0x16, 0x17, or 0x18, with a length of 1 byte. The length of the field length is 4 bytes, and the value is the length of the opaque. The value of the field is the actual value, with a length of the actual length of the field;

[0051] When the encoding mode is the object - type second mode, the value of the field type in the target message is 0x56, 0x57, or 0x58, with a length of 1 byte. The maximum length of the field length is 3 bytes, and the value is the length of the opaque. The value of the field is the actual value, with a length of the actual length of the field;

[0052] Among them, 0x16 and 0x56 indicate that the field type is opaque, 0x17 and 0x57 indicate that the field type is java obj, and 0x18 and 0x58 indicate that the field type is dotnet obj.

[0053] In an embodiment of the present invention, the determining the encoding mode according to the attributes and transmission mode of the application data includes:

[0054] When the field type of the application data is a message and the message is empty, the encoding mode is the message - type first mode;

[0055] When the field type of the application data is a message and the message is not empty, the encoding mode is the message - type second mode;

[0056] The encoding the application data according to the encoding mode, variant data type, and value of the custom encoding value to generate a target message includes:

[0057] When the encoding mode is the message - type first mode, the value of the field type in the target message is 0x19, with a length of 1 byte. The length of the message length is 4 bytes, and the value is 0;

[0058] When the encoding mode is the message - type second mode, the value of the field type in the target message is 0x19, with a length of 1 byte. The length of the message length is 4 bytes, and the value is the value of the message length. The value of the message content is the serialized message content, with a length of the value of the message length.

[0059] A second aspect of the embodiments of the present invention provides a method for parsing data in message transmission, which is applied to a message receiver and includes the following steps:

[0060] Receive the target message sent by the message sender;

[0061] Parse the target message.

[0062] The third aspect of the embodiments of the present invention provides a data encapsulation device in message transmission, which is applied to a message sender and includes:

[0063] A determination module, configured to determine an encoding mode according to the attributes and transmission mode of application data;

[0064] A generation module, configured to encode the application data according to the encoding mode, variant data type, and value of a custom encoding value to generate a target message; wherein, the value of the custom encoding value indicates an empty string and its value or a non-empty value boolean type and its value; the transmission mode is included in the target message;

[0065] A sending module, configured to transmit the target message to a message receiver.

[0066] The fourth aspect of the embodiments of the present invention provides a data parsing device in message transmission, which is applied to a message receiver and includes:

[0067] A receiving module, configured to receive the target message sent by a message sender;

[0068] A parsing module, configured to parse the target message.

[0069] Advantages of the present invention:

[0070] The present invention encodes application data by adopting different encoding modes according to the attributes and transmission mode of application data, so as to encode different data types of application data with different encodings, and the same data type can further adopt different encodings. After encoding, the largest data is represented by the smallest number of transmission bytes, reasonably utilizing resources, improving the transmission efficiency, and enhancing the performance of the application system.

[0071] Other features and advantages of the present invention will be described in the following specification, and, in part, will be obvious from the specification, or will be understood by implementing the present invention. The objectives and other advantages of the present invention can be realized and obtained by the structures specifically pointed out in the written specification, claims, and drawings.

[0072] The technical solutions of the present invention will be further described in detail below through the drawings and embodiments. Description of the Drawings

[0073] The drawings are used to provide further understanding of the present invention, and constitute a part of the specification. They are used together with the embodiments of the present invention to explain the present invention, and do not constitute a limitation to the present invention. In the drawings:

[0074] Figure 1 It is a schematic flowchart of a data encapsulation method and a parsing method in message transmission provided by an embodiment of the present invention;

[0075] Figure 2 A block diagram schematic of a method for encapsulating data in message transmission and a parsing device provided by an embodiment of the present invention. Detailed implementation manners

[0076] The following further describes the present invention in detail with reference to specific embodiments, but the implementation manners of the present invention are not limited thereto.

[0077] As Figure 1 shown, a first aspect of an embodiment of the present invention provides a method for encapsulating data in message transmission, which is applied to a message sender and includes the following steps:

[0078] Step 11, determining an encoding mode according to the attributes and transmission mode of application data.

[0079] Step 12, encoding the application data according to the encoding mode, variant data type, and value of the custom encoding value to generate a target message.

[0080] Among them, different attributes and transmission modes correspond to different encoding modes; the value of the custom encoding value indicates an empty string and its value or a non-empty value boolean type and its value; the transmission mode is included in the target message.

[0081] Step 13, transmitting the target message to the message receiver.

[0082] In this embodiment, different encoding modes are used to encode application data according to the attributes and transmission mode of application data, so that different data types of application data are encoded using different encoding modes, and the same data type can further be encoded using different encoding modes. After encoding, the largest data is represented by the smallest number of transmission bytes, avoiding resource waste caused by using the same encoding (for example, if smaller-length data is also encoded using a larger fixed length, it will cause resource waste), and rationally utilizing resources. At the same time, the same transmission mode can use different encoding methods according to actual needs, further rationally utilizing resources, improving the transmission efficiency, and enhancing the performance of the application system.

[0083] A second aspect of an embodiment of the present invention provides a method for encapsulating data in message transmission, including the following steps:

[0084] Step 21, the message sender determines an encoding mode according to the attributes and transmission mode of application data.

[0085] In this step, different attributes and transmission modes of application data can correspond to different coding modes. The message sender can determine which category each field or each type of field of the application data belongs to, determine the type of the transmission mode, and which conditions other attributes meet, so as to automatically match the corresponding coding mode. The transmission mode can be set as needed. The present invention represents more specific field types of application data in the form of variant data types.

[0086] Through a mapping table, fixed numerical values are used to correspond to basic data types, as shown in Table 1 specifically:

[0087]

[0088]

[0089] Table 1

[0090] Step 22, the message sender encodes the application data according to the coding mode, variant data type, and value of the custom coding value to generate a target message.

[0091] Among them, different attributes and transmission modes correspond to different coding modes; the value of the custom coding value indicates an empty string and its value or a non-empty value boolean type and its value; the target message includes the transmission mode.

[0092] In this step, the application data is encoded after determining the coding mode of each field.

[0093] Specifically, the specific encoding method is described in detail as follows:

[0094] 1. When the field type of the application data is String:

[0095] 1. If it is an empty string, the coding mode is the first string mode. At this time, the transmission mode does not need to be considered. When the coding mode is the first string mode, the coding method in the target message is: the value of the field type is 0x83, and the length of the field type is 1 byte. Here, the value of the field type is represented by 0x83, 0x83 is the custom coding value, 0x83 can represent that the field type is a string and is an empty string, and 0x83 represents both the field type and an attribute of the string.

[0096] 2. When it is a non-empty string and the transmission mode is the first transmission mode NONE, the encoding mode is the second string mode. When the encoding mode is the second string mode, the encoding method in the target message is as follows: the length of the field type is 1 byte, the value of the field type is 0x03, the length of the string length is 4 bytes, the value of the string length is the actual length of the string, the length of the string is the actual length of the string plus 1, and the value of the string is a null-terminated string.

[0097] Here, when encoding the string, it is necessary to encode the field type, the value of the field type, the string length, the value of the string length, the length of the string, and the value of the string. The length of the string and the string length are different. There is an information in the encoding information that limits the string length. For example, it is required to limit the string length of a certain field in the application data to only 4 bytes (specifying the length of the content to be filled).

[0098] For a null-terminated string, when parsing the message, it can be directly parsed without copying, which improves the parsing speed of the string.

[0099] 3. If the transmission mode is the second transmission mode FAST and the maximum actual length of the string is less than 21 bits, the encoding mode is the third string mode. Here, the attributes of the application data are further restricted. When the transmission mode is the second transmission mode FAST and the maximum actual length of the string is less than 21 bits, the encoding mode is determined to be the third string mode.

[0100] When the encoding mode is the third string mode, the encoding method in the target message is as follows: the length of the field type is 1 byte, the value of the field type is 0x43, the maximum length of the string length is 3 bytes, the value of the string length is the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value of the string is a null-terminated string. Here, the length of the string length can be 1 to 3 bytes.

[0101] 4. If the transmission mode is the second transmission mode FAST and the minimum actual length of the string is 21 bits, the encoding mode is the fourth string mode.

[0102] When the encoding mode is the fourth string mode, the encoding method in the target message is as follows: the length of the field type is 1 byte, the value of the field type is 0x03, the length of the string length is 4 bytes, the value of the string length is the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value of the string is a null-terminated string.

[0103] When the transmission mode is the second transmission mode, different coding modes can be adaptively selected according to the length of the string to perform encoding efficiently, so as to make reasonable use of resources.

[0104] 5. If the transmission mode is the third transmission mode MAX and the maximum actual length of the string is less than 21 bits, determine that the coding mode is the fifth string mode.

[0105] When the coding mode is the fifth string mode, the coding method in the target message is as follows: the length of the field type is 1 byte, the value of the field type is 0x43, the maximum length of the string length is 3 bytes, the value of the string length is the actual length of the string, the length of the string is the actual length of the string, and the value of the string is the string without carrying null. Here, the length of the string length can be 1 to 3 bytes.

[0106] 6. If the transmission mode is the third transmission mode MAX and the minimum actual length of the string is 21 bits, determine that the coding mode is the sixth string mode.

[0107] When the coding mode is the sixth string mode, the coding method in the target message is as follows: the length of the field type is 1 byte, the value is 0x03, the length of the string length is 4 bytes, the value of the string length is the actual length of the string, the length of the string is the actual length of the string, and the value of the string is the string without carrying null.

[0108] For example, the coding method is shown in Table 2: compact is the transmission mode.

[0109]

[0110]

[0111] Table 2

[0112] In this embodiment, encoding can be performed according to the coding methods that can be adopted according to different lengths of the string under the same transmission mode.

[0113] Second, when the field type of the application data is Int:

[0114] 1. When the field type of the application data is Int8, the coding mode is the Int8 mode.

[0115] When the coding mode is the Int8 mode, the coding method in the target message is as follows: the length of the field type is 1 byte, the value of the field type is 0x07, the length of the field value is 1 byte, and the field value is the actual value.

[0116] For example, the coding method is shown in Table 3:

[0117] Field Name Size Value Type 1 0x07 Value 1 Value

[0118] Table 3

[0119] 2. When the field type of the application data is Int16, the transmission mode is the first transmission mode NONE, and the minimum length of the field value is 7 bits, the encoding mode is the 16-bit integer first mode.

[0120] When the encoding mode is the 16-bit integer first mode, the encoding method in the target message is: the value of the field type is 0x09, the length of the field type is 1 byte, the length of the field value is 2 bytes, and the field value is the actual value.

[0121] 3. When the field type of the application data is Int16, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the field value is less than 7 bits, the encoding mode is the 16-bit integer second mode.

[0122] When the encoding mode is the 16-bit integer second mode, the encoding method in the target message is: the value of the field type is 0x49, the length of the field type is 1 byte, the length of the field value is 1 byte, and the field value is the actual value.

[0123] For example, the encoding method is shown in Table 4:

[0124]

[0125] Table 4

[0126] 4. When the field type of the application data is Int32, the transmission mode is the first transmission mode NONE, and the minimum length of the field value is 21 bits, the encoding mode is the 32-bit integer first mode.

[0127] When the encoding mode is the 32-bit integer first mode, the encoding method in the target message is that the value of the field type is 0x0B, the length of the field type is 1 byte, the length of the field value is 4 bytes, and the field value is the actual value.

[0128] 5. When the field type of the application data is Int32, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the field value is less than 21 bits, the encoding mode is the 32-bit integer second mode.

[0129] When the encoding mode is the 32-bit integer second mode, the encoding method in the target message is that the value of the field type is 0x4B, the length of the field type is 1 byte, the maximum length of the field value is 3 bytes, and the field value is the actual value. The length of the field value can be 1 to 3 bytes.

[0130] For example, the encoding method is shown in Table 5:

[0131]

[0132] Table 5

[0133] 6. When the field type of the application data is Int64, the transmission mode is the first transmission mode NONE, and the minimum length of the value of the field is 49 bits, the encoding mode is the 64-bit integer first mode.

[0134] When the encoding mode is the 64-bit integer first mode, the encoding method in the target message is that the value of the field type is 0x0D, the length is 1 byte, the length of the value of the field is 8 bytes, and the value is the actual value.

[0135] 7. When the field type of the application data is Int64, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the value of the field is less than 49 bits, the encoding mode is the 64-bit integer second mode.

[0136] When the encoding mode is the 64-bit integer second mode, the encoding method in the target message is: the value of the field type is 0x4D, the length is 1 byte, the maximum length of the value of the field is 7 bytes, and the value of the field is the actual value. The length of the value of the field can be 1 to 7 bytes.

[0137] For example, the encoding method is shown in Table 6:

[0138]

[0139]

[0140] Table 6

[0141] III. When the field type of the application data is boolean:

[0142] 1. When the transmission mode is the first transmission mode NONE, the encoding mode is the boolean first mode.

[0143] When the encoding mode is the boolean first mode, the encoding method in the target message is: the value of the field type is 0x11, the length of the field type is 1 byte, the length of the value of the field is 4 bytes, and the value of the field is the actual value.

[0144] 2. When the transmission mode is the fourth transmission mode not NONE, the encoding mode is the boolean second mode.

[0145] When the encoding mode is the boolean second mode, the value of the field type in the target message is 0xD1 or 0x51, and the length of the field type is 1 byte.

[0146] Among them, 0xD1 and 0x51 are custom encoding values. 0xD1 can indicate that the type of the field is boolean and the value is true, and 0x51 can indicate that the type of the field is boolean and the value is false. Here, the custom encoding value can reduce the length and bytes of the encoded data and save space.

[0147] For example, the encoding method is shown in Table 7:

[0148]

[0149] Table 7

[0150] IV. When the field type of the application data is an object: The object here is a non-directly-readable object. Like a string, the size of a non-directly-readable object is variable. The non-directly-readable object can be OPAQUE, JAVA_OBJ, or.NET_OBJ. The non-directly-readable object first stores its size and then stores the data.

[0151] 1. When the transmission mode is the first transmission mode NONE or the minimum length of the object is 21, the encoding mode is the first object type mode.

[0152] When the encoding mode is the first object type mode, the encoding method in the target message is: the value of the field type is 0x16, 0x17, or 0x18, the length of the field type is 1 byte, the length of the field length is 4 bytes, the value of the field length is the length of the opaque, the value of the field is the actual value, and the length of the field is the actual length of the field.

[0153] 2. When the transmission mode is the fourth transmission mode not NONE and the maximum length of the object is less than 21 bits, the encoding mode is the second object type mode;

[0154] When the encoding mode is the second object type mode, the encoding method in the target message is: the value of the field type is 0x56, 0x57, or 0x58, the length of the field type is 1 byte, the maximum length of the field length is 3 bytes, the value of the field length is the length of the opaque, the value of the field is the actual value, and the length of the field is the actual length of the field.

[0155] Among them, 0x16 and 0x56 indicate that the field type is opaque, 0x17 and 0x57 indicate that the field type is java obj, and 0x18 and 0x58 indicate that the field type is dotnet obj.

[0156] For example, the encoding method is shown in Table 8:

[0157]

[0158]

[0159] Table 8

[0160] V. When the field type of the application data is a message, the variant data type also supports nesting messages, that is, one message can be stored in another message. In this embodiment, the message is encoded as follows:

[0161] 1. When the message is empty, the encoding mode is the first message mode.

[0162] When the encoding mode is the first message mode, the encoding method in the target message is: the value of the field type is 0x19, the length of the field type is 1 byte, the length of the message length is 4 bytes, and the value of the message length is 0.

[0163] 2. When the message is not empty, the encoding mode is the second message mode.

[0164] When the encoding mode is the second message mode, the encoding method in the target message is: the value of the field type is 0x19, the length of the field type is 1 byte, the length of the message length is 4 bytes, the value of the message length is the actual value of the message length, the value of the message content is the serialized message content, and the length of the message content is the actual value of the message length.

[0165] For example, the encoding method is shown in Table 9:

[0166]

[0167]

[0168] Table 9

[0169] In this step, for uncertain input data types, they can be expressed in a unified variant manner, expanding the application scenarios; the largest integer type data can be represented with the smallest number of transmission bytes. (Transmission optimization) The smallest number of transmission bytes is used during transmission, but a larger integer type is used during use. For example, it is defined as int64, but during actual transmission, it is varint. The null placeholder can be used, but it is not used for transmitting data and is used to split data, enabling fast data parsing. For data exceeding a certain value, a fixed length or variable length can be adaptively selected, and automatic optimization is performed according to the occupied space. For strings, an end marker can be added or not. After adding the end marker, there is no need to copy from the message and it can be directly parsed, improving the string parsing speed.

[0170] Step 23, the message sender transmits the target message to the message receiver.

[0171] In this embodiment, when transmitting application data of the same size, the data type and encapsulation method used use fewer bytes during transmission than the transmission method in the prior art.

[0172] Step 24, the message receiver receives the target message sent by the message sender.

[0173] Step 25, the message receiver parses the target message.

[0174] After obtaining the target message, the message receiver parses the target message. If parsing the custom encoding value, only need to parse the custom encoding value to directly obtain the field type and its value, only need to parse one kind of encoding, without parsing two kinds of encoding of type and value. If the value of the string is a string ending with null, when parsing the message, it can be directly parsed without copying, improving the parsing speed of the string.

[0175] Such as Figure 2 As shown, the third aspect of the embodiment of the present invention provides a data encapsulation device in message transmission, which is applied to the message sender and includes:

[0176] A determination module 31, configured to determine an encoding mode according to the attributes of the application data and the transmission mode;

[0177] A generation module 32, configured to encode the application data according to the encoding mode, variant data type and the value of the custom encoding value to generate a target message; wherein, the value of the custom encoding value indicates an empty string and its value or a non-empty value boolean type and its value; the target message includes the transmission mode;

[0178] A sending module 33, configured to transmit the target message to the message receiver.

[0179] In an embodiment of the present invention, the determining the encoding mode according to the attributes of the application data and the transmission mode includes:

[0180] When the field type of the application data is String and it is an empty string, the encoding mode is the first string mode;

[0181] When the field type of the application data is String and the transmission mode is the first transmission mode NONE, the encoding mode is the second string mode;

[0182] When the field type of the application data is String and the transmission mode is the second transmission mode FAST and the maximum actual length of the string is less than 21 bits, the encoding mode is the third string mode;

[0183] When the field type of the application data is String, the transmission mode is the second transmission mode FAST, and the minimum actual length of the string is 21 bits, the encoding mode is the fourth string mode;

[0184] When the field type of the application data is String, the transmission mode is the third transmission mode MAX, and the maximum actual length of the string is less than 21 bits, the encoding mode is the fifth string mode;

[0185] When the field type of the application data is String, the transmission mode is the third transmission mode MAX, and the minimum actual length of the string is 21 bits, the encoding mode is the sixth string mode;

[0186] Encoding the application data according to the encoding mode, variant data type, and value of the custom encoding value to generate a target message, including:

[0187] When the encoding mode is the first string mode, the value of the field type in the target message is 0x83, and the length is 1 byte;

[0188] When the encoding mode is the second string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string length is 4 bytes, the value is the actual length of the string, the length of the string is the actual length of the string plus 1, and the value is a null-terminated string;

[0189] When the encoding mode is the third string mode, the length of the field type in the target message is 1 byte, the value is 0x43, the maximum length of the string length is 3 bytes, the value is the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value is a null-terminated string;

[0190] When the encoding mode is the fourth string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string length is 4 bytes, the value is the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value is a null-terminated string;

[0191] When the encoding mode is the fifth string mode, the length of the field type in the target message is 1 byte, the value is 0x43, the maximum length of the string length is 3 bytes, the value is the actual length of the string, the length of the string is the actual length of the string, and the value is a non-null-carrying string;

[0192] When the encoding mode is the sixth string mode, the length of the field type in the target message is 1 byte, with a value of 0x03, the length of the string length is 4 bytes, with a value of the actual length of the string, the length of the string is the actual length of the string, and the value is a string without null.

[0193] In an embodiment of the present invention, the determining the encoding mode according to the attributes and transmission mode of the application data includes:

[0194] When the field type of the application data is Int8, the encoding mode is the Int8 mode;

[0195] When the field type of the application data is Int16, the transmission mode is the first transmission mode NONE, and the minimum length of the value of the field is 7 bits, the encoding mode is the 16-bit integer first mode;

[0196] When the field type of the application data is Int16, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the value of the field is less than 7 bits, the encoding mode is the 16-bit integer second mode;

[0197] When the field type of the application data is Int32, the transmission mode is the first transmission mode NONE, and the minimum length of the value of the field is 21 bits, the encoding mode is the 32-bit integer first mode;

[0198] When the field type of the application data is Int32, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the value of the field is less than 21 bits, the encoding mode is the 32-bit integer second mode;

[0199] When the field type of the application data is Int64, the transmission mode is the first transmission mode NONE, and the minimum length of the value of the field is 49 bits, the encoding mode is the 64-bit integer first mode;

[0200] When the field type of the application data is Int64, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the value of the field is less than 49 bits, the encoding mode is the 64-bit integer second mode;

[0201] The encoding the application data according to the encoding mode, variant data type and value of the custom encoding value to generate a target message includes:

[0202] When the encoding mode is the Int8 mode, the length of the field type in the target message is 1 byte, with a value of 0x07, the length of the value of the field is 1 byte, with a value of the actual value;

[0203] When the encoding mode is the 16-bit integer first mode, the value of the field type in the target message is 0x09, the length is 1 byte, the length of the field value is 2 bytes, and the value is the actual value;

[0204] When the encoding mode is the 16-bit integer second mode, the value of the field type in the target message is 0x49, the length is 1 byte, the length of the field value is 1 byte, and the value is the actual value;

[0205] When the encoding mode is the 32-bit integer first mode, the value of the field type in the target message is 0x0B, the length is 1 byte, the length of the field value is 4 bytes, and the value is the actual value;

[0206] When the encoding mode is the 32-bit integer second mode, the value of the field type in the target message is 0x4B, the length is 1 byte, the maximum length of the field value is 3 bytes, and the value is the actual value;

[0207] When the encoding mode is the 64-bit integer first mode, the value of the field type in the target message is 0x0D, the length is 1 byte, the length of the field value is 8 bytes, and the value is the actual value;

[0208] When the encoding mode is the 64-bit integer second mode, the value of the field type in the target message is 0x4D, the length is 1 byte, the maximum length of the field value is 7 bytes, and the value is the actual value.

[0209] In an embodiment of the present invention, the determining the encoding mode according to the attributes and transmission mode of the application data includes:

[0210] When the field type of the application data is a boolean type and the transmission mode is the first transmission mode NONE, the encoding mode is the boolean first mode;

[0211] When the field type of the application data is a boolean type and the transmission mode is the fourth transmission mode not NONE, the encoding mode is the boolean second mode;

[0212] The encoding the application data according to the encoding mode, variant data type, and value of the custom encoding value to generate a target message includes:

[0213] When the encoding mode is the boolean first mode, the value of the field type in the target message is 0x11, the length is 1 byte, the length of the field value is 4 bytes, and the value is the actual value;

[0214] When the encoding mode is the boolean second mode, the value of the field type in the target message is 0xD1 or 0x51, and the length is 1 byte.

[0215] In an embodiment of the present invention, determining the encoding mode according to the attributes and transmission mode of the application data includes:

[0216] When the field type of the application data is an object, and the transmission mode is the first transmission mode NONE or the minimum length of the object is 21, the encoding mode is the first object type mode;

[0217] When the field type of the application data is an object, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the object is less than 21 bits, the encoding mode is the second object type mode;

[0218] Encoding the application data according to the encoding mode, variant data type, and value of the custom encoding value to generate a target message includes:

[0219] When the encoding mode is the first object type mode, the value of the field type in the target message is 0x16, 0x17, or 0x18, the length is 1 byte, the length of the field length is 4 bytes, the value is the length of opaque, and the value of the field is the actual value, and the length is the actual length of the field;

[0220] When the encoding mode is the second object type mode, the value of the field type in the target message is 0x56, 0x57, or 0x58, the length is 1 byte, the maximum length of the field length is 3 bytes, the value is the length of opaque, and the value of the field is the actual value, and the length is the actual length of the field;

[0221] Among them, 0x16 and 0x56 indicate that the field type is opaque, 0x17 and 0x57 indicate that the field type is java obj, and 0x18 and 0x58 indicate that the field type is dotnet obj.

[0222] In an embodiment of the present invention, determining the encoding mode according to the attributes and transmission mode of the application data includes:

[0223] When the field type of the application data is a message and the message is empty, the encoding mode is the first message type mode;

[0224] When the field type of the application data is a message and the message is not empty, the encoding mode is the second message type mode;

[0225] Encoding the application data according to the encoding mode, variant data type, and value of the custom encoding value to generate a target message includes:

[0226] When the encoding mode is the first message type mode, the value of the field type in the target message is 0x19, the length is 1 byte, the length of the message length is 4 bytes, and the value is 0;

[0227] When the encoding mode is the second message type, the value of the field type in the target message is 0x19, the length is 1 byte, the length of the message length is 4 bytes, the value is the value of the message length, and the value of the message content is the serialized message content with a length of the value of the message length.

[0228] The fourth aspect of the embodiments of the present invention provides a data parsing device in message transmission, which is applied to a message receiver and includes:

[0229] A receiving module, configured to receive a target message sent by a message sender;

[0230] A parsing module, configured to parse the target message.

[0231] The fifth aspect of the embodiments of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements a data encapsulation method or a parsing method for data in message transmission provided by the embodiments of the present invention.

[0232] The sixth aspect of the embodiments of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of a data encapsulation method or a parsing method for data in message transmission provided by the embodiments of the present invention.

[0233] Among them, the memory may include a random access memory (RAM), or may also include a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.

[0234] The aforementioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware systems.

[0235] The method provided by the embodiments of the present invention can be applied to an electronic device. Specifically, the electronic device can be: a desktop computer, a portable computer, a smart mobile terminal, a server, etc. There is no limitation here. Any electronic device that can implement the present invention belongs to the protection scope of the present invention.

[0236] For the embodiments of the apparatus / electronic device, since they are basically similar to the method embodiments, the description is relatively simple. For the relevant parts, please refer to the partial description of the method embodiments.

[0237] The present invention is described with reference to the flowcharts and / or block diagrams of methods, devices (apparatus), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the specified functions in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0238] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device implements the specified functions in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0239] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable device provide steps for implementing the specified functions in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0240] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention also intends to include these changes and modifications.

Claims

1. A method for encapsulating data in message transmission, characterized in that: Applied to the message sender, including the following steps: Determine the encoding mode according to the attributes and transmission mode of the application data; Encoding the application data according to the encoding mode, the variant data type and the value of the custom encoding value to generate a target message; wherein the value of the custom encoding value indicates an empty string and its value or a non-empty value Boolean type and its value; and the target message includes the transmission mode; transmitting the target message to a message recipient; The determining of the encoding mode according to the attributes and transmission mode of the application data includes: When the field type of the application data is String and is an empty string, the encoding mode is the first string mode; When the field type of the application data is String and the transmission mode is the first transmission mode NONE, the encoding mode is the second string mode; When the field type of the application data is String, and the transmission mode is the second transmission mode FAST, and the maximum actual length of the string is less than 21 bits, the encoding mode is the third string mode; When the field type of the application data is String, the transmission mode is the second transmission mode FAST, and the minimum actual length of the string is 21 bits, the encoding mode is the fourth string mode; When the field type of the application data is String, and the transmission mode is the third transmission mode MAX, and the maximum actual length of the string is less than 21 bits, the encoding mode is the fifth string mode; When the field type of the application data is String, the transmission mode is the third transmission mode MAX, and the minimum actual length of the string is 21 bits, the encoding mode is the sixth string mode; The encoding of the application data according to the encoding mode, the variant data type and the value of the custom encoding value to generate a target message includes: When the encoding mode is the first string mode, the value of the field type in the target message is 0x83, and the length is 1 byte; wherein 0x83 is a custom encoding value, and 0x8 indicates that the field type is a string, and is an empty string; When the encoding mode is the second string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string length is 4 bytes, the value is the actual length of the string, the length of the string is the actual length of the string plus 1, and the value is a string terminated by null; When the encoding mode is the third string mode, the length of the field type in the target message is 1 byte, the value is 0x43, the maximum length of the string length is 3 bytes, the value is the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value is a string terminated by null; When the encoding mode is the fourth string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string length is 4 bytes, the value is the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value is a string terminated by null; When the encoding mode is the fifth string mode, the length of the field type in the target message is 1 byte, the value is 0x43, the maximum length of the string length is 3 bytes, the value is the actual length of the string, the length of the string is the actual length of the string, and the value is a string that does not carry null; When the encoding mode is the sixth string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string is 4 bytes, the value is the actual length of the string, the length of the string is the actual length of the string, and the value is a string without null.

2. The method according to claim 1, characterized in that The determining of the encoding mode according to the attributes and transmission mode of the application data includes: When the field type of the application data is Int8, the encoding mode is Int8 mode; When the field type of the application data is Int16, the transmission mode is the first transmission mode NONE, and the minimum length of the field value is 7 bits, the encoding mode is the 16-bit integer first mode; When the field type of the application data is Int16, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the field value is less than 7 bits, the encoding mode is the 16-bit integer second mode; When the field type of the application data is Int32, the transmission mode is the first transmission mode NONE, and the minimum length of the field value is 21 bits, the encoding mode is the 32-bit integer first mode; When the field type of the application data is Int32, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the field value is less than 21 bits, the encoding mode is the 32-bit integer second mode; When the field type of the application data is Int64, the transmission mode is the first transmission mode NONE, and the minimum length of the field value is 49 bits, the encoding mode is the 64-bit integer first mode; When the field type of the application data is Int64, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the field value is less than 49 bits, the encoding mode is the 64-bit integer second mode; The encoding of the application data according to the encoding mode, the variant data type and the value of the custom encoding value to generate a target message includes: When the encoding mode is Int8 mode, the length of the field type in the target message is 1 byte, the value is 0x07, the length of the field value is 1 byte, and the value is the actual value; When the encoding mode is the 16-bit integer first mode, the value of the field type in the target message is 0x09, the length is 1 byte, the length of the field value is 2 bytes, and the value is the actual value; When the encoding mode is the 16-bit integer second mode, the value of the field type in the target message is 0x49, the length is 1 byte, the length of the field value is 1 byte, and the value is the actual value; When the encoding mode is the 32-bit integer first mode, the value of the field type in the target message is 0x0B, the length is 1 byte, the length of the field value is 4 bytes, and the value is the actual value; When the encoding mode is the 32-bit integer second mode, the value of the field type in the target message is 0x4B, the length is 1 byte, the maximum length of the field value is 3 bytes, and the value is the actual value; When the encoding mode is the 64-bit integer first mode, the value of the field type in the target message is 0x0D, the length is 1 byte, the length of the field value is 8 bytes, and the value is the actual value; When the encoding mode is the 64-bit integer second mode, the value of the field type in the target message is 0x4D, the length is 1 byte, the maximum length of the field value is 7 bytes, and the value is the actual value.

3. The method according to claim 2, characterized in that The determining of the encoding mode according to the attributes and transmission mode of the application data includes: When the field type of the application data is a Boolean type and the transmission mode is the first transmission mode NONE, the encoding mode is a Boolean first mode; When the field type of the application data is a Boolean type and the transmission mode is the fourth transmission mode not NONE, the encoding mode is the Boolean second mode; The encoding of the application data according to the encoding mode, the variant data type and the value of the custom encoding value to generate a target message includes: When the encoding mode is the Boolean first mode, the value of the field type in the target message is 0x11, the length is 1 byte, the length of the field value is 4 bytes, and the value is the actual value; When the encoding mode is the Boolean second mode, the value of the field type in the target message is 0xD1 or 0x51, and the length is 1 byte; wherein 0xD1 and 0x51 are custom encoding values, 0xD1 indicates that the field type is Boolean and the value is true, and 0x51 indicates that the field type is Boolean and the value is false.

4. The method according to claim 1, characterized in that The determining of the encoding mode according to the attributes and transmission mode of the application data includes: When the field type of the application data is an object, and the transmission mode is the first transmission mode NONE or the minimum length of the object is 21, the encoding mode is the object type first mode; When the field type of the application data is object, the transmission mode is the fourth transmission mode not NONE, and the maximum length of the object is less than 21 bits, the encoding mode is the object type second mode; The encoding of the application data according to the encoding mode, the variant data type and the value of the custom encoding value to generate a target message includes: When the encoding mode is the object type first mode, the value of the field type in the target message is 0x16, 0x17 or 0x18, the length is 1 byte, the length of the field length is 4 bytes, the value is the length of the opaque, the value of the field is the actual value, and the length is the actual length of the field; When the encoding mode is the object type second mode, the value of the field type in the target message is 0x56, 0x57 or 0x58, the length is 1 byte, the maximum length of the field length is 3 bytes, the value is the length of the opaque, the value of the field is the actual value, and the length is the actual length of the field; Among them, 0x16 and 0x56 indicate that the field type is opaque, 0x17 and 0x57 indicate that the field type is java obj, and 0x18 and 0x58 indicate that the field type is dotnet obj.

5. The method according to claim 1, characterized in that The determining of the encoding mode according to the attributes and transmission mode of the application data includes: When the field type of the application data is message and the message is empty, the encoding mode is the first message type mode; When the field type of the application data is a message and the message is not empty, the encoding mode is the message type second mode; The encoding of the application data according to the encoding mode, the variant data type and the value of the custom encoding value to generate a target message includes: When the encoding mode is the message type first mode, the value of the field type in the target message is 0x19, the length is 1 byte, the length of the message length is 4 bytes, and the value is 0; When the encoding mode is the message type second mode, the value of the field type in the target message is 0x19, the length is 1 byte, the length of the message length is 4 bytes, the value is the value of the message length, the value of the message content is the serialized message content, and the length is the value of the message length.

6. A method for parsing data in message transmission, characterized in that: Applied to the message receiver, it includes the following steps: Receive the target message sent by the message sender; Parsing the target message; The target message is generated by encoding the application data according to the encoding mode, the variant data type and the value of the custom encoding value; wherein the value of the custom encoding value indicates an empty string and its value or a non-empty value Boolean type and its value; the target message includes a transmission mode; The encoding mode is determined according to the attributes and transmission mode of the application data; The determining of the encoding mode according to the attributes and transmission mode of the application data includes: When the field type of the application data is String and is an empty string, the encoding mode is the first string mode; When the field type of the application data is String and the transmission mode is the first transmission mode NONE, the encoding mode is the second string mode; When the field type of the application data is String, and the transmission mode is the second transmission mode FAST, and the maximum actual length of the string is less than 21 bits, the encoding mode is the third string mode; When the field type of the application data is String, the transmission mode is the second transmission mode FAST, and the minimum actual length of the string is 21 bits, the encoding mode is the fourth string mode; When the field type of the application data is String, and the transmission mode is the third transmission mode MAX, and the maximum actual length of the string is less than 21 bits, the encoding mode is the fifth string mode; When the field type of the application data is String, the transmission mode is the third transmission mode MAX, and the minimum actual length of the string is 21 bits, the encoding mode is the sixth string mode; The encoding of the application data according to the encoding mode, the variant data type and the value of the custom encoding value to generate a target message includes: When the encoding mode is the first string mode, the value of the field type in the target message is 0x83, and the length is 1 byte; wherein 0x83 is a custom encoding value, and 0x8 indicates that the field type is a string, and is an empty string; When the encoding mode is the second string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string length is 4 bytes, the value is the actual length of the string, the length of the string is the actual length of the string plus 1, and the value is a string terminated by null; When the encoding mode is the third string mode, the length of the field type in the target message is 1 byte, the value is 0x43, the maximum length of the string length is 3 bytes, the value is the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value is a string terminated by null; When the encoding mode is the fourth string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string length is 4 bytes, the value is the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value is a string terminated by null; When the encoding mode is the fifth string mode, the length of the field type in the target message is 1 byte, the value is 0x43, the maximum length of the string length is 3 bytes, the value is the actual length of the string, the length of the string is the actual length of the string, and the value is a string that does not carry null; When the encoding mode is the sixth string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string is 4 bytes, the value is the actual length of the string, the length of the string is the actual length of the string, and the value is a string without null.

7. A data encapsulation device in message transmission, characterized in that: Applicable to the message sender, including: A determination module, used to determine the encoding mode according to the attributes and transmission mode of the application data; A generating module, configured to encode the application data according to the encoding mode, the variant data type and the value of the custom encoding value to generate a target message; wherein the value of the custom encoding value indicates an empty string and its value or a non-empty value Boolean type and its value; and the target message includes the transmission mode; A sending module, used for transmitting the target message to a message recipient; The determining of the encoding mode according to the attributes and transmission mode of the application data includes: When the field type of the application data is String and is an empty string, the encoding mode is the first string mode; When the field type of the application data is String and the transmission mode is the first transmission mode NONE, the encoding mode is the second string mode; When the field type of the application data is String, and the transmission mode is the second transmission mode FAST, and the maximum actual length of the string is less than 21 bits, the encoding mode is the third string mode; When the field type of the application data is String, the transmission mode is the second transmission mode FAST, and the minimum actual length of the string is 21 bits, the encoding mode is the fourth string mode; When the field type of the application data is String, and the transmission mode is the third transmission mode MAX, and the maximum actual length of the string is less than 21 bits, the encoding mode is the fifth string mode; When the field type of the application data is String, the transmission mode is the third transmission mode MAX, and the minimum actual length of the string is 21 bits, the encoding mode is the sixth string mode; The encoding of the application data according to the encoding mode, the variant data type and the value of the custom encoding value to generate a target message includes: When the encoding mode is the first string mode, the value of the field type in the target message is 0x83, and the length is 1 byte; wherein 0x83 is a custom encoding value, and 0x8 indicates that the field type is a string, and is an empty string; When the encoding mode is the second string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string length is 4 bytes, the value is the actual length of the string, the length of the string is the actual length of the string plus 1, and the value is a string terminated by null; When the encoding mode is the third string mode, the length of the field type in the target message is 1 byte, the value is 0x43, the maximum length of the string length is 3 bytes, the value is the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value is a string terminated by null; When the encoding mode is the fourth string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string length is 4 bytes, the value is the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value is a string terminated by null; When the encoding mode is the fifth string mode, the length of the field type in the target message is 1 byte, the value is 0x43, the maximum length of the string length is 3 bytes, the value is the actual length of the string, the length of the string is the actual length of the string, and the value is a string that does not carry null; When the encoding mode is the sixth string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string is 4 bytes, the value is the actual length of the string, the length of the string is the actual length of the string, and the value is a string without null.

8. A device for analyzing data in message transmission, characterized in that: Applicable to the message receiver, including: A receiving module, used for receiving a target message sent by a message sender; A parsing module, used for parsing the target message; The target message is generated by encoding the application data according to the encoding mode, the variant data type and the value of the custom encoding value; wherein the value of the custom encoding value indicates an empty string and its value or a non-empty value Boolean type and its value; the target message includes a transmission mode; The encoding mode is determined according to the attributes and transmission mode of the application data; The determining of the encoding mode according to the attributes and transmission mode of the application data includes: When the field type of the application data is String and is an empty string, the encoding mode is the first string mode; When the field type of the application data is String and the transmission mode is the first transmission mode NONE, the encoding mode is the second string mode; When the field type of the application data is String, and the transmission mode is the second transmission mode FAST, and the maximum actual length of the string is less than 21 bits, the encoding mode is the third string mode; When the field type of the application data is String, the transmission mode is the second transmission mode FAST, and the minimum actual length of the string is 21 bits, the encoding mode is the fourth string mode; When the field type of the application data is String, and the transmission mode is the third transmission mode MAX, and the maximum actual length of the string is less than 21 bits, the encoding mode is the fifth string mode; When the field type of the application data is String, the transmission mode is the third transmission mode MAX, and the minimum actual length of the string is 21 bits, the encoding mode is the sixth string mode; The encoding of the application data according to the encoding mode, the variant data type and the value of the custom encoding value to generate a target message includes: When the encoding mode is the first string mode, the value of the field type in the target message is 0x83, and the length is 1 byte; wherein 0x83 is a custom encoding value, and 0x8 indicates that the field type is a string, and is an empty string; When the encoding mode is the second string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string length is 4 bytes, the value is the actual length of the string, the length of the string is the actual length of the string plus 1, and the value is a string terminated by null; When the encoding mode is the third string mode, the length of the field type in the target message is 1 byte, the value is 0x43, the maximum length of the string length is 3 bytes, the value is the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value is a string terminated by null; When the encoding mode is the fourth string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string length is 4 bytes, the value is the actual length of the string plus 1, the length of the string is the actual length of the string plus 1, and the value is a string terminated by null; When the encoding mode is the fifth string mode, the length of the field type in the target message is 1 byte, the value is 0x43, the maximum length of the string length is 3 bytes, the value is the actual length of the string, the length of the string is the actual length of the string, and the value is a string that does not carry null; When the encoding mode is the sixth string mode, the length of the field type in the target message is 1 byte, the value is 0x03, the length of the string is 4 bytes, the value is the actual length of the string, the length of the string is the actual length of the string, and the value is a string without null.

Citation Information

Patent Citations

  • Data communication method and device

    CN103297183A