1 Introduction

Vehicular ad hoc Networks (VANETs) and Cellular Mobile Networks (CMN) have no previous defined topology and nodes can move freely. In other words, flexibility in topology is an important aspect of these networks. As the VANET environment matures, more and more new networks are being used, including cloud-based networks and software-based networks. They require to access to the available resources in a secure platform and with high quality (Javadpour et al. 2020; Javadpour 2019a). Nodes can be considered as routers or end-systems to share communication resources with others and transmit data through dynamic backbone. VANETs are a different form of mobile ad hoc networks (MANETs) with some differences in communication nodes and environment (Wu et al. 2013; Liang et al. 2015). WAVE (Wireless Access in Vehicular Environments) protocol provides basic conditions for implementing VANETs in Dedicated ShortRange Communications (DSRC). Rapid advances in the field of wireless communications technologies have created a lot of changes in various areas in our everyday lives (Kponyo et al. 2013). One of the applications which is expected to be very lucrative is the safety of vehicles. Smart vehicles with wireless communication equipment can quickly communicate with each other and with RSUs (Liang et al. 2015). It helps to prevent traffic congestions, suggest alternative routes, estimate arrival times and generally improve road safety and performance (Eze et al. 2014; Wolny 2008). Discussions and investigation on the causes of accidents have increased not only by researches in universities but even by industry and governments. Routing in VANETs is affected by several conditions such as environment, vehicles location, directions and speed and atmospheric conditions. On the other hand, driver behavior; restrictions and road rules; mobility and high speeds cause changes in topology of the network. (Abboud and Zhuang 2016; Hossain et al. 2017).

Considering the importance of maintaining QoS in traffic jams, in the proposed method we use PSO algorithms to find the optimized route in VANETs. It combines IEEE 802.11P-based multi-hub clustering to accomplish acceptable packet delivery rates and low latency. The structure of paper is as follows: the first section contains the introduction of VANETs and QoS Routing (QoSR) and then we will review some related research background. The next section presents the proposed method for implementation common standards and simulation tools are considered. In forth section the results of applying NS2 simulator to evaluate the proposed method are presented. We also used VanetMobiSim (Sohail and Wang 2018), a specific simulator for VANETs to examine the behavior of vehicles. Finally in the last section, we summarized our work with discussions and conclusions.

2 Literature

A number of routing methods for VANETs have been presented in the literature, but the high mobility of high speed cars and the variation in speeds in different environments have not been analyzed in depth. Data transmission quality plays a very important role in the intellectual transport system (ITS). The concept of routing algorithms has been examined in VANETs recently. It is due to the specific requirements of VANETs, such as speed, adequate response time which make the available wireless algorithms are not suitable for VANETs (Eze et al. 2014). The network should be designed in a way which it transmits delay sensitive messages such as safety messages instantly. Safety messages include post-accident warning, road safety warning, speed/stop advisor, road traffic warning, line change and emergency vehicle approach. Flooding dissemination and geographic distribution, request-response, subscription, broadcast and routing are all types of data transfer protocols that have been used. Routing in VANET is used for optimally disseminate, reduce overhead and reduce the delivery latency of a message.

Authors in Hashem Eiza et al. 2015 present a situation aware (SA) routing protocol implementing ant colony algorithm. The purpose of this protocol is to resolve the path locally and send error messages to the source node to interrupt the current data transfer. The conceptual model of this article is illustrated in Fig. 1. First step in SA refers to awareness of the environmental and vehicles conditions such as the location, direction, speeds, traffic and atmospheric conditions. In the next step, all the information should be used to present an up to date routing algorithm. In the final step, it is necessary to predict the route of the vehicles and the time period of connection. The achieved QoSR rate has 7.65% error.

Fig. 1
figure 1

Classical model for Routing in VANETs (Hashem Eiza et al. 2015)

In (Lei et al. 2014) MPLS-based routing algorithm is proposed for VANETs. It assumes that vehicle has a numerical map based on source and destination addresses to find the best route. Authors in Perdana et al. (2015) consider a weight for each node based on connection quality and mobility to increase the reliability. The MultiHop algorithm in Salvo et al. (2015) follows moving nodes and increases the survival time of the cluster and reduces global overhead. Cluster size can change according to the population of the vehicles, the speed and minimum required bandwidth or QoS. Routing in VANETs can be separated into three groups, proactive routing, reactive routing and hybrid mode. In reactive mode, routing takes place on demand but it requires a lot of energy to get the path. Proactive routing is suggested for situations in which the location of the nodes is clear. In the hybrid mode, a combination of proactive and reactive routing is used based on the network status (Watfa 2010). In Table 1, we have provided a detailed comparison of the studies in the literature.

Table 1 Comparing different routing algorithms in VANET

3 Proposed method (QoSR-PSO)

In VANETs, several nodes act as hosts and routers at the same time. Due to movement of them in different topologies, the major challenges of mobile ad hoc network are to create reliable paths and reduce latency (Bhavana et al. 2012). Nodes may also run out of energy and break down the network. It is important to consider energy level of nodes (Hashem Eiza et al. 2015; Javadpour et al. 2018b; Mirmohseni et al. 2021). In this section, a QoSR is proposed for VANETs to reduce response time, improving QoS, updating the load balancing by using the PSO algorithm. Recently, due to the large development of heuristic algorithms for various applications, many researchers have focused on using these algorithms for routing in the network. The major disadvantages of these methods are uncertainty in reaching the optimal solution. The most important advantages are the abundance of maneuverability, their simple and very fast design. Choosing the right fitness function is necessary to choose the best cluster as there are many cases in which sender and receiver are not directly connected and they need to find the best routing path.

Figure 2 shows nodes communication with RSUs by a bilateral graph. Vehicles in the transition domain of a cluster head (CH) is shown with dashed line. Cluster members (CM) communicate directly with their respective CHs (Ucar et al. 2016). CMs can transfer with others through IEEE80211P MAC. eNode is a sophisticated base station that controls radio communications by many tools and integrates radio resource management and decision-making. When an eNodeBS receives a data packet for propagation, it will be distributed multiple times for all CHs covered by RSUs.

Fig. 2
figure 2

An overview of node communication in VANETs (Ucar et al. 2016)

The proposed algorithm based on particle swarm optimization is explained in detail in this section. PSO is a soft computational method that is generally based on bird swarm theory. PSO is developed by continuously optimizing nonlinear functions. In addition to finding space and adjusting vehicle positions for the optimal positioning, it takes into account the previous position of the vehicle and the previous positions of its neighbors. There are many constraints involved in VANETs, such as frequent topology changes, interference, predetermined transport directions, clustering, and extremely high vehicle speeds. Therefore, choosing the next vehicle (CH) is an important task in VANETs.

We present our QoSR routing algorithm based on PSO. It is a global optimization method that solves problems when the answer is an argument or an external in n dimensional area. PSO searches for optimal solution of the problem by modeling the behavior of a set of particles. By moving these particles in the reaction space, the evaluation of the results is performed on the basis of a merit criterion. Over time, particles tend to accelerate toward particles with a higher merit values in the same communication group. The abundance of swarming particles makes the method flexible against the local optimal response problem. It specifies any particle that has a position.

$$ v_{i}^{t + 1} = w*v_{i}^{t} + c_{i} *{\text{rand}}_{1} *\left( {y_{i} - x_{i}^{t} } \right) + c_{j} *{\text{rand}}_{2} *\left( {y_{j} - x_{i}^{t} } \right) $$
(1)
$$ x_{i}^{t + 1} = x_{i}^{t} + v_{i}^{t + 1} $$
(2)
$$ w = w_{\max } - t*\frac{{w_{\max } - w_{\min } }}{t\_\max } $$
(3)

Particle i moves in space with speed of vi(t) at iteration t. Particles memorize the best positions throughout their lives. The best experience of a particle or the best position observed by particle is called yi. Particles are aware of the best observed position in the entire group which is called \({\widehat{y}}\). The ci and cj are constant and w is the initial weight that decreases linearly from wmax to wmin. t-max is the maximum number of repetitions that are considered for the algorithm. It is expected to increase the QoS by utilizing PSO in dedicating the communication path between two vehicles. The flowchart of applying PSO to VANET is illustrated in Fig. 3. The details of our method for path routing are shown in Table 2.

Fig. 3
figure 3

Proposed path optimization algorithm by using collective particle optimization in VANET

Table 2 QoSR-PSO path routing optimization algorithm

4 Simulation and evaluation

The network model has been implemented with MobiSim's VANET package. The network's nodes are distributed randomly based on the class model for the intended layers. There are two scheduling protocols for RSUs: LTE and TDMA. The UDP and TCP protocols are used for communicating between nodes and clusters. For simulation, QoS-related criteria such as Packer Delivery Rate (PDR), overhead are considered. Schematic overview of the simulation of this research is shown in Fig. 4. The XML file depicted in Fig. 4 contains relative information about the vehicle schematic diagram. In addition, NS2 simulator helps in planning and executing TCP and UDP algorithms for wired and wireless networks. A vehicle's behavior can also be changed by modifying network algorithms with NS2. NS2 is implemented in a platform using C +  + programming language with an Otcl interpreter as user interface. In addition to networking protocols such as UDP and TCP, NS implements various traffic models such as Web, Telnet, VBR, and FTP routing algorithms, in addition to several queueing mechanisms such as RED and CBQ.

Fig. 4
figure 4

Schematic overview of routing simulator in this research based on different transmission protocols

In order to simulate and evaluate the proposed protocol, we need to choose a suitable mobility model for VANETSs. Each mobility model defines the movement pattern of the nodes including the pattern of displacement, velocity, and acceleration of the nodes over time. The more the mobility model in the simulation is in line with the suitable mobility model of moving nodes in real situation, the closer the simulation results will be to the reality. Figure 5 shows the classification of existing mobility models (Ananda and Devaraju 2017).

Fig. 5
figure 5

Some of self-contained mobility for QoSR [39]

In the first presentation of the Random Waypoint model, it was used to calculate QoSR in self-contained networks. Each node stops for a predefined period called the pause time (PT), and then moves toward a random point in a straight line at a random velocity. In order to reach other points, it repeats the same procedure after reaching the destination. Research from the CMU Monarch team has generated the Random Waypoint mobility model for NS2. This tool allows the user to define pause time, maximum speed, number of nodes, and dimensions of the node mobility environment, as well as the duration of the network simulation.

The proposed algorithm is compared in different scenarios in terms of different evaluation criteria (permittivity and delay), with SAMQ algorithm (Hashem Eiza et al. 2015). Our simulator is a combination of NS2 software with VanetMobiSim to simulate vehicular ad hoc networks. NS2 is a discrete-event simulation tool suitable for dynamic nature of communication networks (Mirjazaee and Moghim 2015; Fathy et al. 2012; Javadpour 2019b; Sangaiah et al. 2021). VanetMobiSim simulates roads and geo-routing of transport in urban space scenarios in VANETs. We use random mobility to simulate and evaluate proposed protocol for VANETs. The more simulation parameters are in line with mobility pattern of vehicles in reality, the results are more accurate and reliable. Nodes stop at a predefined time (stop time), move to a randomly determined point with a random speed. Throughput is calculated according to Eq. (8). In this relation μ the number of bits received in t time unit. The EndToEnd delay is calculated according to Eq. (9). D is delay of a packet, Td is the arrival time of packet to destination, and Ts is transportation time. Packet delivery ratio (PDR) is equal to ratio of received packets to (Receive_Pckt) number of sent ones (Sent_Pckt) and is presented in Eq. (10).

$$ {\text{Throughput}} = \frac{\mu }{t} $$
(8)
$$D = T_{d} - T_{s}$$
(9)
$${\text{PDR}} = {\text{Received}}\,{\text{Packets}}/{\text{Sent}}\,{\text{Packets}}$$
(10)

4.1 Evaluation and results

The results of proposed method (QoSR-PSO) created on collective PSO is presented on a 10-km six-lane traffic scenario with two independent driving directions for vehicles. We implement the highway with typical mobility presented in [51], which is based on road traffic concept, instructions and drivers’ behavior. The results are compared with SAMQ, GA, MPLS, VACO, PUMA and Multi-hop methods for different criteria, packet delivery rates, routing overhead, delay and lost packets (Hashem Eiza et al. 2015). Figure 6 illustrates simulation scheme is shown in Linux urban environment (Hashem Eiza et al. 2015). Table 3 contains simulation parameters in NS2.

Fig. 6
figure 6

Simulation scheme in Linux environment

Table 3 Simulation parameters in NS2

4.2 Simulation results

Our simulation is based on NS2 wireless package with the stop time of one second. We have compared our result with GA, SAMQ, MPLS, VACO, PUMA, Multi-hop for average EndtoEnd delay (E2Ed) (Fig. 7), an average time for a packet to reach its destination is defined as packet delay. E2Ed is determined by stand in line delay, broadcasting, packaging and Sending. By increasing maximum speed, average E2Ed increases in all algorithms because of network topology and breakdown path rate. The proposed method has less delay compare to other methods due to the simulation environment and node distribution. The broken path causes high delay in SAMQ. The genetic algorithm does not provide adequate latency due to the high overhead and complex connections between RSUs and vehicles and the high vehicle environment.

Fig. 7
figure 7

The details of Average E2Ed delay transmission in VANETs

In MPLS method, labeling in routing and updating of switches in the routing process produces high spatial complexity and as a result, delay will increase. In PUMA, due to high synchronization and mobility, the latency rate increases MPLS has large number of updates and switches synchronization and this is causing delay for labeling neighbors and adjacent nodes to form clusters. E2Ed delay in the QoSR-PSO is lower than other algorithms, smaller packets are transmitted in the network and nodes can easily obtain their requested packets. The QoSR-PSO has 17% lower than SAMQ algorithm in E2Ed. Figure 5 demonstrates the positive relation between the average PDR and Num.Of Vehicles. Due to the high complexity of VACO algorithm, the delivery rate is not optimal. In SAMQ and the QoSR-PSO, the packet delivery rate is increasing by adding nodes to the simulation environment. By rising the Num.of nodes and VANET density, E2Ed in all algorithms is reduced, which is due to increasing number of routes among Sender and destination. The maximum speed of nodes is 130 m/s and the number of nodes is 25. Using network coding to transfer packets affects stop time of the nodes. By rising the Num.of nodes in area, network dynamics decreases and the network becomes more constant, which does not lead to re-routing. That’s the reason that our algorithm works more efficiently. Also link loss ratio is lower, resulting in less delay. Delay has been decreased by 8.4, 10.2, 7.1, 4.4, 11.8 and 15.6 percent for GA, SAMQ, MPLS, VACO, PUMA and multi hop, respectively.

A comparison of average packet delivery rates with benchmark studies is shown in Fig. 8. The higher delivery rate in our presented method is due to particle positioning and clustering. In simulation scenarios, SAMQ and MPLS deliver fewer packets by increasing their speed and number. The rate of packet delivery in GA and PUMA methods is also reduced due to the spatial complexity of these methods and the overhead in the network. SAMQ has the closest performance to our QoSR-PSO method. Proposed method improves packet delivery rate compare to GA 13%; SAMQ 4.3%, MPLS 10.2%; VACO 11%; PUMA 16%; and 18% for multi-hop.

Fig. 8
figure 8

The Details of PDR for Number of vehicles and Data Transmission in VANETs

In Fig. 9, control overhead is evaluated based on the number of nodes. As shown in Figure, control overhead increases in the QoSR-PSO. The simulations are based on the frequency of repetitions between sender and receiver. Movement of packets and the initial expectation for the formation of the first hub for routing vehicles cause high control overhead to the network. High generated overhead at the beginning of the simulation shows that the formation of long-delayed hubs raise the complexity of VANETs, and this complexity increases as network E2Ed. As the V2V and V2RSU communication increases by executing the simulation for longer time, control overload becomes optimum. The high complexity in PUMA generates high overload. In metaheuristic methods such as SMAQ and GA, the overhead method is improving due to the number of simulation iterations. The QoSR-PSO improves control overload compared to GA 11.6%; SAMQ 5.7%; MPLS 5.2%; VACO, 3.1%; PUMA 10.1% and Multi-hop for 7.2%.

Fig. 9
figure 9

A: The details of Overhead and Data transmissions in VANETs

Figure 10 considers dropped packets rate. Increasing the nodes does not affect in QoS and dropped packets because in the simulations with PSO the corresponding output is optimized and ultimately the Num.of packets is reduced. In VACO, packets are lost more often because of path complexity. SMAQ and GA behave similarly for packet loss. SAMQ like the QoSR-PSO has performed very well in establishing the received packets and has a low rate of lost packets. High complexity of GA has caused many packets to be lost. Sending packets between several different hubs and updating the created paths in multi-hop has increased the packet loss rate. On PDR it can be seen that the missing packets have increased. Spatial complexity of MPLS and high synchronization and mobility of PUMA are other reasons of high dropped packets rate. The proposed method compared to the GA 10.4%; SAMQ 14.8%; MPLS 8.7%; VACO 7.8%; PUMA 14.5%; Multi-hop 11.6% improves the packet loss rate.

Fig. 10
figure 10

Dropped packets rate for Number of vehicles

5 Conclusion

VANET advancements can change our life if they can provide solid solutions to road safety. Unlike traditional networks, VANETS as an example of ad hoc networks have no predefined topology as nodes can easily move. Due to the mobility of nodes in VANETs, information transmission is a crucial issue. It can be affected by traffic or accident information. In this paper, we have used a set of particles using PSO to seek the optimal solution. For our QoSR-PSO simulation, we use an open source software called VANET-MOBISIM and an open source environment called NS2. In addition to evaluating delay and drop rate, we evaluated control overhead and average packet delivery rate with our presented approach. There are 25 maximum vehicles with a top speed of 150 m/s. The delay has been decreased by 8.4, 10.2, 7.1, 4.4, 11.8 and 15.6 percent for GA, SAMQ, MPLS, VACO, PUMA and multi hop, respectively. Packet delivery has improved 13% for GA; 4.3% for SAMQ, 10.2% for MPLS; 11% for VACO; 16%; for PUMA and 18% for multi-hop. In addition, control overload is improved by 11.6% compared to GA; 5.7% for SAMQ; 5.2% for MPLS; 3.1% for VACO; 10.1% for PUMA; and 7.2% for Multi-hop. Additionally, compared with GA 10.4%; SAMQ 14.8%; MPLS 8.7%; VACO 7.8%; PUMA 14.5%; Multi-hop 11.6%, our proposed approach significantly reduces packet loss.