# Fast Program Codes Dissemination for Smart Wireless Software Defined Networks

Authors: Xiao Liu; Tianyi Wei; Anfeng Liu
Journal: Scientific Programming
 (2016)

---

## Abstract

In smart wireless software defined networks (WSDNs), sensor nodes are deployed in the monitored area to sense data. In order to increase the flexibility of WSDNs configuration, sensor nodes use programmable technology. Thus, programming and software engineering that integrate Internet of Things (IoT) lead to a smart world. Due to the large capacity of program codes and the limited energy of wireless network, only a subset of nodes is selected to spread program codes, and the remaining nodes are in sleep status to save energy. In this paper, a fast program codes dissemination (FPCD) scheme for smart wireless software defined networking is proposed; many nodes in the area far from the sink will be selected to spread program codes; those areas have much energy left, while the area near the sink chooses less number of active nodes to spread program codes to save energy. Thus, FPCD scheme can reduce delay for spreading program codes while retaining network lifetime. The theoretical analysis and experimental results show that our approach can reduce transmission delay by 10.76%–105.791% while retaining network lifetime compares with previous broadcast schemes.


---

## Body

## 1. Introduction

In the Internet of Things (IoT), millions of objects with sensors collect data and send the data to control center servers that analyze, manage, and use the data in order to construct smart world applications, such as smart manufacturing, smart grid, smart and connected health, smart home, and intelligent transportation systems and even smart city [1–6]. What is more, programming and software engineering are integrated into the Internet of Things and cloud computing, which works towards a smart world.WSDNs can configure and update program codes in sensor nodes so that IoT has new features, because of the flexibility of configuration and updates of this software, which attracted wide attention of researchers. In WSDNs, program codes in sensor nodes are spread to all network by broadcasting; the program codes have new features after sensor nodes recompiled this program code. Program codes dissemination is a fundamental operation in WSDN [7]. Broadcast is one of the main transmission modes for program codes in WSDNs. The aim of broadcast is to propagate program codes to all nodes in a minimum latency. This problem has been studied extensively and has been shown to be NP-hard [8]. Some urgent applications such as life monitoring, intelligent transportation systems, and industrial automation often have very stringent requirements on program codes dissemination delay [9], and the system does not work properly by a lack of program codes, which could lead to serious accidents, such as the loss of personnel and property. Nevertheless, the harshness of wireless environments and the characteristics of WSDNs pose severe challenges on designing efficient program codes dissemination scheme. Energy of sensor nodes is limited, and thus sensor nodes usually select a small part of nodes to transmit program codes [10–13]. If the number of active nodes is small, the speed for spreading program codes is slow, and the energy consumption in this time is low; thus, network lifetime is higher. Otherwise, if the larger number of active nodes is selected to transmit program codes, the transmission delay is less, but the network lifetime is low. The issue of tradeoff between lifetime and delay is a challenging issue. There are some researches about program codes (or bulk data) dissemination in wireless sensing networks, those researches mainly focus on how to select the optimal scheduling policy to minimize energy consumption and broadcasts delay. To the best of our knowledge, these studies only achieved tradeoff between network lifetime and propagation delay, but not optimized network lifetime and the propagation delay at the same time. A fast program codes dissemination (FPCD) scheme is proposed to prolong lifetime and reduce broadcast delay at same time toward smart Internet of Things. The main contributions of the FPCD scheme can be listed as follows: (1) FPCD scheme uses a method of global vision to optimize program codes dissemination and thus reduce program codes dissemination delay while retaining origin broadcasting agreement, which has broad applicability.In this paper, we not only consider the energy consumption of program codes dissemination, but also the energy consumption of other operations in the network, which can take full advantage of energy to improve broadcast performance. WSDNs not only have broadcast operation of program codes, but also data collection operation. Data operation is a regular behavior, but broadcasting and updating program codes are temporary and infrequent operations [14]. For broadcasting program codes, the energy consumption is lower in the area near the sink. But in the process of data collection, the energy consumption in the area far away from the sink is lower, and the energy consumption in the area near the sink is higher. Thus, the FPCD scheme adopts a different strategy, the way is to increase the number of active nodes in the area far away from the sink. Because the transmission delay is related to the number of active nodes, increasing the number of nodes involved in broadcasting can effectively reduce the disseminate delay of program codes.( 2 ) The optimization parameters and the number of active nodes in different areas are discussed and calculated in the FPCD scheme. The performance of the FPCD scheme outperforms existing ones. Through our simulation study, we demonstrate that, for the proposed scheme, broadcast delay can be reduced and energy efficiency can be enhanced simultaneously. Compared with the former scheme, the broadcast delay can be reduced by as much as 10.76%. More importantly, the proposed scheme improves the performances without harming network lifetime, which is difficult to achieve in the previous schemes.The rest of this paper is organized as follows. In Section2, the related works are reviewed. The system model is described in Section 3. In Section 4, a novel FPCD scheme is presented for WSDNs. The performance analysis for FPCD scheme is provided in Section 5. Section 6 shows experimental results and comparison. We conclude in Section 7.


## 2. Related Work

Program codes (or bulk data) dissemination has been formulated and investigated in [15]. It can be divided into following types depending on different performance requirements of broadcast operation for different application.( 1 ) The minimum transmission broadcast (MTB) problem: in such studies, the objective of this study is how to reduce broadcast times. In previous schemes, the node is in an active state. Thus, the method for reducing broadcast times is to find a Minimum Connected Dominating Set (MCDS) of the network [16]. In a network as a tree, nodes in the tree can cover the entire network. Thus, as long as one node in the tree broadcasts data packet once, all nodes in the tree can receive the data packet. In [17], authors proved that building a minimum flooding tree is identical to finding an MCDS.In fact, one goal of reducing broadcast times is to reduce energy consumption. The broadcast method about reducing energy consumption has received a lot of researches. Lim and Kim [18] proposed a heuristic algorithm broadcast BIP (broadcast incremental power). It builds a broadcast tree whose root is source node; in the process of building tree, one node uncovered by the tree will be added to the broadcast tree, and the cost paid is minimized. Wieselthier et al. [19] optimized BIP algorithm; it proposed an effective search algorithm r-shrink; the energy consumption can be reduced by reschedule the nonleaf nodes of broadcast tree.In most WSDNs, in order to save energy, a node alternates between dormant and active states, this method is developed and applied to WSNs for energy conservation [20–23]. In broadcast, due to this mechanism that a node is required to transmit broadcast message multiple times to all its neighbor nodes at different moments. As a result, the MTB problem in duty cycled networks (MTB-DC problem) needs to be investigated for solutions in which both the set of forwarding nodes and their broadcast schedules are identified.Liu [24] proposed Level-Based Approximation Scheme to identify the forwarding nodes and their corresponding receivers for all time slots and then constructed a broadcast backbone by connecting these forwarding nodes to the broadcast source.( 2 ) The minimum latency broadcast scheduling (MLBS): in this scheme, it reduces not only the energy consumption of node, but also the transmission time for broadcasting [25, 26].Le Duc et al. [25] considered MLBS in duty cycled WSNs and presented two approximation algorithms, BS-1 and BS-2, that produce a maximum latency of at most ((Δ-1)TH) and 13TH, respectively. Here, Δ is the maximum degree of nodes, T denotes the number of time slots in a scheduling period, and H is the broadcast latency lower bound obtained from the shortest path algorithm.Zhao et al. [26] proposed a Broadcast over Duty Cycle and LEACH (BOD-LEACH) protocol, takes advantage of the LEACH’s energy efficient clustering. The proposed protocol added new common static and dynamic broadcast periods to support and accelerate broadcasting. The dynamic periods are scheduled following the past arrivals of messages and using a Markov chain model.Khiati and Djenouri demonstrated that epidemic theory is suitable for data dissemination by using broadcasting protocols in wireless sensor networks [27]. Khiati and Djenouri found that if the number of selected active nodes is large, the energy consumption is higher, the speed of data dissemination is fast, and converge time is lower. Conversely, if the number of selected active nodes is small, the energy consumption is less; thus, network lifetime is high. Previous schemes adopt fixed parameters to ensure network obtains desired level of performance under dynamic environments. Thus, Khiati and Djenouri proposed an epidemic-based algorithm by dynamically adjusting the number of selected active nodes to meet delay requirements while minimizing energy consumption.The scheme in [27] is the most similar with the scheme about this paper. But the ratio of active node is equal in the whole network for their scheme. The energy left of network cannot be full used; thus, data dissemination converge time is higher. In the FPCD scheme, the active node ratio is determined according to the adequacy degree of energy which can make full use of energy and improve the level of performance for WSDNs.


## 3. System Model

### 3.1. Network Model

( 1 ) We consider WSDNs consisting of a large number of homogenous sensor nodes and one sink node. The sink node is regarded as the control center. Those sensor nodes are deployed in the target area such as environment monitor, industrial field, and smart field [27–30]. The network radius is R, and the transmission radius of sensor nodes is r. The sink node is in the center of a network. The density of sensor nodes in the network is ρ. The sensor nodes are powered by battery whose energy is limited. The energy of the sink is unlimited.( 2 ) Duty cycling is adopted by nodes to reduce energy consumption. A node has two statues: awake and sleep. The duty cycle is the ratio of time in awake status to the cycle time. When node is in an awake status, the node can spread data. But the energy consumption in this time is higher. And when node is in a sleep status, its wireless transmission device is turned off, and thus the data cannot be transmitted to other nodes, but their energy consumption in this time is lower 100–1000 times than the energy consumption of node when node is in an awake state. Thus, the smaller duty cycle is, the lower the energy consumption is. But, if duty cycle is low, the ratio of active node is small, the delay of data dissemination will be slower, but network lifetime is longer. On the other hand, if duty cycle is high, the ratio of active node is higher, and the delay of data dissemination will be faster at cost of low lifetime.( 3 ) Senor node senses surrounding environment; when sensor nodes sense event that interests user, the sensed data can be sent to the sink by multiple-hop method. Considering the probability of occurrence of an event is λ. But when the operating system of sensor node upgrade, or the debug in software of sensor node need to be fixed, the software codes of operating system need to be spread to all nodes in the network. The sink collects the data which are sensed by node, this process is called data collection, and the process for disseminating program codes to each node is called data dissemination.


### 3.2. Energy Consumption Model

In this paper, we adopt the topical energy consumption model in [28–33], where the transmission energy consumption, ωt, follows (1) and energy consumption, ωr, for receiving the following (2):(1)ωt,1d=lEelec+lεfsd2ifd<d0ωt,2d=lEelec+lεampd4ifd≧d0,(2)ωr=lEelec,where Eelec represents transmitting circuit loss. Both the free space (d2 power loss) and the multipath fading (d4 power loss) channel models are used. If the transmission distance is less than the threshold d0, the power amplifier loss is based on free space model; if the transmission distance is larger than or equal to the threshold d0, respectively, the multipath attenuation model is used. εfs and εamp are the energy required by power amplification in the two models.


### 3.3. Problem Statement

In a WSDN, the sink disseminates program codes to sensor nodes; then, the sensor nodes diffuse those program codes to the nodes far from the sink. The aim of this paper is to reduce the dissemination delay [34] while minimizing energy consumption. Thus, the aims of this paper are as follows.(  1) Minimization Program Codes Dissemination Delay. In this paper, the dissemination (or broadcast) delay refers to the time between the sink (control center) disseminates program codes and all nodes receive the program codes except for the nodes that never receive program codes through broadcast. Let Tinit be the time before broadcast program codes, and let Tend be the time when all nodes receive the program codes. Thus, the broadcast delay T can be expressed as(3)min⁡T=min⁡Tinit-Tend.(  2) Maximization Network Lifetime. Network lifetime Γ refers to the elapsed time when the first node dies in the network. Because the death of first node can affect the connection of network, the program codes sent by the sink cannot broadcast to all nodes. Thus, the aim of this paper is to prolong network lifetime. Let Einit stand for the initial energy of nodes in the network, and let ei be the consumption energy of node in the network. Thus, network lifetime can be expressed as follows:(4)max⁡Γ=max⁡∑i=1nEinitei.(  3) Maximization Effective Energy Utilization Rate (Denoted as δ ). δ refers to the ratio of energy consumption of network to the total energy in the network. ei is the energy consumption of node in the network; Einit is the initial energy of node in the network. Our target is to maximize energy utilization of whole the network. Thus, the effective energy utilization can be expressed as follows:(5)max⁡δ=max⁡∑i=1nei∑i=1nEinit.Obviously, the goal of the FPCD is to minimize delay,T, maximize the network life, Γ, and make effective energy utilization, δ, which can be summarized as follows:(6)min⁡T=min⁡Tinit-Tendmax⁡Γ=max⁡∑i=1nEiniteimax⁡δ=max⁡∑i=1nei∑i=1nEinit.


## 3.1. Network Model

( 1 ) We consider WSDNs consisting of a large number of homogenous sensor nodes and one sink node. The sink node is regarded as the control center. Those sensor nodes are deployed in the target area such as environment monitor, industrial field, and smart field [27–30]. The network radius is R, and the transmission radius of sensor nodes is r. The sink node is in the center of a network. The density of sensor nodes in the network is ρ. The sensor nodes are powered by battery whose energy is limited. The energy of the sink is unlimited.( 2 ) Duty cycling is adopted by nodes to reduce energy consumption. A node has two statues: awake and sleep. The duty cycle is the ratio of time in awake status to the cycle time. When node is in an awake status, the node can spread data. But the energy consumption in this time is higher. And when node is in a sleep status, its wireless transmission device is turned off, and thus the data cannot be transmitted to other nodes, but their energy consumption in this time is lower 100–1000 times than the energy consumption of node when node is in an awake state. Thus, the smaller duty cycle is, the lower the energy consumption is. But, if duty cycle is low, the ratio of active node is small, the delay of data dissemination will be slower, but network lifetime is longer. On the other hand, if duty cycle is high, the ratio of active node is higher, and the delay of data dissemination will be faster at cost of low lifetime.( 3 ) Senor node senses surrounding environment; when sensor nodes sense event that interests user, the sensed data can be sent to the sink by multiple-hop method. Considering the probability of occurrence of an event is λ. But when the operating system of sensor node upgrade, or the debug in software of sensor node need to be fixed, the software codes of operating system need to be spread to all nodes in the network. The sink collects the data which are sensed by node, this process is called data collection, and the process for disseminating program codes to each node is called data dissemination.


## 3.2. Energy Consumption Model

In this paper, we adopt the topical energy consumption model in [28–33], where the transmission energy consumption, ωt, follows (1) and energy consumption, ωr, for receiving the following (2):(1)ωt,1d=lEelec+lεfsd2ifd<d0ωt,2d=lEelec+lεampd4ifd≧d0,(2)ωr=lEelec,where Eelec represents transmitting circuit loss. Both the free space (d2 power loss) and the multipath fading (d4 power loss) channel models are used. If the transmission distance is less than the threshold d0, the power amplifier loss is based on free space model; if the transmission distance is larger than or equal to the threshold d0, respectively, the multipath attenuation model is used. εfs and εamp are the energy required by power amplification in the two models.


## 3.3. Problem Statement

In a WSDN, the sink disseminates program codes to sensor nodes; then, the sensor nodes diffuse those program codes to the nodes far from the sink. The aim of this paper is to reduce the dissemination delay [34] while minimizing energy consumption. Thus, the aims of this paper are as follows.(  1) Minimization Program Codes Dissemination Delay. In this paper, the dissemination (or broadcast) delay refers to the time between the sink (control center) disseminates program codes and all nodes receive the program codes except for the nodes that never receive program codes through broadcast. Let Tinit be the time before broadcast program codes, and let Tend be the time when all nodes receive the program codes. Thus, the broadcast delay T can be expressed as(3)min⁡T=min⁡Tinit-Tend.(  2) Maximization Network Lifetime. Network lifetime Γ refers to the elapsed time when the first node dies in the network. Because the death of first node can affect the connection of network, the program codes sent by the sink cannot broadcast to all nodes. Thus, the aim of this paper is to prolong network lifetime. Let Einit stand for the initial energy of nodes in the network, and let ei be the consumption energy of node in the network. Thus, network lifetime can be expressed as follows:(4)max⁡Γ=max⁡∑i=1nEinitei.(  3) Maximization Effective Energy Utilization Rate (Denoted as δ ). δ refers to the ratio of energy consumption of network to the total energy in the network. ei is the energy consumption of node in the network; Einit is the initial energy of node in the network. Our target is to maximize energy utilization of whole the network. Thus, the effective energy utilization can be expressed as follows:(5)max⁡δ=max⁡∑i=1nei∑i=1nEinit.Obviously, the goal of the FPCD is to minimize delay,T, maximize the network life, Γ, and make effective energy utilization, δ, which can be summarized as follows:(6)min⁡T=min⁡Tinit-Tendmax⁡Γ=max⁡∑i=1nEiniteimax⁡δ=max⁡∑i=1nei∑i=1nEinit.


## 4. Main Design of FPCD

### 4.1. Research Motivation

( 1 ) The energy left in non-hotspots area is abundant but not in use.Besides program codes dissemination, WSDNs can collect data from sensor nodes. In the process of data collection, sensor nodes in the network send data to the sink, nodes in the area near the sink transmit much more data to the sink, and thus the energy consumption of nodes in the area near the sink is more than the energy consumption of nodes in the area far away from the sink. It is shown in Figure1 that the energy consumption of node is unbalanced. The left energy of node is given in Figure 2. As can be seen, many nodes in the network have much energy left. According to relevant research, when the network dies from hotspots problem, the energy left in the network is up to 90%. Thus, the main idea of proposed scheme is to make full use of the energy left in the nonhotspots area to increase the number of active nodes to transmit program codes to reduce dissemination delay.Figure 1
The energy consumption of WSDN.Figure 2
The left energy of WSDN.( 2 ) The number of active nodes is large and the dissemination delay is small, but the energy consumption is higher.When the sink spreads program codes to all nodes except the nodes that never receive program codes in the network, if the dissemination delay of program codes is smaller, the performance in the network is better. However, in WSDNs, nodes use the way of duty cycling to save energy. When duty cycle of network is smaller, the ratio of active node in the network is lower, and the number of nodes in an awake status is smaller, resulting in the speed for spreading program codes being slower; thus, the transmission delay is bigger. Figure3 shows the relationship between delivery delay and different number of active nodes. As can be seen, the more the number of active nodes is, the less the dissemination delay is. For some emergency event, the number of active nodes should be increased to reduce transmission delay. The reason is that if there are many active nodes, the sink will have many neighbor nodes in the range of transmission radius. When the sink node wants to spread program codes to the network. In program codes transmission, the program codes can be spread from one node to many nodes, the time for spreading program codes to the network is short, and the transmission delay is less. Otherwise, the transmission delay is higher.Figure 3
The dissemination delay under different number of active nodes.( 3 ) If using energy left in the network to increase the number of active nodes, the dissemination delay can be reduced while retaining network lifetime.In previous schemes, the system cannot reduce dissemination delay under the condition that network lifetime cannot be reduced. The reason is that the larger the number of active nodes is, the less the transmission delay is, but the higher the energy consumption of node is. Thus, increasing the number of active nodes may affect the energy consumption to damage network lifetime. The relationship between the energy consumption and the number of active nodes is shown in Figure4. From Figure 4, with the number of active nodes growing, the energy consumption grows. The main idea of the proposed scheme is to make full use of the energy left in the network to increase the number of active nodes to reduce the transmission delay. In the FPCD scheme, the number of active nodes is adjusted dynamically according to the energy left in the network while retaining network lifetime.Figure 4
The energy consumption in different areas.From the above analysis, the broadcast quality of overall network is based on the residual energy. Adjusting the number of active nodes dynamically can achieve better comprehensive broadcast performances. For this reason, a fast program codes dissemination (FPCD) scheme is proposed.


### 4.2. The Calculation of Energy Consumption of the Network

The nodes at different distances from the sink have definite energy consumption. The value is given by theoretical analysis. Considering that all nodes in network adopt the same duty cycle. The energy consumption of nodes at different areas is calculated.Firstly, because nodes in different areas use same duty cycle, the number of active nodes in different areas is the same. Due to the same broadcast operation in different areas, the energy consumption in different areas is the same. But the main operation of WSDN is data collection. In the process of data collection, the energy consumption is unbalanced, the energy consumption for data collection is given in Theorem1.Theorem 1.
Considering network radius isR, transmission radius of node is r. The probability of occurrence of an event is λ, each data packet is transmitted to the sink using shortest routing path. Considering node i whose distance from the sink is l, l=zr+x, ωt is the energy consumption for transmission of one-bit data. ωr is the energy consumption for receiving one-bit data. After one round of data collection, the energy consumption Edatal  for data operation of node i is (7)Edatal=z+1+zz+1r2lλωt+z+zz+1r2lλωrz=R-lr.Proof.
Considering network radius isR, the node transmission radius is r, the generation rate of event is λ. The data packet is routed based on the shortest routing. Considering node whose distance from sink is l, l=hr+x, where h is the hop counts from the node to the sink. The number of transmitting data loaded by this node is(8)z+1+zz+1r2lλ∣z=R-lr.
The number of receiving data loaded by this node is(9)z+zz+1r2lλ∣z=R-lr.
Andωt is the energy consumption for transmitting data. ωr is the energy consumption for receiving data. So the energy consumption of node i is(10)z+1+zz+1r2lλωt+z+zz+1r2lλωr.


### 4.3. Adjustable Calculation of the Number of Active Nodes

Compared with previous scheme, the FPCD scheme can adjust the number of active nodes based on the remaining energy. Therefore, the calculating method of the number of active nodes in different regions of the network is given in this section.Theorem 2.
Considering nodei whose distance from the sink is l,  l=hr+x, ωt is the energy consumption for transmission one bit data. ωr is the energy consumption for receiving one bit data. d is the length of program codes. The number of active nodes in the area at l m distance from the sink is nl in one duty cycle, after one round of program code transmission, the total energy consumption Eprol of the area whose distance from the sink is l is (11)Eprol=nlωrd+nl+rωtd.Proof.
In the FPCD scheme, for nodei whose distance from the sink is l, l=hr+x. When the sink spreads program codes to all nodes except the nodes that never receive the packet, the total energy consumption of the area whose distance from the sink is l include two kinds of energy: one is the energy consumption for receiving program codes from the last hop node and the other energy consumption is the consumed energy for spreading program codes to the next hop nodes. There are nl active nodes in this area, this area will receive nl program codes from the last node, and thus the energy consumption for receiving those program codes is(12)Erel=nlωrd.
But those program codes should be spread to next nodes; in the next areas, there arenl+r active nodes, each active node should receive those program codes once. Thus, the energy consumption for transmitting program codes is(13)Esel=nl+rωtd.
The total energy consumptionEprol of the area whose distance from the sink is l is(14)Eprol=nlωrd+nl+rωtd.Theorem 3.
Considering nodei whose distance from the sink is l, l=hr+x. Emax is the maximum energy consumption for data collection and spread program code in the network. The number of nodes in the area at l distance from the sink is ntotall. In the FPCD scheme, considering the optimized number of active nodes in the area at l=hr+x distance from the sink is nloptimize, it should meet (15)nloptimizeα+nl+roptimize=Emax-ntotallEdatalωtd.Proof.
In the FPCD scheme, the aim is to make full use of the energy left to increase the number of active nodes to reduce the transmission delay. For nodei whose distance from the sink is l, l=hr+x. According to Theorem 2, the total energy consumption of the area at l m distance from the sink is Eprol, the energy consumption of nodes at l m distance from the sink is Edatal according to Theorem 1. In order to increase the number of active nodes to reduce transmission delay while retaining network lifetime, the total energy consumption in this area at l m distance from the sink is Eprol+ntotallEdatal. Thus, the difference between the maximum energy consumption of the network and the total energy consumption in this area is ΔE=Emax-(Eprol+ntotallEdatal). The total energy consumption of this area should be close to the maximum energy consumption to make full use of the energy left in this area. That is,(16)Emax=nloptimizeωrd+nl+roptimizeωtd+ntotallEdatal.
It can be seen thatωr can be instead as αωt, and α is a constant. Equation (16) is (17)Emax=nloptimizeαωtd+nl+roptimizeωtd+ntotallEdatal.
The optimizable number of active nodes in different areas is(18)nloptimizeα+nl+roptimize=Emax-ntotallEdatalωtd.


### 4.4. Scheduling Method

The number of active nodes is adjusted adaptively by the FPCD scheme according to the energy left of node. The main goal of FPCD scheme is to increase the number of active nodes in the area far away from the sink to reduce the transmission delay while retaining network lifetime.In this paper, program codes are transmitted to all nodes after the sink receives the data from all sensor nodes. First, the sink collects data from sensor nodes, and the nodes consume energy. Second, the sink spreads program codes. This scheme mainly studies the program codes transmission. In the beginning of program codes transmission, the energy of nodes is the energy left of node in data collection. In the process of data collection, sensor nodes sense data from the surrounding environment, and then the sensed data can be transmitted to the sink. When those data packets are transmitted from the area atl distance to the sink, the message about energy consumption for transmitting data packet is recorded in the area at l distance from the sink; it is El. In the FPCD scheme, when the sink spreads program codes to nodes in the network, the program codes can be spread to their neighbor nodes, until the program codes to all nodes except the nodes that never receive the program codes. Before the sink spreads the program codes, the maximum energy consumption Emax is set as 0, the message about Emax is stored in the program codes. When one node receives the program codes, the energy consumption of node i for transmitting the program codes is Ei, the area where the node stays will record the energy consumption(19)El=El+Ei.IfEl>Emax, the maximum energy consumption can be instead as El; that is, Emax=El. After a round of program codes transmission, the message about the maximum energy consumption of nodes will be returned to the sink. Considering the requirements transmission delay is ζr, the transmission delay in this transmission is ζc. In the FPCD scheme, its aim is that the number of active nodes can be adjusted dynamically to ensure the transmission delay ζc in program codes dissemination smaller than the requirement transmission delay ζr, and network lifetime is higher as soon as possible.The sink will send messages including (Emax, ζr, ζc) to nodes at l distance from the sink. For node i at l distance from the sink, when node i receives the message from the sink, if ζc>ζr, it shows that the transmission delay in this time is bigger than the requirement transmission delay, the number of active node should be increased to reduce transmission delay. But if ζc<ζr, it shows that the transmission delay in this time is smaller than the requirement transmission delay, the number of active node should be reduced to improve network lifetime.Whenζc>ζr, the transmission delay is higher than the requirement transmission delay, the number of active nodes should be increased, and the method for increasing the number of active node is as follows.( 1 ) When node i receives the feedback message from the sink, it first computes the energy difference between the maximum energy consumption Emax and the energy consumption El; it is as follows:(20)ΔE=Emax-El.When the area atl distance from the sink increase one active node, the energy consumption in the area can increase EΔ, the number of increased active nodes is(21)Δn=ΔEEΔ.IfΔn<1, the number of active nodes will add 1 in the next round of program codes dissemination, if the energy consumption of this area is lower than Emax, the number of active nodes is correct in this area. But when the energy consumption of this area is higher than Emax, the number of active nodes does not need to be adjusted.IfΔn>1, the areas at l distance from the sink will increase by Δn active nodes, the number of adjustable active nodes in this area is as follows:(22)nl=nl+Δn.The number of active nodes will be instead with the valuenl+Δn if the transmission delay is smaller than the requirement transmission delay in the next process of program codes transmission. But if the transmission delay is higher than the requirement transmission delay in the network, the number of active nodes will be instead with nl+Δn, and the number of active nodes in the areas nearest the sink adds one.Whenζc<ζr, the transmission delay is smaller than the requirement transmission delay; in order to improve the network lifetime, the number of active nodes in the area near the sink is reduced by 1.Each area atl distance from the sink has marking information Bl which is used to express whether the number of active node in this area should be adjusted. Bl=1 shows the number of active nodes in this area should be adjusted in the next process of program codes transmission, Bl=0 shows the number of active node in this area is not adjusted in the next process of program codes transmission, continuing the process of adjusting the number of active nodes in different areas, until all Bl are 0 in the network. It shows the number of active nodes in this area is optimized.When nodes are in an active status, the nodes will spread program codes in the duty cycle time, until the program code reaches all nodes except the nodes that never receive program codes. The number of active nodes in the area will be adjusted in the next cycle time, until the system reaches stable status.The FPCD scheme algorithm is given in Algorithm1.Algorithm 1:A fast program codes dissemination (FPCD) scheme.
/∗∗ the requirement minimum transmission delay is ζr, the energy consumption of the area at l distance from the sink is El after the data collection is over.∗∗/ Initialize: each area at l distance from the sink records the energy consumption in the last program code spread period: El. The maximum energy consumptionEmax=0. Δζ is a delay threshold Part I: The action of node in message report to sink: (1) Forprogram code P which reach node i at l distance from the sinkDo (2)  El=El+Ei; // the energy consumption will be record in // this area (3)  If (El>Emax) (4)   Emax=El; (5)  End if (6) send program code P with Emax to next node (7)  If the number of active nodes in this area changes (8)   Bl=1; (9)  Else (10)   Bl=0; (11)  End IF (12)End For Part II: The action of sink: (13) ζu=ζc-ζr, (14) For each program code flow where ζu<0 and ζu>Δζ // the current transmission delay is lower than that the requirement // transmission delay of application, the number of active nodes // should be reduced. (15)  The last node in the program code path send tuple (Emax,ζr,ζc) along the reverse routing directions to different areas in this program code flow path; // feedback control the data flow which do not meet the // requirement of application (16) Sink get ζc, Emax from program code P; (17) Emax can be updated by sink after a round of program codes transmission (18) Sink send (Emax,ζr,ζc) to each area in the network; (19) Each area receives the tuple do action as steps (20)−(27); (20)  If  Bl=1 // The number of active nodes in this area is reduced to reach // the stable state (21)  The number of active nodes in this area should be adjust according to steps (45)–(51); (22)  update Emax, ζc; (23)   send tuple (Emax,ζr,ζc) to each node; (24)  Else (25)   If (the current reliability do not meet the requirement of application) // the number of active nodes in the area near sink can be reduced. (26)     Let nl=nl-1 // The number of active nodes in the area with largest energy consumption minus 1 End if (27)  End if (28) End for (29) For each data flow where ζu>0 and ζu>Δζ // the current transmission delay is bigger than that the requirement // transmission delay of application, the number of active nodes // should be increased. (30)  Continue steps (15), (16), (17), and (18) (31)  If the area at l distance from the sink receives the tuples; (32)   If  Bl=1 // The number of active nodes in this area is increased (33)   The number of active nodes in this area should be adjust according to steps (45)–(51); (34)   Else (35)    If  ζu<Δζ // It shows that the system is in a balanced state. (36)    Stop the process for adjust the number of active nodes in different areas (37)     Else // The number of active nodes in the area nearest sink can be // increased. (38)      Let nl=nl+1 (39)      End if (40)    End if (41)  update Emax, ζc; (42) End for (43) Continue the steps (13)–(42) for adjusting the number of active nodes, until ζu<Δζ; (44) The method for adjusting the number of active nodes in the area atldistance from the sink (45) Let ΔE=Emax-El, EΔ=ΔEϑ; (46)  Compute Δnl base Eq. (21) according ΔE; (47)  If  Δnl>1 (48)   nl=nl+Δnl; (49)  Else (50)   nl=nl+1; (51)  End if


## 4.1. Research Motivation

( 1 ) The energy left in non-hotspots area is abundant but not in use.Besides program codes dissemination, WSDNs can collect data from sensor nodes. In the process of data collection, sensor nodes in the network send data to the sink, nodes in the area near the sink transmit much more data to the sink, and thus the energy consumption of nodes in the area near the sink is more than the energy consumption of nodes in the area far away from the sink. It is shown in Figure1 that the energy consumption of node is unbalanced. The left energy of node is given in Figure 2. As can be seen, many nodes in the network have much energy left. According to relevant research, when the network dies from hotspots problem, the energy left in the network is up to 90%. Thus, the main idea of proposed scheme is to make full use of the energy left in the nonhotspots area to increase the number of active nodes to transmit program codes to reduce dissemination delay.Figure 1
The energy consumption of WSDN.Figure 2
The left energy of WSDN.( 2 ) The number of active nodes is large and the dissemination delay is small, but the energy consumption is higher.When the sink spreads program codes to all nodes except the nodes that never receive program codes in the network, if the dissemination delay of program codes is smaller, the performance in the network is better. However, in WSDNs, nodes use the way of duty cycling to save energy. When duty cycle of network is smaller, the ratio of active node in the network is lower, and the number of nodes in an awake status is smaller, resulting in the speed for spreading program codes being slower; thus, the transmission delay is bigger. Figure3 shows the relationship between delivery delay and different number of active nodes. As can be seen, the more the number of active nodes is, the less the dissemination delay is. For some emergency event, the number of active nodes should be increased to reduce transmission delay. The reason is that if there are many active nodes, the sink will have many neighbor nodes in the range of transmission radius. When the sink node wants to spread program codes to the network. In program codes transmission, the program codes can be spread from one node to many nodes, the time for spreading program codes to the network is short, and the transmission delay is less. Otherwise, the transmission delay is higher.Figure 3
The dissemination delay under different number of active nodes.( 3 ) If using energy left in the network to increase the number of active nodes, the dissemination delay can be reduced while retaining network lifetime.In previous schemes, the system cannot reduce dissemination delay under the condition that network lifetime cannot be reduced. The reason is that the larger the number of active nodes is, the less the transmission delay is, but the higher the energy consumption of node is. Thus, increasing the number of active nodes may affect the energy consumption to damage network lifetime. The relationship between the energy consumption and the number of active nodes is shown in Figure4. From Figure 4, with the number of active nodes growing, the energy consumption grows. The main idea of the proposed scheme is to make full use of the energy left in the network to increase the number of active nodes to reduce the transmission delay. In the FPCD scheme, the number of active nodes is adjusted dynamically according to the energy left in the network while retaining network lifetime.Figure 4
The energy consumption in different areas.From the above analysis, the broadcast quality of overall network is based on the residual energy. Adjusting the number of active nodes dynamically can achieve better comprehensive broadcast performances. For this reason, a fast program codes dissemination (FPCD) scheme is proposed.


## 4.2. The Calculation of Energy Consumption of the Network

The nodes at different distances from the sink have definite energy consumption. The value is given by theoretical analysis. Considering that all nodes in network adopt the same duty cycle. The energy consumption of nodes at different areas is calculated.Firstly, because nodes in different areas use same duty cycle, the number of active nodes in different areas is the same. Due to the same broadcast operation in different areas, the energy consumption in different areas is the same. But the main operation of WSDN is data collection. In the process of data collection, the energy consumption is unbalanced, the energy consumption for data collection is given in Theorem1.Theorem 1.
Considering network radius isR, transmission radius of node is r. The probability of occurrence of an event is λ, each data packet is transmitted to the sink using shortest routing path. Considering node i whose distance from the sink is l, l=zr+x, ωt is the energy consumption for transmission of one-bit data. ωr is the energy consumption for receiving one-bit data. After one round of data collection, the energy consumption Edatal  for data operation of node i is (7)Edatal=z+1+zz+1r2lλωt+z+zz+1r2lλωrz=R-lr.Proof.
Considering network radius isR, the node transmission radius is r, the generation rate of event is λ. The data packet is routed based on the shortest routing. Considering node whose distance from sink is l, l=hr+x, where h is the hop counts from the node to the sink. The number of transmitting data loaded by this node is(8)z+1+zz+1r2lλ∣z=R-lr.
The number of receiving data loaded by this node is(9)z+zz+1r2lλ∣z=R-lr.
Andωt is the energy consumption for transmitting data. ωr is the energy consumption for receiving data. So the energy consumption of node i is(10)z+1+zz+1r2lλωt+z+zz+1r2lλωr.


## 4.3. Adjustable Calculation of the Number of Active Nodes

Compared with previous scheme, the FPCD scheme can adjust the number of active nodes based on the remaining energy. Therefore, the calculating method of the number of active nodes in different regions of the network is given in this section.Theorem 2.
Considering nodei whose distance from the sink is l,  l=hr+x, ωt is the energy consumption for transmission one bit data. ωr is the energy consumption for receiving one bit data. d is the length of program codes. The number of active nodes in the area at l m distance from the sink is nl in one duty cycle, after one round of program code transmission, the total energy consumption Eprol of the area whose distance from the sink is l is (11)Eprol=nlωrd+nl+rωtd.Proof.
In the FPCD scheme, for nodei whose distance from the sink is l, l=hr+x. When the sink spreads program codes to all nodes except the nodes that never receive the packet, the total energy consumption of the area whose distance from the sink is l include two kinds of energy: one is the energy consumption for receiving program codes from the last hop node and the other energy consumption is the consumed energy for spreading program codes to the next hop nodes. There are nl active nodes in this area, this area will receive nl program codes from the last node, and thus the energy consumption for receiving those program codes is(12)Erel=nlωrd.
But those program codes should be spread to next nodes; in the next areas, there arenl+r active nodes, each active node should receive those program codes once. Thus, the energy consumption for transmitting program codes is(13)Esel=nl+rωtd.
The total energy consumptionEprol of the area whose distance from the sink is l is(14)Eprol=nlωrd+nl+rωtd.Theorem 3.
Considering nodei whose distance from the sink is l, l=hr+x. Emax is the maximum energy consumption for data collection and spread program code in the network. The number of nodes in the area at l distance from the sink is ntotall. In the FPCD scheme, considering the optimized number of active nodes in the area at l=hr+x distance from the sink is nloptimize, it should meet (15)nloptimizeα+nl+roptimize=Emax-ntotallEdatalωtd.Proof.
In the FPCD scheme, the aim is to make full use of the energy left to increase the number of active nodes to reduce the transmission delay. For nodei whose distance from the sink is l, l=hr+x. According to Theorem 2, the total energy consumption of the area at l m distance from the sink is Eprol, the energy consumption of nodes at l m distance from the sink is Edatal according to Theorem 1. In order to increase the number of active nodes to reduce transmission delay while retaining network lifetime, the total energy consumption in this area at l m distance from the sink is Eprol+ntotallEdatal. Thus, the difference between the maximum energy consumption of the network and the total energy consumption in this area is ΔE=Emax-(Eprol+ntotallEdatal). The total energy consumption of this area should be close to the maximum energy consumption to make full use of the energy left in this area. That is,(16)Emax=nloptimizeωrd+nl+roptimizeωtd+ntotallEdatal.
It can be seen thatωr can be instead as αωt, and α is a constant. Equation (16) is (17)Emax=nloptimizeαωtd+nl+roptimizeωtd+ntotallEdatal.
The optimizable number of active nodes in different areas is(18)nloptimizeα+nl+roptimize=Emax-ntotallEdatalωtd.


## 4.4. Scheduling Method

The number of active nodes is adjusted adaptively by the FPCD scheme according to the energy left of node. The main goal of FPCD scheme is to increase the number of active nodes in the area far away from the sink to reduce the transmission delay while retaining network lifetime.In this paper, program codes are transmitted to all nodes after the sink receives the data from all sensor nodes. First, the sink collects data from sensor nodes, and the nodes consume energy. Second, the sink spreads program codes. This scheme mainly studies the program codes transmission. In the beginning of program codes transmission, the energy of nodes is the energy left of node in data collection. In the process of data collection, sensor nodes sense data from the surrounding environment, and then the sensed data can be transmitted to the sink. When those data packets are transmitted from the area atl distance to the sink, the message about energy consumption for transmitting data packet is recorded in the area at l distance from the sink; it is El. In the FPCD scheme, when the sink spreads program codes to nodes in the network, the program codes can be spread to their neighbor nodes, until the program codes to all nodes except the nodes that never receive the program codes. Before the sink spreads the program codes, the maximum energy consumption Emax is set as 0, the message about Emax is stored in the program codes. When one node receives the program codes, the energy consumption of node i for transmitting the program codes is Ei, the area where the node stays will record the energy consumption(19)El=El+Ei.IfEl>Emax, the maximum energy consumption can be instead as El; that is, Emax=El. After a round of program codes transmission, the message about the maximum energy consumption of nodes will be returned to the sink. Considering the requirements transmission delay is ζr, the transmission delay in this transmission is ζc. In the FPCD scheme, its aim is that the number of active nodes can be adjusted dynamically to ensure the transmission delay ζc in program codes dissemination smaller than the requirement transmission delay ζr, and network lifetime is higher as soon as possible.The sink will send messages including (Emax, ζr, ζc) to nodes at l distance from the sink. For node i at l distance from the sink, when node i receives the message from the sink, if ζc>ζr, it shows that the transmission delay in this time is bigger than the requirement transmission delay, the number of active node should be increased to reduce transmission delay. But if ζc<ζr, it shows that the transmission delay in this time is smaller than the requirement transmission delay, the number of active node should be reduced to improve network lifetime.Whenζc>ζr, the transmission delay is higher than the requirement transmission delay, the number of active nodes should be increased, and the method for increasing the number of active node is as follows.( 1 ) When node i receives the feedback message from the sink, it first computes the energy difference between the maximum energy consumption Emax and the energy consumption El; it is as follows:(20)ΔE=Emax-El.When the area atl distance from the sink increase one active node, the energy consumption in the area can increase EΔ, the number of increased active nodes is(21)Δn=ΔEEΔ.IfΔn<1, the number of active nodes will add 1 in the next round of program codes dissemination, if the energy consumption of this area is lower than Emax, the number of active nodes is correct in this area. But when the energy consumption of this area is higher than Emax, the number of active nodes does not need to be adjusted.IfΔn>1, the areas at l distance from the sink will increase by Δn active nodes, the number of adjustable active nodes in this area is as follows:(22)nl=nl+Δn.The number of active nodes will be instead with the valuenl+Δn if the transmission delay is smaller than the requirement transmission delay in the next process of program codes transmission. But if the transmission delay is higher than the requirement transmission delay in the network, the number of active nodes will be instead with nl+Δn, and the number of active nodes in the areas nearest the sink adds one.Whenζc<ζr, the transmission delay is smaller than the requirement transmission delay; in order to improve the network lifetime, the number of active nodes in the area near the sink is reduced by 1.Each area atl distance from the sink has marking information Bl which is used to express whether the number of active node in this area should be adjusted. Bl=1 shows the number of active nodes in this area should be adjusted in the next process of program codes transmission, Bl=0 shows the number of active node in this area is not adjusted in the next process of program codes transmission, continuing the process of adjusting the number of active nodes in different areas, until all Bl are 0 in the network. It shows the number of active nodes in this area is optimized.When nodes are in an active status, the nodes will spread program codes in the duty cycle time, until the program code reaches all nodes except the nodes that never receive program codes. The number of active nodes in the area will be adjusted in the next cycle time, until the system reaches stable status.The FPCD scheme algorithm is given in Algorithm1.Algorithm 1:A fast program codes dissemination (FPCD) scheme.
/∗∗ the requirement minimum transmission delay is ζr, the energy consumption of the area at l distance from the sink is El after the data collection is over.∗∗/ Initialize: each area at l distance from the sink records the energy consumption in the last program code spread period: El. The maximum energy consumptionEmax=0. Δζ is a delay threshold Part I: The action of node in message report to sink: (1) Forprogram code P which reach node i at l distance from the sinkDo (2)  El=El+Ei; // the energy consumption will be record in // this area (3)  If (El>Emax) (4)   Emax=El; (5)  End if (6) send program code P with Emax to next node (7)  If the number of active nodes in this area changes (8)   Bl=1; (9)  Else (10)   Bl=0; (11)  End IF (12)End For Part II: The action of sink: (13) ζu=ζc-ζr, (14) For each program code flow where ζu<0 and ζu>Δζ // the current transmission delay is lower than that the requirement // transmission delay of application, the number of active nodes // should be reduced. (15)  The last node in the program code path send tuple (Emax,ζr,ζc) along the reverse routing directions to different areas in this program code flow path; // feedback control the data flow which do not meet the // requirement of application (16) Sink get ζc, Emax from program code P; (17) Emax can be updated by sink after a round of program codes transmission (18) Sink send (Emax,ζr,ζc) to each area in the network; (19) Each area receives the tuple do action as steps (20)−(27); (20)  If  Bl=1 // The number of active nodes in this area is reduced to reach // the stable state (21)  The number of active nodes in this area should be adjust according to steps (45)–(51); (22)  update Emax, ζc; (23)   send tuple (Emax,ζr,ζc) to each node; (24)  Else (25)   If (the current reliability do not meet the requirement of application) // the number of active nodes in the area near sink can be reduced. (26)     Let nl=nl-1 // The number of active nodes in the area with largest energy consumption minus 1 End if (27)  End if (28) End for (29) For each data flow where ζu>0 and ζu>Δζ // the current transmission delay is bigger than that the requirement // transmission delay of application, the number of active nodes // should be increased. (30)  Continue steps (15), (16), (17), and (18) (31)  If the area at l distance from the sink receives the tuples; (32)   If  Bl=1 // The number of active nodes in this area is increased (33)   The number of active nodes in this area should be adjust according to steps (45)–(51); (34)   Else (35)    If  ζu<Δζ // It shows that the system is in a balanced state. (36)    Stop the process for adjust the number of active nodes in different areas (37)     Else // The number of active nodes in the area nearest sink can be // increased. (38)      Let nl=nl+1 (39)      End if (40)    End if (41)  update Emax, ζc; (42) End for (43) Continue the steps (13)–(42) for adjusting the number of active nodes, until ζu<Δζ; (44) The method for adjusting the number of active nodes in the area atldistance from the sink (45) Let ΔE=Emax-El, EΔ=ΔEϑ; (46)  Compute Δnl base Eq. (21) according ΔE; (47)  If  Δnl>1 (48)   nl=nl+Δnl; (49)  Else (50)   nl=nl+1; (51)  End if


## 5. Performance Analysis in Theory

### 5.1. Broadcast Delay Analysis

This section analyzes the transmission delay in the FPCD scheme. Program codes are generated by the sink and then are spread to the area far away from the sink. In this paper, the broadcast method for program code is that the sink sends program codes to nodes in the transmission range, the nodes that receive the program codes continue transmitting program codes until reach the network boundary. In this process, each node only receives program codes once when the program codes are transmitted by the sink once. Program codes dissemination can be divided into 2 stages; in the first stage, program codes are spread to the area far away from the sink, until program codes reach the network boundary. In the second stage, though program codes reach the network boundary, some nodes cannot receive program codes; program codes are broadcast several times until the broadcast is over. The first stage is a stage of expansion; the area for broadcasting program codes expands outward; the second stage is the stabilization phase. At this stage, the area of program codes dissemination is not expanded, but the number of broadcast nodes is increased. Thus, the delay of program codes dissemination can be divided into two parts:(1) the delay in the expansion phase; (2) the delay in stabilization phase. The delay in the expansion phase mainly depends on the time for spreading program codes to the network boundary. However, the requirement time for spreading program codes to the network boundary is very complex; it depends on several factors: (1) network size: the larger the network is, the longer the transmission delay is; (2) the transmission radius of node: the bigger the transmission radius is, the farther the transmission distance is when program codes are transmitted once, and thus the lower the transmission delay is; (3) the ratio of active node: apparently, the larger the number of active nodes is, the farther the distance traveled is, and the smaller the delay is. In the following, we analyze the expected distance for spreading program codes to the area far away from the sink, so that the expected hop for spreading program codes to the network boundary can be got in theory, which can obtain the minimum expected propagation delay in the first stage.Definition 4 (dissemination forwarding distancey).
As shown in Figure5, node A is broadcast node, node B is in the transmission range of node A, and the distance from node B to the sink is farther than the distance from nodes in the transmission range of node A to the sink. A line OA is used to connect the sink O and node A, and C is the intersection of broadcast radius of node A and line OA. The length from longitudinal projection point of node B in line OA to C is broadcast forwarding distance y.
Because the transmission range isr, broadcast forwarding distance y is in [0, 2r]. If y>r, this shows that program codes can be transmitted to nodes whose distance from the sink is longer than the distance from node A to the sink. But if y<r, this shows that program codes cannot be transmitted to nodes whose distance from the sink is longer than the distance form node A to the sink. The reason is that when node A broadcasts program codes, all nodes in the broadcast radius range of node A, whose distance from the sink is longer than the distance from node A to the sink, are in sleep states, and areas whose distance from the sink is shorter than the distance from node A to the sink have active nodes, and thus y<r. Such a broadcast is meaningful, and the program codes can be spread in the next time.Figure 5
The illustration of the broadcast forwarding distance.Theorem 5.
Considering the distance from nodeA to the sink is l m, the transmission radius is r and the density of network is ρ. The ratio of active node is ε. When program codes are spread once by node A, the expected traveled propagation distance is Gl:(23)Gl=∫02ry-r1-1-εϑl-r+ydyρ1-εAlyρ,where ϑ=2cos-1⁡(l2+l+y-r2-r2/2ll+y-r), (24)Aly=2r2cos-1⁡ξ-ξl+y-r2-ξ2-2cos-1⁡ξl+y-rl+y-r2-ξl+y-r2-ξ2,ξ=l2+l+y-r2-r22l.Proof.
As shown in Figure5, when the maximum distance for spreading program codes is l-r+y, it shows that all nodes in the shaded areas are in sleep status, but some nodes in the range of l-r+y distance are in active status. The area of the black shaded area in Figure 6 is calculated as follows: the sector area ∢CAB as the center of A minus arcuate area COB^ which is the intersecting area of the arc as the center of the sink O and the arc as the center of A. The arcuate area COB^ is divided into two parts: one is the area of the red shaded part, and the other is the area of triangle ⊿CAB. The area of the red shaded part is the sector area ∢COB minus the area of triangle ⊿COB. Due to ϑ=∠COB=2cos-1⁡(l2+l+y-r2-r2/2ll+y-r). Thus, the area of sector area ∢COB is 2cos-1⁡(l2+l+y-r2-r2/2ll+y-r)l+y-r2, the length of line OD is l2+l+y-r2-r2/2l, and the length of line DB is l+y-r2-l2+l+y-r2-r2/2l2. The area of triangle  ⊿COB is as follows:(25)l+y-r2-l2+l+y-r2-r22l2l2+l+y-r2-r22l.Thus, the area of red shaded area is (26)2cos-1⁡l2+l+y-r2-r22ll+y-rl+y-r2-l+y-r2-l2+l+y-r2-r22l2l2+l+y-r2-r22l.The length of line AD is l2+l+y-r2-r2/2l-l=(l+y-r2-r2-l2)/2l. The area of triangle ⊿CAB is(27)l+y-r2-r2-l22ll+y-r2-l2+l+y-r2-r22l2.∠CAB=2cos-1⁡((l+y-r2-r2-l2)/2lr). Thus, the area of sector area ∢CAB is 2r2cos-1⁡(l+y-r2-r2-l2/2lr), the area of the black shaded area in Figure 6 is(28)Aly=2r2cos-1⁡l+y-r2-r2-l22lr-l+y-r2-r2-l22ll+y-r2-l2+l+y-r2-r22l2-2cos-1⁡l2+l+y-r2-r22ll+y-rl+y-r2-l+y-r2-l2+l+y-r2-r22l2l2+l+y-r2-r22l.
However, the number of nodes in shaded area isAlyρ, the probability of which all nodes in shaded area are in sleep status is 1-εAlyρ.
But the probability of which area within the range of distancel-r+y from the sink has nodes in awake status is as follows: considering the width of this area is dy∣dy→0, thus the area of this area is ϑl-r+ydy.
The number of nodes in this area isϑl-r+ydyρ; thus, the probability of which area has one node at least in awake status is as follows:(29)1-1-εϑl-r+ydyρ.
The probability of spreading program codes to the area atl-r+y distance from the sink is as follows:(30)1-1-εϑl-r+ydyρ1-εAlyρ.
In this time, the forward propagation distance isy-r. Therefore, the total expected forwarding distance is as follows:(31)Gl=∫02ry-r1-1-εϑl-r+ydyρ1-εAlyρ.Figure 6
The calculation of the broadcast forwarding distance.Since the expected forwarding distance is shown in Theorem5 when program codes is spread in one hop, the following will estimate broadcast times of spreading program codes from the sink to the network boundary. Gl in Theorem 5 is the expected forwarding distance of spreading program codes from nodes at l m distance from the sink to other node. Because the Gl in different distance has little difference, using G to express the forwarding distance in the network with transmission radius is r. If the distance from the sink to the network boundary is R, the hop count can be calculated as(32)Hr=RG.Since the delay for spreading program codes in each hop isτ, the time for spreading program codes from the sink to the network boundary is τHr. When program codes is spread to the network boundary, the network will be into the second stage. In the process of spreading program codes to network boundary, nodes that receive program codes will broadcast the program codes to neighbor nodes, nodes in the network boundary will be the last to receive the program codes. Thus, the time for spreading program codes in second stage is the time of spreading program codes to nodes in the network boundary. The required time in second stage is regarded as the time in which all nodes in the broadcast cycle receive program codes, considering the duty length of node is τ, its duty cycle ε can ensure the ratio ε of active node. Because program codes can be broadcast once in one τ, thus after (1/ε)τ cycle, each node will be in awake status once, all nodes can receive the program codes. From the above analysis, it can be obtained that the propagation delay of the entire network is as follows:(33)D=RG+1ετ.Theorem5 gives the dissemination forwarding distance. Many factors affect dissemination forwarding distance; Figure 7 shows the relationship between the active node ratio and forwarding distance. In Figure 7, the forwarding distance refers to the transmission distance for spreading program codes to the area far away from the sink; it is expressed as y→. As can be seen from Figure 5, if most areas in the transmission radius of node A do not have nodes in active status, then y→≤0. The probability of this situation is 1-ερπr2/2, it is small. Thus, generally speaking, y→>0. The bigger ε is, the probability that there are active node in the area far away from the sink in the range of broadcast of node A is bigger, and y→ is larger. The results are shown in Figure 7; the bigger ε is, the bigger y→ is, which shows that the forwarding distance of broadcast once is bigger, and the delay of spreading program codes to entire network is smaller.Figure 7
The relation ofε and forwarding distance.Figure8 shows the y→ in different ρ. Its trend is the greater node density is, the greater its y→ is. If the number of active nodes is large, the probability that the node far away from the sink in the range of broadcast of node A receive program codes is larger, the longer the forwarding distance is. At the same time, when the density of node is increased, program codes are easily diffused and the delay for spreading program codes is smaller.Figure 8
The relation ofρ and forwarding distance.Figure9 shows the forwarding distance under different transmission radius r. As can be seen, the bigger r is, the bigger y→ is, and the smaller the transmission delay is. But when r=R, the delay of network in the first stage is 0. Figure 10 gives y→ under different r and ρ. The rule is that the bigger r is and the bigger ρ is, the bigger y→ is.Figure 9
The forwarding distance under differentε and r.Figure 10
The forwarding distance under differentρ and r.Figures11 and 12 give the transmission delay under different node density ρ and different active node ratio ε. The transmission delay in the figure is referred to the expected delay of network. The rule is that when the node density and the active node ratio ε are increased, the dissemination delay is reduced. Its reason is that when ρ and ε are increased, large number of nodes can receive the program codes in program codes dissemination, the data can be broadcast to other nodes by those nodes, the speed for broadcasting data is fast. When ρ and ε are increased, the forwarding distance is longer when program codes broadcast once according to Theorem 5, the speed of spreading program codes to network boundary is fast, and the delay is small. The bigger r is, the longer forwarding distance is, and the smaller the delay is.Figure 11
The dissemination delay under differentr and ρ.Figure 12
The dissemination delay under differentr and ε.Based on Section4, Figure 13 shows the value of ε in different areas. In the FPCD scheme, the area near the sink adopts the same ε with the previous scheme; it is the initial values 0.2 and 0.3 of ε in Figure 13. Then, the FPCD scheme increases the ε in the area far from the sink according to the energy consumption. It can be seen that ε in the area far away from the sink is higher than the initial ε.Figure 13
The value ofε in a FPCD scheme.Since different areas have differentε in the FPCD scheme, the forwarding distance in different areas is different. The bigger ε is, the longer the forwarding distance is, and the delay is smaller; it is shown in Figure 14. Figure 15 gives the dissemination delay in the FPCD scheme and other schemes. Compared to the scheme with the same ε, the dissemination delay in the FPCD scheme is reduced by 13.25%–27.57%.Figure 14
The forwarding distance in a FPCD scheme.Figure 15
The dissemination delay in FPCD scheme and other schemes under differentr.


### 5.2. Broadcast Times Analysis

In program codes dissemination, broadcasting program codes is the most energy-consuming operation; therefore, the best method to save energy is to reduce broadcast times. There is an example to illustrate the relationship ofε and broadcast times. The bigger ε is, the smaller the requirement broadcast times are. The most special case is that when r=R, it shows that the sink broadcasts program codes once, and all nodes in the network can receive program codes. If ε=1, all nodes in the network can receive data when the sink spread program codes once. But if ε is smaller, the number of nodes that receive data is less; thus, the requirement broadcast times are long. Theorem 6 gives the requirement broadcast times in a certain ε.Figure16 shows the relationship between ε and broadcast times. With the increase of ε, the requirement broadcast times of program codes dissemination are reduced. The broadcast times can be obtained according to the different ε in different areas in Figure 13 and Theorem 6 (see Figure 17). Finally, Figure 18 shows the total broadcast times in the FPCD scheme and other schemes; it can be seen that the FPCD scheme can reduce the requirement broadcast times greatly.Figure 16
The number of broadcasts under the differentr.Figure 17
The broadcast times in different areas in FPCD scheme and other schemes.Figure 18
The broadcast times in FPCD scheme and the scheme with sameε under different r.Theorem 6.
Considering a network with network radiusR, the transmission radius is r and node density of network is ρ. The ratio of active node is ε. The requirement broadcast times B of all the network and the number of receiving data R are(34)B=R2r21εR=πR2ρ-R2r21ε.Proof.
The number of nodes within the communication range isnr=πr2ρ. When one node broadcasts program codes, εnr-1 nodes will receive the data. Because the status of node will change in the (1/ε)τ cycle, thus the number of nodes updated is εnr each cycle. That is to say, in the (1/ε)τ cycle, the status of each node can be updated once, and there are 1/ε nodes to spread program codes; εnr-1 nodes receive data packet in one broadcast.
The number of broadcast packets in the network isnR=πR2ρ. A total of communication cell is m=πR2ρ/πr2ρ=R2/r2; thus, the amount of broadcast in entire network is as follows: broadcast time is B=m(1/ε)=(R2/r2)(1/ε); the times for receiving data are as follows:(35)R=mnr-1ε=R2r2πr2ρ-1ε=πR2ρ-R2r21ε.


### 5.3. Energy Consumption and Network Lifetime Analysis

This section analyzes the energy consumption in the FPCD scheme and previous schemes. Firstly, as long as the network has energy left, the FPCD scheme can make full use of left energy to increase the number of active nodes, thereby improving the performance of program codes dissemination. Thus, energy efficiency in the FPCD scheme is 100% in theory.Considering the energy efficiency in other schemes. From the above analysis, each node receives program codes once. If one node receives new data, the node can spread the data once. Thus, the energy consumption of program codes dissemination is balanced. But in the process of data collection, the energy consumption of network is not balanced. The energy left of network is given.In the process of data collection, the energy consumption of node nearest the sink is(36)Emax=z0+1+z0z0+1r2l0λωt+z0+z0z0+1r2l0λωr∣z0=R-l0r.The energy consumption of the area at l distance from the sink (37)El=z+1+zz+1r2lλωt+z+zz+1r2lλωr∣z=R-lr.Thus, the energy left in the area at l distance from the sink is (38)Els=Emax-El.The remaining energy of entire network is that considering a small arc area at thel distance from the sink, the width of the arc area is dl; when dl→0, the area of this arc area is 2πldl; thus, the remaining energy of this area is 2πldlρEls. So the energy left of all network is as follows:(39)Etotals=∫l0R2πlρElsdl=2πρ∫l0RlEmax-Eldl.The available energy consumption of the network isπR2ρEmax.Thus, the energy efficient is as follows:(40)μe=EtotalsπR2ρEmax=2∫l0RlEmax-EldlR2Emax.Based on the above analysis, Figure19 gives the energy consumption of data collection in different areas. As can be seen, the energy consumption in the area near the sink is higher than the energy consumption in the area far away from the sink; thus, the area far away from the sink has much energy left. It can be seen from Figure 20 that most areas have 80% energy left; the average energy left reaches 90%. Figure 21 shows the energy consumption in the FPCD scheme and the previous scheme. It shows that the remaining energy network can fully be used for program dissemination, the FPCD scheme has a very high energy efficiency, and it is more than 4 times that in other strategies.Figure 19
The energy consumption for data collection in different areas.Figure 20
The ratio of energy left of node in different areas in the network to total energy of nodes.Figure 21
The energy efficiency in the FPCD scheme and other schemes.


## 5.1. Broadcast Delay Analysis

This section analyzes the transmission delay in the FPCD scheme. Program codes are generated by the sink and then are spread to the area far away from the sink. In this paper, the broadcast method for program code is that the sink sends program codes to nodes in the transmission range, the nodes that receive the program codes continue transmitting program codes until reach the network boundary. In this process, each node only receives program codes once when the program codes are transmitted by the sink once. Program codes dissemination can be divided into 2 stages; in the first stage, program codes are spread to the area far away from the sink, until program codes reach the network boundary. In the second stage, though program codes reach the network boundary, some nodes cannot receive program codes; program codes are broadcast several times until the broadcast is over. The first stage is a stage of expansion; the area for broadcasting program codes expands outward; the second stage is the stabilization phase. At this stage, the area of program codes dissemination is not expanded, but the number of broadcast nodes is increased. Thus, the delay of program codes dissemination can be divided into two parts:(1) the delay in the expansion phase; (2) the delay in stabilization phase. The delay in the expansion phase mainly depends on the time for spreading program codes to the network boundary. However, the requirement time for spreading program codes to the network boundary is very complex; it depends on several factors: (1) network size: the larger the network is, the longer the transmission delay is; (2) the transmission radius of node: the bigger the transmission radius is, the farther the transmission distance is when program codes are transmitted once, and thus the lower the transmission delay is; (3) the ratio of active node: apparently, the larger the number of active nodes is, the farther the distance traveled is, and the smaller the delay is. In the following, we analyze the expected distance for spreading program codes to the area far away from the sink, so that the expected hop for spreading program codes to the network boundary can be got in theory, which can obtain the minimum expected propagation delay in the first stage.Definition 4 (dissemination forwarding distancey).
As shown in Figure5, node A is broadcast node, node B is in the transmission range of node A, and the distance from node B to the sink is farther than the distance from nodes in the transmission range of node A to the sink. A line OA is used to connect the sink O and node A, and C is the intersection of broadcast radius of node A and line OA. The length from longitudinal projection point of node B in line OA to C is broadcast forwarding distance y.
Because the transmission range isr, broadcast forwarding distance y is in [0, 2r]. If y>r, this shows that program codes can be transmitted to nodes whose distance from the sink is longer than the distance from node A to the sink. But if y<r, this shows that program codes cannot be transmitted to nodes whose distance from the sink is longer than the distance form node A to the sink. The reason is that when node A broadcasts program codes, all nodes in the broadcast radius range of node A, whose distance from the sink is longer than the distance from node A to the sink, are in sleep states, and areas whose distance from the sink is shorter than the distance from node A to the sink have active nodes, and thus y<r. Such a broadcast is meaningful, and the program codes can be spread in the next time.Figure 5
The illustration of the broadcast forwarding distance.Theorem 5.
Considering the distance from nodeA to the sink is l m, the transmission radius is r and the density of network is ρ. The ratio of active node is ε. When program codes are spread once by node A, the expected traveled propagation distance is Gl:(23)Gl=∫02ry-r1-1-εϑl-r+ydyρ1-εAlyρ,where ϑ=2cos-1⁡(l2+l+y-r2-r2/2ll+y-r), (24)Aly=2r2cos-1⁡ξ-ξl+y-r2-ξ2-2cos-1⁡ξl+y-rl+y-r2-ξl+y-r2-ξ2,ξ=l2+l+y-r2-r22l.Proof.
As shown in Figure5, when the maximum distance for spreading program codes is l-r+y, it shows that all nodes in the shaded areas are in sleep status, but some nodes in the range of l-r+y distance are in active status. The area of the black shaded area in Figure 6 is calculated as follows: the sector area ∢CAB as the center of A minus arcuate area COB^ which is the intersecting area of the arc as the center of the sink O and the arc as the center of A. The arcuate area COB^ is divided into two parts: one is the area of the red shaded part, and the other is the area of triangle ⊿CAB. The area of the red shaded part is the sector area ∢COB minus the area of triangle ⊿COB. Due to ϑ=∠COB=2cos-1⁡(l2+l+y-r2-r2/2ll+y-r). Thus, the area of sector area ∢COB is 2cos-1⁡(l2+l+y-r2-r2/2ll+y-r)l+y-r2, the length of line OD is l2+l+y-r2-r2/2l, and the length of line DB is l+y-r2-l2+l+y-r2-r2/2l2. The area of triangle  ⊿COB is as follows:(25)l+y-r2-l2+l+y-r2-r22l2l2+l+y-r2-r22l.Thus, the area of red shaded area is (26)2cos-1⁡l2+l+y-r2-r22ll+y-rl+y-r2-l+y-r2-l2+l+y-r2-r22l2l2+l+y-r2-r22l.The length of line AD is l2+l+y-r2-r2/2l-l=(l+y-r2-r2-l2)/2l. The area of triangle ⊿CAB is(27)l+y-r2-r2-l22ll+y-r2-l2+l+y-r2-r22l2.∠CAB=2cos-1⁡((l+y-r2-r2-l2)/2lr). Thus, the area of sector area ∢CAB is 2r2cos-1⁡(l+y-r2-r2-l2/2lr), the area of the black shaded area in Figure 6 is(28)Aly=2r2cos-1⁡l+y-r2-r2-l22lr-l+y-r2-r2-l22ll+y-r2-l2+l+y-r2-r22l2-2cos-1⁡l2+l+y-r2-r22ll+y-rl+y-r2-l+y-r2-l2+l+y-r2-r22l2l2+l+y-r2-r22l.
However, the number of nodes in shaded area isAlyρ, the probability of which all nodes in shaded area are in sleep status is 1-εAlyρ.
But the probability of which area within the range of distancel-r+y from the sink has nodes in awake status is as follows: considering the width of this area is dy∣dy→0, thus the area of this area is ϑl-r+ydy.
The number of nodes in this area isϑl-r+ydyρ; thus, the probability of which area has one node at least in awake status is as follows:(29)1-1-εϑl-r+ydyρ.
The probability of spreading program codes to the area atl-r+y distance from the sink is as follows:(30)1-1-εϑl-r+ydyρ1-εAlyρ.
In this time, the forward propagation distance isy-r. Therefore, the total expected forwarding distance is as follows:(31)Gl=∫02ry-r1-1-εϑl-r+ydyρ1-εAlyρ.Figure 6
The calculation of the broadcast forwarding distance.Since the expected forwarding distance is shown in Theorem5 when program codes is spread in one hop, the following will estimate broadcast times of spreading program codes from the sink to the network boundary. Gl in Theorem 5 is the expected forwarding distance of spreading program codes from nodes at l m distance from the sink to other node. Because the Gl in different distance has little difference, using G to express the forwarding distance in the network with transmission radius is r. If the distance from the sink to the network boundary is R, the hop count can be calculated as(32)Hr=RG.Since the delay for spreading program codes in each hop isτ, the time for spreading program codes from the sink to the network boundary is τHr. When program codes is spread to the network boundary, the network will be into the second stage. In the process of spreading program codes to network boundary, nodes that receive program codes will broadcast the program codes to neighbor nodes, nodes in the network boundary will be the last to receive the program codes. Thus, the time for spreading program codes in second stage is the time of spreading program codes to nodes in the network boundary. The required time in second stage is regarded as the time in which all nodes in the broadcast cycle receive program codes, considering the duty length of node is τ, its duty cycle ε can ensure the ratio ε of active node. Because program codes can be broadcast once in one τ, thus after (1/ε)τ cycle, each node will be in awake status once, all nodes can receive the program codes. From the above analysis, it can be obtained that the propagation delay of the entire network is as follows:(33)D=RG+1ετ.Theorem5 gives the dissemination forwarding distance. Many factors affect dissemination forwarding distance; Figure 7 shows the relationship between the active node ratio and forwarding distance. In Figure 7, the forwarding distance refers to the transmission distance for spreading program codes to the area far away from the sink; it is expressed as y→. As can be seen from Figure 5, if most areas in the transmission radius of node A do not have nodes in active status, then y→≤0. The probability of this situation is 1-ερπr2/2, it is small. Thus, generally speaking, y→>0. The bigger ε is, the probability that there are active node in the area far away from the sink in the range of broadcast of node A is bigger, and y→ is larger. The results are shown in Figure 7; the bigger ε is, the bigger y→ is, which shows that the forwarding distance of broadcast once is bigger, and the delay of spreading program codes to entire network is smaller.Figure 7
The relation ofε and forwarding distance.Figure8 shows the y→ in different ρ. Its trend is the greater node density is, the greater its y→ is. If the number of active nodes is large, the probability that the node far away from the sink in the range of broadcast of node A receive program codes is larger, the longer the forwarding distance is. At the same time, when the density of node is increased, program codes are easily diffused and the delay for spreading program codes is smaller.Figure 8
The relation ofρ and forwarding distance.Figure9 shows the forwarding distance under different transmission radius r. As can be seen, the bigger r is, the bigger y→ is, and the smaller the transmission delay is. But when r=R, the delay of network in the first stage is 0. Figure 10 gives y→ under different r and ρ. The rule is that the bigger r is and the bigger ρ is, the bigger y→ is.Figure 9
The forwarding distance under differentε and r.Figure 10
The forwarding distance under differentρ and r.Figures11 and 12 give the transmission delay under different node density ρ and different active node ratio ε. The transmission delay in the figure is referred to the expected delay of network. The rule is that when the node density and the active node ratio ε are increased, the dissemination delay is reduced. Its reason is that when ρ and ε are increased, large number of nodes can receive the program codes in program codes dissemination, the data can be broadcast to other nodes by those nodes, the speed for broadcasting data is fast. When ρ and ε are increased, the forwarding distance is longer when program codes broadcast once according to Theorem 5, the speed of spreading program codes to network boundary is fast, and the delay is small. The bigger r is, the longer forwarding distance is, and the smaller the delay is.Figure 11
The dissemination delay under differentr and ρ.Figure 12
The dissemination delay under differentr and ε.Based on Section4, Figure 13 shows the value of ε in different areas. In the FPCD scheme, the area near the sink adopts the same ε with the previous scheme; it is the initial values 0.2 and 0.3 of ε in Figure 13. Then, the FPCD scheme increases the ε in the area far from the sink according to the energy consumption. It can be seen that ε in the area far away from the sink is higher than the initial ε.Figure 13
The value ofε in a FPCD scheme.Since different areas have differentε in the FPCD scheme, the forwarding distance in different areas is different. The bigger ε is, the longer the forwarding distance is, and the delay is smaller; it is shown in Figure 14. Figure 15 gives the dissemination delay in the FPCD scheme and other schemes. Compared to the scheme with the same ε, the dissemination delay in the FPCD scheme is reduced by 13.25%–27.57%.Figure 14
The forwarding distance in a FPCD scheme.Figure 15
The dissemination delay in FPCD scheme and other schemes under differentr.


## 5.2. Broadcast Times Analysis

In program codes dissemination, broadcasting program codes is the most energy-consuming operation; therefore, the best method to save energy is to reduce broadcast times. There is an example to illustrate the relationship ofε and broadcast times. The bigger ε is, the smaller the requirement broadcast times are. The most special case is that when r=R, it shows that the sink broadcasts program codes once, and all nodes in the network can receive program codes. If ε=1, all nodes in the network can receive data when the sink spread program codes once. But if ε is smaller, the number of nodes that receive data is less; thus, the requirement broadcast times are long. Theorem 6 gives the requirement broadcast times in a certain ε.Figure16 shows the relationship between ε and broadcast times. With the increase of ε, the requirement broadcast times of program codes dissemination are reduced. The broadcast times can be obtained according to the different ε in different areas in Figure 13 and Theorem 6 (see Figure 17). Finally, Figure 18 shows the total broadcast times in the FPCD scheme and other schemes; it can be seen that the FPCD scheme can reduce the requirement broadcast times greatly.Figure 16
The number of broadcasts under the differentr.Figure 17
The broadcast times in different areas in FPCD scheme and other schemes.Figure 18
The broadcast times in FPCD scheme and the scheme with sameε under different r.Theorem 6.
Considering a network with network radiusR, the transmission radius is r and node density of network is ρ. The ratio of active node is ε. The requirement broadcast times B of all the network and the number of receiving data R are(34)B=R2r21εR=πR2ρ-R2r21ε.Proof.
The number of nodes within the communication range isnr=πr2ρ. When one node broadcasts program codes, εnr-1 nodes will receive the data. Because the status of node will change in the (1/ε)τ cycle, thus the number of nodes updated is εnr each cycle. That is to say, in the (1/ε)τ cycle, the status of each node can be updated once, and there are 1/ε nodes to spread program codes; εnr-1 nodes receive data packet in one broadcast.
The number of broadcast packets in the network isnR=πR2ρ. A total of communication cell is m=πR2ρ/πr2ρ=R2/r2; thus, the amount of broadcast in entire network is as follows: broadcast time is B=m(1/ε)=(R2/r2)(1/ε); the times for receiving data are as follows:(35)R=mnr-1ε=R2r2πr2ρ-1ε=πR2ρ-R2r21ε.


## 5.3. Energy Consumption and Network Lifetime Analysis

This section analyzes the energy consumption in the FPCD scheme and previous schemes. Firstly, as long as the network has energy left, the FPCD scheme can make full use of left energy to increase the number of active nodes, thereby improving the performance of program codes dissemination. Thus, energy efficiency in the FPCD scheme is 100% in theory.Considering the energy efficiency in other schemes. From the above analysis, each node receives program codes once. If one node receives new data, the node can spread the data once. Thus, the energy consumption of program codes dissemination is balanced. But in the process of data collection, the energy consumption of network is not balanced. The energy left of network is given.In the process of data collection, the energy consumption of node nearest the sink is(36)Emax=z0+1+z0z0+1r2l0λωt+z0+z0z0+1r2l0λωr∣z0=R-l0r.The energy consumption of the area at l distance from the sink (37)El=z+1+zz+1r2lλωt+z+zz+1r2lλωr∣z=R-lr.Thus, the energy left in the area at l distance from the sink is (38)Els=Emax-El.The remaining energy of entire network is that considering a small arc area at thel distance from the sink, the width of the arc area is dl; when dl→0, the area of this arc area is 2πldl; thus, the remaining energy of this area is 2πldlρEls. So the energy left of all network is as follows:(39)Etotals=∫l0R2πlρElsdl=2πρ∫l0RlEmax-Eldl.The available energy consumption of the network isπR2ρEmax.Thus, the energy efficient is as follows:(40)μe=EtotalsπR2ρEmax=2∫l0RlEmax-EldlR2Emax.Based on the above analysis, Figure19 gives the energy consumption of data collection in different areas. As can be seen, the energy consumption in the area near the sink is higher than the energy consumption in the area far away from the sink; thus, the area far away from the sink has much energy left. It can be seen from Figure 20 that most areas have 80% energy left; the average energy left reaches 90%. Figure 21 shows the energy consumption in the FPCD scheme and the previous scheme. It shows that the remaining energy network can fully be used for program dissemination, the FPCD scheme has a very high energy efficiency, and it is more than 4 times that in other strategies.Figure 19
The energy consumption for data collection in different areas.Figure 20
The ratio of energy left of node in different areas in the network to total energy of nodes.Figure 21
The energy efficiency in the FPCD scheme and other schemes.


## 6. Experimental Results and Analyses

OMNET++ is employed for experimental verification [35]. Without loss of generality, the network parameters are as follows: network radius R = 400 m, packet transfer radius r = 50 m, event generation probability of node in one round λ = 0.1, and 200 nodes are deployed. Other parameters settings refer to Table 1. We compare FPCD scheme against the same active ratio scheme. In the same active ratio scheme, the number of active nodes in different areas is the same. That is, the number of active nodes in the area far from the sink is the same as the number of active nodes in the area near the sink. Program codes not only are transmitted to the network boundary but also are transmitted to the neighbor nodes. The aim is that all nodes in the network receive the program codes produced by the sink.Table 1
Network parameters.
Symbol Description Value d 0 Threshold distance (m) 87 r s Sensing range (m) 15 E e l e c Transmitting circuit loss (nJ/bit) 50 e f s Power amplification for the free space (pJ/bit/m2) 10 e a m p Power amplification for the multipath fading (pJ/bit/m4) 0.0013 E i n i t Initial energy (J) 0.5


### 6.1. Comparative Analysis of Broadcast Times

The number of broadcast nodes is shown in Figure22. As can be seen, the number of broadcast nodes in the FPCD scheme is higher than that in the same active ratio scheme. When the ratio of active nodes in the area near the sink is 30%, the number of broadcast nodes in those two schemes is higher than the number of broadcast nodes in the network with 20% active nodes in the area near to the sink. The ratio of the number of broadcast nodes in the FPCD scheme to the same active ratio scheme is shown in Figure 23. From Figure 23, the number of broadcast nodes in the FPCD scheme is 1.08889–2 times that in the same active ratio scheme when the ratio of active nodes in the area near the sink is 30%. The number of broadcast nodes in the FPCD scheme is 1.08824–2.5 times that in the same active ratio scheme when the ratio of active nodes in the area near to the sink is 20%. It shows that FPCD scheme has better performance.Figure 22
The number of broadcast nodes in FPCD scheme and the same active ratio scheme.Figure 23
The ratio of number of broadcast nodes in FPCD scheme to the same active ratio scheme.


### 6.2. Comparative Analysis of Broadcast Delay

The transmission delay of network under different proportion of active nodes in the area near the sink in the FPCD scheme and the same active ratio scheme is given in Figure24. As can be seen, (1) with the increase of the ratio of active nodes in the area near the sink, the transmission delay of network is reduced in those two schemes. The reason is that with the increase of ratio of active nodes in the area near to the sink, the energy consumption of the nodes nearest the sink is increased. Thus, there is more energy left in the areas far away from the sink, the energy left in the areas far away from the sink should be used to increase the number of active nodes while retaining the network lifetime. Thus, the program codes can be transmitted to all nodes except the nodes that never receive the program codes with a short time. (2) The transmission relay of network in the FPCD scheme is smaller than that of the same active ratio scheme.Figure 24
The transmission delay under difference ratio of active nodes in the area near the sink.The ratio of transmission delay of network under different ratio of active nodes in the area near the sink in the FPCD scheme to the same active ratio scheme is given in Figure25. As can be seen, the transmission delay of network in FPCD scheme is 0.63921 times that in the same active ratio scheme when the ratio of active nodes in the area near the sink is 30%. It shows that the FPCD scheme has better performance.Figure 25
The ratio of transmission delay under difference ratio of active nodes in the area near the sink in FPCD scheme to PCDE scheme.The transmission delay of network under different transmission radiusr in the FPCD scheme and the same active ratio scheme is given in Figure 26. It can be seen that no matter what the transmission radius r is, the transmission delay of network in the FPCD scheme is smaller than that of the same active ratio scheme. The transmission delay of network is reduced with the increase of transmission radius r. The reasons are that (1) in the FPCD scheme, the number of active nodes in the area far away from the sink is increased, when the sink spreads program codes to nodes; there are many nodes in the range of transmission radius; the program codes can be spread to all nodes quickly; thus, the program codes can be spread to all nodes except the nodes that never receive the program codes with a very short time. In the FPCD scheme, the number of active nodes in the area far away from the sink is increased. Thus, the transmission delay is reduced. (2) When the r increase, the hop count from the sink to nodes which are farthest from the sink is reduced. When the sink spread the program codes to the nodes, the program codes can reach the nodes far away from the sink in a small hop count, so the transmission delay is reduced.Figure 26
The transmission delay under different transmission radiusr in FPCD scheme and the same active ratio scheme.The ratio of transmission delay of network under different transmission radiusr in the FPCD scheme to the same active ratio scheme is given in Figure 27. The transmission delay in FPCD scheme is 1.1076–2.05791 times that in the same active ratio scheme when the ratio of active nodes in the area near the sink is 20%.Figure 27
The ratio transmission delay under different transmission radiusr in FPCD scheme to the same active ratio scheme.The transmission delay of network under different network radiusR in the FPCD scheme and the same active ratio scheme is shown in Figure 28. It can be seen that the transmission delay of network in the FPCD scheme is smaller than that in the same active ratio scheme. The transmission delay of network is increased with the increase of network radius R. The larger the network radius R is, the hop counts from the sink to the nodes which farthest from the sink is increased due to the fixed transmission radius. Thus, when the sink sends program codes, the nodes which are farthest from the sink receive the program codes at more hop count, resulting in bigger transmission delay.Figure 28
The transmission delay under different transmission radiusR in FPCD scheme and the same active ratio scheme.


### 6.3. Comparative Analysis of Energy Consumption and Network Lifetime

The energy consumption of nodes in different areas in the FPCD scheme and the same active ratio scheme is given in Figure29. As can be seen, (1) when the nodes’ distance from the sink is 10, the energy consumption of nodes in the area in the FPCD scheme is lower than that in the same active ratio scheme. (2) But when the nodes’ distance from the sink is bigger than 20, the energy consumption of nodes in those areas in the FPCD scheme is higher than the energy consumption of nodes in those areas in the same active ratio scheme, and the energy consumption in those areas is not bigger than the maximum energy consumption in the network, which shows that the FPCD scheme cannot affect the network lifetime. The reason is that, in the FPCD scheme, the number of active nodes in the area far away from the sink is increased. The number of receiving program codes is more, and the number of transmitting program codes is more. Thus, the energy consumption in this area in FPCD scheme is much higher than that of the same active ratio scheme.Figure 29
The energy consumption in different areas.The ratio of energy consumption of nodes in different areas in the FPCD scheme to the same active ratio scheme is shown in Figure30. It can be seen that (1) when the nodes’ distance from the sink is 30, the energy consumption of this area in FPCD scheme is 0.96263 times that of the same active ratio scheme. In the other areas, the energy consumption in the FPCD scheme is 1.00148–10.23938 times that in the same active ratio scheme. It shows that the FPCD scheme can make full use of the energy left in the area far from the sink while retaining network lifetime.Figure 30
The ratio of energy consumption in different areas in FPCD scheme to PCDE scheme.The total of energy consumption under different ratios of active nodes in the area near the sink in FPCD scheme and the same active ratio scheme is given in Figure31. As can be seen, (1) with the increase of the ratio of active nodes in the area near the sink, the total of energy consumption is increased. (2) The total of energy consumption in the FPCD scheme is higher than that in the same active ratio scheme. In the FPCD scheme, the number of active nodes in the area far from the sink is increased. When the proportion of active nodes nearest the sink is increased, the energy consumption of nodes near the sink is higher. Thus, there is more energy left to increase the number of active nodes in the areas far away from the sink. Thus, the number of active nodes in the areas far away from the sink is more. Nodes in areas far from the sink consume more energy, and thus the total of energy consumption in the network increased.Figure 31
The total of energy consumption under different ratio of active nodes in the area near the sink in FPCD scheme and the same active ratio scheme.Network lifetime under different proportion of active nodes nearest to the sink in the FPCD scheme and the same active ratio scheme is given in Figure32. As can be seen, the network lifetime in the FPCD scheme is not lower than that in PCDE scheme. Though the total of energy consumption in the FPCD scheme is higher than that in the same active ratio scheme, the FPCD scheme cannot affect the network lifetime.Figure 32
Network lifetime under different ratio of active nodes in the area near the sink in FPCD scheme and the same active ratio scheme.The total of energy consumption under different network radiusr in the FPCD scheme and the same active ratio scheme is given in Figure 33. From Figure 33, the total of energy consumption in the FPCD scheme is higher than that of the same active ratio scheme. In the FPCD scheme, the number of active nodes in the area far from the sink is increased. When the sink spreads program codes, nodes far from the sink receive large number of program codes from the last nodes, and the energy consumption in this areas for receiving the program codes is increased. But at the same time, those nodes will transmit those program codes to many active nodes, the energy consumption for transmitting program codes is increased. In the same active ratio scheme, the number of active nodes is the same in different areas. Thus, the total of energy consumption in the FPCD scheme is higher than that in the same active ratio scheme. It can be seen from Figure 29. The energy consumption in the area near to the sink in the FPCD scheme is smaller than that in the same active ratio scheme and the energy consumption in other areas in the FPCD scheme is higher than that of the same active ratio scheme. The total of energy consumption in the FPCD scheme is higher than that of the same active ratio scheme. It shows that the FPCD scheme can improve energy efficient.Figure 33
The total of energy consumption under different transmission radiusr in FPCD scheme and the same active ratio scheme.Network lifetime under different network radiusr in the FPCD scheme and the same active ratio scheme is given in Figure 34. As can be seen, the network lifetime in the FPCD scheme is not lower than that in the same active ratio scheme. Though the number of active nodes in the area far away from the sink is increased, the energy consumption of this area is not higher than the energy consumption of nodes near to the sink. Thus, the network lifetime in the FPCD scheme is not lower than that of the same active ratio scheme.Figure 34
Network lifetime under different transmission radiusr in FPCD scheme and the same active ratio scheme.The total of energy consumption under different network radiusR in the FPCD scheme and the same active ratio scheme is given in Figure 35. From Figure 35, the total of energy consumption in the FPCD scheme is higher than that in the same active ratio scheme. With the increase of the network radius R, due to the fixed transmission radius r, the hop counts from the sink to nodes farthest from the sink are increased. The energy consumption for spreading the program codes from the sink to nodes farthest from the sink is higher. So the total of energy consumption of network in the FPCD scheme is higher than that in the same active ratio scheme.Figure 35
The total of energy consumption under different transmission radiusR in FPCD scheme and the same active ratio scheme.Network lifetime under different network radiusR in the FPCD scheme and the same active ratio scheme is given in Figure 36. As can be seen, network lifetime in the FPCD scheme is not lower than that of the same active ratio scheme. It shows that the FPCD scheme cannot damage the network lifetime. Tough the FPCD scheme has better performance from Figure 36, it makes full use of the energy to improve the number of active nodes far from the sink.Figure 36
Network lifetime under different transmission radiusR in FPCD scheme and the same active ratio scheme.


## 6.1. Comparative Analysis of Broadcast Times

The number of broadcast nodes is shown in Figure22. As can be seen, the number of broadcast nodes in the FPCD scheme is higher than that in the same active ratio scheme. When the ratio of active nodes in the area near the sink is 30%, the number of broadcast nodes in those two schemes is higher than the number of broadcast nodes in the network with 20% active nodes in the area near to the sink. The ratio of the number of broadcast nodes in the FPCD scheme to the same active ratio scheme is shown in Figure 23. From Figure 23, the number of broadcast nodes in the FPCD scheme is 1.08889–2 times that in the same active ratio scheme when the ratio of active nodes in the area near the sink is 30%. The number of broadcast nodes in the FPCD scheme is 1.08824–2.5 times that in the same active ratio scheme when the ratio of active nodes in the area near to the sink is 20%. It shows that FPCD scheme has better performance.Figure 22
The number of broadcast nodes in FPCD scheme and the same active ratio scheme.Figure 23
The ratio of number of broadcast nodes in FPCD scheme to the same active ratio scheme.


## 6.2. Comparative Analysis of Broadcast Delay

The transmission delay of network under different proportion of active nodes in the area near the sink in the FPCD scheme and the same active ratio scheme is given in Figure24. As can be seen, (1) with the increase of the ratio of active nodes in the area near the sink, the transmission delay of network is reduced in those two schemes. The reason is that with the increase of ratio of active nodes in the area near to the sink, the energy consumption of the nodes nearest the sink is increased. Thus, there is more energy left in the areas far away from the sink, the energy left in the areas far away from the sink should be used to increase the number of active nodes while retaining the network lifetime. Thus, the program codes can be transmitted to all nodes except the nodes that never receive the program codes with a short time. (2) The transmission relay of network in the FPCD scheme is smaller than that of the same active ratio scheme.Figure 24
The transmission delay under difference ratio of active nodes in the area near the sink.The ratio of transmission delay of network under different ratio of active nodes in the area near the sink in the FPCD scheme to the same active ratio scheme is given in Figure25. As can be seen, the transmission delay of network in FPCD scheme is 0.63921 times that in the same active ratio scheme when the ratio of active nodes in the area near the sink is 30%. It shows that the FPCD scheme has better performance.Figure 25
The ratio of transmission delay under difference ratio of active nodes in the area near the sink in FPCD scheme to PCDE scheme.The transmission delay of network under different transmission radiusr in the FPCD scheme and the same active ratio scheme is given in Figure 26. It can be seen that no matter what the transmission radius r is, the transmission delay of network in the FPCD scheme is smaller than that of the same active ratio scheme. The transmission delay of network is reduced with the increase of transmission radius r. The reasons are that (1) in the FPCD scheme, the number of active nodes in the area far away from the sink is increased, when the sink spreads program codes to nodes; there are many nodes in the range of transmission radius; the program codes can be spread to all nodes quickly; thus, the program codes can be spread to all nodes except the nodes that never receive the program codes with a very short time. In the FPCD scheme, the number of active nodes in the area far away from the sink is increased. Thus, the transmission delay is reduced. (2) When the r increase, the hop count from the sink to nodes which are farthest from the sink is reduced. When the sink spread the program codes to the nodes, the program codes can reach the nodes far away from the sink in a small hop count, so the transmission delay is reduced.Figure 26
The transmission delay under different transmission radiusr in FPCD scheme and the same active ratio scheme.The ratio of transmission delay of network under different transmission radiusr in the FPCD scheme to the same active ratio scheme is given in Figure 27. The transmission delay in FPCD scheme is 1.1076–2.05791 times that in the same active ratio scheme when the ratio of active nodes in the area near the sink is 20%.Figure 27
The ratio transmission delay under different transmission radiusr in FPCD scheme to the same active ratio scheme.The transmission delay of network under different network radiusR in the FPCD scheme and the same active ratio scheme is shown in Figure 28. It can be seen that the transmission delay of network in the FPCD scheme is smaller than that in the same active ratio scheme. The transmission delay of network is increased with the increase of network radius R. The larger the network radius R is, the hop counts from the sink to the nodes which farthest from the sink is increased due to the fixed transmission radius. Thus, when the sink sends program codes, the nodes which are farthest from the sink receive the program codes at more hop count, resulting in bigger transmission delay.Figure 28
The transmission delay under different transmission radiusR in FPCD scheme and the same active ratio scheme.


## 6.3. Comparative Analysis of Energy Consumption and Network Lifetime

The energy consumption of nodes in different areas in the FPCD scheme and the same active ratio scheme is given in Figure29. As can be seen, (1) when the nodes’ distance from the sink is 10, the energy consumption of nodes in the area in the FPCD scheme is lower than that in the same active ratio scheme. (2) But when the nodes’ distance from the sink is bigger than 20, the energy consumption of nodes in those areas in the FPCD scheme is higher than the energy consumption of nodes in those areas in the same active ratio scheme, and the energy consumption in those areas is not bigger than the maximum energy consumption in the network, which shows that the FPCD scheme cannot affect the network lifetime. The reason is that, in the FPCD scheme, the number of active nodes in the area far away from the sink is increased. The number of receiving program codes is more, and the number of transmitting program codes is more. Thus, the energy consumption in this area in FPCD scheme is much higher than that of the same active ratio scheme.Figure 29
The energy consumption in different areas.The ratio of energy consumption of nodes in different areas in the FPCD scheme to the same active ratio scheme is shown in Figure30. It can be seen that (1) when the nodes’ distance from the sink is 30, the energy consumption of this area in FPCD scheme is 0.96263 times that of the same active ratio scheme. In the other areas, the energy consumption in the FPCD scheme is 1.00148–10.23938 times that in the same active ratio scheme. It shows that the FPCD scheme can make full use of the energy left in the area far from the sink while retaining network lifetime.Figure 30
The ratio of energy consumption in different areas in FPCD scheme to PCDE scheme.The total of energy consumption under different ratios of active nodes in the area near the sink in FPCD scheme and the same active ratio scheme is given in Figure31. As can be seen, (1) with the increase of the ratio of active nodes in the area near the sink, the total of energy consumption is increased. (2) The total of energy consumption in the FPCD scheme is higher than that in the same active ratio scheme. In the FPCD scheme, the number of active nodes in the area far from the sink is increased. When the proportion of active nodes nearest the sink is increased, the energy consumption of nodes near the sink is higher. Thus, there is more energy left to increase the number of active nodes in the areas far away from the sink. Thus, the number of active nodes in the areas far away from the sink is more. Nodes in areas far from the sink consume more energy, and thus the total of energy consumption in the network increased.Figure 31
The total of energy consumption under different ratio of active nodes in the area near the sink in FPCD scheme and the same active ratio scheme.Network lifetime under different proportion of active nodes nearest to the sink in the FPCD scheme and the same active ratio scheme is given in Figure32. As can be seen, the network lifetime in the FPCD scheme is not lower than that in PCDE scheme. Though the total of energy consumption in the FPCD scheme is higher than that in the same active ratio scheme, the FPCD scheme cannot affect the network lifetime.Figure 32
Network lifetime under different ratio of active nodes in the area near the sink in FPCD scheme and the same active ratio scheme.The total of energy consumption under different network radiusr in the FPCD scheme and the same active ratio scheme is given in Figure 33. From Figure 33, the total of energy consumption in the FPCD scheme is higher than that of the same active ratio scheme. In the FPCD scheme, the number of active nodes in the area far from the sink is increased. When the sink spreads program codes, nodes far from the sink receive large number of program codes from the last nodes, and the energy consumption in this areas for receiving the program codes is increased. But at the same time, those nodes will transmit those program codes to many active nodes, the energy consumption for transmitting program codes is increased. In the same active ratio scheme, the number of active nodes is the same in different areas. Thus, the total of energy consumption in the FPCD scheme is higher than that in the same active ratio scheme. It can be seen from Figure 29. The energy consumption in the area near to the sink in the FPCD scheme is smaller than that in the same active ratio scheme and the energy consumption in other areas in the FPCD scheme is higher than that of the same active ratio scheme. The total of energy consumption in the FPCD scheme is higher than that of the same active ratio scheme. It shows that the FPCD scheme can improve energy efficient.Figure 33
The total of energy consumption under different transmission radiusr in FPCD scheme and the same active ratio scheme.Network lifetime under different network radiusr in the FPCD scheme and the same active ratio scheme is given in Figure 34. As can be seen, the network lifetime in the FPCD scheme is not lower than that in the same active ratio scheme. Though the number of active nodes in the area far away from the sink is increased, the energy consumption of this area is not higher than the energy consumption of nodes near to the sink. Thus, the network lifetime in the FPCD scheme is not lower than that of the same active ratio scheme.Figure 34
Network lifetime under different transmission radiusr in FPCD scheme and the same active ratio scheme.The total of energy consumption under different network radiusR in the FPCD scheme and the same active ratio scheme is given in Figure 35. From Figure 35, the total of energy consumption in the FPCD scheme is higher than that in the same active ratio scheme. With the increase of the network radius R, due to the fixed transmission radius r, the hop counts from the sink to nodes farthest from the sink are increased. The energy consumption for spreading the program codes from the sink to nodes farthest from the sink is higher. So the total of energy consumption of network in the FPCD scheme is higher than that in the same active ratio scheme.Figure 35
The total of energy consumption under different transmission radiusR in FPCD scheme and the same active ratio scheme.Network lifetime under different network radiusR in the FPCD scheme and the same active ratio scheme is given in Figure 36. As can be seen, network lifetime in the FPCD scheme is not lower than that of the same active ratio scheme. It shows that the FPCD scheme cannot damage the network lifetime. Tough the FPCD scheme has better performance from Figure 36, it makes full use of the energy to improve the number of active nodes far from the sink.Figure 36
Network lifetime under different transmission radiusR in FPCD scheme and the same active ratio scheme.


## 7. Conclusion

WSDNs have the important function for propagating program codes, but for some urgent applications, they often have very stringent requirements on program codes dissemination delay. So it is important to minimum transmission delay for spreading program codes while maximizing the network lifetime. In previous schemes, the transmission delay and network lifetime cannot be optimized at the same time. In this paper, a fast program codes dissemination (FPCD) scheme for wireless software defined networking is proposed to reduce the transmission delay while maximum network lifetime. The innovation of FPCD scheme is that the number of active nodes in different areas can be adjusted dynamically according to the energy difference between the energy consumption in this area and the maximum energy consumption in the network. The energy left can be full used to increase the number of active nodes to reduce the transmission delay while maximum the network lifetime. Thus, FPCD scheme has better performances.



---

*Source: 6907231-2016-10-18.xml*