## 3 Proposed Smart Route: IoV-Based Congestion Detection and Avoidance (CDA) Using Rerouting
### IoV-Based Congestion Detection (IoV-Based CD)  
Vehicular mobility is an essential factor that influences the structure of vehicles' dynamics. Despite the high speed and randomness of the vehicles' speed, road topology, speed limits, traffic rules, and nearby vehicle speed restrict the vehicle movement. To design a feasible traffic congestion detection scheme, it is essential to consider the relationship between speed and inter-vehicle spacing [40]. In this paper, we used the essential mobility factors for traffic jam detection and prevention. In the given scenario (as shown in Figure 2), four junction points are highly susceptible to the massive traffic jam. Thus, to avoid unwanted enormous traffic jam, it is necessary to predict real-time congestion on each vulnerable junction point. For this purpose, it is assumed that each arrival point has an RSU located significantly away (i.e., 1 km) from the AOI so that to detect early congestion. The installed RSU acts as a traffic controller and aims to monitor the specified road segment for real-time congestion detection. Considering the basic transportation rules [41] and basic microscopic parameters [20], we derived two parameters for congestion detection, i.e., (1) road segment occupancy rate and (2) single-vehicle occupancy time. The definition of the occupancy rate is given in the above section. However, occupancy time can be defined as below:  
**Definition 1**.: _The single-vehicle occupancy time is the amount of time required by a vehicle to cover a particular distance (equal to the vehicle's length) with its current speed [42]. Mathematically, it can be written as below:_  
\[O_{t}=\frac{L_{v}}{V_{v}} \tag{5}\]  
_where \(O_{t}\) is the occupied time of a particular vehicle. The parameters \(L_{v}\) and \(V_{v}\) represent the length of the vehicle and the speed of the vehicle, respectively. The congestion can be detected with the help of the road segment occupancy rate (i.e., if \(O_{i}>0.7\), then segment \(i\) is considered to be congested) or vehicle occupied time (i.e., if \(O_{t}>0.6s\), then the given zone will be congested). The values of both metrics, i.e., occupancy time and occupancy rate, are derived from the safety transportation time limit, i.e., time headway [20]. The complete procedure of the IoV-based CD is given below in Algorithm 1._  
In Algorithm 1, it is shown that initially all vehicles register with RSU. The registration of a particular vehicle is done by the periodic Hello messages/Beacons disseminated by every vehicle on the road. Later, the total capacity of each road segment, the current number of vehicles, the occupation rate, and the occupation time are calculated. The occupation rate and occupation time are the primary factors for congestion detection. If the values of these factors exceed the given threshold, the congestion will be detected, as shown at the end of Algorithm 1.  
```
1:for\(s\in S\)do
2:\(RSU\longleftarrow Register\)
3:endfor
4:\(C\longleftarrow\frac{S\xi_{long}}{v_{long}+min\psi}\)
5:\(K_{c}\longleftarrow\mathit{Count}(V,seg)\)
6:\(O_{rate}\longleftarrow\frac{K_{c}}{c}\)
7:\(O_{t}\longleftarrow\frac{1}{V_{c}}\)
8:if\(K_{c}>\delta\) OR \(O_{t}>\tau\)then
9:\(\mathit{Con\_Dec}\longleftarrow 1\)
10:else
11:\(\mathit{Con\_Dec}\longleftarrow 0\)
12:endif
```  
**Algorithm 1** IoV-based Congestion Detection (executed at RSU).