# On Applicability of Network Coding Technique for 6 LoWPAN-based Sensor Networks
## 3 Network Coding for 6 LoWPAN-Based Wireless Sensor Networks
### Network Coding for 6 LoWPAN (NC6 LoWPAN) WSNs
Thus, the main function of the NC layer in the NC6 LoWPAN is to buffer the native unicast packets belonging to different sessions, check the coding opportunity, prepare encoded broadcast packets using bitwise XOR operation (according to Equation (7)), and perform decoding. The location of the NC layer that is shown in Figure 2 provides implementation simplicity, which is required in resource-limited sensor nodes. Furthermore, the NC layer allows for coding and decoding of the 6 LoWPAN datagrams rather than the IPv6 packets. The encoding is performed in the intermediate nodes using native unicast packets, which belong to different sessions. As has already been mentioned, to increase network coding opportunity during normal WSN operation (at low traffic volume), these packets have to be buffered in the intermediate nodes. The size of buffers is limited by the node's memory that has been allocated to the NC operations. The encoded packet can be formed if at least two native packets transferred to different next hop nodes are buffered. Figure 3 shows six IPv6 unicast streams (\(s_{1}\)...\(s_{6}\)). Only some packets crossing nodes 2 and 4 can be encoded. For example, packets from the stream \(s_{1}\) and \(s_{2}\) can be encoded only if they meet in node 2. Broadcast encoded stream (MAC layer broadcast) is depicted as \(c_{1}\). Similarly, packets from the streams \(s_{3}\) and \(s_{4}\) can be encoded in node 2, while packets from the streams \(s_{5}\) and \(s_{6}\) can be encoded in node 4. The proposed network coding mechanism decreases the overall traffic in a sensor network (particularly in synchronised network). However, it should be noticed that native packets that are buffered in the intermediate nodes increase the overall end-to-end packets delay. The NC techniques often detect poor links (for example, based on the expected transmission count metric) to limit  
Figure 3: Network coding opportunity in intermediate nodes. Figure 2: Location of the Network Coding (NC) layer. coding operation and then to decrease the number of decoding errors [13]. At this stage, to keep the NC6 LoWPAN simplicity, it was assumed that sensors do not detect poor links. Potential errors during transmission of encoded packets affect decoding errors. Many solutions for the IEEE 802.11-based networks provide some kind of error correction mechanisms allowing for acknowledging the correctly received encoded packets (ACKs and pseudo-broadcast transmission in [13]). Similar mechanisms can also be used in WSNs, but they introduce additional signalling traffic, especially unwanted in a sensor network. It was assumed that the higher packet loss ratio resulting from decoding errors could be accepted from many WSN services point of view if the network lifetime will be extended. Nevertheless, to limit such effect, the next version of the NC6 LoWPAN will be equipped with a relatively simple solution allowing for links quality detection. Additionally, to avoid instability in network operation that is caused by potential decoding errors, the signalling packets are not buffered and encoded (e.g., multicast Neighbour Discovery or RPL packets). The NC buffering time directly influences the coding efficiency and the network operation, which is discussed in Section 4. The encoding procedure at the NC layer is described in Algorithm 1. Native 6 LoWPAN packets, as received from the upper layer (named _CurrentNativePackets_), are checked according to message type (unicast or multicast, user data or signalling messages) in Steps 2-14. The current native packets that are excluded from further coding process are sent directly to the MAC layer (Step 8, 13), and then to the next hop node. Remaining current native packets can potentially be encoded depending on the node's role recognised in Steps 15-20. In the source nodes (_CurrentNodeRole_ = _SourceNode_), the current native packets are sent to the MAC layer (Step 24) without encoding (decoding is not possible) if they are sent directly to the neighbouring sink node (checked in Step 23).