Lossless compression algorithm for data of Internet of Things
By designing a combination of file control blocks, data bitmap blocks and compressed data blocks in IoT data, the problem of low efficiency in lossless compression of IoT data is solved, efficient data compression and decompression is achieved, storage costs are reduced and storage is improved. transmission efficiency.
Patent Information
- Application Number
- CN202410833081.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-10-01
AI Technical Summary
While maintaining data integrity and accuracy, existing IoT data lossless compression technology has a low compression ratio and low efficiency, and cannot effectively meet the storage and transmission needs of IoT data.
A lossless compression algorithm for Internet of Things data is designed, which realizes lossless compression and decompression of data through the combination of file control blocks, data bitmap blocks and compressed data blocks, including initialization, data change detection, checksum, output compressed data and Error recovery ensures data integrity and accuracy.
It achieves efficient data compression (about 5 times), maintains data integrity and accuracy, reduces storage costs, and improves transmission efficiency and data processing performance.
Smart Images

Figure CN118733545A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Internet of Things data, and in particular to a lossless compression algorithm for Internet of Things data. Background Art
[0002] At present, the compression technology of IoT real-time database can be mainly divided into lossy compression and lossless compression. Lossy compression is an irreversible compression. Its principle is to selectively retain some data and discard some data through certain data screening rules, and ensure that the restoration accuracy of the decompression algorithm is within the allowable range of system accuracy error. Lossless compression is also called redundancy compression. It is a reversible compression. Its essence is to reduce the redundant components in the source data, but it cannot discard the valid information in the source data, so as to ensure that the source data before compression and the data after decompression and restoration are completely consistent.
[0003] The IoT data lossless compression algorithm is designed for the storage and transmission needs of large amounts of data in the IoT. Due to the unique properties of IoT data, including fixed-length data frames, data packets with timestamps, fixed collection intervals, and small changes between data frames, conventional lossless compression, when not taking into account the characteristics of IoT data, generally will not have a very high compression ratio while maintaining data integrity and accuracy, and the data compression efficiency is not high. Summary of the invention
[0004] The purpose of the present invention is to solve the technical problems existing in the prior art and provide a lossless compression algorithm for Internet of Things data.
[0005] To achieve the above object, the technical solution provided by the present invention is: a lossless compression algorithm for IoT data, the algorithm includes a file control block FCB, lossless compression, decompression algorithm design and matters needing attention; the decompression algorithm design includes a data bitmap block BITMAP, a compressed data block DATA;
[0006] The specific steps of lossless compression are as follows:
[0007] Initialization: Read the first frame of data, save it completely as the reference frame, and set the corresponding data bitmap change description byte to all 1s, which means that all bytes have changed;
[0008] Data change detection: For subsequent data frames, the difference with the reference frame is compared byte by byte; if the bytes are the same, the corresponding position in the data change description byte of the data bitmap block is marked as 0; if the bytes are different, they are marked as 1 and the byte is included in the data bitmap block; at the same time, the reference frame is changed to the latest data and used as the reference frame for comparison of the next frame of data.
[0009] Checksum: A checksum is added at the end of the data frame of the compressed data block to detect whether the data is damaged during transmission or storage; at the same time, the corresponding data bitmap of the checksum is marked as 1.
[0010] Output compressed data: Output the file control block, data bitmap block and compressed data block into a compressed file in a certain format;
[0011] Error recovery: Design a certain error recovery mechanism. When it is detected that the checksum at the end of the compressed data frame is inconsistent, the previous correct data frame is automatically used as a reference to recover the damaged data frame.
[0012] Preferably, the file control block FCB includes the following information:
[0013] Compression algorithm version: used to identify the format and version of compressed data to ensure correct parsing during decompression;
[0014] Start time: the time point when data collection starts;
[0015] Data frame collection interval: a fixed time interval used to identify the time difference between adjacent data frames;
[0016] Data bit size: the number of bytes used for each collected data record;
[0017] Data frame length: fixed length of each data frame;
[0018] Total number of data frames: records the number of data frames in the entire compressed data block, which helps determine when the decompression ends.
[0019] Preferably, the data compressed by the algorithm is composed of a data change description byte of a data bitmap block BITMAP and a data frame of a compressed data block DATA;
[0020] Data bitmap block BITMAP: used to describe the changes between the current data frame and the previous frame. A bitmap is used to represent the changes between data frames. Each bit corresponds to whether the corresponding byte has changed.
[0021] Compressed data block DATA: The actual data content, which only contains the changed bytes and the checksum of each frame.
[0022] Preferably, the decompression algorithm design also includes reading the file control block, restoring the data frame, and outputting the decompressed data;
[0023] Read file control block: parse the start time, acquisition data frame interval time and data frame length from the compressed file;
[0024] Restore data frame: read the data change description byte of the data bitmap block BITMAP and the data frame of the compressed data block DATA, and restore the complete data frame according to the data change description byte of the data bitmap block BITMAP. For the position with 0 in the description byte, use the byte of the corresponding position of the previous frame to fill it; for the position with 1, use the corresponding byte in the data frame; repeat this process until all data frames are restored;
[0025] Output decompressed data: Output the decompressed data in the order and time interval of the original data frames.
[0026] Preferably, considerations include error handling, performance optimization, and compatibility considerations;
[0027] Error handling: Error detection and correction mechanisms should be added during the design of lossless compression and decompression algorithms to deal with situations where data is corrupted or formatted incorrectly;
[0028] Performance optimization: further optimize compression and decompression performance by using more efficient algorithms and data structures;
[0029] Compatibility considerations: Ensure the algorithm’s compatibility with existing IoT systems and standards for smooth integration in practical applications.
[0030] Beneficial effects of the present invention:
[0031] The compression algorithm provided by the present invention can achieve efficient data compression (about 5 times) while maintaining the integrity and accuracy of the data, which is of great significance for the storage, transmission and processing of IoT data, and helps to reduce storage costs, improve transmission efficiency and optimize data processing performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The drawings described herein are used to provide further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0033] Figure 1 The figure is a flow chart of the principle of the present invention. DETAILED DESCRIPTION
[0034] This section will describe in detail the specific embodiments of the present invention. The preferred embodiments of the present invention are shown in the accompanying drawings. The purpose of the accompanying drawings is to supplement the description of the text part of the specification with graphics, so that people can intuitively and vividly understand each technical feature and the overall technical solution of the present invention, but it cannot be understood as a limitation on the scope of protection of the present invention.
[0035] The preferred embodiment of the present invention is a lossless compression algorithm for IoT data, the algorithm includes a file control block FCB, lossless compression, decompression algorithm design and matters needing attention, the decompression algorithm design includes a data bitmap block BITMAP, and a compressed data block DATA;
[0036] 1. File Control Block FCB
[0037] The file control block contains the following information:
[0038] Compression algorithm version: used to identify the format and version of compressed data to ensure correct parsing during decompression.
[0039] Start time: The time point when data collection starts.
[0040] Data frame collection interval: a fixed time interval used to identify the time difference between adjacent data frames.
[0041] Data bit size: the number of bytes used for each collected data record;
[0042] Data frame length: The fixed length of each data frame.
[0043] Total number of data frames: records the number of data frames in the entire data set, which helps determine when to end the decompression.
[0044] 2. Data bitmap block BITMAP: used to describe the changes between the current data frame and the previous frame. A bitmap is used to represent the changes between data frames, and each bit corresponds to whether a byte has changed.
[0045] 3. Compressed data block DATA: actual data content, only contains changed bytes.
[0046] 4. Lossless compression steps:
[0047] Initialization: Read the first frame of data, save it completely as the reference frame, and set the data change description bytes to all 1 (indicating that all bytes have changed).
[0048] Data change detection: For subsequent data frames, the difference with the previous frame is compared byte by byte. If the bytes are the same, the corresponding position in the data change description byte of the data bitmap block is marked as 0. If the bytes are different, they are marked as 1 and included in the data frame of the compressed data block.
[0049] Output compressed data: Output the file control block and data block (including data change description bytes and acquisition data frames) into a compressed file in a certain format.
[0050] Checksum: A checksum is added at the end of the compressed data frame to detect whether the data is damaged during transmission or storage.
[0051] Error recovery: Design certain error recovery mechanisms, such as using the previous correct data frame as a reference to recover damaged data frames.
[0052] 6. Decompression algorithm design
[0053] The decompression algorithm design also includes reading the file control block, restoring the data frame, and outputting the decompressed data;
[0054] Read the file control block: parse the start time, acquisition data frame interval time and data frame length from the compressed file.
[0055] Restore the data frame:
[0056] Read the data change description byte and the acquisition data frame. Restore the complete data frame based on the data change description byte. For the position of 0 in the description byte, use the byte of the corresponding position in the previous frame to fill; for the position of 1, use the corresponding byte in the acquisition data frame. Repeat this process until all data frames are restored.
[0057] Output decompressed data:
[0058] Output the decompressed data according to the order and time interval of the original data frames.
[0059] 7. Notes
[0060] Error handling: During compression and decompression, error detection and correction mechanisms should be added to deal with situations where data is corrupted or formatted incorrectly.
[0061] The above description is only a preferred implementation mode of the present invention. Any technical solution that achieves the purpose of the present invention by substantially the same means belongs to the protection scope of the present invention.
[0062] Performance optimization: Compression and decompression performance can be further optimized by using more efficient algorithms and data structures.
[0063] Compatibility considerations: Ensure the algorithm’s compatibility with existing IoT systems and standards for smooth integration in practical applications.
[0064] Example 1
[0065] Construct an actual data collection case of the Internet of Things. Assume that the Internet of Things system collects 255 data per second, and the data table is collected continuously for 1 minute for a total of 60 times to form a collection raw data table. Each data is 1 byte, so the size of the raw data table is 255*60=15300 bytes. Construct a raw data table as shown in the following table, where a(i,j) represents one byte of collected data.
[0066]
[0067] Since most IoT data changes slowly or even does not change, most of the data collected every second may remain basically unchanged. Assume that only the first column changes every second, while the other columns remain unchanged. According to this compression algorithm, a bitmap block as shown in the following table can be constructed, with one bit corresponding to one BYTE byte in the above table, plus the reserved checksum corresponding bit, its size is 256 / 8*60=1920 bytes, of which the last bit is reserved for the checksum bit of each frame of data.
[0068]
[0069] Since the first frame of data is the first data, as the reference frame, the first row of the bitmap block is 1, and the first column of each frame of data changes, so the first column of the bitmap block is 1, and other data does not change, and is marked as 0 in the bitmap block. The checksum bit changes with each frame of data, and the last column is 1, as shown in the following table:
[0070]
[0071] As shown in the following table, in the compressed data block, the first row of data a(1,1), a(2,1) ... a(256,1) is first recorded as the reference frame data, with a subtotal of 256 bytes. Then only the first column of changed data, a(1,2), a(1,3) ... a(1,60) is recorded, with a subtotal of 59 bytes. Add 59 checksum data, and the two data blocks have a total of 374 bytes.
[0072] a(1,1) a(2,1) a(3,1) ...... a(256,1) a(1,2) a(256,2) a(1,3) a(256,3) ......a(256,60)
[0073] Therefore, the total number of bytes after compression = 1920 + 374 = 2294 bytes, excluding the file control block, and the compression ratio is 15300 / 2294 = 6.67 times.
[0074] If the original data uses more recording byte lengths, generally each original data is double-byte and four-byte, the recording time is longer and the data changes are smaller, the compression ratio will be correspondingly higher.
[0075] Reference Figure 1 , the working principle of the algorithm of the present invention is:
[0076] First, read the original data table collected by the Internet of Things, analyze the original data table, determine the software compression version, the start time of the record, the data collection interval, the data bit size, the data frame length, the total number of data frames, and construct the file control block FCB. Then, according to the data frame length and the total number of data frames, construct the data bitmap block BITMAP, write the first data frame into the compressed data block, and mark the corresponding bitmap as 1, and then start from the second frame to compare the records one by one. If the corresponding bit is the same as the previous data frame, the corresponding bit in the data bitmap is marked as 0. If there is a change, the corresponding bit is represented as 1, and the compressed data block adds the changed data. Compare in sequence until the original data comparison is completed. In addition, add a checksum record of this data frame at the end of each data frame. At the same time, the checksum change is also counted in the data bitmap block; finally, write the file control block, data bitmap block, and compressed data block into a file to generate a data compression file.
[0077] In summary, the compression algorithm provided by the present invention can achieve efficient data compression (about 5 times) while maintaining the integrity and accuracy of the data, which is of great significance for the storage, transmission and processing of IoT data, and helps to reduce storage costs, improve transmission efficiency and optimize data processing performance.
[0078] The above are preferred implementation modes of the present invention. Any technical solution that achieves the purpose of the present invention by substantially the same means shall fall within the protection scope of the present invention.
Claims
1. A lossless compression algorithm for IoT data, characterized by: The algorithm includes file control block FCB, lossless compression, decompression algorithm design and precautions; the decompression algorithm design includes data bitmap block BITMAP and compressed data block DATA; The specific steps of lossless compression are as follows: Initialization: Read the first frame of data, save it completely as the reference frame, and set the corresponding data bitmap change description byte to all 1s, which means that all bytes have changed; Data change detection: For subsequent data frames, compare the difference with the reference frame byte by byte; if the bytes are the same, the corresponding position in the data change description byte of the data bitmap block is marked as 0; if the bytes are different, they are marked as 1 and the byte is included in the data bitmap block; at the same time, the reference frame is changed to the latest data and used as the reference frame for the next frame data comparison; Checksum: Add a checksum at the end of the data frame of the compressed data block to detect whether the data is damaged during transmission or storage; at the same time, mark the corresponding data bitmap of the checksum as 1; Output compressed data: Output the file control block, data bitmap block and compressed data block into a compressed file in a certain format; Error recovery: Design a certain error recovery mechanism. When it is detected that the checksum at the end of the compressed data frame is inconsistent, the previous correct data frame is automatically used as a reference to recover the damaged data frame.
2. The IoT data lossless compression algorithm according to claim 1, characterized in that: The file control block FCB includes the following information: Compression algorithm version: used to identify the format and version of compressed data to ensure correct parsing during decompression; Start time: the time point when data collection starts; Data frame collection interval: a fixed time interval used to identify the time difference between adjacent data frames; Data bit size: the number of bytes used for each collected data record; Data frame length: fixed length of each data frame; Total number of data frames: records the number of data frames in the entire compressed data block, which helps determine when the decompression ends.
3. The IoT data lossless compression algorithm according to claim 1, characterized in that: The data compressed by this algorithm consists of the data change description bytes of the data bitmap block BITMAP and the data frame of the compressed data block DATA; Data bitmap block BITMAP: used to describe the changes between the current data frame and the previous frame. A bitmap is used to represent the changes between data frames. Each bit corresponds to whether the corresponding byte has changed. Compressed data block DATA: The actual data content, which only contains the changed bytes and the checksum of each frame.
4. The IoT data lossless compression algorithm according to claim 1, characterized in that: The decompression algorithm design also includes reading the file control block, restoring the data frame, and outputting the decompressed data; Read file control block: parse the start time, acquisition data frame interval time and data frame length from the compressed file; Restore data frame: read the data change description byte of the data bitmap block BITMAP and the data frame of the compressed data block DATA, and restore the complete data frame according to the data change description byte of the data bitmap block BITMAP. For the position with 0 in the description byte, use the byte of the corresponding position of the previous frame to fill it; for the position with 1, use the corresponding byte in the data frame; Repeat this process until all data frames are recovered; Output decompressed data: Output the decompressed data in the order and time interval of the original data frames.
5. The IoT data lossless compression algorithm according to claim 1, characterized in that: Considerations include error handling, performance optimization, and compatibility considerations; Error handling: Error detection and correction mechanisms should be added to the design of lossless compression and decompression algorithms to deal with data corruption or format errors; Performance optimization: further optimize compression and decompression performance by using more efficient algorithms and data structures; Compatibility considerations: Ensure the algorithm’s compatibility with existing IoT systems and standards for smooth integration in practical applications.
