Dynamic data compression method, system and device in adaptive network broadband environment and storage medium
By monitoring the network bandwidth in real time and adjusting the encoding and decoding strategies dynamically, the inefficiency of traditional data transmission methods in dynamic bandwidth environments is solved, flexible data compression and efficient transmission are achieved, and suitable for a variety of application scenarios.
Patent Information
- Application Number
- CN202411380731.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-01-07
AI Technical Summary
Traditional data transmission methods cannot effectively deal with bandwidth fluctuations in dynamically changing network bandwidth environments, resulting in inefficient transmission efficiency and waste of resources, and cannot adapt to the needs of different application scenarios.
By monitoring the real-time network bandwidth, dynamically adjust the encoding and decoding strategy of data according to the pre-configured broadband threshold. If the bandwidth is greater than the threshold, it is coded by bytes. If the bandwidth is less than the threshold, it is coded by bit, and uses custom data structures and encodings. Decoding operations enable flexible data compression.
It improves the flexibility and efficiency of data transmission, reduces computing overhead in a broadband environment, and maximizes the amount of compressed data in a narrowband environment. It is suitable for a variety of application scenarios such as sensor data and Internet of Things device communication.
Smart Images

Figure CN119276948A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of data compression, and specifically relates to a dynamic data compression method, system, device and storage medium in an adaptive network broadband environment. Background Art
[0002] With the rapid development and popularization of the Internet, the utilization of network bandwidth resources has become increasingly important. Different network bandwidth environments will have a significant impact on the efficiency of data transmission. Traditional data transmission methods usually use fixed compression strategies, but in practical applications, this method cannot adapt to dynamically changing network bandwidth conditions, resulting in low transmission efficiency or waste of resources.
[0003] At present, traditional data transmission methods have many limitations, such as:
[0004] (1) Disadvantages of fixed compression strategies: Traditional data transmission methods usually use fixed compression algorithms, which perform very differently in broadband and narrowband environments. In broadband environments, excessive compression will waste computing resources, while in narrowband environments, insufficient compression will lead to inefficient data transmission.
[0005] (2) Challenges in dynamic network environments: With the popularization of mobile Internet and wireless networks, network bandwidth has become more dynamic and unpredictable. In this case, fixed compression strategies cannot effectively cope with fluctuations in network bandwidth, resulting in instability and inefficiency in data transmission;
[0006] (3) Optimization requirements for resource utilization: In actual applications, user requirements and application scenarios are diverse. For example, sensor data transmission has low bandwidth requirements but is more sensitive to latency, especially in real-time monitoring systems. Financial data updates require high-frequency low-latency transmission to ensure the real-time and accuracy of data. IoT device communication has low bandwidth requirements, but latency and reliability are very critical, especially in automated control systems.
[0007] Therefore, it is particularly important to propose a method that can adaptively adjust the compression strategy according to the real-time network bandwidth. Summary of the invention
[0008] Purpose of the invention: To solve one or more defects existing in the current traditional data transmission methods, the present invention proposes a dynamic data compression method, system, device and storage medium in an adaptive network broadband environment, which optimizes resource utilization and transmission efficiency through a flexible compression method.
[0009] Technical solution: A dynamic data compression method in an adaptive network broadband environment, comprising the following steps:
[0010] When the user triggers the sending operation, the current network bandwidth of the local machine is obtained;
[0011] The current network bandwidth of the local machine is compared with the pre-configured broadband threshold. If the current network bandwidth of the local machine is greater than the pre-configured broadband threshold, the data to be sent will be encoded and decoded byte by byte; if the current network bandwidth of the local machine is not greater than the pre-configured broadband threshold, the data to be sent will be encoded and decoded bit by bit.
[0012] Furthermore, the encoding and decoding of the data to be sent byte by byte includes:
[0013] According to the self-defined byte-by-byte data structure, each member variable in the byte-by-byte data structure is filled according to the data to be sent, so as to obtain the filled byte-by-byte data structure; the byte-by-byte data structure includes: required items, optional items and structure type; each optional item corresponds to a Boolean optional item flag; when the Boolean optional item flag is 1, it indicates that the optional item exists; when the Boolean optional item flag is 0, it indicates that the optional item does not exist;
[0014] According to the Boolean optional flag, encoding operation is performed on the filled byte data structure to obtain encoded data;
[0015] According to the encoding operation, a corresponding decoding operation is performed.
[0016] Furthermore, the encoding operation is performed on the filled byte data structure according to the Boolean optional item flag to obtain the encoded data, and the specific operation includes:
[0017] Define the actual byte number offset for storage and define the intermediate byte buffer;
[0018] According to the principle that the required items are directly stored in the intermediate byte buffer, and the optional items are stored in the intermediate byte buffer as needed according to the Boolean optional item flag, each member variable in the byte data structure is traversed to fill the intermediate byte buffer, and the byte number offset is accumulated and assigned;
[0019] Open a send buffer area and assign values according to the byte number offset;
[0020] Fill in the message header, encoding type and data length to obtain the encoded data.
[0021] The decoding operation corresponding to the encoding operation includes:
[0022] Define the buffer area to store the actual byte data and define the intermediate byte offset;
[0023] According to the analysis of the message header, the encoded data is extracted from the decrypted data and stored in the buffer area;
[0024] Define a byte structure variable to store decoding information;
[0025] The data stored in the cache area is traversed and offset. The required items are directly assigned to the member variables of the corresponding byte data structure. The optional items are assigned to the member variables of the corresponding byte data structure as needed according to the Boolean optional item flag. The data is parsed into the member variables of the byte data structure, and the intermediate byte offset is accumulated and assigned according to the length of the member variables of the corresponding byte data structure until the decoding is completed.
[0026] Furthermore, the encoding and decoding of the data to be sent bit by bit includes:
[0027] According to the self-defined byte-by-byte data structure, each member variable in the byte-by-byte data structure is filled according to the data to be sent, so as to obtain the filled byte-by-byte data structure; the byte-by-byte data structure includes: required items, optional items and structure type; each optional item corresponds to a Boolean optional item flag; when the Boolean optional item flag is 1, it indicates that the optional item exists; when the Boolean optional item flag is 0, it indicates that the optional item does not exist;
[0028] For each byte data structure, define a corresponding member bit allocation structure, which is used to define the number of bits of each member variable;
[0029] Fill each member variable in the byte-by-byte data structure according to the data to be sent, and obtain the filled byte-by-byte data structure;
[0030] Traverse each member variable of the byte data structure, allocate the structure definition according to the required and optional items, calculate the total number of bits of data to be sent, and open a sending buffer for the corresponding bytes;
[0031] Define a bit buffer, traverse each member variable of the byte data structure, allocate the structure definition according to the required and optional items, create a bitset of the corresponding number of bits for each member variable of the byte data structure, and assign the member variable value of the byte data structure to the bitset;
[0032] Define the bit offset, use a loop to assign the bitset bit value to the bit buffer, and accumulate and update the bit offset;
[0033] Assign the bit value of the bit buffer to the send buffer;
[0034] Fill in the message header, encoding type, data length, and end the bit encoding;
[0035] According to the encoding operation, a corresponding decoding operation is performed.
[0036] Furthermore, for each byte data structure, a corresponding member bit allocation structure is defined, and the specific operations include:
[0037] Determine the value range of each member variable, and determine the minimum number of digits required for each member variable based on the value range;
[0038] Create a member bit allocation structure and allocate bits for each member variable.
[0039] The present invention discloses a dynamic data compression system in an adaptive network broadband environment, comprising:
[0040] The network bandwidth acquisition unit is used to acquire the current network bandwidth of the local machine when the user triggers the sending operation;
[0041] The encoding and compression unit is used to compare the current network bandwidth of the local machine with the pre-configured broadband threshold. If the current network bandwidth of the local machine is greater than the pre-configured broadband threshold, the data to be sent will be encoded and decoded byte by byte; if the current network bandwidth of the local machine is not greater than the pre-configured broadband threshold, the data to be sent will be encoded and decoded bit by bit.
[0042] Furthermore, the encoding and decoding of the data to be sent byte by byte includes:
[0043] According to the self-defined byte-by-byte data structure, each member variable in the byte-by-byte data structure is filled according to the data to be sent, so as to obtain the filled byte-by-byte data structure; the byte-by-byte data structure includes: required items, optional items and structure type; each optional item corresponds to a Boolean optional item flag; when the Boolean optional item flag is 1, it indicates that the optional item exists; when the Boolean optional item flag is 0, it indicates that the optional item does not exist;
[0044] According to the Boolean optional flag, encoding operation is performed on the filled byte data structure to obtain encoded data;
[0045] According to the encoding operation, a corresponding decoding operation is performed.
[0046] Furthermore, the encoding and decoding of the data to be sent bit by bit includes:
[0047] According to the self-defined byte-by-byte data structure, each member variable in the byte-by-byte data structure is filled according to the data to be sent, so as to obtain the filled byte-by-byte data structure; the byte-by-byte data structure includes: required items, optional items and structure type; each optional item corresponds to a Boolean optional item flag; when the Boolean optional item flag is 1, it indicates that the optional item exists; when the Boolean optional item flag is 0, it indicates that the optional item does not exist;
[0048] For each byte data structure, define a corresponding member bit allocation structure, which is used to define the number of bits of each member variable;
[0049] Fill each member variable in the byte-by-byte data structure according to the data to be sent, and obtain the filled byte-by-byte data structure;
[0050] Traverse each member variable of the byte data structure, allocate the structure definition according to the required and optional items, calculate the total number of bits of data to be sent, and open a sending buffer for the corresponding bytes;
[0051] Define a bit buffer, traverse each member variable of the byte data structure, allocate the structure definition according to the required and optional items, create a bitset of the corresponding number of bits for each member variable of the byte data structure, and assign the member variable value of the byte data structure to the bitset;
[0052] Define the bit offset, use a loop to assign the bitset bit value to the bit buffer, and accumulate and update the bit offset;
[0053] Assign the bit value of the bit buffer to the send buffer;
[0054] Fill in the message header, encoding type, data length, and end the bit encoding;
[0055] According to the encoding operation, a corresponding decoding operation is performed.
[0056] The present invention also discloses a computer device, including a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above disclosed method for dynamic data compression in an adaptive network broadband environment are implemented.
[0057] The present invention also discloses a storage medium, wherein the storage medium stores a data compression program, and when the data compression program is executed by at least one processor, the steps of the above disclosed dynamic data compression method in an adaptive network broadband environment are implemented.
[0058] Beneficial effects: Compared with the prior art, the present invention has the following advantages:
[0059] (1) The method of the present invention starts the function of monitoring the network bandwidth of the local machine by software when the user sends an operation trigger, and compares the bandwidth with the actual bandwidth according to the bandwidth threshold configured by the user. When the bandwidth is greater than the threshold, in order to improve the local encoding and decoding efficiency, the byte-based encoding and decoding is adopted; when the bandwidth is less than the threshold, in order to improve the data transmission efficiency between the sending end and the receiving end, the bit-based encoding and decoding is adopted, which can significantly improve the flexibility and efficiency of data transmission. In a broadband environment, the byte-based encoding and decoding can reduce the computing overhead and improve the encoding and decoding efficiency; in a narrowband environment, the bit-based encoding and decoding can maximize the compressed data volume and improve the transmission efficiency.
[0060] (2) The method of the present invention is not only applicable to various network bandwidth environments, but also can adapt to a variety of application scenarios, such as sensor data transmission, financial data update, Internet of Things device communication, etc., and has broad application prospects and practical value. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 is a flow chart of the present invention;
[0062] Figure 2 A flowchart of obtaining the network bandwidth of the local device according to the present invention;
[0063] Figure 3 It is a principle diagram of byte-by-byte encoding and decoding of the present invention;
[0064] Figure 4 It is a schematic diagram of the bit-by-bit encoding and decoding of the present invention. DETAILED DESCRIPTION
[0065] The technical solution of the present invention is now further described in conjunction with the accompanying drawings and embodiments.
[0066] Embodiment 1:
[0067] like Figure 1 As shown, this embodiment discloses a dynamic data compression method in an adaptive network broadband environment, which mainly includes the following steps:
[0068] Step 1: When the user sends an operation trigger, start monitoring the local network bandwidth; Figure 2 As shown, in some embodiments, the local network bandwidth monitoring can be performed according to the following sub-steps:
[0069] Load the iphlpapi library; the iphlpapi library contains the required header files, which are used to provide an API for obtaining network interface information;
[0070] Call the API to obtain the network interface table; in some embodiments, the GetIfTable2 function can be used to obtain a table containing all network interfaces;
[0071] Traverse the network interface table to extract the required bandwidth information;
[0072] Processing or storing the extracted bandwidth information;
[0073] After using the network interface table, call the FreeMibTable function to release the allocated memory.
[0074] Combination Figure 2 , the sample code for local network bandwidth monitoring is as follows:
[0075]
[0076]
[0077] Step 2: Compare the actual bandwidth of the local network with the pre-configured broadband threshold. When the actual bandwidth of the local network is greater than the pre-configured broadband threshold, in order to improve the local encoding and decoding efficiency, encoding and decoding are performed on a byte basis; when the actual bandwidth of the local network is not greater than the pre-configured broadband threshold, in order to improve the data transmission efficiency between the sender and the receiver, encoding and decoding are performed on a bit basis. The relationship between encoding and decoding and encryption and decryption is encoding-encryption, decryption-decoding, and the encryption and decryption process is not within the scope of detailed description of this patent.
[0078] like Figure 3 As shown, in this embodiment, encoding and decoding by byte can be achieved by following the steps below:
[0079] Define the byte data structure, including: direct declaration of required elements: all required elements are declared directly in the data structure; declaration of optional elements: optional elements are compressible spaces, used in pairs with the fill-in identifier of Boolean optional elements; data type declaration: use data types reasonably according to actual data element requirements, enumeration types can be represented by char storage, integer variables can select appropriate char array storage according to the data range, and data type declarations are placed in a separate header file for use by the data sender and data receiver.
[0080] The sample code for defining the byte data structure is as follows:
[0081]
[0082]
[0083] like Figure 3 As shown, the following encoding operations are performed at the data sending end:
[0084] Fill each member variable in the byte data structure according to the actual data;
[0085] Define the actual byte number offset for storage and define the intermediate byte buffer;
[0086] According to the principle that required elements are directly stored in the intermediate byte buffer, and optional elements are stored in the intermediate byte buffer as needed according to the optional item flag, each member variable in the byte data structure is traversed to fill the intermediate byte buffer, and the byte number offset is accumulated and assigned;
[0087] Open a send buffer area and assign values according to the byte number offset;
[0088] Fill in the message header, encoding type, data length, etc.;
[0089] End of byte encoding.
[0090] The byte encoding implementation strategy and sample code are as follows:
[0091]
[0092]
[0093]
[0094] The main idea of the above demonstration code is: when encoding the outer data structure, perform moderate compression according to the optional flag, encapsulate each member variable of the outer structure one by one, and decide whether to encapsulate the optional elements according to the optional flag. If the optional elements exist, further encapsulate the data of the inner structure; when encoding the inner data structure, perform moderate compression according to the optional flag, encapsulate each member variable of the inner structure one by one, and decide whether to encapsulate the optional elements according to the optional flag; and repeat this process.
[0095] The inner data structure mentioned in the above demonstration code refers to the data structure corresponding to the optional items, which may be a structure or a basic type such as int, such as struct Example; and the outer data structure refers to a direct byte structure, such as struct TemplateStruct, which is the outermost byte structure with a required flag and an optional flag. In other words, the outer data structure must be a structure, and the inner data structure may be a structure or a basic type such as int. The outer data and inner data refer to the process of defining and assigning corresponding type variables according to the direct byte structure and the optional data structure. When the optional items are structures, usually when coding, if you know which optional structures to fill in, assign the optional content first, and then fill the direct byte structure uniformly. This approach is more intuitive, which is also the purpose of the demonstration code. In actual coding encapsulation, you can also assign values from the direct byte structure member by member, and when the optional flag is 1, fill the data structure corresponding to the optional items.
[0096] like Figure 3 As shown, the decoding operation is performed at the data receiving end:
[0097] Define the buffer area to store the actual byte data and define the intermediate byte offset;
[0098] From the decrypted data, according to the parsing of the message header, the actual encoded byte data is extracted and stored in the buffer area;
[0099] Define a byte structure variable to store decoding information;
[0100] Traverse the byte data in the buffer and get the offset value. According to the principle that the required elements are directly assigned to the corresponding byte structure member variables, the optional elements are assigned to the corresponding byte structure member variables as needed according to the optional flags, parse the data into the byte structure variable, and the intermediate byte number offset is accumulated and assigned according to the length of the corresponding byte structure member;
[0101] Byte decoding is finished.
[0102] The byte-by-byte decoding implementation strategy and sample code are as follows:
[0103]
[0104]
[0105]
[0106] The main idea of the above demonstration code includes: decoding the outer data structure and the inner data structure in turn.
[0107] like Figure 4 As shown, in this embodiment, bit-by-bit encoding and decoding can be achieved through the following steps:
[0108] For each byte data structure, define a corresponding member bit allocation structure, which is used to define the number of bits of each member variable; the specific operations include:
[0109] Analyze the data structure: determine the value range of each member variable, and determine the minimum number of digits required for each member based on the value range;
[0110] Create a bit definition structure: assign bits to each member variable.
[0111] The sample code for member bit allocation structure definition is as follows:
[0112]
[0113]
[0114] Encoding operations are performed at the data sending end, including:
[0115] Fill the byte data structure according to the actual data;
[0116] Traverse each member variable of the byte data structure, allocate the structure according to the required and optional items, and the number of member bits, calculate the total number of bits of actual data, and open a sending buffer for the corresponding bytes;
[0117] Define a bit buffer, traverse each member variable of the byte data structure, allocate the structure according to the required and optional items, create a bitset of the corresponding number of bits for each member variable of the byte data structure, and assign the member variable value of the byte data structure to the bitset;
[0118] Define the bit offset, use a loop to assign the bitset bit value to the bit buffer, and accumulate and update the bit offset;
[0119] Use custom bitset_2_array to assign the bit value of the bit buffer to the send buffer;
[0120] Fill in the message header, encoding type, data length, etc.; end the bit encoding.
[0121] The bit-by-bit encoding implementation strategy and sample code are as follows:
[0122]
[0123]
[0124]
[0125] The main idea of the above code is:
[0126] Define an int variable offset_bit to perform displacement statistics. According to the data of the filled byte data structure, the number of bits of the members in the matching member bit allocation structure is added one by one with the bool optional identifier in the byte data structure. Then use ceil(offset_bit / 8.0) to calculate the required number of bytes and allocate a send buffer.
[0127] Define a bit buffer sendbufbit, define an int variable tmpoffset_bit, fill and shift the bit buffer, and use the basic variables of the bitset class to directly assign values to the bit storage area according to the data of the filled byte data structure, in conjunction with the bool optional identifier in the byte data structure, assign values to the members in the member bit allocation structure that matches the byte structure data, and then use the loop and the tmpoffset_bit shift variable to assign the bit members one by one to the bit buffer sendbufbit;
[0128] Store the data bit by bit in the bit buffer sendbufbit, use the custom bitset_2_array function to convert and copy the value of the bit buffer to the send buffer, and after the send buffer is ready, perform data transmission;
[0129] During the above encoding operation, the custom bitset_2_array function is implemented as follows: initialize the variable, n_bytes is used to record the number of bytes generated, traverse the bit data area bits of the bitset type, traverse every 8 bits, convert it into a byte, initialize a character ch to 0, for each bit, check whether it is 1, use bitwise or assignment to set the corresponding bit to 1, check whether it is 0, use bitwise and combined with bitwise negation assignment to set the corresponding bit to 0, store ch in the buffer, increase the n_bytes count for each 8 bits processed to update the byte count.
[0130] Decoding operation is performed at the data receiving end:
[0131] Define the byte buffer area that stores the actual data;
[0132] From the decrypted data, according to the parsing of the message header, the actual encoded data is extracted and stored in the byte buffer;
[0133] Define the bit buffer and use array_2_bitset to assign the value of the byte buffer to the bit buffer;
[0134] Define a byte structure variable to store decoding information;
[0135] Define the intermediate bit buffer area to store the bit values of the member variables of the member bit allocation structure and define the bit offset;
[0136] Traverse the bit buffer, assign the structure definition according to the number of bit positions of the members, use loops and bit position offsets to assign values to the intermediate bit buffers, and then use bitset_2_array to assign the position of the intermediate bit buffer to the member variables corresponding to the byte data structure, and decode the optional bit area as needed according to the decoded optional flag; clear the intermediate bit buffer, and update the bit position offset cumulatively; repeat this process;
[0137] End of bitwise decoding.
[0138] Combination Figure 4 , the bitwise decoding implementation strategy and demonstration code are as follows:
[0139]
[0140]
[0141]
[0142] The main ideas of the above code include:
[0143] Extract the actual data portion from the received packet and copy the data from the receive buffer to the local byte buffer using memcpy;
[0144] Define a bit buffer recvbufbit, use the custom array_2_bitset function to convert the receive buffer data into a bit array for storage; read the data in the bit buffer and assign values to the byte structure: read the bit value of each member in sequence, and extract the member variables one by one according to the member bit allocation structure definition and assign them to the corresponding members of the byte structure.
[0145] Decode bit by bit and assign values to the byte structure: define an intermediate bit buffer tmpbits to store the bit values of each member in the bit allocation structure; define an int variable tmpoffset_bit to read and shift the data storage bit buffer recvbufbit, allocate the structure definition according to the number of member bits, use the loop and the tmoffset_bit shift variable to read the bit value from the data storage bit buffer and assign it to the intermediate bit buffer tmpbits, and then assign the intermediate bit buffer tmpbits to the corresponding member in the byte data structure through the custom bitset_2_array function. When the member is an optional item flag of the byte data structure, decide whether to decode the optional element according to the optional flag, and then clear the intermediate bit buffer tmpbits to read the next member variable, and repeat this process. In this way, data can be read bit by bit and filled into the data structure defined by bytes.
[0146] In the above steps, the array_2_bitset() function implements: initializing the variable, n_bits is used to record the number of bits of the byte to be converted, traversing the byte data area buf of the char* type by byte, traversing every 8 bits, and setting them bit by bit to the bit data area bits of the bitset type, defining a character ch, initializing it to the value on the corresponding byte, and using the set function of the bitset to use the bitwise AND combined with the shift operation of 1 for each bit, and assigning it to the bit data area bit by bit. Before assigning the bit data area bit by bit, n_offset is assigned to the byte offset * 8 to update the offset of the bit data area.
[0147] In this embodiment, the bitset_2_array and array_2_bitset implementation demonstration codes are as follows:
[0148]
[0149]
[0150] The method of this embodiment can adaptively select a suitable compression strategy according to the real-time network bandwidth situation, thereby improving data transmission efficiency and resource utilization, and specifically includes the following advantages:
[0151] Real-time monitoring of network bandwidth: When the user sends an operation trigger, the software starts monitoring the local network bandwidth function to obtain real-time bandwidth information.
[0152] Dynamically adjust compression strategy: Compare the actual bandwidth with the bandwidth threshold configured by the user. When the actual bandwidth is greater than the threshold, byte-based encoding and decoding is used to improve encoding and decoding efficiency. When the actual bandwidth is less than the threshold, bit-based encoding and decoding is used to improve data transmission efficiency.
[0153] Flexible encoding and decoding methods: It provides two encoding and decoding strategies: byte-based and bit-based, and describes in detail the implementation methods of these two strategies, including data structure definition, encoding and decoding steps.
Claims
1. A dynamic data compression method in an adaptive network broadband environment, characterized in that: The following steps are involved: When the user triggers the sending operation, the current network bandwidth of the local machine is obtained; The current network bandwidth of the local machine is compared with the pre-configured broadband threshold. If the current network bandwidth of the local machine is greater than the pre-configured broadband threshold, the data to be sent will be encoded and decoded byte by byte; if the current network bandwidth of the local machine is not greater than the pre-configured broadband threshold, the data to be sent will be encoded and decoded bit by bit.
2. The method for dynamic data compression in an adaptive network broadband environment according to claim 1, characterized in that: The specific operations of encoding and decoding the data to be sent byte by byte include: According to the self-defined byte-by-byte data structure, each member variable in the byte-by-byte data structure is filled according to the data to be sent, so as to obtain the filled byte-by-byte data structure; the byte-by-byte data structure includes: required items, optional items and structure type; each optional item corresponds to a Boolean optional item flag; when the Boolean optional item flag is 1, it indicates that the optional item exists; when the Boolean optional item flag is 0, it indicates that the optional item does not exist; According to the Boolean optional flag, encoding operation is performed on the filled byte data structure to obtain encoded data; According to the encoding operation, a corresponding decoding operation is performed.
3. The method for dynamic data compression in an adaptive network broadband environment according to claim 2, characterized in that: The encoding operation is performed on the filled byte data structure according to the Boolean optional item flag to obtain the encoded data, and the specific operation includes: Define the actual byte number offset for storage and define the intermediate byte buffer; According to the principle that the required items are directly stored in the intermediate byte buffer, and the optional items are stored in the intermediate byte buffer as needed according to the Boolean optional item flag, each member variable in the byte data structure is traversed to fill the intermediate byte buffer, and the byte number offset is accumulated and assigned; Open a send buffer area and assign values according to the byte number offset; Fill in the message header, encoding type and data length to obtain the encoded data; The decoding operation corresponding to the encoding operation includes: Define the buffer area to store the actual byte data and define the intermediate byte offset; According to the analysis of the message header, the encoded data is extracted from the decrypted data and stored in the buffer area; Define a byte structure variable to store decoding information; The data stored in the cache area is traversed and offset. The required items are directly assigned to the member variables of the corresponding byte data structure. The optional items are assigned to the member variables of the corresponding byte data structure as needed according to the Boolean optional item flag. The data is parsed into the member variables of the byte data structure, and the intermediate byte offset is accumulated and assigned according to the length of the member variables of the corresponding byte data structure until the decoding is completed.
4. The method for dynamic data compression in an adaptive network broadband environment according to claim 1, characterized in that: The specific operations of encoding and decoding the data to be sent bit by bit include: According to the self-defined byte-by-byte data structure, each member variable in the byte-by-byte data structure is filled according to the data to be sent, so as to obtain the filled byte-by-byte data structure; the byte-by-byte data structure includes: required items, optional items and structure type; each optional item corresponds to a Boolean optional item flag; when the Boolean optional item flag is 1, it indicates that the optional item exists; when the Boolean optional item flag is 0, it indicates that the optional item does not exist; For each byte data structure, define a corresponding member bit allocation structure, which is used to define the number of bits of each member variable; Fill each member variable in the byte-by-byte data structure according to the data to be sent, and obtain the filled byte-by-byte data structure; Traverse each member variable of the byte data structure, allocate the structure definition according to the required and optional items, calculate the total number of bits of data to be sent, and open a sending buffer for the corresponding bytes; Define a bit buffer, traverse each member variable of the byte data structure, allocate the structure definition according to the required and optional items, create a bitset of the corresponding number of bits for each member variable of the byte data structure, and assign the member variable value of the byte data structure to the bitset; Define the bit offset, use a loop to assign the bitset bit value to the bit buffer, and accumulate and update the bit offset; Assign the bit value of the bit buffer to the send buffer; Fill in the message header, encoding type, data length, and end the bit encoding; According to the encoding operation, a corresponding decoding operation is performed.
5. The method for dynamic data compression in an adaptive network broadband environment according to claim 4, characterized in that: For each byte data structure, a corresponding member bit allocation structure is defined, and the specific operations include: Determine the value range of each member variable, and determine the minimum number of digits required for each member variable based on the value range; Create a member bit allocation structure and allocate bits for each member variable.
6. A dynamic data compression system in an adaptive network broadband environment, characterized in that: include: The network bandwidth acquisition unit is used to acquire the current network bandwidth of the local machine when the user triggers the sending operation; The encoding and compression unit is used to compare the current network bandwidth of the local machine with the pre-configured broadband threshold. If the current network bandwidth of the local machine is greater than the pre-configured broadband threshold, the data to be sent will be encoded and decoded byte by byte; if the current network bandwidth of the local machine is not greater than the pre-configured broadband threshold, the data to be sent will be encoded and decoded bit by bit.
7. The dynamic data compression system in an adaptive network broadband environment according to claim 6, characterized in that: The specific operations of encoding and decoding the data to be sent byte by byte include: According to the self-defined byte-by-byte data structure, each member variable in the byte-by-byte data structure is filled according to the data to be sent, so as to obtain the filled byte-by-byte data structure; the byte-by-byte data structure includes: required items, optional items and structure type; each optional item corresponds to a Boolean optional item flag; when the Boolean optional item flag is 1, it indicates that the optional item exists; when the Boolean optional item flag is 0, it indicates that the optional item does not exist; According to the Boolean optional flag, encoding operation is performed on the filled byte data structure to obtain encoded data; According to the encoding operation, a corresponding decoding operation is performed.
8. The dynamic data compression system in an adaptive network broadband environment according to claim 6, characterized in that: The specific operations of encoding and decoding the data to be sent bit by bit include: According to the self-defined byte-by-byte data structure, each member variable in the byte-by-byte data structure is filled according to the data to be sent, so as to obtain the filled byte-by-byte data structure; the byte-by-byte data structure includes: required items, optional items and structure type; each optional item corresponds to a Boolean optional item flag; when the Boolean optional item flag is 1, it indicates that the optional item exists; when the Boolean optional item flag is 0, it indicates that the optional item does not exist; For each byte data structure, define a corresponding member bit allocation structure, which is used to define the number of bits of each member variable; Fill each member variable in the byte-by-byte data structure according to the data to be sent, and obtain the filled byte-by-byte data structure; Traverse each member variable of the byte data structure, allocate the structure definition according to the required and optional items, calculate the total number of bits of data to be sent, and open a sending buffer for the corresponding bytes; Define a bit buffer, traverse each member variable of the byte data structure, allocate the structure definition according to the required and optional items, create a bitset of the corresponding number of bits for each member variable of the byte data structure, and assign the member variable value of the byte data structure to the bitset; Define the bit offset, use a loop to assign the bitset bit value to the bit buffer, and accumulate and update the bit offset; Assign the bit value of the bit buffer to the send buffer; Fill in the message header, encoding type, data length, and end the bit encoding; According to the encoding operation, a corresponding decoding operation is performed.
9. A computer device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of a dynamic data compression method in an adaptive network broadband environment as described in any one of claims 1 to 5 when executing the computer program.
10. A storage medium, characterized in that: The storage medium stores a data compression program, and when the data compression program is executed by at least one processor, the steps of a dynamic data compression method in an adaptive network broadband environment as described in any one of claims 1 to 5 are implemented.