# A Routing Algorithm for WiFi-Based Wireless Sensor Network and the Application in Automatic Meter Reading

Authors: Li Li; Xiaoguang Hu; Baochang Zhang
Journal: Mathematical Problems in Engineering
 (2013)

---

## Abstract

The Automatic Meter Reading (AMR) network for the next generation Smart Grid is required to possess many essential functions, such as data reading and writing, intelligent power transmission, and line damage detection. However, the traditional AMR network cannot meet the previous requirement. With the development of the WiFi sensor node in the low power cost, a new kind of wireless sensor network based on the WiFi technology can be used in application. In this paper, we have designed a new architecture of WiFi-based wireless sensor network, which is suitable for the next generation AMR system. We have also proposed a new routing algorithm called Energy Saving-Based Hybrid Wireless Mesh Protocol (E-HWMP) on the premise of current algorithm, which can improve the energy saving of the HWMP and be suitable for the WiFi-based wireless sensor network. The simulation results show that the life cycle of network is extended.


---

## Body

## 1. Introduction

Many countries have been carrying their own Smart Grid plan into reality [1, 2]. Although the focuses of their plans are different, the intellectualization of power utilization for terminal users is important work in most countries. As the footstone of the Smart Grid, the new generation of AMR system in Smart Grid not only can collect the data of power meters remotely, but also can have functions of power rationing, multirate billing, remote on-off control, power line loss test, antistealing, and the monitoring and management of power line and meters. Those functions should send data to terminal users, such as power meters, which is different from the old AMR systems. So a new generation of AMR architecture should be researched to meet the Smart Grid’s new requirements [3].There are many kinds of AMR communication technologies in the world now, such as Radio Frequency (RF) [4, 5], ZigBee-based wireless sensor network (WSN) [6–8], GPRS and 3G [9, 10], Power Line Carrier Communication (PLC) [11–13], and 485 bus. Among these technologies, WSN and PLC are considered to be the key technologies to build a new generation of Smart Grid AMR systems in the future. In this paper, we mainly discuss the wireless sensor network for AMR and management of the terminal users.The communication technologies of Wireless Sensor Networks used in short-range wireless are ZigBee, Ultrawide Band (UWB) WiFi (Wireless Fidelity), and so forth. With the development of SoC technology in recent years, the ultralow power WiFi System on SoC chip has emerged [14, 15]. As a result, WiFi-based wireless sensor networks come into use [16–22]. WiFi-based wireless sensor network has many special characteristics, such as high bandwidth, a large range covering, direct accessing to the WiFi hotspots at intelligent buildings, and smart home without additional equipment. The characteristics make it possible to decrease the costs, so WiFi-based wireless sensor network is more suitable for the AMR and management system in intelligent buildings and smart home.Recently, many researchers and developers pay much attention to WiFi-based wireless sensor networks. GainSpan, a company invested by Intel, developed the famous low-power WiFi sensor chips GS 1010 [14], and G2 Microsystems developed the G2C5x series chips [15]. It was reported that power consumption of GS 1010 sensor nodes is so low that a WiFi node can work five to ten years with an AA battery; of course, the working time also depends on the frequencies and time when the chip wakes up to work. Yu-Ping Chen compared GS 1010 with ZigBee sensors in standby and startup power consumption and got the conclusion that the average standby and startup power consumption of the WiFi sensor chip is less than the ZigBee sensor [23].In China, some researchers have done much work in this area too.  Shuang has developed a WiFi-based sensor node with GS 1010 chip and realized data transition and node positioning function [16]. Hongyi et al. have also realized remote environments monitoring system indoor and outdoor with GS 1010 chip [17]. Bin and Qiang have also done much application research work in these fields [18, 19]. Wu has designed and developed the hardware of a WiFi-based wireless sensor network node with ARM9-based S3C2440 processor [20]. There are more researchers who discussed and described the new applications with WiFi sensor network node [21, 22].The aforementioned researchers mainly focus on hardware design and application of WiFi sensor node. However, the research work on routing protocols and security algorithm of WiFi-based wireless sensor network is much less. The current WiFi’s AP is powered by a power line with unrestricted power and has higher calculation ability and large storage space. The routing protocols and security algorithms of the current WiFi technology are complex and nodes’ energy saving has not been considered in the protocols. Nodes of wireless sensor networks are powered by batteries and are usually used in an unattended area. So the cost is higher when it is used in large-scale application. And the hardware’s storage space and calculating ability of the WSN node are very limited. For the pervious reason, current WiFi technology cannot be directly applied to wireless sensor networks. We must upgrade the protocols and improve the security algorithms to meet the new requests.On the basis of study work of original WiFi routing protocol HWMP, new method on improving the energy saving ability of HWMP to adapt the new features is described in this paper. Simulation work on the new routing protocol has been done with NS2, and the simulation results show that the life cycle of the network is extended to some degree.


## 2. The Architecture of Remote AMR Referring Wireless Mesh

In general, the network topologies of a large scale wireless sensor network are of a hierarchical network structure. The nodes of hierarchical wireless sensor network include several clusters and each of them consists of a cluster head and several cluster members. Cluster head is responsible for coordinating the work of nodes in the cluster and data integration and cluster members are common nodes. According to the difference between the cluster head and normal nodes, the hierarchical network structures are divided into two types, isomorphic hierarchical structure and heterogeneous hierarchical structure. In isomorphic hierarchical structure network, the cluster head nodes and the common members are the same, and the cluster head is selected from common cluster members using a specific clustering algorithm. In heterogeneous hierarchical structure network, the nodes’ energy of the cluster head and the common members are different. And the cluster head is usually a special one with more powerful processing and communication capabilities, whose node energy is more powerful or unrestricted.On the Internet of Things, natural gas meters, water meters, and power meters are nodes of the wireless sensor network. Because power meters can be powered by power line, its node energy can be unrestricted. But for water meters and natural gas meters, it is difficult to be powered by power line. They can be powered only by batteries and their node energy is restricted. For these reasons, the heterogeneous hierarchical structure is suitable for remote meter reading network. The power meter is the smart control center and the head of heterogeneous clusters. Besides reading and transmitting local data, power meter can be used to collect and transfer the data from water meters and natural gas meters in the wireless network. Further more, it is easy to act as control center of other kinds of nodes at home in the future. The heterogeneous hierarchical structure network is shown in Figure1 [24].Figure 1
The topology of heterogeneous hierarchical network.There are three types of topologies in the WiFi network, point to point, point to multipoints in Star Network, and wireless mesh structure. The standards for WiFi are IEEE 802.11 series, in which IEEE 802.11s is specially made for wireless mesh structure. Wireless mesh structure is shown in Figure2. In mesh network, routing protocols are used to build mesh paths between Mesh Points and Mesh Access Points and each Mesh Point works just like a route to provide relay services. Mesh Access Point (MAP) can be Mesh Point or Access Point which can provide access services to the mobile client terminals in the mesh network [25].Figure 2
802.11s structure of Wireless Mesh Network.If we compare the structure of Mesh Network on IEEE 802.11s with heterogeneous hierarchical wireless sensor network, we can find that they are very similar. Mesh Portal can work as a gateway and provide access to other networks, Mesh Portal is similar to the sink node of wireless sensor network, MAP is similar to the cluster head of heterogeneous hierarchical network, and mobile client terminals are similar to the common nodes in wireless sensor network. So, the protocol of WiFi Wireless Mesh Network can be used with the WiFi-based wireless sensor network after being optimized, such as routing protocol and security technology.We have designed the architecture of WiFi-based new generation of remote Automatic Meter Reading Network which is shown in Figure3 [3], which can be used in intelligent community buildings.Figure 3
The structure of  WiFi-based AMR network.Comparing Figure3 with Figure 2, we can find that they are very similar in the topology structure. The concentration server is similar to MPP, the concentrator of buildings is similar to MAP, and the meters are similar to mobile terminal. Because the energy of power meter is unrestricted, the power meters can be connected to build a tree, which is like the bone of network. And this character is very similar to HWMP’s tree routing expanding. In addition, power meter is also responsible for bidirectional data transmission between water meter and gas meter.So we can refer to the structure of wireless mesh to realize remote AMR network. For example, we can design the network topology and route referring to the routing protocols of Mesh Network, and we can build security system of AMR network referring to the security protocols of Mesh Network. But we must note that most of the nodes of wireless sensor network are powered by batteries, so their node energy is restricted and the calculating capability and storage capacity are limited. So the network protocols of WiFi Wireless Mesh Network can only be used in the new generation of remote AMR network after being optimized. Since the default routing protocol of Wireless Mesh is HWMP, we should reduce the energy consumption of nodes running with HWMP.


## 3. Routing Protocol of HWMP

Hybrid Wireless Mesh Protocol (HWMP) is the default routing protocol of Wireless Mesh Standard IEEE 802.11s [26, 27], which is the hybrid of reactive routing protocol and tree topology-based proactive routing protocol. It is a routing protocol specifically for Wireless Mesh, in which the nodes of Mesh are relatively fixed and the nodes in trunk vary a little. According to HWMP, Mesh nodes can be added or deleted easily.Being a kind of hybrid routing protocol, HWMP includes reactive routing protocol and proactive routing protocol. The tree-based proactive routing protocol is adopted in backbone network, and the Radio-Metric AODV (RM-AODV) is adopted in variable network topology, which is evolved from AODV. AODV is an IP-based routing protocol and works in network layer, which uses the number of hops as metric. RM-AODV is MAC address-based routing protocol and works in physical layer, which uses Radio-Aware routing metric to choose path.A Mesh Point acts as the MPP (Mesh Portal Point) and the root node of the tree routing network when a mesh network begins. Other MP Points proactively maintain the path to root node and the root node maintains the paths to each Mesh Point. In this way, a two-way proactive path tree of distance vector can be built. When there is data to be sent in an MP, it will send the data to the gateway node according to the path tree first. If the data should be sent to an external network, the MPP gateway will send the data packet to destination via external network link. Otherwise, if the data is sent to other MPs in the Mesh Network, the gateway will send it to the right Mesh Point. When the destination MP receives the data from the source node in inner network, it will send back the corresponding routing request packet by starting the Radio-Metric Ad hoc On-Demand Distance Vector (RM-AODV). When the source node receives the packet, it will add the paths directly according to the received packet, through which the source node and the destination node are hop connected. If the transmission efficiency of a new path is higher, it will be used in the following transmission work. Since there is distance between gateway node and other Mesh Points in a Mesh Network, the hop transmission through nodes in inner network is more efficient and needs less network resources. The hybrid routing configuration process is shown in Figure4.Figure 4
Configuration process of HWMP.HWMP uses the serial number of destination address to check the timeout and invalid routing information. If the newly received serial number of routing information is smaller than the known serial number of the Mesh Point, the routing information will be discarded for being timeout. In such way, the problems of routing loops and traditional distance vector protocol, such as counting infinitely, can be avoided. Every path in the routing table has a time limit. All invalid routing paths will be deleted automatically. Validity of every path will be reset when frames with data are sent or new routing information is generated.A default Radio-Aware routing metric is defined for IEEE 802.11s devices according to the routing protocol HWMP in the newly issued formal standard 802.11s [26]. Airtime link metric is a measure to calculate the channel resources consumed in the data frame sending via a specific wireless link. Formula (1) is used in calculating the consumption of spare time in every link. The path metric is the sum of all link metrics. Consider the following:
(1)Ca=[O+Btr]11-efr,
where O is channel Access Overhead; Bt is number of bits in test frame; and  r is transmission bit rate; efr is error rate of every frame.O is all the Channel Access Overheads, which include frame headers, training sequences, and access protocol frames. It varies depending on the technology of physical layer, such as IEEE 802.11b or 802.11g. Bt is the number of bits in test frame which is 8192 bits. The input parameters r and efr are the data rates in Mb/s and the frame error rate for the test frame size Bt, respectively. The rate r represents the data rate at which the mesh STA would transmit a frame of standard size Bt based on current conditions and its estimation is dependent on local implementation of rate adaptation. The frame error rate efr is the probability that when a frame of standard size Bt is transmitted at the current transmission bit rate r, the frame is corrupted due to transmission error.


## 4.  Analysis and Improvement of HWMP Routing Protocol

### 4.1. HWMP Work Flow Analysis

After analyzing the simulation code of HWMP in NS-2.33 developed by Wireless Software Research and Development Group of Institute of Information Transmission Problems under the Russian Academy of Sciences [28], we find that HWMP code is similar to AODV protocol code of NS2. They are all mainly composed of protocol body, routing table, broadcast timer, route cache timer, cache broadcast ID timer, and route cache queue.When a packet is received, which means the function recv(Packet*, Handler*) is called, different functions are called to deal with it according to the packet type.(1)
If it is a protocol packet, function recvHWMP( ) will be called to deal with it. The TTL will be minus 1 before different functions are called according to different packet types.
(a)
If it is a routing requested packet, the function recvPREQ(Packet*) will be called to deal with it. If the packet is generated by the node itself or has already been received, the node will discard it and the process will be ended. Otherwise, the node will deposit the serial number of the packet in cache, add the path sent by the packet to reverse route and forward the packet. After that, the node will call the corresponding function to deal with it according to the destination address. If the node is the destination node, the function send PREP will be called. If the node is not the destination node and the route to destination node is known, the function send PREP will insert the next hop node into the precursor list between source node and destination node. If the route to destination node is unknown, the number of hops will be plus 1 and the function forward will be called to broadcast the packet.(b)
If it is routing response packet, the function recvPREP(Packet*) will be called. The node should query the route to destination node. If there is no such route, a new route should be added. After the new route is added, the node should update the route information to the destination node and distribute the related packets. If the node is not the destination node but it knows the route to destination, the number of hops will be plus 1 and the function forward will be called to distribute the packet. Accordingly, the response precursor list will be updated. If the node is not the destination node and it does not know the route to destination, the packet will be discarded.(2)
If what the node received is an already sent data packet or TTL of the packet equals 0, the node will terminate the process. If the packet is generated by upper-layer protocol, the node will add data header to it. HWMP works according to the path selection protocol in the second layer and its addressing mode is MAC address, but in the source code the IP address is used instead for technical reasons. Finally the node handles it according to destination route.The aforementioned is the routing process of HWMP protocol. In fact, there is a precompiling switch in the head file of hwmp.cc. The switch, “#define ROOT_INDEX(4)”, is used to start the tree proactive routing protocol and call a timer; thus, the route table can be updated every 10 seconds. If we disable the switch, the tree proactive routing protocol of HWMP will not start and there is no difference between HWMP and RM-AODV.There should be a route error packet in the HWMP protocol, according to which the related node can take the right action when there is link error.


### 4.2. Improved Routing Protocol E-HWMP

By analyzing the work flow of HWMP protocol, it can be found that the node energy is not considered in routing selection. But, in fact, there are some nodes that are battery-powered in hybrid AMR network based on WiFi wireless sensor network, and their node energy is restricted. Nodes with adequate energy should be considered in priority when the next hop node should be selected. So it is necessary to adjust the original HWMP protocol to meet the requirements of the nodes with limited energy. The adjustment includes adding energy model to call the energy parameters of nodes, modifying the data packet header of protocol packet and original routing metric of HWMP in airtime. The adjusted protocol is called Energy saving-based Hybrid Wireless Mesh Protocol (E-HWMP) routing protocol.


#### 4.2.1. The Improvement of Routing Metric in Airtime

The calculation method for routing airtime metric of HWMP is shown in formula (1). We know that it is irrelevant to node energy, so if we want the remaining energy of nodes to be considered in route selection according to HWMP, we can add parameter of node energy to it by multiplying original routing airtime metric E  times. The method to get E is shown in formula (2):
(2)E=∑i=1Nodecnt(1energyi),
where  Nodecnt is the collection of all nodes on the route and energyi is current energy of node i.The bigger the number of hops is, the bigger the value ofE is in case that all the nodes in route have the same quantity of energy. If the number of hops is fixed, the more the rest energy in routing nodes is and the smaller the value of E is. By examining the remaining energy of nodes in route before the path is built, the case in which the nodes with high-energy consumption are selected can be avoided. In such way, the route loop problem can be effectively avoided.The way to calculate the metric is shown in formula (3):
(3)Metric=E*∑Ca=∑i=1Nodecnt1energyi*∑j=1LinkcntCaj,where  Caj is the airtime of the jth link and  Linkcnt  is the collection of all the links in the route.


#### 4.2.2. Adding Node Energy Coefficient

As there is no node energy coefficient in the HWMP codes, the file that defines the node energy model, mobilenode.h, should be called. After that, the remaining energy in the current node can be read by a pointer. A pointer is defined in the previous codes to point to the current node and to get the remaining energy in the node. The perviousindexmeans the ID of current node and energyi  is the energy value of current node.


#### 4.2.3. Adjusting the Data Structure of the HWMP Packet Header

PREQ and PREP of RM-AODV are adopted to build the route tree and find on-demand routing in both proactive and reactive routing. There is no energy-related parameter in original path request packet (PREQ) and path response packet (PREP) of HWMP, so the packet headers of PREQ and PREP which use routing metric should be revised. A data variable named energylost should be used to record the sum of recipros the left energy value in current path, as is shown in formula (4):
(4)energylost+=1energyi.The revised packet header of path request (PREQ) is shown in Figure5, and the revised packet header of path response (PREP) is shown in Figure 6. The energy parameter energylost is newly added to record the reciprocal sum of the left energy value in the current path automatically.Figure 5
The modified packet header structure of PREQ.Figure 6
The modified packet header structure of PREP.


#### 4.2.4. Analysis of Work Flow

By analyzing the codes of HWMP, we can learn that the PREQ request should be sent at first to build a path when an MP sends data to another MP or builds a path to root node. So, the routing metric should be revised in the function recvPREQ where the PREQ is received and processed. The value of the new routing metric equals the value of the original routing metric mulplfied by the energy parameter, energylost.There is a similar routing metric in function recvPREP. There might be a difference between the information in the PREP packet and the current network for the reason that the PREP packets might not be sent from the destination node and the PREP packets could also be sent from the nodes in the path to destination node. And the energy information is varying from time to time. So the path selection rules in function recvPREP do not need to be modified.We name the improved protocol E-HWMP to distinguish it from the original protocol HWMP. We use a new routing metric related to node energy to get the network topology and route. In such way, we try to reduce the energy demand to the nodes, and the life cycle of network may be extended.


## 4.1. HWMP Work Flow Analysis

After analyzing the simulation code of HWMP in NS-2.33 developed by Wireless Software Research and Development Group of Institute of Information Transmission Problems under the Russian Academy of Sciences [28], we find that HWMP code is similar to AODV protocol code of NS2. They are all mainly composed of protocol body, routing table, broadcast timer, route cache timer, cache broadcast ID timer, and route cache queue.When a packet is received, which means the function recv(Packet*, Handler*) is called, different functions are called to deal with it according to the packet type.(1)
If it is a protocol packet, function recvHWMP( ) will be called to deal with it. The TTL will be minus 1 before different functions are called according to different packet types.
(a)
If it is a routing requested packet, the function recvPREQ(Packet*) will be called to deal with it. If the packet is generated by the node itself or has already been received, the node will discard it and the process will be ended. Otherwise, the node will deposit the serial number of the packet in cache, add the path sent by the packet to reverse route and forward the packet. After that, the node will call the corresponding function to deal with it according to the destination address. If the node is the destination node, the function send PREP will be called. If the node is not the destination node and the route to destination node is known, the function send PREP will insert the next hop node into the precursor list between source node and destination node. If the route to destination node is unknown, the number of hops will be plus 1 and the function forward will be called to broadcast the packet.(b)
If it is routing response packet, the function recvPREP(Packet*) will be called. The node should query the route to destination node. If there is no such route, a new route should be added. After the new route is added, the node should update the route information to the destination node and distribute the related packets. If the node is not the destination node but it knows the route to destination, the number of hops will be plus 1 and the function forward will be called to distribute the packet. Accordingly, the response precursor list will be updated. If the node is not the destination node and it does not know the route to destination, the packet will be discarded.(2)
If what the node received is an already sent data packet or TTL of the packet equals 0, the node will terminate the process. If the packet is generated by upper-layer protocol, the node will add data header to it. HWMP works according to the path selection protocol in the second layer and its addressing mode is MAC address, but in the source code the IP address is used instead for technical reasons. Finally the node handles it according to destination route.The aforementioned is the routing process of HWMP protocol. In fact, there is a precompiling switch in the head file of hwmp.cc. The switch, “#define ROOT_INDEX(4)”, is used to start the tree proactive routing protocol and call a timer; thus, the route table can be updated every 10 seconds. If we disable the switch, the tree proactive routing protocol of HWMP will not start and there is no difference between HWMP and RM-AODV.There should be a route error packet in the HWMP protocol, according to which the related node can take the right action when there is link error.


## 4.2. Improved Routing Protocol E-HWMP

By analyzing the work flow of HWMP protocol, it can be found that the node energy is not considered in routing selection. But, in fact, there are some nodes that are battery-powered in hybrid AMR network based on WiFi wireless sensor network, and their node energy is restricted. Nodes with adequate energy should be considered in priority when the next hop node should be selected. So it is necessary to adjust the original HWMP protocol to meet the requirements of the nodes with limited energy. The adjustment includes adding energy model to call the energy parameters of nodes, modifying the data packet header of protocol packet and original routing metric of HWMP in airtime. The adjusted protocol is called Energy saving-based Hybrid Wireless Mesh Protocol (E-HWMP) routing protocol.


### 4.2.1. The Improvement of Routing Metric in Airtime

The calculation method for routing airtime metric of HWMP is shown in formula (1). We know that it is irrelevant to node energy, so if we want the remaining energy of nodes to be considered in route selection according to HWMP, we can add parameter of node energy to it by multiplying original routing airtime metric E  times. The method to get E is shown in formula (2):
(2)E=∑i=1Nodecnt(1energyi),
where  Nodecnt is the collection of all nodes on the route and energyi is current energy of node i.The bigger the number of hops is, the bigger the value ofE is in case that all the nodes in route have the same quantity of energy. If the number of hops is fixed, the more the rest energy in routing nodes is and the smaller the value of E is. By examining the remaining energy of nodes in route before the path is built, the case in which the nodes with high-energy consumption are selected can be avoided. In such way, the route loop problem can be effectively avoided.The way to calculate the metric is shown in formula (3):
(3)Metric=E*∑Ca=∑i=1Nodecnt1energyi*∑j=1LinkcntCaj,where  Caj is the airtime of the jth link and  Linkcnt  is the collection of all the links in the route.


### 4.2.2. Adding Node Energy Coefficient

As there is no node energy coefficient in the HWMP codes, the file that defines the node energy model, mobilenode.h, should be called. After that, the remaining energy in the current node can be read by a pointer. A pointer is defined in the previous codes to point to the current node and to get the remaining energy in the node. The perviousindexmeans the ID of current node and energyi  is the energy value of current node.


### 4.2.3. Adjusting the Data Structure of the HWMP Packet Header

PREQ and PREP of RM-AODV are adopted to build the route tree and find on-demand routing in both proactive and reactive routing. There is no energy-related parameter in original path request packet (PREQ) and path response packet (PREP) of HWMP, so the packet headers of PREQ and PREP which use routing metric should be revised. A data variable named energylost should be used to record the sum of recipros the left energy value in current path, as is shown in formula (4):
(4)energylost+=1energyi.The revised packet header of path request (PREQ) is shown in Figure5, and the revised packet header of path response (PREP) is shown in Figure 6. The energy parameter energylost is newly added to record the reciprocal sum of the left energy value in the current path automatically.Figure 5
The modified packet header structure of PREQ.Figure 6
The modified packet header structure of PREP.


### 4.2.4. Analysis of Work Flow

By analyzing the codes of HWMP, we can learn that the PREQ request should be sent at first to build a path when an MP sends data to another MP or builds a path to root node. So, the routing metric should be revised in the function recvPREQ where the PREQ is received and processed. The value of the new routing metric equals the value of the original routing metric mulplfied by the energy parameter, energylost.There is a similar routing metric in function recvPREP. There might be a difference between the information in the PREP packet and the current network for the reason that the PREP packets might not be sent from the destination node and the PREP packets could also be sent from the nodes in the path to destination node. And the energy information is varying from time to time. So the path selection rules in function recvPREP do not need to be modified.We name the improved protocol E-HWMP to distinguish it from the original protocol HWMP. We use a new routing metric related to node energy to get the network topology and route. In such way, we try to reduce the energy demand to the nodes, and the life cycle of network may be extended.


## 4.2.1. The Improvement of Routing Metric in Airtime

The calculation method for routing airtime metric of HWMP is shown in formula (1). We know that it is irrelevant to node energy, so if we want the remaining energy of nodes to be considered in route selection according to HWMP, we can add parameter of node energy to it by multiplying original routing airtime metric E  times. The method to get E is shown in formula (2):
(2)E=∑i=1Nodecnt(1energyi),
where  Nodecnt is the collection of all nodes on the route and energyi is current energy of node i.The bigger the number of hops is, the bigger the value ofE is in case that all the nodes in route have the same quantity of energy. If the number of hops is fixed, the more the rest energy in routing nodes is and the smaller the value of E is. By examining the remaining energy of nodes in route before the path is built, the case in which the nodes with high-energy consumption are selected can be avoided. In such way, the route loop problem can be effectively avoided.The way to calculate the metric is shown in formula (3):
(3)Metric=E*∑Ca=∑i=1Nodecnt1energyi*∑j=1LinkcntCaj,where  Caj is the airtime of the jth link and  Linkcnt  is the collection of all the links in the route.


## 4.2.2. Adding Node Energy Coefficient

As there is no node energy coefficient in the HWMP codes, the file that defines the node energy model, mobilenode.h, should be called. After that, the remaining energy in the current node can be read by a pointer. A pointer is defined in the previous codes to point to the current node and to get the remaining energy in the node. The perviousindexmeans the ID of current node and energyi  is the energy value of current node.


## 4.2.3. Adjusting the Data Structure of the HWMP Packet Header

PREQ and PREP of RM-AODV are adopted to build the route tree and find on-demand routing in both proactive and reactive routing. There is no energy-related parameter in original path request packet (PREQ) and path response packet (PREP) of HWMP, so the packet headers of PREQ and PREP which use routing metric should be revised. A data variable named energylost should be used to record the sum of recipros the left energy value in current path, as is shown in formula (4):
(4)energylost+=1energyi.The revised packet header of path request (PREQ) is shown in Figure5, and the revised packet header of path response (PREP) is shown in Figure 6. The energy parameter energylost is newly added to record the reciprocal sum of the left energy value in the current path automatically.Figure 5
The modified packet header structure of PREQ.Figure 6
The modified packet header structure of PREP.


## 4.2.4. Analysis of Work Flow

By analyzing the codes of HWMP, we can learn that the PREQ request should be sent at first to build a path when an MP sends data to another MP or builds a path to root node. So, the routing metric should be revised in the function recvPREQ where the PREQ is received and processed. The value of the new routing metric equals the value of the original routing metric mulplfied by the energy parameter, energylost.There is a similar routing metric in function recvPREP. There might be a difference between the information in the PREP packet and the current network for the reason that the PREP packets might not be sent from the destination node and the PREP packets could also be sent from the nodes in the path to destination node. And the energy information is varying from time to time. So the path selection rules in function recvPREP do not need to be modified.We name the improved protocol E-HWMP to distinguish it from the original protocol HWMP. We use a new routing metric related to node energy to get the network topology and route. In such way, we try to reduce the energy demand to the nodes, and the life cycle of network may be extended.


## 5. Simulation

In order to verify the effect of the improved E-HWMP protocol, we did simulation tests. In the tests, the energy model of NS2 is used. Energy model of NS2 can be started by TCL language in the energy simulation process and run according to the parameters set in TCL script. Surely the left energy information in the current node should be called in the codes if the energy information is considered in the routing protocol.The simulation tests generate six different scenes which have 50, 100, 150, 200, 250, and 300 static nodes. The sensor nodes are random distributions in the scenes and each scene is 1000 m* 1000 m large. At the same time, when the number of nodes is 100, more tests were taken with three grades of initial energy, 5 J, 10 J, and 15 J. The details of the parameters are shown in Table 1.Table 1
Parameters of the passive routing test.
Simulation time
100 s
Transfer protocol
UDP
Packet types
CBR
Transmission rate
1 Mbps
Transmission distance
200 m
Mac layer
802.11 DCF
Antenna type
Omnidirectional antenna
Node moving speed
FixedThe time of the first timeout node in the original HWMP and the improved E-HWMP is shown in Figure7. The initial energy of all nodes is 15 J, the transmission power is 1 W, the receiving power is 1 W, and the waiting power is 0.05 W.Figure 7
The time of first timeout node in different protocols.The figure shows that the life cycle of the first timeout node in the case of E-HWMP is obviously extended when the number of nodes is not 200, and there is little difference between the life cycles of two protocols in the scale of 200 nodes. It should be noted that there is a 10-second extension, improved by 25 percent, when the number of nodes is 250.The average end-to-end delay time in different situations is shown in Figure8.Figure 8
End-to-end time delay in the environment of different nodes.The figure shows that there is little difference between the two protocols when the number of nodes is 250. There is a decrease in time delay in E-HWMP when the number of nodes is 100, 150, or 300. But there is more time delay when the number of nodes is 200.As is shown in Figure9, the life cycle of the first timeout node in E-HWMP is extended to a certain degree when there are 100 nodes in the system and the initial energies are 5 J, 10 J, and 15 J, respectively.Figure 9
The simulation result of E-HWMP and HWMP with 100 nodes and different initial energies.Furthermore, in the proactive routing test an8*12 point matrix is built, which can simulate the network topology of the building meter reading system. The distance between two adjacent nodes is 200 meters. The root node which simulates the concentrator of buildings is located on the top of the lattice, and it is connected with other nodes in the middle of lattice by one hop. The topology is shown in Figure 10.Figure 10
The topology of proactive routing for test.The results of this simulation show that the time of the first timeout node of E-HWMP is 71.1927 s, while the time of the first timeout node of HWMP is 70.0268 s. There is more than a 1-second delay in the time of first timeout node in the E-HWMP protocol compared with HWMP protocol.


## 6. Conclusion

Compared with the original HWMP, the life cycle of the first timeout node in E-HWMP is extended to a certain degree and the existing period of the network is prolonged, at the same time, there is no large difference in the end-to-end time delay between E-HWMP and HWMP.The result of the simulation of the AMR system under proactive routing model in the situation of apartment building shows that E-HMWP is more suitable than HWMP for the remote AMR network.



---

*Source: 320894-2013-09-05.xml*