Optimizing Retransmission Threshold in Wireless Sensor Networks

The retransmission threshold in wireless sensor networks is critical to the latency of data delivery in the networks. However, existing works on data transmission in sensor networks did not consider the optimization of the retransmission threshold, and they simply set the same retransmission threshold for all sensor nodes in advance. The method did not take link quality and delay requirement into account, which decreases the probability of a packet passing its delivery path within a given deadline. This paper investigates the problem of finding optimal retransmission thresholds for relay nodes along a delivery path in a sensor network. The object of optimizing retransmission thresholds is to maximize the summation of the probability of the packet being successfully delivered to the next relay node or destination node in time. A dynamic programming-based distributed algorithm for finding optimal retransmission thresholds for relay nodes along a delivery path in the sensor network is proposed. The time complexity is OnΔ·max1≤i≤n{ui}, where ui is the given upper bound of the retransmission threshold of sensor node i in a given delivery path, n is the length of the delivery path and Δ is the given upper bound of the transmission delay of the delivery path. If Δ is greater than the polynomial, to reduce the time complexity, a linear programming-based (1+pmin)-approximation algorithm is proposed. Furthermore, when the ranges of the upper and lower bounds of retransmission thresholds are big enough, a Lagrange multiplier-based distributed O(1)-approximation algorithm with time complexity O(1) is proposed. Experimental results show that the proposed algorithms have better performance.


Introduction
Wireless Sensor Networks (WSNs) have been increasingly deployed for a wide variety of real-time applications, such as industrial Internet-of-Things, emergency response, critical infrastructure monitoring and process measurement and control. In real-time applications, deadline misses in data transmission may bring about irreparable damage [1][2][3][4]. For mission-critical tasks, not only the packet delivery deadline should be met, but also the transmission reliability is supposed to be guaranteed. Therefore, providing reliable and timely data delivery in WSNs is crucial to the success of the mission.
In supporting mission critical-tasks, data delivery is required to be timely and reliable, but it is challenging for desirable Quality of Service (QoS). Due to the transmission uncertainties, wireless link dynamics and the queueing dynamics, wireless link qualities in sensor networks can vary at a wide range of timescales [5,6], which also results in node failures and connectivity varying over time [7]. In practical sensor networks, the sensor node may need multiple retransmissions for successfully forwarding a packet at each hop. A maximum number of retransmissions, i.e., retransmission threshold, is usually set for each node to prevent transmitting a packet over a bad link unlimitedly, and the packet will be eventually dropped by the sender after the maximum number of transmission retries. The success of a packet delivery is probabilistic, and thus, the WSNs are rendered unreliable.
QoS supported by the underlying networks aims to meet end users' satisfaction with the services that the system provides [8]. The QoS provisioning in data delivery can be measured in the form of performance metrics, such as delay, packet loss rate and throughput. There exists a tradeoff among the QoS requirements, such as transmission reliability and deliver delay. Thus, the soft QoS supported can be accomplished, in which the soft QoS refers to achieving the QoS requirements with probability. Many efforts have been made to improve transmission reliability and deliver delay in WSNs, including quality measurement of forwarding data [5,9,10] and real-time routing protocol designing [11][12][13].
The main methodology applied in the existing works is to exploit a delivery path based on the QoS-aware forwarding quality metrics to improve the performance of packet transmission. However, there exist limited studies on the optimization of the retransmission threshold for each node in a delivery path, which imposes a significant effect on the probability of a packet being successfully transmitted within specified deadline. Most protocols set the same retransmission threshold for all sensor nodes in advance without considering the delay requirement and link quality, so that the delivery performance in terms of latency and reliability is decreased. We use an example inspired by the one in [14] to show the impact of retransmission threshold on the performance, illustrated in Figure 1. The number associated with each link is the probability for a packet being successfully delivered to the next node through the link, denoted by p suc , which means that on average, 1 p suc transmission trials are needed to successfully deliver a packet through the link. The integer variable A denotes the number of packets in the buffer waiting to be served. The delivery path for the first packet is S → B → C → D 1 , and the path for the second packet is S → E → D 2 . We assume that one transmission takes 10 ms, and the deadline of delivering the first packet from node S to node D 1 is 90 ms. For delivering the packet to node D 1 before the deadline, the summation of transmission trials along the path must be no more than nine, that is the result of 90 ms divided by one transmission time of 10 ms. Traditional protocols set the same retransmission threshold for each relay node in advance. If the protocol is set by a high retransmission threshold, such as 29, in the CTPprotocol [15], without the consideration of delay requirement, thus the probability for successfully transmitting the first packet through the link S → B can be significantly improved. However, this strategy may make the deadlines of both packets expire and consumes more system resource. If the maximum number of transmission trials is three for each node, in view of the summation of transmission trials, there are no more than nine. Then, the probability of the first packet passing the link S → B is 1 − 0.9 3 = 0.271. However, if the retransmission thresholds of the three nodes are set to 6, 0 and 0, that is the maximum numbers of transmission trials are 7, 1 and 1, then the probability is 1 − 0.9 6 = 0.927. In terms of latency and reliability, there is a tradeoff in determining the retransmission threshold. Therefore, the retransmission threshold should be carefully chosen to achieve desirable QoS provisioning [9]. From the example above, it is obvious that the retransmission threshold has significant impact on the delivery performance in terms of delay and reliability. Few studies focus on the optimization of the retransmission threshold [5,14], and they have the following two major disadvantages. In the feedback control-based framework [5], a heuristic method for adjusting the transmission numbers is proposed, which does not provide the reliability guarantee. In our previous work [14], a greedy-based algorithm for finding optimal retransmission thresholds is proposed, which overlooks the impact of queue length on the forwarding quality. The aforementioned observation motivates us to investigate the problem of finding optimal retransmission thresholds in this paper. The problem is formalized as an integer optimization problem first. Then, a dynamic programming-based distributed algorithm for solving the problem is proposed. It can be run on a sensor node and enables the node to adaptively set the optimal retransmission threshold based on the link quality and the remaining time to deadline. Its time complexity is O (n∆ · max 1≤i≤n {u i }), where u i is the given upper bound of the retransmission threshold of sensor node i in a given delivery path and n is the length of the delivery path. The complexity depends on delivery delay ∆. If ∆ is less than or equal to the polynomial, the complexity of the algorithm is polynomial. Otherwise, the algorithm is not efficient. In this case, a (1 + p min )-approximation algorithm is provided based on the linear programming. Furthermore, when the ranges of the upper and lower bounds of the retransmission thresholds are big enough, a Lagrange multiplier-based distributed O(1)-approximation algorithm with time complexity O(1) is developed. The main contributions of the paper are as follows.

•
The problem of finding optimal retransmission thresholds for each node along a delivery path is defined and is formalized as an integer optimization problem. • A Dynamic Programming-based Distributed Algorithm (DPDA) for solving the problem above is proposed; the correctness of the algorithm is proven; and its time and space complexity are In case of the delivery delay ∆ being greater than the polynomial, a Linear Programming-based (1 + p min )-Approximation Algorithm (LPAA) is proposed. Simulation experiments are conducted to evaluate the proposed algorithms. Simulation results show that the proposed algorithms in the paper have better performance for real-time data delivery.
The rest of this paper is organized as follows. The related works on real-time data delivery are surveyed in Section 2. In Section 3, the problem is described. In Section 4, a dynamic programming-based distributed algorithm for finding optimal retransmission thresholds is provided. Section 5 gives a linear programming-based approximation algorithm, and the ratio bound is analyzed. In Section 6, a Lagrange multiplier-based distributed O(1)-approximation algorithm with time complexity O(1) is proposed. Experimental results are illustrated in Section 7, and Section 8 concludes this paper.

Related Works
The real-time performance of packet delivery is a fundamental factor in sensor networks, and many efforts have been made to design efficient real-time routing protocols in WSNs. Most of the existing works addressed the following two challenges. First, it is essential to design the metric, which measures the forwarding quality, such as node forwarding quality [9], link quality [10], data aggregation [2] and energy efficiency [12]. Approximate aggregation for tracking quantiles and range countings is presented in [2], where a dynamic binary tree based deterministic tracking algorithm is proposed. Based on the actual number of data transmissions, link-Quality of Forwarding (QoF) and node-QoF metrics are proposed in [9]. A data-driven-based link quality prediction approach is provided in [10], which combines the packet reception ratio and the physical-layer information. Considering queuing delay, the Weighted End-to-End Delay (WEED) metric is introduced in [11]; the work focuses on selecting the path with the minimum expected end-to-end delay. In multi-hop wireless networks, the routing decision takes spatial reusability into account to improve the end-to-end throughput [16]. The authors in [17] utilize the expected available bandwidth to capture the logical intra-flow and inter-flow interference, and an isotonic metric of expected delay is proposed. Dependence among links was revealed recently. By exploiting the low correlated forwarding links, link-correlation Opportunistic Routing (OR) is given in [18]. Facing the uncertainties in wireless communication, the multi-timescale adaptation routing protocol is provided in [6], which can adapt to in situ delay conditions in routing delay.
To provide real-time packet delivery, QoS provisioning protocols and transmission scheduling protocols have also been extensively studied. The literature [13] studies geographic opportunistic routing protocol for multi-constrained QoS provisioning in WSNs, and the problem is formulated as a multi-objective multi-constraint optimization problem. By differentiating the priorities of user-level applications, the author in [19] develops an optimization tool for balancing the system resources and presents a cluster-based routing protocol. Under the constraints of delay and load balancing requirements, a centralized heuristic algorithm for selecting the path with minimal cost is provided in [20]. To separate the packet of different QoS requirements, a virtual hybrid potential field is introduced in [21]. Considering capacitated multicast routing problem, the work [22] provides the approximation algorithms for multicast k-path routing and multicast k-tree routing. By supporting slot rescheduling, the segmented slot assignment-based method for improving retransmission efficiency is proposed in [23]. Pan et al. [24] formulate joint routing and scheduling into an optimization problem and solve the problem with a column generation method. To route around the dead end relay node, the authors in [25] propose the cross-layer protocol, which integrates geographic routing with the contention-based MAC protocol. The author in [26] map the scheduling of data flow to multiprocessor scheduling and prove an upper bound of the end-to-end communication delay.
There exist limited studies on optimizing the retransmission threshold [5,14]. A distributed route maintenance framework is proposed in [5], which enables the link to adjust the retransmission number. However, the proposed heuristic method cannot provide the reliability guarantee theoretically. In our previous work [14], a greedy-based algorithm for finding optimal retransmission thresholds is proposed, which overlooks the impact of queue length on the forwarding quality. To overcome the shortage of the method, we investigate the problem of finding optimal retransmission thresholds in this paper.

Problem Description
In this section, the problem of finding optimal retransmission thresholds for each node along a delivery path is defined and is formalized as a general integer optimization problem. We prove that the problem is NP-hard.

Problem Definition
Suppose that the end-to-end path is P = j 1 , j 2 , . . . , j n+1 , where j 1 and j n+1 are source and destination nodes and other j i 's are relay nodes. There exist the following four attributes for each link j i → j i+1 .
• transmission time t: This means that once transmission costs time, including encoding and wireless communication. Usually each sensor node takes the same time for once transmission. • transmission failure probability p i : p i denotes the transmission failure probability over the link j i → j i+1 . It means that p i is the probability of a transmission failure due to either collisions or bad channel quality when node j i forwards a packet to node j i+1 .
• retransmission threshold K i : This means that the maximum number of retransmission trials is K i . It is obvious that the maximum number of transmission retries is K i + 1, and thus, the packet will be eventually dropped by the sender after the K i + 1 transmission retries. It can be known that is the probability of a packet being successfully delivered to node j i+1 . • retransmission threshold A i : Each hop delay consists of the transmission delay over the wireless link and the queuing delay in the buffer [9]. A i denotes the number of the packets queued at node j i , which means that there exist A i + 1 packets to be forwarded [6].
We define the metric of a given retransmission threshold as the probability of a packet being successfully delivered through the link. Existing works exploit multipath routing to guarantee both reliability and deliver delay in WSNs [13,27,28]. Similarly to [5,9], we aggregate the measure over a path based on the metric and aim at maximizing the summation of the probability of the packet delivered to the next relay node along the given path within the deadline. The path-metric estimates the given path forwarding quality, and it considers both transmission reliability and delay constraint.
The end-to-end delay over a path is the summation of the delays of all of the hops along the path. Let δ denote the delay constraint. Then, the problem of finding the optimal retransmission thresholds for each node can be formulated as the following integer optimization problem, where L i and U i are the given lower and upper bounds of the retransmission threshold of node i.
Each hop delay consists of the transmission delay and the queuing delay in the buffer; thus, the maximum delay latency for each hop is (A i + 1)(K i + 1)t. The first inequality constraint means that the deliver delay of the last packet served at source node j 1 is no more than the deadline constraint δ. The second inequalities mean that the retransmission thresholds should be bounded in a given interval.
For the convenience of formalization and analysis, let ∆ denote δ/t. For any i ∈ {1, 2, ..., n}, let a i = A i + 1, k i = K i + 1, l i = L i + 1 and u i = U i + 1; then, the problem above is equivalent to the following integer optimization problem.

Computational Complexity Analysis
In this subsection, we construct a 0-1 Knapsack problem [29], and we prove that integer optimization Equation (2) is equivalent to the proposed 0-1 Knapsack problem. The computational complexity of the 0-1 Knapsack problem is NP-hard [29]; thus the hardness of the problem for calculating optimal retransmission thresholds is NP-hard.
Thus, we can formulate a 0-1 Knapsack problem as follows.
.., C * n,u n −l n are the optimal solutions to Equation (3), then there exist j 1 , ..., j n , such that: Proof. The proof is by contradiction. Suppose that C * 1,1 , C * 1,2 , ..., C * 1,u 1 −l 1 , C * 2,1 , ..., C * n,u n −l n are the optimal solutions to Equation (3) and that they enable the objective function value to achieve the minimum. For given m, if there is no integer in {0, 1, ..., u m − l m } such that Equation (5) are true, then there must exist integers r, t, q ∈ {1, ..., u m − l m } such that C * m,r = 1, C * m,t = 0, C * m,q = 1 and r < t < q. We can construct a solution, whose objective function values are less than that of C * 1,1 , ..., C * n,u n −l n , by exchanging C * m,t and C * m,q . Suppose that C 1,1 , C 1,2 , ..., C n,u n −l n are derived by merely exchanging C * m,t and C * m,q . Firstly, we prove that C 1,1 , C 1,2 , ..., C n,u n −l n are feasible solutions of Equation (3). For any i ∈ {1, 2, ..., n} and j ∈ {1, ..., u i − l i }, C * i,j and C i,j are 0, 1 variables. It is obvious that ∑ a m C m,j . According to the construction of the solution, C * i,j and C i,j are identical correspondingly, except for C * m,t and C * m,q .
.., C n,u n −l n are the feasible solutions to Equation (3). Based on the definition of S i,j , it can be derived that ∑ n i=1 p Thus, the following inequality can be derived.
Therefore, the objective function value of Equation (3) is a lower bound of that of Equation (2). Since C * 1,1 , ..., C * n,u n −l n are the optimal solutions of Equation (3), there exist j 1 , ..., j n , such that Equation (5) .., k * n are the feasible solutions of Equation (2), and hence: Thus, the objective function value of Equation (2) is a lower bound of that of Equation (3). Based on the analysis above, we can conclude that k * 1 , ..., k * n are the optimal solutions of Equation (2); the values of the two objective functions are identical. (2) is NP-hard. That is, finding optimal retransmission thresholds for each node in a delivery path is NP-hard.

Corollary 4. The hardness of integer optimization Equation
Proof. Based on Theorem 3, the hardness of Equation (2) is identical to 0-1 programming Equation (3), which is equivalent to the Knapsack problem. Since the Knapsack problem is NP-hard [29], the hardness of integer optimization Equation (2) is NP-hard.

Dynamic Programming-Based Distributed Algorithm for Optimal Retransmission Thresholds
As analyzed in Section 3.2, the problem of finding optimal retransmission thresholds is equivalent to the 0-1 Knapsack Problem. Thus, it can be solved by a dynamic programming-based pseudo-polynomial time algorithm [29]. In this section, we first prove the correctness of the dynamic programming-based algorithm, which can output the optimal resolutions to Equation (3). We design a dynamic programming-based algorithm to solve the proposed 0-1 Knapsack Problem, and then, according to Theorem 3, the optimal retransmission thresholds can be derived based on the resolutions to Equation (3). Theorem 5. If C 1,1 , C 1,2 , ..., C n,u n −l n are the optimal solutions to Equation (3), then C 1,2 , ..., C n,u n −l n are the optimal solutions to the following problem.
Proof. The proof is by contradiction. If C 1,2 , ..., C n,u n −l n are not optimal solutions to Equation (8), suppose that Z 1,2 , ..., Z n,u n −l n are the optimal solutions of Equation (8). Then, C 1,1 , Z 1,2 , ..., Z n,u n −l n are batter solutions of Equation (3), which leads to a contradiction. The proof demonstrates the correctness of the dynamic programming-based algorithm.
To briefly describe the recursive procedure, based on Lemma 2, the following mappings are introduced, (3) is equivalent to the following knapsack problem.
When the object set is {S h , S h+1 , ..., S sum } and the capacity is bounded by j, we use m(h, j) to express the minimum cost. Then, we derive the recursive equation of m(h, j).
Additionally, the initial conditions are as follows.
m(sum, j) = 0 0 ≤ j − ∑ n h=1 a h l h < a n S sum j − ∑ n h=1 a h l h ≥ a n Suppose that node j i needs to forward a packet with delivery delay ∆ and that the end-to-end path is j i , j i+1 , ..., j n . Since the packet is the first one queued at node j i , a i = 1. Therefore, finding the optimal retransmission threshold k i for the packet over link from j i to j i+1 is equivalent to solving the following integer optimization problem.
According to Theorem 3, the above Equation (10) is equivalent to the following knapsack Equation (11).
Based on the above analysis, knapsack Equation (11) is a special instance of Equation (9), where the 'object' set is {S u i−1 −l i−1 +1 , ..., S sum } and the 'capacity' is bounded by ∆ . Suppose C u i−1 −l i−1 +1 , ...., C sum are the optimal solutions of Equation (11), then ∑ u i −l i h=u i−1 −l i−1 +1 C h is the optimal retransmission threshold of node j i . The message exchanges among network nodes are enhanced to carry necessary information of link quality and queue length [6,11], so that each node can independently calculate the optimal retransmission threshold based on the path forwarding quality and the remaining time to deadline. Such a property enables the node to adaptively set the optimal retransmission threshold in a scalable manner. The proposed dynamic-based distributed algorithm for the optimal retransmission threshold is described in Algorithm 1.
We present the analysis for the computational complexity of Algorithm 1. The recurrence process of the algorithm yields the time computation of (∆ − ∑ n h=i a i l i ) · (∑ n h=i u i − l i ). Thus, the time complexity of the proposed distributed algorithm is O (n∆ · max 1≤i≤n {u i }). Space complexity can be similarly analyzed, that is O (n∆ · max 1≤i≤n {u i }).

Linear Programming-Based Approximation Algorithm
The dynamic programming-based algorithm proposed in Section 4 is not efficient, if ∆ is greater than the polynomial function with respect to n. In this section, we construct a linear programming problem and prove that the solution of the proposed problem can be used to construct the approximate solution of integer optimization Equation (2). Additionally, then, a linear programming-based (1 + p min )-approximation algorithm is provided.

Mathematical Foundations
According to p i , l i and u i , piecewise linear function f i (z) is defined as follows, where h ∈ {0, 1, ..., u i − l i − 1}. We use an example to illustrate the defined function, as depicted in Figure 2.
Algorithm 1: Dynamic Programming-based Distributed Algorithm for the optimal retransmission threshold (DPDA). Proof. For any i, since f i (z) is a piecewise linear function, f i (z) = 0, where z ∈ (l i + h, l i + h + 1) and h ∈ {0, 1, ..., u i − l i − 1}. Thus, f i (z) satisfies the sufficient condition of convexity function if z ∈ (l i + h, l i + h + 1). Now, we prove that f i (z) is a convex function if z ∈ {l i , l i + 1, ..., u i }.
According to the constraints of Equation (2), a general optimization problem can be formulated as follows.
Theorem 7. The objective function value of Equation (12) is a lower bound of that of Equation (2), which implies that a feasible solution can be derived based on the optimal resolutions of Equation (12).
Proof. Suppose that k 1 , k 2 , ..., k n are the optimal solutions to Equation (2). For any i ∈ {1, 2, ..., n}, let x i = k i . Thus, x 1 , x 2 , ..., x n are feasible solutions to Equation (12), and hence: Therefore, the objective function value of Equation (12) is a lower bound of that of Equation (2). (12) is equivalent to the following linear programming problem, and then, the general optimization Equation (12) can be solved by the linear programming technique.

Linear Programming-Based Approximation Algorithm
Suppose that λ 1,0 , λ 1,1 , ..., λ n,u n −l n are the optimal solutions to Equation (13). For any i ∈ . Thus, z 1 , z 2 , ..., z n are the optimal solutions to Equation (12) according to the proof of Theorem 8. To obtain the feasible solutions of integer optimization Equation (2), rounding optimal fractional solutions is a natural idea [29]. The following theorem guarantees that the ratio bound of the rounding approach is 1 + p min , where p min is the minimum of the probabilities of one transmission failure along the given end-to-end path. Theorem 9. For any i ∈ {1, 2, ..., n}, the ratio bound of the rounding approach is 1 + p min , if z i ≥ ln p min ln p i , where p min = min{p 1 , p 2 , ..., p n }.
Proof. Suppose that z 1 , z 2 , ..., z n are the optimal solutions to Equation (12), which are derived from the optimal solutions of linear programming Equation (13). Denote k 1 , k 2 , ..., k n as the optimal solutions to Equation (1). From Theorem 7, the approximation ratio r satisfies the following formula.
According to the proof of Theorem 8, for any i ∈ {1, 2, ..., n}, there must exist integer j i in {0, 1, ..., u i − l i − 1}, such that z i ∈ [l i + j i , l i + j i + 1]. Based on the convexity of p x i , we know that: Let p min = min{p 1 , p 2 , .., p n }; we have: Additionally, then, the approximation ratio r satisfies the following formula: (17) For any i ∈ {1, 2, ..., n}, since z i ≥ ln p min In conclusion, the ratio bound is 1 + p min .
The link properties vary as a result of environmental conditions changing at a longer timescale [6,15], then the difference of failure transmission probability among links is little. Thus, the premises of Theorem 9 are always satisfied in practical sensor networks. Since the objective function value of Equation (12) is decreasing with respect to z i , its optimum value can be achieved if and only if ∑ n i=1 a i z i = ∆. For a general linear programming problem, finding optimal solutions incurs high computational overhead. However, it can be efficiently solved if the problem is to optimize a linear function subject to linear equality constraints [30].
The linear programming-based distributed approximation algorithm running at each sensor node is described in Algorithm 2, which is derived from the convex programming algorithm in [30]. f L h (x) and f R h (x) are the left and right derivative of f h (x), respectively. The proposed algorithm in [30] can yield optimal solutions for the piecewise linear convex function. For any i ∈ {1, 2, ..., n}, the derivative of f i (x) is discontinuous and constant. According to the proposed algorithm [30], the termination condition can be satisfied when the optimal retransmission threshold is not L i or U i . The maximum number for iteration rounds can be assigned in advance. The algorithm can also be stopped if the convergence condition is not achieved. Therefore, figuring out the retransmission threshold of node j i can be achieved.

Lagrange Multiplier-Based Distributed O(1)-Approximation Algorithm
In practical sensor networks, the optimal retransmission thresholds hardly hit the given upper or lower bounds. Therefore, we aim at finding the optimal retransmission thresholds when the ranges of the upper and lower bounds of the retransmission thresholds are big enough. In Section 6.1, we formalize the problem as an integer optimization problem and provide a mathematical method for finding the approximate solution of the problem. Then, a Lagrange multiplier-based distributed O(1)-approximation algorithm with time complexity O(1) is provided.

Mathematical Foundations
Compared to integer optimization Equation (1), the problem of optimal retransmission thresholds in the case that the ranges of the upper and lower bounds of retransmission thresholds are big enough can be formulated as follows, which implies that the optimization problem has no interval constraints of retransmission thresholds.

Algorithm 2:
Linear Programming-Based distributed Approximation Algorithm for the retransmission threshold (LPAA).
if Min ≥ y h+1 − t h+1 then Min = y h+1 − t h+1 , temp = h + 1; if Min = 0 then return x i1 ; else if x i1 hits the lower bound l i or the upper bound u i then return x i1 − 1 and stop; else According to the convex programming algorithm [30], adjust x i1 and x t ; The following lemma provides a mathematical method to figure out the optimal solutions of Equation (18) in the real number field; that is for any i, k i is a real number. Lemma 10 is the foundation for the rounding technique.
Proof. For any i ∈ {1, 2, ..., n}, p x i is a decreasing function. By contradiction, it is easily proven that the objective function achieves the maximum if and only if ∑ n i=1 a i x i = ∆. Since x 1 , x 2 , ..., x n are real numbers and the only constraint is equality, then we can derive the optimal solutions by the Lagrange multiplier method. We integrate the objective function and the constraint multiplied by ω to the following Lagrange function: is a function with respect to x 1 , ..., x n . The gradients on x 1 , ..., x n and ω are as follows: For any i ∈ {1, 2, ..., n} and j ∈ {1, 2, ..., n}, we have ∂ 2 Λ The Hessian matrix of Λ(x 1 , x 2 , ..., x n ) is as follows.
Then, the following equalities can be easily derived.
Proof. According to the proof of Lemma 10, if x 1 , ..., x n are the solutions of Equation (20), then they are the optimal solutions to Equation (19).
It is obvious that log −a i (ln p i ) −1 p i = ln a i + ln −(ln p i ) −1 ln p i ; the following equation can be derived.

Lagrange Multiplier-Based Distributed O(1)-Approximation Algorithm
The computation of the logarithm is undesired to execute on the sensor node; the log values needed can be stored on the sensor node in advance.  (22) are stored in the sensor node. The proposed Lagrange multiplier-based distributed approximation algorithm is described in Algorithm 3. It is easily known that the computation cost is O(n), where n is the number of hops from the source node to the destination node. Since the number of sensor nodes along the given end-to-end delivery path is no more than a few dozen, hence the computation complexity of the algorithm is O(1).
Similarly to the linear programming-based approximation algorithm, approximate solutions to integer optimization Equation (18) can be derived by rounding the optimal fractional solutions. The following theorem guarantees that the ratio bound of the rounding approach is 1 + p min . Due to 0 < p min < 1, the ratio bound of the Lagrange multiplier-based approximation algorithm is two.
Proof. Since x 1 , x 2 , ..., x n are the optimal solutions to Equation (19), ∑ n i=1 a i x i = ∆, and hence, ∑ n i=1 a i x i ≤ ∆. Thus, x 1 , ..., x n are the feasible solutions to Equation (18). Suppose that k 1 , k 2 , ..., k n are the optimal solutions to Equation (18). Obviously, the objective function value of Equation (19) is an upper bound of that of Equation (18). Thus, the following inequalities can be derived.
, and hence, the approximation ratio r satisfies the following equation: In conclusion, the ratio bound is 1 + p min , if for any i ∈ {1, 2, ..., n}, x i ≥ ln p min ln p i . Similarly, we know that the premises of Theorem 12 are easily satisfied in practical sensor networks.

Experiment Evaluation
The effectiveness and efficiency of the proposed algorithms are evaluated through simulations in this section. Several experiments are conducted to demonstrate the relationships between the performance of real-time data delivery and the input parameter, such as deadline, the number of hops of the given delivery path and the number of packets queued at the relay node. The first two group of simulations are carried out by MATLAB, and the third group is implemented with NS2.
One hundred sensor nodes and the sink are randomly deployed into a region of size 200 m × 200 m (m for meters), and we assume that the sensors have the same transmission radius. In each simulation, source and destination nodes are randomly selected. Each simulation is repeated 100 times and the simulation result corresponds to the average value over 100 times. To understand the benefits of the proposed algorithms, the comparison with the general method is conducted. The main idea of the general method is that we set the same retransmission threshold for all of the sensor nodes.
The first group of experiments is to investigate the Deadline Success Ratio (DSR) of the proposed algorithms, where DSR is the ratio of the packets delivered to the destination before their deadlines. Figure 3a shows the relationship between the deadlines and DSRs. The proposed algorithms have better performance. For example, when the deadline is 0.22 s, the DSRs of LMDAA and general method are 74% and 61%, respectively. Furthermore, we investigate the impact of the number of hops of a delivery path on the DSR. The remaining time to the deadline and link quality have been considered; thus, our algorithms can achieve higher deadline success ratios as shown in Figure 3b. Figure 3c depicts the relationship between the average number of packets queued at relay nodes and DSRs. From Figure 3c, the DSR becomes worse with the increase of the packets queued on the condition that the deadline is a constant. LMDAA is a distributed algorithm and enables the node to adaptively set the optimal retransmission threshold based on the link quality and the remaining time to the deadline. Therefore, LMDAA has better performance in terms of DSR than that of LPAA.  The second group of experiments is to investigate the Real-Time Ratio (RTR) of the proposed algorithms, where RTR is the ratio of the packets delivered to the destination before their deadlines among the packets successfully delivered to the destination node. Figure 4a shows the relationship between the deadlines and RTRs. As expected, the proposed algorithms can reach higher RTR than that of the general method. Figure 4b depicts the relationship between the number of hops of a delivery path and RTRs. The figure shows that our algorithms have better performance. For example, the real-time ratio of LPAA is more than 60%. Similarly, we investigate the impact of the average number of packets queued at relay nodes on RTR, with results illustrated in Figure 4c. Experimental results show that the proposed algorithms can reduce the deliveries of the packets, which cannot meet their deadlines. Therefore, our algorithms can improve the real-time ratio and energy efficiency.  The third group of simulations is implemented with NS2, which is a widely-used simulation tool in wireless sensor networks. From the experimental results of the first two groups of simulations, LMDAA can reveal the effectiveness of the proposed algorithms more neutrally, then we compare the results of LMDAA and the general method. The reasons why DSRs in the simulations implemented by NS2 are lower than those in case of MATLAB are as follows. For identical transmission failure probability, the link quality in NS2 simulation is much worse, which leads to a lower packet delivery ratio. Secondly, we have to set stationary retransmission thresholds in advance in NS2 simulations, and the retransmission thresholds cannot be adaptively set based on the link quality and remaining time during the packet delivery. As shown in Figure 5a-c, the proposed algorithm has better performance in real-time data delivery, in the case of worse wireless links or a severe delivery delay requirement. The forth group of experiments is to investigate the computing performance of LPAA and LMDAA, and the correctness of the approximation ratio is verified. We prove that the objective function value of Equation (12) is a lower bound of that of Equation (2), then ∑ n i=1 (1 − f i (z i )) generated by the optimal solution of Equation (12) is an upper bound of Equation (1). In the experiments, the Approximation Ratio (AR) is the ratio of ∑ n i=1 (1 − f i (z i )) generated by the optimal solutions of linear programming Equation (13) to that of the approximated solutions output by LPAA and LMDAA. Figure 6a-c demonstrates the relationships between the approximation ratio and the input parameter. Experimental results show that the objective function value of the approximation results returned by LPAA and LMDAA is very close to that of the optimal ones. Additionally, the proposed approximation algorithms can achieve high accuracy in terms of optimal retransmission thresholds.

Conclusions
The retransmission threshold in wireless sensor networks is critical to the latency of data transmitting in the networks. The problem of finding optimal retransmission thresholds for each node along a delivery path is defined and is formalized as an integer optimization problem. A dynamic programming-based distributed algorithm for finding the optimal retransmission threshold is proposed. The correctness of the algorithm is proven, and its time and space complexity are analyzed. When the delivery delay ∆ is greater than polynomial, a linear programming-based (1 + p min )-approximation algorithm is proposed. Furthermore, in the case of the ranges of the upper and lower bounds of the retransmission thresholds being big enough, a Lagrange multiplier-based distributed O(1)-approximation algorithm with time complexity O(1) is proposed. Simulation results show that the proposed algorithms have better performance for real-time data delivery.