## 4 Design of SocialCode
### The Flow of SocialCode
#### 4.4.2 The CCD Reception Procedure  
The flow of the CCD reception procedure is shown in Figure 7. Its details are described as follows.  
_Appl. Sci._**2018**, \(8\), 2035  
Figure 7: Flow of the CCD reception procedure.  
When node \(v\) receives the beacon message sent by a destination node, it will store the ID, selfishness, interest and bitmap values carried in this beacon message. At this time, this procedure has been finished.
2. If this beacon message is issued by an intermediate node, node \(v\) stores the ID, selfishness, interest and queue length of this intermediate node and the ttl value of the first packet in the output queue of this sending node. Then node \(v\) exits this procedure.
3. If node \(v\) receives an ACK(CR) packet which carries the credit value CR, it will update its credit value \(credit_{v}\) as \(credit_{v}+CR\)) and stop this procedure. For example, when the nearby destination node has successfully received an innovative SLNC-coded piece broadcast by node \(v\) in the preceding service time slot, it would subtract \(\alpha\) from its credit value and send an ACK(\(\alpha\)) back to node \(v\) for increasing the credit value of node \(v\) by \(\alpha\).
4. If node \(v\) does not receive an ACK(CR) packet at step 3, if further checks whether the ttl value of the received packet, that is, the SLNC-coded piece, is zero or not. If yes, it must drop this piece. Otherwise, it will decide its node type based on its interest and selfishness values for this piece.
5. If node \(v\) is the irrelevant node, it will drop this piece and exit this procedure.
6. If node \(v\) is the intermediate node, it will check whether its credit value is not less than \(\delta\). If no, it will drop this piece and exit this procedure.
7. If node \(v\) finds this piece is a duplicate one, it will add \(\delta\) to its credit value, drop this piece and finally reply an ACK(\(-\delta\)) to punish the nearby node that broadcasts this duplicate piece. Otherwise, it will subtract \(\delta\) from its credit value, store this piece in its output queue and finally reply an ACK(\(\delta\)) to stimulate the node that forwards this non-duplicate piece. Then node \(v\) exits this procedure.
8. If the type-checking operation at step 4 recognizes node \(v\) is not the irrelevant or intermediate one, this node must further examine whether the received SLNC-coded piece is innovative to it. If no, it will drop this piece.
9. After this, there are two cases to handle. First, if node \(v\) is a destination one, it will increase its credit value by \(\beta\) and reply an ACK(\(-\beta\)) to punish the node broadcast this non-innovative piece. Second, if node \(v\) is an overhearing one, it will not issue an ACK packet to request any credit from the sending node when it receives a non-innovative piece, according to guideline 2 in Section 3.2. Then node \(v\) exits this procedure.
10. If node \(v\) receives an innovative SLNC-coded piece at step 8 and its credit value is less than \(\alpha\), it must drop this piece and exit this procedure, even this piece is innovative to it. Otherwise, it will subtract \(\alpha\) from its credit value, reply an ACK(\(\alpha\)) to stimulate the node broadcast this coded piece, cache this piece in its decoding buffer and try to decode buffered pieces.
11. If the original content pieces can be decoded from buffered pieces, node \(v\) will pass them to the upper layer. Otherwise, node \(v\) stops this procedure.
12. Further, if this node is the destination one, it will update the SLNC-coded pieces that will be broadcast in successive service time slots when it has recovered the original content pieces. If this node is the overhearing one, it will not re-broadcast the received pieces, due to its high selfishness on this content data. After this step, node \(v\) has finished its CCD reception procedure.