# A Cooja-Based Tool for Coverage and Lifetime Evaluation in an In-Building Sensor Network+
## 3 WSN-Maintain  
Cooja [1] is a very popular network simulator within the WSN research community, but it does not model sensor coverage, focusing instead on network connectivity and protocol performance. However, in practice, it is the ability of a sensor network to provide a satisfactory level of coverage that defines its ultimate utility for end-users. WSN-Maintain is designed to allow users to evaluate different techniques to turn on redundant nodes to maintain coverage requirements. This tool is run in parallel with Cooja. The relationship between WSN-Maintain and Cooja is depicted in Figure 1.  
**Draw building floor plan and deploy sensor nodes**: With WSN-Maintain, users can import the floor plan of a building from an XML file or manually draw one by clicking and dragging walls and doors on its canvas. While we use walls and doors as indoor obstacles that can limit communication and sensing capabilities, for simplicity, we currently do not consider the types of construction materials used. In addition to the floor plan, users can click on the canvas to place sensor nodes, click on a room to automatically deploy all nodes for 100% coverage or load their locations from a file. To automatically deploy sensor nodes in a room, the boundary of the room must be identified. To identify the boundary, we create and scan rectangular grids, starting from the location on the canvas that is clicked by a user. The rectangular grids augment until they hit the obstacles. After the room is identified, sensor nodes are added one by one until the room is 100% covered. The first sensor node is deployed at the user's clicked location, and the rest are greedily added to maximise the coverage of the room. **Create network connectivity**: To calculate network connectivity, WSN-Maintain currently supports two types of radio mediums, _i.e._, the unit disk graph model (UDGM) and directed graph radio medium (DGRM). With UDGM, the topology file contains node locations, transmission range, interference range, transmission success ratio and receive success ratio. As we follow the specified format of files from Cooja, we can only create a network with homogeneous communication capabilities using UDGM. That is, all sensor nodes have the same range and receive success ratio. To create a heterogeneous network, users may opt for DGRM. With DGRM, WSN-Maintain can either automatically calculate received signal strength and receive success ratio for every pair of sensor nodes using the formula specified in [9,10] or take real link quality traces as a topology file. The received signal strength (RSS) at a distance \(d\) (\(P_{r}(d)\)) is:  
\[P_{r}(d)=P_{t}-PL(d) \tag{1}\]  
where \(P_{t}\) is the output power of the transmitter and \(PL(d)\) is the path loss. Table 1 shows the Tmote Sky output power configuration for CC2420 [7], an IEEE 802.15.4-compatible radio. The in-building radio propagation model that takes into account the effects of obstacles (walls) between the transmitter and the receiver on the same floor is given by [10]:  
\[PL(d)=PL(d_{0})+10n\,\log_{10}(\frac{d}{d_{0}})+\sum WAF \tag{2}\]  
Figure 1: WSN-Maintain and Cooja framework. where \(d\) is the transmitter-receiver distance, \(d_{0}\) a reference distance, \(n\) the path loss exponent (the rate at which the signal decays), and WAF is the _wall attenuation factor_. Based on the measurement in [11], WAF is chosen to be 3.1 dBm. Table 2 shows the real signal propagation measurements conducted using Tmote Sky with the maximum power level (\(P_{t}=0\) dBm) in line-of-sight (LOS) and non-line-of-sight (NLOS) conditions reported in [12]. The packet reception rate (PRR) at a distance \(d\) (\(p(d)\)) is given by:  
\[p(d)=(1-\frac{1}{2}\exp^{-\frac{\gamma(d)}{2}\frac{1}{0.8d}})^{8f} \tag{3}\]  
where \(f\) is the frame size, which is 128 bytes for Tmote Sky's CC2420.