# Efficient V2V Communications by Clustering-Based Collaborative Caching +
## 3 The Proposed Method
### Content Fetching  
Here, we explain how content is fetched in the proposed method using Figure 4.  
When a CM requests content, it sends an interest packet containing the name of the requested content to its CH (step 1 in the figure). The CH tries to reply to the request in the following order.  
* If the CH itself has the requested content, it replies with a data packet.
* If one of its CMs has the content, the CH adds the ID of the request vehicle to the interest packet and forwards it to the CM that has the cached content (step 4 in the figure).
* If no vehicle in its cluster has the requested content, the CH first tries to forward the interest packet to other CHs according to its FIB (steps 2 and 3 in the figure).  
Figure 4: Communication process of the proposed method.  
Figure 3: After receiving the beacon, a new cluster will be created.  
When a CM receives an interest packet from its CH and has the requested content, it sends a data packet to the requester (step 5 in the figure). The CM communicates with the requester directly if it can, and otherwise, it relays the content via its CH. Due to potential packet loss in the wireless environment, a CM may not have the requested content. In such cases, the CM sends a content-not-found message to its CH. Then, the CH, accordingly, forwards the interest packet towards the content provider via other CHs.  
A CH, on receiving a data packet, forwards it to the content requester according to the PIT (steps 6 and 7 in the figure).  
In some cases, there may be no CH available as a forwarder. A CH forwards an interest packet to the CM that is closest to the content provider, using this CM as a relay. When a CM receives an interest packet from a CH outside of its cluster, it sends the interest packet to its CH which further forwards this towards the content provider.  
Algorithm 1 is the pseudo-code for interest and packet handling.  
```
1 ProcedureOnRecievingInterestPacket
2 ifAm 1 a CH?then
3 ifDo I store the requested content?then
4 Reply with a data packet;
5 elseifDose one of the CMs store the requested content?then
6 Forward the interest packet to the CM;
7 else
8 Forward the interest packet towards the content provider;
9
10 end if
11 else
12//Interest packet handling for a CM
13 ifDo I store the requested content?then
14 ifIs it possible to send a packet to a one-hop-before vehicle?then
15 Send a data packet to the vehicle;
16 else
17 Send a data packet to the CH;
18 end if
19 else
20 Send a content-not-found packet to the CH;
21
22 end if
23
24 end if
25 ProcedureOnRecievingDataPacket
26 ifAm 1 a CH?then
27 ifIs the packet destination one of my CMs?then
28 Forward the packet to the CM;
29 ifDoes the CM have empty buffers?then
30 Record that the CM has the content in the buffer;
31 else
32\(//\)StoreContentInCluster is defined later.
33 Call StoreContentInCluster with the content as the parameter;
34
35 end if
36 else
37 Forward the packet according to PIT;
38 Call StoreContentInCluster with the content as the parameter;
39
40 end if
41
42 end if
43
44 end if
45
46 end if
47
48 end for
```  
**Algorithm 1**Packet management