# Distributed Reliable and Efficient Transmission Task Assignment for WSNs
## 5 Reliable and Efficient Task Allocation Algorithm for WSNs
### Distributed Task Assignment
#### 5.2.2 Distributed Reliable and Efficient Task Allocation in Planar Topology
 \tag{14}\]  
For a write request, it is first sent to the replica as a coordinator, and then the coordinator propagates the write to all other replicas. After getting at least \(W-1\) responses, the coordinator returns. Read requests are handled in the same way as write requests, although the coordinator should wait for at least \(R-1\) responses. If the read replica set overlaps with the write replica set, the read request can return the most recent value. Otherwise, it will return stale data. Similarly, this paper proposes a method to ensure the final consistency of multiple global views. In this method, each sink maintains a log in addition to the global view that includes the version of the current global view (new), the version of the previous global view (old), and the update operation from the old version to a new version. In a multi-sink WSN, if the network status changes, the changed local sink sends an update request to other sinks. If at least \(W-1\) sinks return a response, the update request is considered successful, and the sink submits an update and broadcasts the update to other sinks. Next, the previously responded \(W-1\) sinks update the current global view version, the previous version of the global view, and the update operation from the old version to the new version in the log. As soon as a sink node initiates a task assignment, the global view needs to be read. In addition to reading the locally saved global view, the sink node issues a read request to the other sinks, then waits for \(R-1\) responses, and finally returns the read result. Since the task allocation has a deadline constraint, to reduce the delay of reading the global view, the algorithm sets \(R=2\) to read the global view of two sinks. Therefore, the complexity of guaranteeing consistency is pushed to the write operation; that is, for the network state update process which is not sensitive to delay, as long as \(R+W>N\) is satisfied, the final consistency can be guaranteed. If concurrent partial updates occur in the network at the same time, the concurrency control protocol is used for processing. (B) Task Assignment Based on Multi-Sink WSNs  
In a planar WSN topology where multiple sinks important, these sinks form a multicast group, and the multiple sinks are equal. To simplify the design, it is assumed that multiple sinks can remain fully connected and the sinks do not fail, as each sink collects the local view, including the physical topology and routing topology. The local views are periodically exchanged so that multiple sinks in the multicast group gradually obtain a global view of the network. The concept of TRETA-Multi-Sink follows: after each sink has acquired the global view and there is a task to be allocated, if the current time of the system is less than the deadline of the task to be assigned, the sink closest to the task can be selected to call the TRETA algorithm for local optimization allocation. Since the sink has a global view and despite a local allocation, the sink can perform a globally optimized task assignment. In the algorithm, multiple sinks select the final consistency when exchanging global views to reduce the communication cost of synchronization between sinks. If the current time of the system is higher than the deadline of the task to be assigned, the current task allocation is interrupted. Specifically, for the task \(m_{i}\) to be assigned, if the current time of the system is less than the deadline of the task, the nearest sink of task \(m_{i}\) is found through the physical topology information and is represented by \(sink_{j}\), which reads the local and adjacent global view version. To ensure the final consistency of the global view between multiple sinks, the reading number of copies is \(R\) according to the NWR model (we let \(R=2\)); if the versions are different, it will read the global view with the latest version. Otherwise, it will read the local - global view of \(sink_{j}\). Then, \(sink_{j}\) calls the TRETA algorithm for local optimization allocation.