# Building SDN-Based Agricultural Vehicular Sensor Networks Based on Extended Open vSwitch
However, when a controller cannot communicate with switches, the performance of flow-based forwarding of the switches will be degraded in SDN-based vehicular sensor networks. This can happen in the following scenarios: (i) the vehicular sensor network topology dynamically changes [15] or a main controller leaves the network, in which case it has to take some time to select a new main controller. In this selection interval, most sensors' communication in the data plane will be interrupted because switches don't know how to forward newly arrived sensor data due to the loss of control [16]; (ii) while the topology of network has changed, switches will still use stale rules until the controller inserts/updates the flow table entries [12]. Therefore, in SDN-based vehicular sensor networks, these problems have a major impact on the performance of sensors and networks in agriculture. The survivability and communication stability call for further improvement. Many attempts have already been carried out to resolve the above problems. For example, the optimization handoff mechanism [16; 17], local agent [12] and OpenFlow's double pipelines [18]. But there are still some challenging issues. First, how to detect the controller failure and perform failure recovery as soon as possible. Second, the mechanism shouldn't limit the flexibility and benefit of SDN in vehicle sensor networks. This paper proposes a new SDN-based vehicular sensor networks architecture approach for precision agriculture. This architecture can minimize the performance penalty of controller connection loss and maintain the scalability and flexibility of SDN at the same time. Based on the idea of stateful processing and service implementation flexibility in the data plane [19], this architecture follows the standard OpenFlow philosophy and extends Open vSwitch to add a stateful match and self-learning service. Through those, it can be aware of different connection states, achieve smooth handoff and process incoming packets by different scenario states. Besides, we argue that the mobile vehicle sensor network's topology may change when a controller communicates with switches which are unavailable at that time. In this case, it can be ensured that the rules are updated in time by different states to avoid using the old rules. We develop connection-state processing and self-learning services on top of Open vSwitch (OVS) to present a prototype implementation. Through experiments, we show that when a controller disconnects, the recovery time is short enough to guarantee an uninterrupted communication in the network. Specifically, the main contributions of this paper are as follows:  
* This new architecture implements a connection state service to detect in real-time the state of vehicle sensor networks, achieves smooth stateful matching according to different scenario states and extends self-learning as a new OpenFlow action to enhance packet-processing capability in the network data plane. * This new architecture maintains the compatibility with OpenFlow, and the flexibility and scalability of SDN. * We describe our prototype implementation on Open vSwitch and evaluate it using a controller failure recovery scenario. The experiment results show that it can achieve a stable throughput with a recovery time of less than 100 ms. The rest of this paper is organized as follows: Section 2 presents the system architecture containing some function designs, followed by Section 3 in which the implementation of modules is described. These concepts are evaluated in Section 4. Some related works are discussed in Section 5. Finally, the paper concludes in Section 6.