## 3 Proposed Method
### Cluster Maintenance  
Whenever a cluster member goes out of range of its cluster head for consecutive three beacon intervals, the vehicle changes its color to white and checks its neighborhood information (\(N_{u}\)) to determine if there is any other active cluster head available in its range. If so, it becomes a member of that cluster and sets the colour and \(C_{id}\) accordingly. Otherwise if it senses any passive cluster head in its transmission range, the vehicle sends a request to that cluster head to trigger it as an active cluster head, and join in that cluster; if there is no cluster head, but a \(GW\) node is available in the neighborhood, it remains un-clustered, however still receives messages that are broadcasted by that \(GW\) node. If no \(GW\) is available, then it initiates the cluster head selection process. If no white neighbours exist in its neighbourhood for a given period, then the node becomes cluster head and the blue neighbours in its range when receiving the beacon from the new cluster head node becomes candidate \(GW\) and the \(GW\) selection process starts.  
Figure 4 represents the state transition diagram showing when the state transition is triggered in vehicles during the execution of the proposed algorithm. Initially, all the vehicles are in the \"Unclustered\" state. If there is any cluster head detected in its neighborhood, it becomes the member of that cluster and transits to \"Cluster Member\" State. If it can hear from more than one cluster head in its transmission range, then it transits to \"Candidate Gateway\" state. If there is no cluster head detected in its transmission range, having few more \"Unclustered\" vehicles then it transits to \"Candidate Cluster Head\" state. After exchanging DC value among 2-hop neighbors, if it has the highest DC then it transits to \"Cluster Head\" and other vehicles with lesser DC will transit to \"Cluster Member\" state. A candidate gateway vehicle upon receiving GW selected message from its cluster head transits to the \"Gateway\" state and others which are not selected will transit back to the \"Cluster Member\" state.  
Figure 3: Cluster formation and gateway selection.  
A cluster member vehicle or gateway vehicle not receiving beacon message for three consecutive intervals will transit back to the \"Unclustered\" state. Also, a cluster head having no neighbors in its transmission range transits back to the \"Unclustered\" state.  
Figures 5 and 6 show the flow chart for cluster formation and gateway selection processes. All vehicles periodically broadcast the beacon message consisting of (id, speed, direction, color, and cluster id). Each vehicle upon receiving the beacon messages from its neighborhood updates its neighbor table \((N_{u})\). If there are no cluster heads which exist in its neighborhood \((N_{u})\), then it becomes the candidate cluster head and computes the degree of cohesion as per Equation (1) and broadcast it to its 2-hop neighbors. Upon receiving DC from other candidate cluster heads in its 2-hop neighborhood, the vehicle with highest DC becomes the cluster head (CH) and others upon receiving the CH message, become the cluster member. If only one cluster head (CH) is detected in its neighborhood \((N_{u})\) then it becomes the member of that cluster. If there more than one CH is detected, then it attaches itself to the CH with highest DC in its transmission range and it becomes a candidate gateway and sends the ids of the CHs it can hear in its transmission range to its CH. Upon receiving the candidate gateway (CGW) messages, the cluster head initiate the Gateway Selection process as described in Section 3.3. Upon receiving the GW Selected message from the CH, the vehicles which are selected by the CH become the GW and others become cluster member.  
Figure 4: State transition in vehicles.  
Figure 5: Cluster formation algorithm.