# An IoT-Based Fog Computing Model
## 5 Terminal Layer Design of Proposed Model  
In this section, the second part of the IoT-FCM model which focuses on the design of the terminal layer is presented. A modification of LIBP [4; 5; 6] is proposed and used as a multi-sink communication protocol. As revealed by [4], LIBP is a frugal routing protocol with good performance in terms of energy consumption. It is based on a beaconing process illustrated by Figure 3 where it can be seen that i) beacon messages are used to build a spanning/collection tree rooted at the sink of the sensor network (node s) and ii) the beaconing process is implemented recursively until a spanning tree is built by broadcasting beacons for children discovery and unicasting beacons to acknowledge and select parents. The principle behind LIBP is to solve a local optimization problem by using a weight associated with a measure of interference (using number of children) in order to get a balanced tree. This is implemented by having each node below the sink node select the parent node with the fewest number of child nodes.  
Though efficient, there is still room for improving the LIBP protocol, such as in areas of energy consumption and robustness of nodes when deployed in a cloud environment. Especially as nodes  
Figure 3: LIBP protocol description.  
need a lot of energy when they communicate with nodes at greater distances. Also if the single sink node fails or is offline, the entire IoT infrastructure stops working. The multi-sink version of the LIBP proposed in this paper attempts to solve these limitations by adding multiple sink nodes to reduce the pressure on the unique sink node. The use of multiple sink nodes extends the sink nodes' battery life and improves the robustness of the entire system. Figures 5 and 6 illustrate respectively a mono-sink sensor network and a multi-sink sensor network derived from the sensor network presented in Figure 4. These figures reveal that (i) besides the failure of the unique sink node (node 1) which can lead to the whole infrastructure stop functioning, the failure of node 2 in the mono-sink sensor network in Figure 5 will lead to partitioning the sensor network into two parts with more than half of its nodes (five nodes) failing to report data to the sink in the multi-sink configuration (ii) the multi-sink sensor networks shown in Figure 6 have a higher potential to prolong the lifetime of the sensor network, by having each non-sink node carry less children. This reduces energy consumption and limits the effect of node failure since only a maximum of 3 nodes will be cut off. For instance, in Figure 6 only three nodes will fail to report their data to node 1 if node 9 fails. Furthermore, if one of the two sink nodes (node 1 for example) fails, is attacked or is offline, the multi-sink version of the LIBP protocol, herein referred to as least interference multi-sink protocol (LIMP) will connect the orphaned nodes to the working sink node (node 8). It thus presents higher availability and robustness to failure since only part of the network may fail when a sink node is attacked or damaged and the multi-sink protocol LIMP can make the child nodes of the failed sink discover and connect to the alternative sink.  
Figure 4: Sensor network illustration.  
Figure 7 presents the detailed structure of the terminal layer on the left sides of Figure 2. The model also follows several rules which are as follows:  
1. There must be at least two nodes with GPRS (General Packet Radio Service). That is the terminal layer should have at least two nodes capable of transmitting IP packets to a fog node.
2. Only nodes with GPRS can become sink nodes. The sink node is selected based on whether the node has the lowest temperature and highest energy.
3. Each node should have a solar panel for energy regeneration.  
Figure 5: Mono sink sensor network.  
Figure 6: MultiSink sensor network illustration.