## 5 Multi-Replication in Data Centric Storage
### Tug of War (ToW)
Therefore, the consumer querying cost per unit interval could be defined as  
\[C_{q_{W_{all}Q_{1}}}=f_{q}\frac{\overline{\delta}\sqrt{n}}{2^{d}}\]  
Later, the cost of storing an event in all the replicas (overall producers' event cost per unit interval) allocated for that event type is:  
\[C_{e_{W_{all}Q_{1}}}=f_{e}k\frac{\overline{\delta}\sqrt{n}}{2^{d}}+f_{e}k(4^{ d}-1)\frac{\sqrt{n}}{2^{d}}=f_{e}k\sqrt{n}(2^{d}-\frac{1-\overline{\delta}}{2^ {d}})\]  
It is composed by two terms: (i) the first one refers to the cost of forwarding the data from the producer to its closest replica, (ii) the second cost is due to replicate the received data in all the remaining replicasusing combing routing. Since we are assuming a uniform deployment, the distance between any two replicas is the same, \(\frac{\sqrt{n}}{2^{d}}\). In order to compute the total cost it is enough with knowing the number of branches used to replicate the information, that is, \(4^{d}-1\). Therefore, the total cost for the write-all-query-one mode is:  
\[C_{W_{all}Q_{1}}=C_{e_{W_{all}Q_{1}}}+2C_{q_{W_{all}Q_{1}}}=f_{e}k\sqrt{n}(2^{d }-\frac{1-\overline{\delta}}{2^{d}})+2f_{q}\frac{\overline{\delta}\sqrt{n}}{2^ {d}}\]  
Notice that the querying cost is multiplied by a 2 factor so that the cost of the reply to the consumer query is also computed. The optimal value of \(d\) in order to reduce the overall cost in the network is obtained by performing an optimization of the previous equation in function of \(d\). Therefore, this optimal value, \(d^{*}\), is:  
\[d^{*}_{W_{all}Q_{1}}=\frac{1}{2}log\left(\frac{2\overline{\delta}}{k}\frac{f_ {q}}{f_{e}}-(1-\overline{\delta})\right)\]  
**Write-one-query-all Mode**  
In this case the cost of storing an event (production cost) in the closest replica is immediate:  
\[C_{e_{W_{1}Q_{all}}}=f_{e}k\frac{\overline{\delta}\sqrt{n}}{2^{d}}\]  
The authors also use a symmetric cost model for the consumption cost, and they define it as:  
\[C_{q_{W_{1}Q_{all}}}=f_{q}\sqrt{n}(2^{d}-\frac{1-\overline{\delta}}{2^{d}})\]  
Therefore, the overall cost and \(d^{*}\) are:  
\[C_{W_{1}Q_{all}}=C_{e_{W_{all}Q_{1}}}+2C_{q_{W_{all}Q_{1}}}=f_{e}k\frac{ \overline{\delta}\sqrt{n}}{2^{d}}+2f_{q}\sqrt{n}(2^{d}-\frac{1-\overline{ \delta}}{2^{d}})\]  
\[d^{*}_{W_{all}Q_{1}}=\frac{1}{2}log\left(\frac{\overline{\delta}k}{2}\frac{f_ {e}}{f_{q}}-(1-\overline{\delta})\right)\]  
As it has been already mentioned, this model is symmetric to the write-all-query-one model. This is only possible if aggregation is assumed in the query reply path. Therefore, the distance cost of a query is the same than that of its reply. In order to apply this model, regular sensors need to know two parameters: \(k\) and the \(\frac{fq}{fe}\) ratio. For \(k\), the number of sensors measuring the same event, the authors do not present any discussion and assume that is a well-know value in the network. However, in a real WSN calculating the actual \(k\) value is quite complex and in general it will not be homogeneous across the network. For the \(\frac{fq}{fe}\) ratio, replication nodes are in contact among them, therefore they have a global overview of this ratio in the network. Then, the ratio is attached to each message sent along the consumption reply path, so those nodes that are in the range of the replying path could learn it. In addition, each regular node includes this ratio when it forwards any message. However, this mechanism cannot assure that all producers and consumers are aware of the current \(\frac{fq}{fe}\) ratio, which could lead to a worse performance since some sensors could evaluate an incorrect number of replicas.