# Evaluation of 6 LoWPAN Generic Header Compression in the Context of a RPL Network
## 5 Methodology and Measurements  
Our implementation of 6 LoWPAN-GHC was added to the smoltcp [6] library (the implementation is not merged into upstream smoltcp but can be found here: [[https://gitlab.com/etrovub/smartnets/smoltcp-rpl-ghc](https://gitlab.com/etrovub/smartnets/smoltcp-rpl-ghc)]([https://gitlab.com/etrovub/smartnets/smoltcp-rpl-ghc](https://gitlab.com/etrovub/smartnets/smoltcp-rpl-ghc)), (accessed on 21 August 2023)). This library is written in the Rust programming language [21]. Rust is a compiled programming language that can be used for embedded devices. It has the advantage of being a memory-safe programming language, as opposed to C. At the same time, Rust can maintain the same performance as C. The smoltcp library already contains common Internet protocols, such as UDP, TCP and ICMPv6. It also contains an implementation of 6 LoWPAN-IPHC, 6 LoWPAN-NHC and the fragmentation mechanism from RFC 4944 [2]. To evaluate our implementation, we simulate a network of nodes running the RPL. RPL control packets contain fields that are unused and set to zero and fields that contain IPv6 addresses. Thus, using 6 LoWPAN-GHC can be beneficial because the IPv6 addresses might be found or partially matched in the dictionary, and consecutive zeros are replaced with the zero instruction. For example, in a DAO packet, two of the fields, Reserved and Flags, are set to zero and the DODAGID field is an IPv6 address. In addition to the simulation study, we run our implementation on real nodes, using nRF52840 devices [22]. These devices are based on the 32-bit ARM Cortex-M4 architecture, running at a clock frequency of 64 MHz. They have 1 MB of flash memory and 256 KB of Random Access Memory (RAM) and house a 2.4 GHz transceiver, with IEEE 802.15.4 protocol support. This is a typical current generation device used in 6 LoWPANs, concerning its clock speed, power draw and system-on-chip design. To run smoltcp on them, the Embassy [23] framework is used. Embassy provides Hardware Abstraction Layers (HALs) for various embedded devices and uses smoltcp as its networking stack. To assess the efficiency of 6 LoWPAN-GHC, we consider three different performance parameters. The first parameter is the compression ratio, which measures the ratio of the original packet size to the compressed one (Equation (1)). A higher compression ratio indicates a more efficient compression. \[\text{compression ratio}=\frac{\text{uncompressed packet size}}{\text{ compressed packet size}} \tag{1}\]  
Figure 3: An example of how an ICMPv6 RPL DAO packet is compressed using Generic Header Compression (6 LoWPAN-GHC). The second parameter is the energy consumption. An outgoing packet travels through the network stack, where it is built and compressed. We denote the energy for building the IPv6 packet as \(E_{b}\) and the energy for compressing the packet as \(E_{c}\). After building and compressing the packet, it is processed and transmitted by the radio unit. The transmission energy is denoted as \(E_{tx}\). The power consumption of an active microcontroller is denoted by \(P_{mcu}\), and the transmission power consumption is denoted by \(P_{tx}\). They are hardware-dependent and can be found in the datasheet of devices. The total energy (\(E\)) required for processing and transmitting a packet can be defined as follows:  
\[E =E_{b}+E_{c}+E_{tx}\] \[=P_{mcu}\cdot(t_{b}+t_{c})+P_{tx}\cdot t_{tx} \tag{2}\]  
For compression without 6 LoWPAN-GHC, \(t_{c}\) contains the 6 LoWPAN-IPHC compression time and the 6 LoWPAN-NHC compression time. We denote the non-6 LoWPAN-GHC compression time by \(t_{c,nhc}\). When using 6 LoWPAN-GHC, \(t_{c}\) contains the 6 LoWPAN-IPHC compression time and the 6 LoWPAN-GHC compression time. This is denoted by \(t_{c,ghc}\). The transmission energy depends on the compression mechanism used since it modifies the number of bytes that are transmitted. We denote the transmission energy for a 6 LoWPAN-GHC compressed packet by \(E_{tx,ghc}\) and the transmission energy for a non-6 LoWPAN-GHC compressed packet by \(E_{tx,nhc}\).