On the Performance of the Cache Coding Protocol

: Network coding approaches typically consider an unrestricted recoding of coded packets in the relay nodes to increase performance. However, this can expose the system to pollution attacks that cannot be detected during transmission, until the receivers attempt to recover the data. To prevent these attacks while allowing for the beneﬁts of coding in mesh networks, the cache coding protocol was proposed. This protocol only allows recoding at the relays when the relay has received enough coded packets to decode an entire generation of packets. At that point, the relay node recodes and signs the recoded packets with its own private key, allowing the system to detect and minimize the effect of pollution attacks and making the relays accountable for changes on the data. This paper analyzes the delay performance of cache coding to understand the security-performance trade-off of this scheme. We introduce an analytical model for the case of two relays in an erasure channel relying on an absorbing Markov chain and an approximate model to estimate the performance in terms of the number of transmissions before successfully decoding at the receiver. We conﬁrm our analysis using simulation results. We show that cache coding can overcome the security issues of unrestricted recoding with only a moderate decrease in system performance.


Introduction
Mobile Ad-hoc Networks (MANET) constitute an infrastructure-less network architecture for mobile devices. In MANETs, network coding has been shown to increase reliability and throughput [1]. In network coding, data are encoded in a sender and transmitted through a network to be decoded at one or multiple receivers. Intermediate nodes in the network can also recombine coded packets (recode) without decoding the original data. Network coding can be considered as a generalized routing, in which relay nodes not only store and forward packets, but also combine packets received from multiple input paths before sending them to any output path [2,3]. Random Linear Network Coding (RLNC) is a simple, yet asymptotically optimal method, where packets are linearly combined using coefficients drawn uniformly at random from the elements of a finite field [2] and then transmitted through the network [4].
However, RLNC with unrestricted and unsupervised recoding is vulnerable to pollution attacks. A pollution attack occurs when a malicious or faulty node injects invalid linear combinations of generation into the network [5]. These invalid coded packets can quickly propagate into other packets via recoding in relay nodes and can prevent the destination node from decoding properly [6]. To prevent pollution attacks, homomorphic signatures, which are preserved through linear combination and recoding, can be used [7][8][9]. This method allows the system to check the integrity of network coded data and also to track and find malicious nodes in the network. However, due to high processing cost, this method is not practical [6]. While there exist alternatives for preventing pollution attacks with reduced processing costs, these solutions place limitations on topologies, require loose clock synchronization on the order of 100 ms, limit the hop count, require large field sizes or demand new public keys to be generated per generation. These requirements are not feasible in dynamic MANET networks. Thus, a new integrity mechanism is needed to mitigate pollution attacks [10].
As an alternative, the authors of [5] proposed a protocol solution called cache coding. Cache coding allows certified relay nodes to recode data only when they have decoded an entire generation. At that time, the relay nodes can generate new recoded packets and sign them with their own identifier. This mechanism generates trusted packets from both the source node and the trusted relay nodes, thus allowing the network to detect pollution attacks before they propagate.
Although [5] presents the protocol to cope with this vulnerability and identifies some bounds on the number of transmissions, a precise analytical model to characterize the performance of cache coding in multi-relay networks is missing. This performance analysis is critical to understand the security-delay trade-off imposed by the protocol. This paper provides two models for analysis of the cache coding protocol. The first model is a simple, yet accurate approximation to predict the number of required transmissions. The second model is based on an absorbing Markov chain inspired by previous works (e.g., [11]) and is used to accurately characterize the total number of transmissions in the system, as well as the number of linearly independent packets in all nodes after some constant transmissions from the source node. Although we focus on a simple relay policy from the cache coding protocol, future work can exploit the Markov chain structure of the problem to derive optimal policies using Markov Decision Processes (MDP) as in recent RLNC work (e.g., [12][13][14]).
We validate our analytical models using simulation results showing the difference between the absorbing Markov chain model, and the simulation results are negligible for all analyzed generation sizes and packet loss rates. For moderate loss rates, there is a 10% deviation in terms of the square average of the difference between our heuristic model and the simulation results. However, the heuristic model loses accuracy for high loss rates. Finally, we show that the cache coding protocol is at most 12% worse than RLNC with unrestricted recoding in terms of the number of transmissions. However, on average, there is only a 7% deviation in terms of the square average of the difference between the expected number of transmissions of cache coding and unrestricted coding protocols. This paper is organized as follows. In Section 2, we discuss the system model and different coding methods in relay nodes. In Sections 3 and 4, we discuss our two analytical models, while Section 5 focuses on validating those models using simulation results. We present our conclusions in Section 6.

System Model
We consider a network topology with one source node S, two relay nodes R 1 and R 2 and a destination node D. A total number of n packets must be sent from S to D. This transmission occurs by using the links shown in Figure 1. Each link has a fixed packet loss rate, e. The packet loss rates are considered constant throughout the transmission and independent of each other.
We define the Degrees of Freedom (DoF ) of a node as the number of linearly independent packets received by that node. In any topology, the transmission will be carried on until the DoF of the destination node are equal to the generation size, i.e., when the destination has enough information to decode the original data. We also define the generation size (n packets) as the number of original data packets that are linearly combined to generate network coded packets.
S generates packets using RLNC. It uses data packets p 1 , p 2 ,..., p n in the generation to create a linear combination with coding coefficients a 1 , a 2 ,..., a n , i.e., ∑ n i=1 a i p i . These coefficients are randomly selected from q elements of a Galois field, i.e., GF(q) [12]. If the field size is not considered very large, there is a chance that a packet received by D is not innovative and hence does not increase the DoF of D. However, in our analysis, we assume that the field size is large enough so that the probability of generating a linearly dependent coded packets for R 1 and R 2 is negligible until they decode the generation. Data are sent in three broadcast transmissions in three time slots as shown in Figure 2, with Tx and Rx indicating the transmission and reception of data, respectively. The first time slot is used for broadcasting from S to both R 1 and R 2 . The second and third time slots are used by R 1 and R 2 to broadcast to D, respectively. This whole process is called a transmission round. We assume a shared channel between all nodes for sending data in this topology, and the TDMA protocol is used to manage each node's access to this shared channel. We assume that whenever a relay node receives a packet, it is permitted to transmit a packet. This packet is determined by one of the following three coding methods.

Source Tx
Source coding (S − C): Upon reception of a transmission from S, R 1 and/or R 2 send a packet to D, which is identical to the packet received from S. Thus, D receives only one independent packet if it receives packets from more than one relay in the same time slot. Repeated coded packets are discarded.
Unrestricted coding (U − C): In this method, R 1 and R 2 receive encoded packets from S. R 1 and R 2 recode packets with previously received coded packets in each relay's buffer and send the newly generated recoded packet to D. Each relay transmits a recoded packet when they receive a coded packet from S.
Cache coding (C − C): In this method, R 1 and R 2 will act like the source coding method until its DoF is equal to the generation size (n). Then, the relay decodes the whole generation. After decoding all packets, the mentioned relay recodes the original packets and sends recoded data to D. This mechanism continues until the end of transmission, where the DoF of D are equal to the generation size (n).

Heuristic
This section derives an approximation to evaluate the performance of the three coding methods described in Section 2 in a system with the topology of Figure 1. We address each method in different subsections. We focus on the expected number of transmissions from S until D decodes a generation of n packets, as well as the expected total number of transmissions in all links in the network.

Source Coding
The probability that a packet is received by D from R 1 and the probability of receiving a packet by D from R 2 are: Meanwhile, the probability of receiving a packet by D from both R 1 and R 2 is: Since the assumption is based on a high field size, a new packet is innovative at D if it is received from either R 1 or R 2 . This probability is equal to P r 1 + P r 2 − P r 1 ∩r 2 . Thus, the probability of receiving a linearly independent packet by D is: Using Equation (3), the expected number of required transmissions from S to decode the generation completely in D is: where n is the size of the generation that D needs to decode and k sc is the number of required transmissions from S to have n linearly independent packets in D. In source coding, every transmission round includes a transmission from S; therefore, this metric is equal to the total number of transmission rounds in the system. The expected number of transmissions in all links requires us to determine the expected number of transmissions from each relay. Since each relay transmits a packet when it receives a packet from S, the expected number of transmissions from each relay is equal to k(1 − e). Hence, the expected number of transmissions in all links is: Note that the expected number of linearly dependent packets received in D, i.e., coded packets received by D from both R 1 and R 2 in the case of this scheme, is given by:

Unrestricted Coding
In the analysis of unrestricted coding, our assumption is that the system operates optimally, i.e., each transmitted coded packet from S is linearly independent for D, as well as for the joint information of both R 1 and R 2 . The latter means that if a transmission from S is successfully received by at least one of R 1 or R 2 and increases their joint DoF, then it is considered a useful transmission. Thus, the approximations derived for the expected number of transmission rounds and total expected number of transmissions in this section are lower bounds to the experimental values. Although this optimal scheme is achievable, from a practical perspective, it may impose increased signaling requirements in the network. A practical scheme requires the same or more coded packet transmissions.
Since the probability that neither R 1 nor R 2 receive the coded packet from S is e 2 , hence the probability of receiving a transmitted packet from S by either R 1 or R 2 is 1 − e 2 . As we require R 1 and R 2 to receive n packets, the expected number of transmissions from S to R 1 and R 2 is: D requires n packets to decode the whole generation. As the probability of receiving a packet by D from a relay node is 1 − e, the expected number of transmissions from R 1 and R 2 to D until D can decode the whole generation is: Summation of Equations (7) and (8) results in the expected number of transmissions in all links being:

Cache Coding
For the cache coding protocol, the total number of transmissions from all links can be separated into three separate contributions, as follows.
1. The probability of receiving a packet by a relay node R 1 or R 2 is 1 − e. As we need n packets in each relay node, the expected number of transmissions from S to R 1 and R 2 until the relays decode the whole generation is equal to n 1−e . 2. Until R 1 and R 2 decode the whole generation, they forward the packets received from S. As each relay node receives n packets until decoding the whole generation, each relay node forwards n coded packets received from S. Thus, the expected number of transmissions from R 1 and R 2 to D until both R 1 and R 2 have decoded the whole generation is equal to 2n. 3. The expected number of transmissions from R 1 and R 2 to D after they have decoded the whole generation requires us to determine the expected number of linearly independent packets received by D before R 1 and R 2 have decoded the whole generation. Before the relay nodes decode the whole generation, the expected number of packets received by D from R 1 is equal to n(1 − e). Meanwhile, the expected number of packets received by D only from R 2 is equal to n(1 − e)e. Hence, the expected number of linearly independent packets in D, before the relay nodes decode the whole generation, is equal to n(1 − e) + n(1 − e)e = n(1 − e 2 ). In order to decode the whole generation, D needs a total of n linearly independent packets; hence, after R 1 and R 2 have decoded the whole generation, D must receive another n − n(1 − e 2 ) linearly dependent packets. Since the probability of receiving a packet by D from R 1 and the probability of receiving a packet by D from R 2 is 1 − e, the expected number of transmissions from R 1 and R 2 to D after they have decoded the whole generation is equal to Summing these three equations, we can calculate the expected number of transmissions in all links as: While the expected number of transmission rounds in the system is: The expected number of transmission rounds before R 1 and R 2 have decoded the data equals the expected number of transmissions from S to R 1 and R 2 , i.e., n 1−e . Moreover, the expected number of transmission rounds after R 1 and R 2 have decoded the data is equal to the expected number of transmissions from R 1 and R 2 to D divided by the number of relays.
In order to determine the expected number of linearly dependent packets in D, we use the fact that the expected number of packets received by D from R 1 or R 2 is equal to n(1 − e) and that the expected number of packets received by D from only one of R 1 and R 2 is equal to ne(1 − e). Thus, the expected number of linearly dependent packets is equal to the subtraction of these two equations.

Absorbing Markov Chain Model
This section provides a full characterization of the cache coding protocol using an analytical model based on an absorbing Markov chain. We define the states as a triple (r 1 , r 2 , r), where r 1 and r 2 are the DoFs in R 1 and R 2 , respectively, and r represents the DoFs in D. Note that r 1 + r 2 ≥ r based on these states. The absorbing states are the states where r = n. This absorbing Markov chain will also include a cost matrix C alongside the matrix of transition probabilities P. While P ij indicates the transition probability from state i to state j, C ij is the total number of transmissions in all links required for the transition from state i to state j. We have derived closed-form expressions for each element of these two matrices.

Transition Probabilities
The transition probabilities between states S = (r 1 , r 2 , r) and S = (r 1 + i, r 2 + j, r + k) are dependent on the the cache coding protocol's stage in the communication process. Thus, we organize the transition probabilities into five cases as follows. In each case, we show how to derive one of the probabilities. Other probabilities are derived in the same way.
1. r 1 ≤ n − 1 and r 2 ≤ n − 1 No single relay node has decoded the data or decodes the data after receiving the new coded packet. Thus, both relays receive the coded packet and forward the received packet to D. Thus, In this case, for example, consider the probability where i = 1, j = 1 and k = 1. This case is the union of three possibilities.
• R 1 and R 2 receive from S. D receives from both R 1 and R 2 . In this case, all receptions are successful, so the probability of this incident is equal to (1 − e) 4 . • R 1 and R 2 receive from S. D receives only from R 1 . In this case, three of four receptions are successful, so the probability of this incident is equal to e·(1 − e) 3 . • R 1 and R 2 receive from S. D receives only from R 2 . In this case, three of four receptions are successful, so the probability of this incident is equal to e·(1 − e) 3 .
In this case, if one the relay node with DoFs equal to n − 1 receives a new packet, it decodes the generation completely and starts to send recoded data to D. However, the other relay node still forwards the received coded packet. Thus, In this case, for example, consider the probability where i = 1, j = 1 and k = 2. This case occurs when R 1 and R 2 both receive a packet from S and D receives a packet from both R 1 and R 2 . Therefore, all four transmissions must be successful; hence, this incident must have a probability of (1 − e) 4 .
3. r 1 = n and r 2 < n In this case, R 1 recodes and sends data to D, while R 2 forwards the received coded packets. Even if R 2 receives a new packet and decodes data completely (the case r 2 = n − 1), it recodes data and sends a recoded packet to the destination, which is different from the packet sent by R 1 . The difference between this case and Case 2 is the fact that R 1 sends a recoded packet to D whether or not it receives a packet from S. However, this event does not occur in Case 2. Thus, In this case, consider the probability where i = 0, j = 1 and k = 1. If r = n − 1, this incident occurs when R 2 receives a packet from S, and also D receives a packet from either R 1 or R 2 . Each of these incidents have a probability of e(1 − e) 2 . Hence, the total probability is equal to 2e(1 − e) 2 .
4. Case 4 : r 1 < n and r 2 = n In this case, R 2 recodes and sends data to D, while R 1 forwards the received coded packets. Even if R 1 receives a new packet and decodes data completely (the case r 1 = n − 1), it recodes data and sends a recoded packet to the destination, which is different from the packet sent by R 2 . The difference between this case and Case 2 is the fact that R 2 sends a recoded packet to D whether or not it receives a packet from S. However, this event does not occur in Case 2.
The probabilities in this case are identical to the previous case. Thus, In this case, both R 1 and R 2 have decoded the data. Therefore, S will not transmit any longer to R 1 or R 2 , while R 1 and R 2 will recode the decoded data and send different coded packets to D.

Cost of Transitions
The cost of any transition is 0, 1, 2 or 3 depending on the number of broadcast transmissions that occur. Using the cases introduced in Section 4.1, we can derive the cost of transitions. The cost of transition is derived using these two facts.
1. S sends a packet unless the DoF of both R 1 and R 2 is equal to n. 2. R 1 and R 2 send a packet when their DoF is equal to n or they receive a packet from S.
Thus, the cost of transitions is as follows.
1. r 1 ≤ n − 1 and r 2 ≤ n − 1 2. r 1 = n − 1 and r 2 ≤ n − 1 or r 1 ≤ n − 1 and r 2 = n − 1   After establishing all transition probabilities in a transition matrix, we can build the fundamental matrix F as follows [15]: where t is the number of transient (non-absorbing) states and r is the number of absorbing states. Q is the matrix of transition probabilities between transient states. R is the matrix of transition probabilities from transient states to absorbing states. I is the identity matrix, and Z is an all-zero matrix. After building this matrix, the mean number of transitions can be calculated using Definition 1. where I is the identity matrix with the same dimensions as Q and Γ is an all-one vector [16].

Calculation of the Number of Transmissions in All Links
The expected number of transmissions in all links is calculated using both transition matrix A and cost matrix C.

Definition 2.
For an absorbing Markov chain in state i, the expected number of transmissions in its next transition is equal to [17]:

Theorem 1.
For an absorbing Markov chain with state probability π, the expected number of transmissions in the next transition is equal to: where A · C represents the element to element multiplication between two matrices A and C and Γ is an all-one column vector.
Proof-sketch of Theorem 1. Using Definition 2, for a system in state i, the expected number of transmissions is equal to ∑ n i=0 A ij · C ij . As π i shows the probability for the system to be in state i, so the expected number of transmissions in the system is equal to ∑ n i=0 π i ∑ n j=0 A ij · C ij .

Results
In this section, we assess the validity of the proposed models and compare the three recoding schemes using various performance measures. We simulate the network topology of Figure 1 using the KODO library [18] in C++ to perform encoding/decoding operations. We have carried 1000 independent experiments for each generation size and packet loss rate and report the average of these measurements. These experiments were carried out by using Galois Field (2 8 ) for encoding/decoding operations. In this section, the deviation between two plots is calculated by the square average between two vectors. The calculation is carried out by using the second vector as a reference vector for calculating the square average. For example "the deviation of x and y is 5%" means that if x and y have n entries, then 1 n ∑ n i=1 ( x i −y i y i ) 2 = 0.05. We have calculated the expected number of transmissions in all links in source coding. Using Equation (5) in Section 3, we can approximate the expected number of transmission in all links for source coding. Figure 3 compares the simulation results with our heuristics, showing a deviation of 10% between heuristics and simulation. This fact shows that the approximated model can estimate this metric within 90-110% of the real value for a wide range of generation sizes and packet loss rates. This difference comes from the fact that additional transmissions from S to both R 1 and R 2 occur, while these packets are not innovative for D.  Figure 4 shows the expected number of transmissions in all links for unrestricted coding. This figure shows that there is a 20% deviation between our heuristic model and simulation results for all generation sizes and packet loss rates. However, for a moderate loss rate, which means less than a 20% loss rate, there is only a 10% deviation between heuristic and simulation results. This gap is created because the proposed heuristic is a lower bound for unrestricted coding.  Figure 5 illustrates the expected number of transmission rounds in order to decode the data in D for different generation sizes in cache coding. We compare our simulation results with the two proposed models. Figure 6 shows the expected number of transmission rounds for different generation sizes in cache coding. In both of these metrics, there is at most a 10% deviation between heuristics and simulation. The deviation between the absorbing Markov chain and simulation is at most 6%. The absorbing Markov chain model is more precise than the heuristics, because we did not consider the number of relay nodes in our heuristic model. Tables 1 and 2 summarize our key results for cache coding.    8 show the expected number of linearly dependent packets received in D for cache coding and source coding, respectively. As shown, this number decreases by increasing the packet loss rate. This comes from the fact that there is a lower probability of receiving the same packets by R 1 and R 2 for higher packet loss rates, which decreases the probability of receiving non-innovative packets in D.  We also compare the performance of cache coding and unrestricted coding. In Figures 9 and 10, we show the expected number of transmissions in all links for these coding schemes. The results for the simulation confirm that there is only a 5% deviation between cache coding and unrestricted coding in terms of expected total number of transmissions. This gap is larger for the results of the heuristics. There is at most a 9% derivation between heuristic models of cache coding and unrestricted coding. These results also show that the deviation between cache coding and unrestricted coding is only 12% in the worst case.

Conclusions and Future Work
This paper presents a model and full characterization for the cache coding protocol presented in [5], as well as an approximated, yet accurate model for this protocol and other protocols of interest. This analysis also considers an achievable lower bound for the number of transmissions in the network, which serves as the gold standard to measure various protocols, including the cache coding protocol.
Using our models and simulation results, we have confirmed that the cache coding protocol, which was originally designed to overcome the security issues of unrestricted coding, can overcome the security issues with a negligible decrease in the performance of the two-relay system analyzed in this paper. Although this fact had been shown by simulations [5], our paper provides the first confirmation using analytical models to describe the system.
Our future work will consider closed-form expressions for other performance metrics, such as the number of linearly dependent packets received by the destination node. Moreover, we will consider extensions of the analytical model to systems with more than two relays. Regarding the probabilistic method, we will take the impact of field size on the probability of receiving an uninnovative packet by the relay and destination nodes into consideration.