## 4 Design of SocialCode
### The Flow of SocialCode
#### 4.4.1 The CCD Broadcast Procedure  
As shown in Figure 6, steps of the CCD broadcast procedure are listed below. Please note that intermediate node \(v\) forwards its first SLNC-coded piece in queue only after each destination node \(i\) has re-broadcast _C(i)_ pieces because its backoff timers, that is, \(\Delta t_{int}(v)\), is longer than that, that is, \(\Delta t_{des}(i)\), of each destination node \(i\).  
(1)When node \(v\) starts the CCD broadcast procedure, it will check whether its output queue has cached SLNC-coded pieces. If no, this node has completed its CCD broadcast procedure.  
Figure 6: Flow of the CCD broadcast procedure.  
Otherwise, this node decides its node type, according to its selfishness and interest values on SLNC-coded content pieces stored in its output queue.
3. If it is the overhearing or irrelevant node, it will not re-broadcast the piece to its nearby nodes. This node then exits its CCD broadcast procedure
4. If this node is the destination node, it will first adopt Equation (1) to calculate its aggregate utility, that is, _util(v)_, based on the selfishness, interest and content bitmap values carried in beacon messages, which are issued by nearby destination nodes. Then, this node will use Equations (2) and (3) to calculate its backoff delay, that is, \(\Delta t_{des}(v)\) and the number of re-encoded content pieces, that is, \(C(v)\), respectively. Finally, it re-encodes \(C(v)\) content pieces, which initial ttl values are set as \(ttl_{max}\).
5. After that, this node has to check whether its credit value is not less than \(|N(v)|\times\beta\times C(v)\), because it must re-broadcast all \(C(v)\) pieces in one batch [18; 19].
6. If yes, it then defers its transmission until its backoff timer expires. At this time, if this node senses an idle service channel, it will update current ttl values of all \(C(v)\) re-encoded content pieces.
7. Later on, it re-broadcasts these content pieces only when their current ttl values are greater than 0. If ttl values of these content pieces are equal to 0, this node will drop these pieces. At this time, this node has finished its CCD broadcast procedure.
8. If the credit value of this node is less than \(|N(v)|\times\beta\times C(v)\) at step 5, it has to wait for next service time slot and goes back to step 5.
9. If node \(v\) is the intermediate node after step 2, it will check whether the ttl value of this received piece is larger than 0. If no, it drops this piece and exits the CCD broadcast procedure.
10. If the ttl value of this received piece is larger than 0, this node has to check whether its credit value is less than \(|N(v)|\times\beta\).
11. If the credit value of intermediate node \(v\) is not less than \(|N(v)|\times\beta\) at step 10 and there is any nearby intermediate node, it adopts Equations (4) and (5) to compute its forwarding priority, that is, \(pri_{v}^{t}\) and backoff delay, that is, \(\Delta t_{int}(v)\), respectively.
12. When the backoff timer, that is, \(\Delta t_{int}(v)\), of intermediate node \(v\) expires, it will broadcast the first SLNC-coded content piece in its queue. Details operations of this step are similar to those of steps 6 and 7 for destination nodes. After that, this node has finished its CCD broadcast procedure.
13. If the credit value of this intermediate node is less than \(|N(v)|\times\beta\) at step 10, it has to wait for next service time slot and goes back to step 10.