## 2 Materials and Methods
### Neighbor RSU Discovery
If the message is not eliminated in the message buffer for a time interval much larger than the transmission period of the ant packet, it indicates that the connectivity quality of the street segment is poor. The poor case can also cause the number of messages in the message buffer to be less than \(M\). The connectivity quality of the street segment from \(RSU_{i}\) to \(RSU_{j}\) is estimated as follows:

Figure 2:2

where \({{\it{ave\_phero}}{{\it{o}}}_{ij}}\) and \({{\it{ave\_time}}}_{ij}\) are the arithmetic average of the ant pheromone values and arithmetic average of the residence time of all messages in the message buffer corresponding to the street segment from intersection \(i\) to intersection \(j\), respectively. Assuming that the number of RSUs in the simulation area is \(N\), the evaluation values of the connectivity quality of all street segments can be stored in a \(N\times N\) matrix \(A\) as follows:

\[A= \begin{bmatrix}\infty&cq_{12}&\cdots&cq_{1n}\\ \mathbf{cq_{21}}&\infty&\cdots&cq_{2n}\\ \vdots&\vdots&\ddots&\vdots\\ \mathbf{cq_{n1}}&\mathbf{cq_{n2}}&\cdots&\infty\end{bmatrix}  \tag{6}\]

The initial value of each element in \(A\) is infinite, denoted as \(\infty\). Since the adjacent RSUs send ant packets to each other, the two adjacent RSUs independently evaluate the connectivity quality of the same street segment according to the received ant packets from opposite directions, which may lead to inconsistent evaluation values, i.e., \(cq_{ij}\
eq cq_{ji}\). In the routing scheme proposed in this paper, the evaluation value of each street segment is unique. Therefore, to be conservative, the minimum value of the evaluation values in different directions of each street segment are taken as the evaluation value of this street segment. In (6), assuming that the bolded matrix element value \(cq_{ij}\) is smaller than \(cq_{ji}\), the matrix A is converted into \(A^{\prime}\) as shown below:

\[A^{\prime}= \begin{bmatrix}\infty&\mathbf{cq_{21}}&\cdots&\mathbf{cq_{n1}}\\ \mathbf{cq_{21}}&\infty&\cdots&\mathbf{cq_{n2}}\\ \vdots&\vdots&\ddots&\vdots\\ \mathbf{cq_{n1}}&\mathbf{cq_{n2}}&\cdots&\infty\end{bmatrix}  \tag{7}\]

### SDN-Based Routing

When the source vehicle \(sv\) needs to send a data packet to the target vehicle \(dv\), the next hop of the packet must be found. For this purpose, it is necessary to determine whether the \(sv\) and the \(dv\) are on the same street segment. In the case of the same street segment, if the \(dv\) is just in the neighbor table of the \(sv\), the next hop is the \(dv\), otherwise, the next hop is calculated by the greedy forwarding algorithm, i.e., the next hop is the node that is closest to the \(dv\) on the same street segment in the neighbor table of the \(sv\). Additionally, in the case where the \(sv\) and the \(dv\) are not on the same street segment, the next hop of the packet is calculated according to the shortest anchor path. The shortest anchor path is an RSU sequence calculated by the SDN server according to the starting RSU and the ending RSU. The first RSU through which the \(sv\) forwards the packet is called the starting RSU, and the last RSU through which the packet arrives at the \(dv\) is named the ending RSU. The starting RSU and the ending RSU are the first and last elements of the shortest anchor path, respectively. The starting RSU \(sr\) and ending RSU \(dr\) are elected based on their distance to the source vehicle \(sv\) and the target vehicle \(dv\). First, the RSUs at both ends of the street segment where the \(sv\) is located are selected as candidate starting RSUs, of which the RSU closer to the \(dv\) is elected as the starting RSU. Similarly, the RSUs at both ends of the street where the \(dv\) is located are determined as the candidate ending RSUs, of which the RSU closer to the starting RSU is selected as the ending RSU.