# Research on Secure Debugging Interaction of Sensor Nodes Based on Visible Light Communication
## 4 System Downlink: Transmission Efficiency Improvement
### Source Coding: The Binary Instruction Compression  
Since the number of transmitted binary codes is large, the transmitting procedure is overlong for debugging interaction due to the low resolution of the low-cost light sensor. Thus, it is necessary to minimize the size of codes by compressing them. The traditional Huffman compression has a high compression ratio, but an extra dictionary must be locally stored in the sensor node and occupies a precious memory resource. The ZIP compression is also not suitable for low-cost sensor nodes due to the large computation overhead. Therefore, we attempt to analyze the characters of binary codes and propose a targeted compression method that removes the redundant data existing in each binary instruction. In our method, without any dictionary, our method complete codes compression in sensor node at low computation overhead.  
Actually, in most debugging sensor node cases, transmitting the entire program image is unnecessary. In our debugging interaction, we repair the local program by updating each function [31]. One function consists of several instructions which finally compress into compressed binary codes. The specific instruction is relative to MCU type. Take MSP430 as an example. It is equipped in TelosB node and uses a 16-bit instruction set that contains 12 double-operand instructions, seven single-operand instructions, and eight jump instructions.  
One instruction can be divided into opcode and operand. The opcode is used to differentiate instruction and difficult to be compressed. In contrast, the operands existing many continuous repetitive bit sequences. Thus, we apply a bitmask to compress operand bit sequences. The operand bit sequences of each instruction is usually a register address or a memory address. And an all-zero sequence and these operand sequences might differ in just a small number of bits. We can use a bitmask to find these different data. There are two additional fields, called mask location and changed segment, which indicate the position of the mask and the different data compared to the all-zero sequence. They can be calculated by doing an OR operation between the all-zero sequence and every operand sequence. Moreover, the mask location is further grouped to facilitate the representation. The pattern and the group number represent the mask locations where changed segments will replace the data. The operand sequence encoding format as it shows in Figure 2. The sort flag must be \"\(11\)\" to indicate that this is an operand sequence. Next, we will introduce the schemes adopted by each pattern shown in Table 1.  
In pattern 1, it means the original data is not compressible and will be transmitted directly. Both pattern 2 and pattern 3 divide 16 bits of data into four groups. Each group has 4 bits in pattern 2 and pattern 3. Pattern 4 divides 16 bits of data into two groups; each group has eight bits. Additionally, when the group number in pattern 4 is \"\(10\)\", it indicates all-zero data. The diagram of pattern 2 to pattern 4 is shown in Figure 3. Actually, our compression method for binary instruction mainly involves search operation for repetitive parts and replacement operation for bit-level compression and, thus, the complexity of the compression algorithm is O(N). We also test the compression time to prove the efficiency of this compression algorithm in Section 6.1.