• 沒有找到結果。

XOR Coding Algorithm

Network Coding Algorithm and Implementation

3.1 XOR Coding Algorithm

XOR coding algorithm uses basic xor for its major operations, and has been implemented between the MAC layer and the IP layer in the practical network environment. Thus, this thesis uses the XOR coding algorithm refered to in the COPE [5]. COPE suggested that packet knowledge can be collected by piggybacking information in ACK and assumed that there exists such ACK mechanisms without too much implementation cost. The same as-sumption is adopted in this work. Each node needs to know whether previous transmissions are successfully received and decoded by its neighbors and which packets has been overheard by its one hop neighbors. These are important implementation issues. However, like COPE, we do not really discuss and handle related issues in this paper and leave them for future studies. The XOR coding algorithm works in the following procedure, but the details of which are depicted in PROCEDURE 1. Each node maintains two buers: one buer stores all the primitive packets ready for transmission and the other, the information pool, stores

undemanded coded packets and primitive packets. In general, primitive packets in the buer are categorized into virtual queues by dierent nexthops, and the number of virtual queues is the same as that of one-hop neighbor nodes. The node maintains a virtual queue that are sequence of the buers and indicates which packet is demanded by its neighbor. In other words, primitive packets in dierent virtual queues are transmitted to dierent nexthops.

Due to the broadcast nature of wireless devices, one-hop neighbor nodes have many oppor-tunities to overhear coded packets. Information pools store undemanded primitive or coded packets overheard as fundamental knowledge for decoding coded packets, and buers store demanded primitive packets. Let buer denote the buffer, and virtualQueuew the virtual queue for neighbor w.

As one node has a transmission opportunity, it rst dequeues a primitive packet p from its buer buffer and assigns it to coded packet codedP acket. The node records the nexthop of p into nextHop to keep a list of all the possible receiving nodes in this coding procedure.

Then, for all its one-hop neighbors w from its one-hop neighbor list neighbor, it extracts a primitive packet q from the virtual queue virtualQueuew and checks whether for all nodes v in nextHop ∪ w can successfully retrieve their demanded primitive packets after coding the content of this packet into codedP acket. If there exists any node that is unable to successfully retrieve its demanded primitive packet, it takes out another primitive packet q' from the virtual queue virtualQueuew to substitute for primitive packet q and re-runs the previous step, until new coded packet codedP acketcan be retrieved successfully by all nodes v in nextHop ∪ w or until there is no unveried primitive packet in the virtual queue virtualQueuew. The content of a primitive packet is rstly encoded into codedPacket if its receivers can both retrieve it from codedPacket and the content of the retrieved primitive packet is the desired one for its receiver. If q can be encoded into codedP acket, codedP acket is encoded with q and nextHop is updated to nextHop ∪ w. The coding procedure for which the greedy heuristic is to increase as many receiving nodes as possible.

A node retrieves information from the coded packet followed by the decoding procedure as shown in Procedure 2. Each node maintains an information pool infoP ool that records a copy of the information of a packet it has received, sent out or retrieved from the coded packet. A node can retrieve information from the coded packet codedP acket with n primitive packets by XOR operation if it has exactly the same n − 1 primitive packets in its infoP ool.

The coding and decoding procedures of the XOR coding algorithm are described in the algorithm 1 and the algorithm 2. While a transmitter has a transmission opportunity and is in preparation of selecting primitive packets from its virtual queues, four conditions should be considered while decideing on what kind of primitive packets should be selected. The four conditions are as follows:

PROCEDURE 1 XORencoding (buf f er, neighbor)

Require: buffer stores primitive packet and neighbor is a list of one hop neighbors.

dequeue a packet p from buffer.

the coded packet codedP acket = p nextHop = {the next hop of packet p}

for ∀w ∈ neighbor do

extract a primitive packet q from virtualQueuew

while ∃v ∈ nextHop ∪ {w}, v cannot decode the coded packet p && virtualQueuew

has unveried primitive packet do

extract a primitive packet q from virtualQueuew

end while

codedP acket = codedP acket ⊕ q nextHop = nextHop ∪ {w}

remove q from buffer end for

return codedP acket

PROCEDURE 2 XORdecoding (v, codedP acket)

Require: node v that wants to decode the received coded packet codedP acket if codedpacket is unscramble then

extract the primitive packet q from coded packet codedP acket if v is the next hop of q then

put q into the bufferv

else

put q into the infoP oolv for the future decoding purpose end if

else

put codedpacket into the infoP oolv

end if

1. Any of the primitive packets' nexthops are not the same. If a transmitter selects the primitive packets P1,P2,..., Pn and two or more primitive packets Pi,Pi+1,..., Pj are transmitted to the same nexthop N, when nexthop N receives the coded packet P0 = P1⊕ P2⊕ ... ⊕ Pn, it cannot recover primitive packets Pi⊕ Pi+1⊕ ... ⊕ Pj from coded packet P0, and Pi ⊕ Pi+1⊕ ... ⊕ Pj is still a scramble for a receiver. Therefore, path diversity must be satised.

2. All the receivers R1, R2, .., Rnhave the packets P0 = P1⊕ P2⊕ ... ⊕ Pi−1⊕ Pi+1⊕ ... ⊕ Pn XORed from their information pools, if a transmitter selects the primitive packets P1,P2,..., Pn to be XORed together. In other words, all the receivers R1, R2, .., Rn have the packets P1 ⊕ P2 ⊕ ... ⊕ Pi−1⊕ Pi+1⊕ ... ⊕ Pn, meaning that all the receivers can recover their demanded primitive packet Pi by calculating Pi = (P1⊕ P2⊕ ... ⊕ Pn) ⊕ (P1⊕ P2⊕ ... ⊕ Pi−1⊕ Pi+1⊕ ... ⊕ Pn).

3. Encode the maximum number of primitive packets in each transmission. If a

trans-to its one-hop neighbor nodes, a large number of nexthops would receive them and may recover its demanded primitive packet in one single transmission. Thus, the more primitive packets are encoded in each transmission the more ecient the network throughput can become.

4. The primitive packets selected to be encoded together should have the similar bit length. Should any dierence in bit length exist between primitive packets selected by a transmitter, the shorter ones are padded with trailing zeros to their data until their bit length is as long as the largest one's. Then, a transmitter can begin to encode them by the XOR coding algorithm and broadcast the coded packets to one-hop neighbors.

In such a transmission, some bandwidths are wasted because useless padded zeroes are also transmitted, the process of which consumes the network capacity. Thus, enlarging the shorter primitive packets by padding zeros wastes the bandwidths of the network. Therefore, by selecting primitive packets with similar lengths to be encoded, the eciency of network bandwidth use can be boosted.

The following example (in [5]) shows how the XOR coding algorithm works and gains benets, and the previous conditions avail. In Figure 3.1(a), node A has packets P1, P2, P3, P4

in its buer and its one-hop neighbors B, C, D overhear some packets. It is assumed that A knows which packets one-hop neighbors have. When A has a transmission opportunity, if A picks up packets P2 and P3 to be encoded into P2⊕ P3 and transmits it, C receives it but can neither extract packet P2 nor packet P3 with packets P1 and P4 in its information pool. Since packets P2 and P3 have the same nextstop, they are not able to be selected to be mixed at the same time. Therefore, any of the primitive packets' nexthops are not the same. (see the previous condition 1).

If A picks up packets P1, P2 and P3, which are to be encoded into P1⊕ P2⊕ P3, which is received by D, D would decode P1⊕P2⊕P3 into P1⊕P2 = (P1⊕ P2⊕ P3)⊕P3. But it cannot extract packet P1 with packets P2. Only when D has one more packet P2 can it recover P1

A

Primitive packets in A’s Buffer Next Hop

(a) A can encode primitive packets to transmit. (b) Nexthops of primitive packets in A's buer.

Figure 3.1: Let the primitive packets to be encoded maximal numbers in each transmission.

from P1⊕ P2⊕ P3 with packets P2 and P3. Therefore, all the receivers R1, R2, .., Rn have the packets P0 = P1⊕ P2⊕ ... ⊕ Pi−1⊕ Pi+1⊕ ... ⊕ Pn XORed from their information pools, if a transmitter selects the primitive packets P1,P2,..., Pnto be XORed together (see the previous condition 2). This certainly ensures that all nexthops can recover their demanded primitive packets from the received coded packet.

Because B and D have packet P33, and none of the nodes has packet P2, packet P3 is more likely to be decoded and is better than packet P2. Therefore, four conditions may occur in terms of packet selection. First, if A selects packets P1 and P3 to be encoded, because C has packet P1, and D has packet P3, C and D can recover their demanded packets from P1 ⊕ P3. Thus, A delivers two packets in one transmission. Second, if A selects packets P1 and P4 to be encoded, because B has packet P1, and D has packet P4, B and D can recover their demanded packets, and A also delivers two packets in this one transmission.

Third, if A selects packets P3 and P4, the same result would occur, and B and C can extract their demanded packets, whereas A delivers two packets in one transmission. Finally, if

packets P1 and P4, and D has packets P3 and P4, each one can recover its demanded packet from P1 ⊕ P2 ⊕ P3. In this case, A delivers three packets in one transmission. Thus, the more primitive packets to be encoded in each transmission, the better it is for network throughput (see condition 3 mentioned above). Therefore, four approaches should be taken while selecting which primitive packets to be encoded.

相關文件