## 4 Store/Carry-Forward (SCF) Module  
Delay tolerant networks (DTNs) are networks with inconsistent connectivity and nonconsecutive end-to-end paths between nodes. DTNs employ the Store/Carry-Forward (SCF) mechanism to manage frequent connectivity disruption [25]. For instance, if a node has data but has no connection to transmit it, the message will be stored in a buffer in the sensor or carried by a vehicle as proposed in Ref. [26] until it finds a forwarding node based on some utility values. Figure 3: EMCR system model. The fundamental question is how to relay packets from the source to the destination fast and reliable through multiple hops. In this research, the Energy-Mobility-Connectivity aware routing protocol (EMCR) utilizes information stored in the neighbor's table to forward the packet toward the destination, typically consisting of two modes--greedy mode and DTN mode. In the greedy mode, packets are forwarded to a neighbor (sensor or vehicle) closest to the destination with the minimum weight. In the presence of a local-maximum problem, when the forwarding node (sensor or vehicle) is the closest to the destination with the minimum weight, the forwarding in the EMCR will change to DTN mode. When a node cannot find any desired neighbor, the sensor will store the packet, and the vehicle will carry the packet for a while until it can forward the packet to some desirable neighbors. Therefore, the DTN mode uses the SCF mechanism to solve the disconnection problem and improve the efficiency of VANET-WSN. When a node has a packet to route in the network layer, the source and destination information is extracted from the packet's IP header. Once the Location Service has determined the packet's destination, the Position Association Set (PAS) is updated (LS). The packet can then choose the next hop. If the destination's position is known, it can proceed; otherwise, it must wait for a response from the Location Service. Since the PAS is updated, the routing table must be recalculated, and the entry with the minimum weight is extracted. If that entry is the current node, then we are in a local-maximum case and the SCF mechanism is employed. The SCF mechanism creates a virtual route towards the current node, and this route is achieved with the help of a DeferredRouteOutput Tag added to the packet that creates a \"route\" for local delivery. Otherwise, a route for the selected entry is created. This process is shown in Algorithm 1. ```
Check destination; ifPosition is knownthen  Calculate weight else  Request information from Location Service. Calculate weight. endif if Local-Maximumthen  Add DefferredRouteOutput Tag. Return Route. else  Create Route for the selected node. Return Route. endif
```  
**Algorithm 1** A packet to be routed in the network  
As described in Algorithm 2, when a packet is received, it is first checked to see if it has the DeferredRouteOutput Tag, which denotes that the SCF mechanism is employed. Then, the packet is stored in the buffer. The buffer has a limited size, which is the number of packets it stores, and limited cache time. Any packet will be dequeued each time the routing table is updated and the route has changed to check if the forwarding node is not the current node or the current node is the destination. If the local-maximum problem is solved, all packets for that destination will be dequeued. On the other hand, if there is no tag in the packet and it is destined for local delivery, the LocalDelivery Callback is called, and the packet is passed to higher layers. If the packet is not for local delivery, then it has to be forwarded, and the UnicastForward Callback is called. ```
if_packet has DeferredRouteOutput Tagthen  Create Query Entry and store the packet. Return. ifLocal Deliverythen  LocalDeliveryCallback. Return. else  Request information from Location Service. Lookup Routing Table for minimum weight. ifLocal-Maximumthen  Add DeferredRouteOutput. Create Route for Local Delivery. UnicastForwardCallback. Return. else  Create Route for selected node. UnicastForwardCallback.