## 2 Materials and Methods
### Neighbor RSU Discovery  
We take the communication delay between the adjacent RSUs at both ends of the street segment as the external characteristic to evaluate the connectivity quality of the street segment, and calculate the evaluation value of the connectivity quality through the ant colony algorithm. Based on the connectivity quality of each street segment, the Dijkstra shortest path algorithm is used to calculate the optimal path. A neighbor RSU of one RSU is the RSU in the same street segment and it does not exist with any additional RSU in the middle. For example, in Figure 4, the neighbor RSUs of _RSU1_ are _RSU2_ and _RSU4_, which are pointed out by the dotted arrow; the neighbor RSUs of _RSU5_ include _RSU2_, _RSU4_, _RSU6_ and _RSU8_, which are indicated by the blue dashed arrows; and _RSU5_, _RSU7_, and _RSU9_, which are identified by red solid line arrows, are neighbor RSUs of _RSU8_. Figure 3: Software-defined VANET architecture. Figure 2: Structure diagram of the system. To assess the packet-relaying quality of each street segment between two adjacent RSUs, each RSU at a street intersection needs to periodically send ant packets to its neighbor RSUs, so it is necessary for each RSU to know all its neighboring RSUs. For this purpose, a neighbor RSU discovery protocol is proposed in this paper. Each RSU periodically broadcasts a neighbor discovery packet NDP, the format of which is shown in the following Figure 5.  
An NDP packet contains the following fields. 1. SRC_RSU_ID: ID of the source RSU that issued the NDP packet. 2. DST_RSU_ID: ID of the destination RSU that received the NDP packet. 3. serial_Number: Every RSU assigns numbers sequentially to the NDP packet it creates. 4. set_of_Street_ID: The set of ID of the street on which the neighbor RSUs have been found. 5. SRC_CAR_ID: ID of the source vehicle that forwarded the NDP packet in each relay transmission. 6. DST_CAR_ID: ID of the destination vehicle that received the NDP packet in each relay transmission. 7. mode: The value of mode can be one of the three values of 0, 1 and 2, which, respectively, represent the three transmission modes of NDP data packets in this protocol, as shown in Figure 6: from RSU to vehicle, from vehicle to vehicle, and from vehicle to RSU. 8. new_Street_ID: ID of street associated with the newly discovered neighbor RSU. The tuple values of \(RSU\_ID\) and \(serial\_Number\) fields are used to uniquely identify an NDP broadcast packet, so that the vehicle node can ignore duplicate broadcast packets. The global configuration parameters of each RSU include \(t_{ndp}\) and \(st\), which are the time between launching successive NDP and the set of neighbor RSUs, respectively. In the initial configuration phase of the RSU, when the quality of the street segment connectivity is good, a timer may be set to run the neighbor RSU discovery protocol for a period of time to fully discover the neighbor RSUs, and store them in the configuration parameter \(st\). RSU NDP broadcasting and receiving procedures are shown in Algorithms 1 and Algorithm 2, respectively. Figure 4: Neighbor RSU. Figure 5: Packet NDP. ```
1:Set timer \(T_{n}\)\(\leftarrow\)\(t_{ndp}\) ;
2:repeat
3: Generate a NDP broadcast packet \(pkt\);
4:\(pkt\_SRC\_RSU\_ID\)\(\leftarrow\) source RSU ID;
5:\(pkt\_DST\_RSU\_ID\)\(\leftarrow\) empty;
6:\(pkt\_serial\_Number\)\(\leftarrow\)incrementing integer;
7:\(pkt\_set\_of\_Street\_ID\)\(\leftarrow\)\(st\);
8:\(pkt\_SRC\_CAR\_ID\)\(\leftarrow\) empty;
9:\(pkt\_DST\_CAR\_ID\)\(\leftarrow\) empty;
10:\(pkt\_mode\)\(\leftarrow\) 0;
11:\(pkt\_new\_street\_ID\)\(\leftarrow\) empty;
12:if the timer reaches a beacon interval then
13: broadcast the packet \(pkt\);
14:endif
15:until\(T_{n}==\)
```  
**Algorithm 1** RSU NDP broadcasting. ```
1:\(rp\)\(\leftarrow\) NDP packet received
2:if\(rp\_DST\_RSU\_ID==\)this RSU ID then
3:if\(rp\_mode\) = 2 then
4: store the \(rp\_new\_Stre\_ID\) to the set \(st\);
5:endif
6:endif
```  
**Algorithm 2** RSU NDP receiving.