We assume that nodes have a stable forwarding behavior for an undetermined time. This entails that the average reputation forwarding value of the nodes is kept stationary during an arbitrary interval. Nevertheless, we also consider the possibility that the forwarding behavior of the nodes will change throughout time starting a new stationary interval. This may be due to the fact that the node either changes its behavior or its neighborhood, which affects its reputation.
As mentioned above, each time a node gets the reputation of a path, an estimation of the reputation of the nodes belonging to that path is updated. For convenience in the nomenclature, we name the set of k consecutive samples of the estimated behavior for a node n, as r1, r2, … , rk instead of \( \widehat{r_{n_1},}\widehat{r_{n_2},}\dots, \widehat{r_{n_k}} \). For the sake of simplicity and clear explanations, we ignore the subscript n to refer to the node n under evaluation. To assign a reputation to that node, we use a moving average. The moving averages that we have considered are the cumulative moving average (CMA) and the exponentially weighted moving average (EWMA) [7].
Cumulative moving average
In the case of using a CMA [7], we compute the average using all the reputation history of a node:
$$ {c}_k=\frac{1}{k}\cdotp \sum \limits_{i=1}^k{r}_i $$
(5)
In Eq. (5), ck represents the CMA of node n after its k-th reputation sample has been estimated. Since past samples are weighted equally than the present ones, this average does not reflect the updated current behavior of the node in case it changed. If the behavior of the node were always the same, this would be a correct average to be implemented.
We assume that the node has a stationary behavior within a time window. Otherwise, it would not have sense to average the reputation samples. Under this assumption, we can recalculate the CMA each time a new stationary window starts. Now, the problem is to obtain the size of that window, that is, we need to detect when a change occurs in the behavior of the node, so that the average only includes samples that have the same stationary behavior. By means of a mechanism that allows us to detect those behavioral changes, we could define the window in which we would average the reputation samples. Each time a new window starts, we forget the old samples, that is, we reset the i counter in Eq. (5).
The set of reputation samples rk of a node n that has a steady behavior can be expressed as a constant value \( \overline{r} \) to which a noisy signal Δrk is superimposed.
$$ {r}_k=\overline{r}+\Delta {r}_k $$
(6)
The noisy signal is a zero mean stochastic process (E[∆rk ] = 0). Therefore, \( \overline{r} \) is the expected value of the samples E[rk], which remains constant for all k samples because of the stationary behavior of the nodes. The second moment of ∆rk is the variance of the samples, which we assume to be constant for the temporary window of steady behavior:
$$ {\sigma}_r^2=E\left[{\left(\Delta {r}_k\right)}^2\right] $$
(7)
In the same way, we can express \( {c}_k={\overline{c}}_k+\Delta {c}_k \). Then, using Eq. (6) in Eq. (5), we obtain
$$ {\overline{c}}_k=E\left[{c}_k\right]=\overline{r} $$
(8)
$$ \Delta {c}_k=\frac{1}{k}\cdotp \sum \limits_{i=1}^k\Delta {r}_i $$
(9)
The expected value of the averaged samples using CMA does not depend on k and remains constant for the time window with steady behavior. Since ∆rk is a zero mean process, ∆ck is a zero mean process as well. In order to evaluate the deviation from the expected value, we calculate the variance of the CMA samples. We assume that forwarding is a memoryless process, that is, a node that forwards only the 50% of the packets throws a coin before each forwarding independently of the others. Under this assumption, we have that processes ∆ri and ∆rj are independent for i ≠ j and the variance is given by Eq. (10):
$$ {\sigma}_c^2(k)=\frac{1}{k^2}\cdotp \sum \limits_{i=1}^kE\left[{\left(\Delta {r}_i\right)}^2\right]=\frac{\sigma_r^2}{k} $$
(10)
Concluding, for the CMA under the assumption of steady behavior in a well-defined temporary window, the expected value of the reputation samples remains the same. Also, the variance of the reputation samples reduces inversely proportional to the number of samples.
Exponentially weighted moving average
Another widely used alternative to average samples is EWMA [7]. While averaging, more emphasis to recent samples is placed reducing exponentially the weight of past samples. We denote wk as the value of the EWMA after processing the rk sample:
$$ {w}_k=\left(1-\beta \right)\cdotp {w}_{k-1}+\beta \cdotp {r}_k $$
(11)
In Eq. (11), β is a factor between 0 and 1 that weights the current sample rk. The higher the β, the more emphasis is given to the present. In general, EWMA has less lag than CMA and is therefore more sensitive to changes.
To calculate the EWMA of a node, it is necessary to take an initial reputation value. A priori we consider that all nodes in the network are collaborative. Therefore, the initial reputation for all nodes must be one. Nevertheless, this proposal is defined in a generic way for any other initial value. Using Eq. (11) recursively, we obtain the moving average as a function of all the reputation samples exponentially weighted, where w0 is the initial value of the moving average:
$$ {w}_k={\left(1-\beta \right)}^k\cdotp {w}_0+\beta \cdotp \sum \limits_{i=0}^{k-1}{\left(1-\beta \right)}^i\cdotp {r}_{k-i} $$
(12)
In the same way that we have done with rk in Eq. (6), we can express \( {w}_k={\overline{w}}_k+\Delta {w}_k \), being \( {\overline{w}}_k \) the asymptotic behavior of the EWMA and ∆wk a stochastic process that superimposes to it. Using Eq. (6) in Eq. (12), we relate \( {\overline{w}}_k \) with \( \overline{r} \) and ∆wk with ∆rk.
$$ {\overline{w}}_k=E\left[{w}_k\right]={\left(1-\beta \right)}^k\cdotp \left({w}_0-\overline{r}\right)+\overline{r} $$
(13)
$$ \Delta {w}_k=\beta \cdotp \sum \limits_{i=0}^{k-1}{\left(1-\beta \right)}^i\cdotp \Delta {r}_{k-i} $$
(14)
We can see that after k samples, the difference between the expected value of the sample and the asymptotic behavior of the moving average, that is \( {\overline{w}}_k-\overline{r} \), has reduced by a factor (1 − β)k. Since (1 − β)k < 1, when the number of samples k grows, this difference tends to zero and \( {\overline{w}}_k \) approaches asymptotically to \( \overline{r} \). Therefore, the greater the β factor, the faster the asymptotic approach to the desired value \( \overline{r} \).
Since ∆rk is a zero mean process, ∆wk is a zero mean process as well. Note that according to our definition of rk (see Eq. (6)), we have that ∆rk = 0, ∀ k < 1.
In order to evaluate the deviation of the EWMA of the reputation samples, from the asymptotic behavior, we calculate the variance of the EWMA of the reputation samples. Using the same assumptions as in CMA, we attain the variance of the EWMA as a function of the variance of the reputation samples (see [7] for further details):
$$ {\sigma}_w^2(k)=\frac{\beta }{2-\beta}\cdotp \left[1-{\left(1-\beta \right)}^{2k}\right]\cdotp {\sigma}_r^2 $$
(15)
Notice that although we suppose that \( {\sigma}_r^2 \) is constant in the stationary window, \( {\sigma}_w^2 \)depends on k. Since always <1, we have that \( {\sigma}_w^2(k)<{\sigma}_r^2 \). This means that the EWMA reduces the deviation of the samples from their mean value. The smaller the β factor is, the smaller the variance \( {\sigma}_w^2(k) \) is. If we compare the variances of EWMA and CMA, we can notice that for CMA, this variance tends to zero when the number of samples increases (Eq. (10)). In contrast, for EWMA, when the number of samples grows, the variance tends to a value that depends on β which is shown in Eq. (16):
$$ {\sigma}_w^2\approx \frac{\beta }{2-\beta}\cdotp {\sigma}_r^2 $$
(16)
Additionally, for EWMA, there is a trade-off between the asymptotic approaching speed and the variance. High values for β entail a quick approach to the average stationary value, but with a low variance reduction. Conversely, low values for β reduce considerably the variance, although with a slow approach.
Stationary time windows detection
CMA is the best option for averaging the reputation samples, in case the behavior of the nodes changes steeply and we are able to detect the moments in which the stationary time windows start and end. To do so, we propose a method to detect changes in the nodes’ behaviors and delimit these stationary time windows. Our proposal is based on the combined use of an EWMA to detect the change of the nodes’ behavior and a CMA to average their reputation values.
Figure 1 shows the EWMA for the reputation of a node that changes, defining two stationary time windows. If the asymptotic behavior of the EWMA was a continuous function, we would have a discontinuity in the derivative each time the stationary behavior of the node changes and there is a Dirac delta function in the second derivative. Since we have a discrete time function, we use the second difference of the EWMA instead of the second derivative in order to detect the end of a stationary time window. We define the first difference of the EWMA as:
$$ {f}_k={w}_k-{w}_{k-1}=\beta \cdotp \left({r}_k-{w}_{k-1}\right) $$
(17)
and the second difference
$$ {d}_k={f}_k-{f}_{k-1}=\beta \cdotp \left({r}_k-{r}_{k-1}\right)-{\beta}^2\cdotp \left({r}_{k-1}-{w}_{k-2}\right) $$
(18)
With this definition, if a peak for dk occurs at k0, it means that the sample \( {r}_{k_0} \) belongs to a new stationary time window. The above expression has no sense for k < 3, since at least three samples are necessary to compute the second difference.
In order to find the values of β that optimize the peak detection, we relate the second difference dk with the samples rk. Using Eq. (12) on Eq. (18), we have:
$$ {d}_k=\beta \cdotp {r}_k-\beta \cdotp \left(1+\beta \right)\cdotp {r}_{k-1}+{\left(\frac{\beta }{1-\beta}\right)}^2\cdotp \left[\beta \cdotp \sum \limits_{i=2}^{k-1}{\left(1-\beta \right)}^i\cdotp {r}_{k-i}+{\left(1-\beta \right)}^k\cdotp {w}_0\right] $$
(19)
Under the assumption that in the stationary window \( {r}_k=\overline{r}+\Delta {r}_k \), we can write \( {d}_k=\overline{d_k}+\Delta {d}_k \), being
$$ \overline{d_k}={\beta}^2\cdotp {\left(1-\beta \right)}^{k-2}\cdotp \left({w}_0-\overline{r}\right) $$
(20)
$$ \Delta {d}_k=\beta \cdotp {\Delta r}_k-\beta \cdotp \left(1+\beta \right)\cdotp \Delta {r}_{k-1}+\frac{\beta^3}{{\left(1-\beta \right)}^2}\cdotp \left[\sum \limits_{i=2}^{k-1}{\left(1-\beta \right)}^i\cdotp \Delta {r}_{k-i}\right] $$
(21)
To relate the noise of the second difference of the EWMA with the noise of the samples, we calculate the standard deviation of dk. As we have said above, we assume that E(Δri · Δrj) = 0, ∀ i ≠ j and \( E\left(\Delta {r}_i^2\right)={\sigma}_r^2,\forall i>0 \) in the stationary window. In this case:
$$ {\sigma}_d^2=E\left({\Delta d}_k^2\right)={\beta}^2\cdotp E\left({\Delta r}_k^2\right)+{\beta}^2\cdotp {\left(1+\beta \right)}^2\cdotp E\left(\Delta {r}_{k-1}^2\right)+\frac{\beta^6}{{\left(1-\beta \right)}^4}\cdotp \left[\sum \limits_{i=2}^{k-1}{\left(1-\beta \right)}^{2i}\cdotp E\left({\Delta r}_{k-i}^2\right)\right] $$
$$ {\sigma}_d^2={\beta}^2\cdotp \left[1+{\left(1+\beta \right)}^2+{\beta}^3\frac{1-{\left(1-\beta \right)}^{2\left(k-2\right)}}{2-\beta}\right]\cdotp {\sigma}_r^2 $$
(22)
Plotting the factor that relates both variances as a function of β, using a different number of samples (see Fig. 2), we get practically the same graph being impossible to distinguish them, then we can approximate the above expression for the case k → ∞(in this case we approximate (1 − β)2(k − 2) ≈ 0, since β < 1).
$$ {\sigma}_d^2\approx 2{\beta}^2\cdotp \frac{2+\beta }{2-\beta}\cdotp {\sigma}_r^2 $$
(23)
For large values of β, the noise \( {\sigma}_d^2 \) increases, being greater than that of the samples \( {\sigma}_r^2 \). Therefore, we have to choose a small value for β if we want to reduce the noise and optimize the detection.
On the other hand, the peak of the second difference will be higher the value of β, being easier to detect. We must compare the value of the peak with the noise and find the value of β that optimizes the peak signal-to-noise ratio. To calculate the peak value, we assume that the reputation of the node changes from a value \( \overline{r_1} \) to a value \( \overline{r_2} \), and this change occurs between the sample k0 − 1 and k0 so that \( {r}_{k_0-1}=\overline{r_1}+\Delta {r}_{k_0-1} \) and \( {r}_{k_0}=\overline{r_2}+\Delta {r}_{k_0} \). Using Eq. (19) we get:
$$ \overline{d_{k_0}}=\beta \cdotp \left(\overline{r_2}-\overline{r_1}\right)+{\beta}^2\cdotp {\left(1-\beta \right)}^{k_0-2}\cdotp \left({w}_0-\overline{r_1}\right) $$
(24)
Comparing this result with Eq. (20), we observe that the peak that appears in the second difference caused by the change of behavior is:
$$ P=\beta \cdotp \left(\overline{r_2}-\overline{r_1}\right) $$
(25)
Using Eqs. (23) and (25), we can define the peak signal-to-noise ratio as a function of β:
$$ \frac{P^2}{\sigma_d^2}=\frac{2-\beta }{2\cdotp \left(2+\beta \right)}\cdotp \frac{{\left(\overline{r_2}-\overline{r_1}\right)}^2}{\sigma_r^2} $$
(26)
Since (2 − β)/2(2 + β) is a decreasing function of β, we can conclude that the lower the β value, the better the detection of a new stationary time window. Obviously, we cannot use β = 0 because in this case, we were not averaging samples.
Proposed averaging algorithm
Our proposal is to average the samples of the reputation of a node using a CMA in the stationary period of steady behavior for each node. We use this average as the reputation of the nodes in order to find the best forwarding routes in the MANET. To delimit this stationary period, in parallel, we calculate the EWMA of the samples using a low value for β, whose value is discussed in the simulation results section. Also, we compute the second difference of that EWMA average obtaining the values dk. We suppose that the samples dk represent an ergodic process and therefore its mean value \( \overline{d_k} \) and its standard deviation \( {\sigma}_{d_k} \) are calculated as follows:
$$ \overline{d_k}=\frac{1}{k}\cdotp \sum \limits_{i=1}^k{d}_i\ \mathrm{and}\kern0.50em {\sigma}_{d_k}=\sqrt{\overline{d_k^2}-{\overline{d_k}}^2}\ \mathrm{being}\ \overline{d_k^2}=\frac{1}{k}\cdotp \sum \limits_{i=1}^k{d}_i^2 $$
(27)
In Eq. (27), k represents the number of samples that we have in the stationary time window. The more samples, the more accurate the result we achieve.
When the absolute value of a new sample dk + 1 is higher than a certain number of standard deviations added to the mean value, a peak detection event occurs. In this case, we start a new CMA with the new samples that belong to a new stationary time window. The peak detection condition is shown in Eq. (28):
$$ \left|{d}_{k+1}\right|>\left|\overline{d_k}\right|+F\cdotp {\sigma}_{d_k} $$
(28)
Since we do not know if the reputation of the node will increase or decrease, we do not know if the peak of the second difference will be positive or negative. Therefore, we use the absolute value of dk + 1 and \( \overline{d_k} \). The factor F determines how much higher the peak should be with respect to the noise. A small F value may be the cause of false positives so that the noise in the samples may seem like a peak. On the other hand, a large F value may be the reason why small changes in the behavior of a node are not detected. As seen in Eq. (25), the amplitude of the peak depends on the difference of both reputations, the old and the new one.
To sum up, the proposed algorithm uses a CMA to average the reputation samples and the second difference of the EWMA with a small β to detect the limits of the stationary time windows.