# SLoPCloud: An Efficient Solution for Locality Problem in Peer-to-Peer Cloud Systems
## 4 Proposed Solutions for Locality Problem in P2P Cloud System
### Cube Connected Cycle Based Overlay Network  
A CCC graph is constructed from a x-dimension Hypercube graph in which each node is replaced by an \(x\) node Ring. In this topology, each node has a coordinate address represented with two numbers \((p,q)\), while \(0<p<x-1\) and \(0<q<2^{x}-1\). As stated above, CCC has also an optimal routing algorithm and benefits from a fixed and small degree, exactly equal to 3, for any number of nodes. While the general locality solution for CCC is as the same as that of Hypercube, the optimal routing algorithm is as follows. At first, the second element of the source and destination addresses are compared. Each \(q\) element contains \(x\) bit binary digits. If \(q\) is the same in both nodes, then \(p\) elements are compared. A difference in \(p\) elements means a difference in the dimension of two nodes. Therefore, to reach the destination node, the path must be moved on the Ring to change the dimension. When the \(p\) elements become equal to each other, then the \(q\) elements have to be compared. If \(q\) values are not equal in both addresses, the corresponding dimension's bit of \(q\) is compared between the source and destination addresses. If they are not equal, the source bit is flipped to become equal to that of the destination. Otherwise, the bit stays as it is. At the next step, the other bits of the parameter \(q\) for the next dimensions have to be compared. When the \(q\) elements of both addresses become equal, the destination is already reached. ```
1: Start the initialization phase of the network by network admin. 2: Form the overlay topology by considering the number of Hypercube dimensions, i.e. \(d\). 3: Arrange the position of the first set of nodes, i.e. \(\aleph\), on the overlay layer as the nodes with lower RTT are placed close to each other. 4: Start the process of joining new nodes. 5: A new node joins the network. 6:repeat
7: The new node broadcasts a message to notify all of its neighboring nodes, far away based on TTL. 8: Wait for a specific timeout, \(\theta\). 9:if no response is received, then
10: Increase TTL by one. 11:endif
12:until The first response is received. 13: Start to assign addresses to the new node, beside the responder. 14: Consider the address of the responder. 15:repeat
16: Flip the least significant bit
17:if The new address is not assigned previously, then
18: The address is assigned to the new node
19:else
20: The changed bit is reset and the next bit is flipped. 21:endif
22:until An address is assigned to the new node. 23:for all nodes \(j\) that are placed in one or two hops away from the newly joined node, in the overlay network. do
24: calculates the RTT among node \(j\) and the new node. 25:endfor
26:while there are still two neighboring nodes in which the RTT of the far away node is less than the more closer one, do
27:for all two neighbor nodes \(i\) and \(j\)do
28: if RTT of one node is less than the other, swap these two nodes. 29:endfor
30:endwhile
31:return 0
```  
**Algorithm 1**SLoPCloud\((d,\aleph,\theta)\)  
Consider an example of the 3-dimension CCC as stated in Figure 3) while \(p\in\{0,1,2\}\) and \(q\in\{000,...,111\}\). Consider nodes \(5:(2,010)\) and \(D:(1,111)\) as the source node and the destination node, respectively. First, by comparing the \(q\) elements we realized that the source node is at the second dimension, i.e., \((p=2)\), while the second bits are not as the same. Therefore, \(q\) element of \(S\) becomes \(110\) and \(p\) element does not change. Then, the dimension is increased by one and becomes zero in modulus of 3, i.e., \(p=(2+1)\%3=0\). The least significant bits are different, therefore \(q\) element changes to \(111\) while \(p\) remains 0. At the next step, we have to change the value of the dimension,i.e., \(p\), to \(1\). Now the source and destination are both at the same dimension and their \(q\) elements are equal. The overall flow of routing, starting from the source node \(S\) and terminating at the destination node \(D\) is as follows.