key: cord-0624898-hije7hgw authors: Sharma, Kanika; Butler, Bernard; Jennings, Brendan title: Scaling and Placing Distributed Services on Vehicle Clusters in Urban Environments date: 2021-10-11 journal: nan DOI: nan sha: 96fa0339fad6e196c21189dd287f323076d3ae74 doc_id: 624898 cord_uid: hije7hgw Many vehicles spend a significant amount of time in urban traffic congestion. Due to the evolution of autonomous cars, driver assistance systems, and in-vehicle entertainment, many vehicles have plentiful computational and communication capacity. How can we deploy data collection and processing tasks on these (slowly) moving vehicles to productively use any spare resources? To answer this question, we study the efficient placement of distributed services on a moving vehicle cluster. We present a macroscopic flow model for an intersection in Dublin, Ireland, using real vehicle density data. We show that such aggregate flows are highly predictable (even though the paths of individual vehicles are not known in advance), making it viable to deploy services harnessing vehicles' sensing capabilities. Our main contribution is a detailed mathematical specification for a task-based, distributed service placement model that scales according to the resource requirements and is robust to the changes caused by the mobility of the cluster. We formulate this as a constrained optimization problem, with the objective of minimizing overall processing and communication costs. Our results show that jointly scaling tasks and finding a mobility-aware, optimal placement results in reduced processing and communication costs compared to an autonomous vehicular edge computing-based na"{i}ve solution. Vehicles will be one of the most important agents in the emerging Internet of Things (IoT) ecosystem, owing to their embedded sensors and built-in cameras, which can be used to capture contextual data for object detection and surveillance [1] . Since each vehicle generates an average of 30 Tb of data per day, it is infeasible to send all the generated data to the Cloud using the controlled and limited cellular bandwidth [2] . The increasing number of Smart vehicles and overall vehicular traffic has inspired the concept of Vehicular Fog Computing (VFC) [3] , [4] , where vehicles are utilised as Fog nodes and play the role of service providers. This new data generation and communication paradigms is motivated by Fog Computing [1] and Mobile Edge computing based models [5] , [6] which provide ubiquitous connectivity and location-aware network responses at the edge of the network, complemented with cloud computing in the network core. Closely-spaced, moving vehicles, could be used to, for example, monitor the compliance of both vehicles and pedestrians to lock-down restrictions introduced in response to the COVID-19 pandemic, by capturing data from essential service vehicles. The video data can also be collected for estimating usage patterns of highways for urban planning, reducing the need for installing more roadside infrastructure. Slowly moving vehicles can also be used to collect 3D roadmap data, to increase the perception range of intelligent vehicles, reducing the need for sending high definition data to the Cloud [7] , [8] . All these use cases require rich computation and communication resources so that this data can be used for insights and decision-making. In this paper, we propose that vehicles lease their otherwise unused processing, communication, and storage resources to collaboratively host data analytics services that can pre-process and filter the data they collect. Thus, a dense group (or cluster) of moving vehicles can cooperatively execute distributed services that comprise: (i) delay-sensitive tasks that have a short sense-actuate cycle and require real-time decision making, and/or (ii) data collection and analytics tasks that are location-and context-specific. Vehicles are distinguished through their mobility (in particular, vehicles join and leave a cluster in a stochastic manner), so the resource allocation task becomes timedependent. Mobility affects both network connectivity and computation capacity, and hence the Quality-of-Service (QoS). Our work aims to utilize the aggregate mobility behavior of vehicles to select reliable vehicle nodes, i.e., those that have a higher probability of staying with a given cluster of vehicles, in order to avoid service failure and reduce the need for service reconfiguration. As depicted in Fig. 1 , one vehicle, or Roadside Unit (RSU), acts as a managing entity to collect and update both the resource and mobility states of the cluster and enable flexible service scaling. We take the specific case of using in-built cameras in cars that are willing to lease their resources, to provide streaming data on request. This data is processed by streaming it to linear chains of tasks, where each task has different processing functionality. One linear chain of tasks form a service that satisfies a service request. We employ a componentoriented distributed service model, where each task can be realised via a collection of multiple task instances (TIs); in this manner each task can be scaled out according to the arXiv:2110.09471v1 [cs.NI] 11 Oct 2021 demand and the available infrastructure resources. For example, using multiple camera instances increases the spatiotemporal coverage of the data collection, thereby increasing the scope for more accurate and efficient data analysis, especially in applications like building 3D road maps for self-driving cars. Moreover, having replicas of computing tasks enables the utilization of distributed resources and reduces the impact of nodes leaving the vehicle cluster. Node and link failure in this service model requires only the replication of a problematic TI onto a more suitable vehicle so the service chain still works, instead of re-configuring the entire service. As the tasks are data-dependent, even if the cluster is computationally rich, it needs to be split into smaller TIs if the link capacity between host nodes is not enough. The task placement also needs to avoid placing TIs on those resource-rich nodes that have a high probability of leaving the cluster. Thus, service deployments can be adapted at run-time according to both the known resource availability and the predicted mobility state of the cluster. This paper builds upon our previous work [9] , where we introduced the problem of the placement of distributed data collection services on a moving vehicle cluster. We modeled the service placement problem as an optimization problem subject to constraints related to node resource capacity, link capacity, distributed application deployment (full deployment, anti-collocation and adjacency constraints) and vehicle mobility. In this paper the following novel contributions are made: • we introduce a macroscopic flow model for vehicle mobility using real vehicle density data from traffic data collected in Dublin, Ireland. We highlight the predictability in vehicle traffic for different time intervals, using Multivariate Linear Regression with an accuracy of 93 to 99%. • we formulate the service placement problem mathematically in two parts: 1) a flexible and distributed service model with data-dependent tasks instead of static service templates; and 2) a mobility-aware infrastructure model; • to validate our approach, we simultaneously place two services with diverse resource requirements (either computation or communication intensive). We also impose multi-tenancy constraints to reuse the same nodes and/or TIs for different applications; • we optimize the service scaling and placement problem by first scaling the linear chain at run-time and then finding a placement plan that optimizes resource usage over a multi-hop cluster, repeating as necessary. • we compare our approach to the naïve solution, presented in [10] . We also validate the applications on a Fog Computing simulator. The paper is organized as follows: §2 describes related research in the field of service placement and task offloading schemes in vehicular networks. In §3, we describe the motivation behind using vehicles as infrastructure, estimate vehicular cluster capacity, and validate vehicle traffic predictability with Multivariate Linear Regression. In §4, we define the system model and the network topology and in §5, we define the constraints and the mathematical formulation of the placement problem. In §6, we introduce application types and run an experiment for an application scenario on a Fog simulator. We then discuss solving the optimization problem, simulation setup and our results. Finally, in §7 we conclude the work and give an outline of our future work. Gerla et al. [11] was the first to introduce the term Vehicular Cloud Computing (VCC) as a distributed computing platform, wherein vehicles form a micro cloud in an ad hoc manner. They identified many important applications for VCC, including urban sensing by uploading videos of congestion and pavement conditions that other vehicles could access. Hou et al. [4] were the first to introduce the concept of Vehicular Fog Computing (VFC) as an architecture that can be used to enable multiple end-user or edge devices to collaborate to carry computation and communication tasks. They considered both slow-moving and parked vehicles and analyzed the quantitative capacity of such a Vehicular Fog. Ma et al. [12] introduced a Platoon-assisted Vehicular Edge Computing system based on the stability of the platoon in vehicular networks. They were the first to introduce a Reinforcement Learning (RL)-based optimization scheme to obtain optimal price strategy of task flows. Lee et al. [3] also modified an RL-based algorithm to make efficient resource allocation decisions leveraging vehicles' movement and parking status to minimise service latency. Zhao et al. [13] jointly optimize the computation offloading decision and computation resource allocation in vehicular networks. They designed a collaborative optimization scheme where offloading decisions are made through a game-theoretic approach and resource allocation is achieved using the Lagrange multiplier method. The feasibility of using vehicles as Fog nodes for video crowd-sourcing and real-time analytics has been studied by Zhu et al. [14] . They evaluated the availability of client nodes that generate data in proportion to the vehicle Fog nodes that process the data, using processing capacity on on-board units. However, they focus solely on the data transmission problem in the model. Xiao et al. [15] also evaluated the achievable performance of a vehicular cloud and analyze the total computation capacity for the same. They also model vehicle mobility patterns using parameters like staying time and the incoming and outgoing flow rate of vehicles. This capacity analysis is a crucial requirement for enabling a vehicular computing model but they do not focus on the service model and applications to be deployed. In Kong et al. [16] , the traditional mobility models for vehicles are replaced by methods based on social patterns, community interest group check-ins on social media data etc. The mobility of vehicle nodes makes the task allocation problem more challenging in Vehicular Fog Computing. Zhu et al. [17] introduced an event-driven dynamic task allocation framework designed to reduce average service latency and overall quality loss. Both multi-source data acquisition and distributed computing in Fog-computingbased intelligent vehicular network are studied by Zhang et al. [18] . They introduce a hierarchical, QoS-aware resource management architecture, but consider the Fog servers as static. Vehicular micro cloud has been studied as virtual edge servers for efficient connection between cars and backend infrastructure in Hagenauer et al. [19] . They use mapbased clustering at intersections, as intersections have line of sight in multiple directions which result in better connectivity between the Cluster Heads (CHs) and other cluster members. Even though they primarily focus on cluster creation and cluster head selection, they evaluate a data collection application, with varying data aggregation rates at the CH. Goudarzi et al. [20] introduced an application placement technique for concurrent IoT applications in Edge and Fog computing environments. They propose a a batch application placement technique based on the Memetic Algorithm to efficiently place tasks of different workflows on appropriate IoT devices, fog servers, or cloud servers. Fog computing based information-centric approaches have been studied by Wu et al. [21] , where Fog nodes act as network monitor for cognitive caching and computational resource configurations. These techniques are crucial for future internet applications like automated driving enabled vehicles. Wu et al. [10] study the dynamic management and configuration of heterogeneous consensus for differentiated and dynamic IoT services in a blockchain. The paper also Our work is motivated by the increasing number of Smart and continuously connected cars, and the unresolved issue of vehicle congestion-especially in urban areas. Before introducing our service scaling and placement scheme we first provide justification that placing services on a vehicle cluster in order to provide time and/or location sensitive sensing functionality is a viable proposition. There are two important aspects: 1) whether traffic flows in an urban setting are likely to be predictable over the course of a day, and 2) whether a slow moving cluster will accommodate sufficient communications capacity between vehicles to facilitate service operation. We find that vehicular flow in urban traffic zones is predictable throughout the day. We also show that the vehicular density pattern at an intersection follows a similar pattern of peak and off-peak flow through different weeks. We use macroscopic vehicle density data to create a generalised flow model for an intersection. This helps in classifying traffic flow into six different driving profiles. The vehicle clusters can then be initiated at the predicted peak traffic times, on any of the traffic flows with an assured density flow. We first focus on a road network near Dublin Airport, using the vehicle flow data captured by the Transport Infrastructure Ireland Traffic Data website 1 . A vehicular flow is defined as the number of detected vehicles passing a point in a period of time. The idea is to use the stochastic traffic flows at an intersection to predict the trajectory of a vehicle cluster. As depicted in (Fig. 2) , we consider northbound flow from A to B and A to C, southbound flow from C' to A' and C' to B, eastbound traffic from B' to C and B' to A. We then employ a linear regression model to predict the traffic flow from one segment to the other, for all the six flows at the intersection. To understand the predictability of the traffic flows, we use the vehicle flow data, collected in the interval of 5, 10 and 15 minutes (based on the estimated travel time between any of the six points at peak and offpeak traffic time of the day) for a period of 24 hours. This data is used to model a generalized traffic flow model for an intersection. We predict the vehicle density at point B taking into consideration the vehicle density at point A, using a linear regression model. We plot the actual and predicted incoming vehicle density at point B, for an interval of 5 minutes (Fig. 3a ) and 10 minutes (Fig. 3b) . The accuracy score of the prediction was 0.915 for a period of 5 minutes and 0.945 for 10 minutes respectively. This way, vehicles can be clustered in six different driving profiles for service execution, corresponding to the above-mentioned six flows. Table 1 depicts the r-value, p-value and the standard error for all the six flows. We then use the vehicle flow data for the last 7 consecutive Mondays to predict a single flow, from A to B, using Multivariate Linear regression for data collected at an interval of 5 ( The same days in the week were studied to have similar patterns of mobility, within a range of a month to two, hence data for 7 consecutive Mondays was used. The predicted and actual vehicle flow at point B is depicted in Fig. 3c , 3d and 3e. The R 2 accuracy score of the prediction was 0.93750, 0.9476 and 0.99216 for 5, 10 and 15 minutes respectively. We also considered the vehicle flow data during the period of COVID-19 lock-down, from 1st to 8th April 2020, to analyze the pattern of flow during the Coronavirus restrictions in Ireland. The restrictions resulted in much less traffic density at the intersection. Fig. 3f and Fig. 3g depict predicted vehicle flow using Multivariate Linear Regression, considering seven consecutive days during the lock-down, with an accuracy score of 0.97987 and 0.98746. We also plot the overall vehicular flow data for four consecutive Mondays, recorded in an interval of 10 minutes (Fig. 3h ) and 30 minutes (Fig. 3i) . The figures depict the consistent and predictable vehicle density data for both northbound and southbound traffic for all four weeks. Beyond the predictability of vehicle mobility patterns, it is crucial to consider the density of vehicles, or how close or spread apart are vehicles at a given time, for the purpose of service placement. We take another real-world dataset to analyze the density and the traffic conditions for a freeway. Calculating density requires the number of vehicles in a given lane or calculated over a mile, averaged over a period 2 that provides access to real-time and historical performance data for the California freeway network. This dataset and platform is a rich resource for many traffic parameters like occupancy, speed, vehicle miles travelled (VMT), etc. at many different granularities of time and space (over a detector/lane/route). Vehicle-to-vehicle (V2V) communication is crucial for our distributed service placement and successful service completion. Reliability of V2V communication amongst vehicles in a cluster depends largely on traffic conditions. Conditions are indicated by vehicle density, which varies if vehicles are in a state of free flow, have delays, operating at full capacity, or are in breakdown condition. Caltrans PeMS provides a parameter called the Level of Service (LOS), which uses vehicle density to analyze the quality of service or the condition of the traffic along a freeway. The freeway LOS is a way to classify the traffic condition into a grading system ranging from A to F. The LOS is also measured from the volume-to-capacity (v/c) ratio, but PeMS estimates the LOS using density only. The relationship between LOS and density is defined in the Highway Capacity Manual (HCM2010) and is summarized in Table 2 . In Fig.4 for the first week in August 2019. As can be noted, there is a significant percentage of vehicles in LOS E which depicts unstable flow due to near full density of traffic, and LOS F which depicts flow breakdown conditions. The percentage of vehicles in LOS E and F constantly increases from 10 am to 5 pm. Almost 20% of vehicles are in LOS F at 5 pm, which represents breakdown or traffic jam conditions. The percentage of vehicles increases significantly in LOS A and B at 8 pm, which depicts free flow and a stable flow of traffic. This analysis gives an estimate of available vehicle density at different times of the day. This reduces the uncertainty in resource availability. The data is a rich resource to detect busiest intersections and bottlenecks where services can be initiated on slow-moving or stopped vehicles. Due to the novelty of using moving vehicles as infrastructure, we estimate the communication capacity of a vehicular network. Estimating the capacity of a vehicular network is a challenging problem to solve as it depends on several factors including the average number of simultaneous transmissions, link capacities, the density of vehicles, mobility in the network, the distance between vehicles, and the transmission range of the vehicles. Our previous analysis shows that the problem of less vehicular density causing a delay in communication is not prevalent in urban centers, and even freeway traffic flow in some cases. We also demonstrated that most traffic flow prediction can be done effectively. The estimation of the capacity of the vehicular network has been done in great detail via customized theoretical studies [22] - [24] . We calculate the effective capacity of the vehicular network obtained using a cooperative scheme from Chen et al. [24] . Theoretical Capacity: We consider the closed-form expression of effective available capacity specified by Chen et al. [24] , which uses a cooperative scheme to derive the communication capacity for a vehicular network. The cooperative strategy uses both V2V and Vehicle-to-Infrastructure (V2I) communication to increase the capacity of vehicular networks. They built an analytical framework to model the data dissemination process and derive a closed form expression of the achievable capacity, given as: . In this expression L is the length of the highway segment, d is the distance between RSUs, W I and W V are the data rate for V2I and V2V communication respectively, ρ is the density of vehicles per meter, p is the proportion of vehicles with download requests in the range [0,1], r I is the range of infrastructure points and r o is the radio range of vehicles. R C is the sensing range for the medium access control protocol. We calculate the available capacity for this case, taking the value for L as 100 km, d as 5, 10 or 15 km, W I as 20 Mb/s, W V as 2 MB/s, ρ as 0.03, 0.04, or 0.05. We take the radio ranges as typical values for Dedicated Short-Range Communication (DSRC) such that r I is 400 m and r o is 200 m. The value of R C is taken as 300-400 m. For these values, the effective available capacity lies in the range of 5-20 Mb/s with different proportions of vehicles participating in the scheme. The density of vehicles, the use of cooperation schemes and the number of participating vehicles have a direct impact on this effective available capacity. The potential computation capacity of a vehicle cluster is dependent on how dense the cluster is, in terms of the number of vehicles that are optimal for placement of a particular service request. The computation capacity is also based on how slow the vehicle cluster is, which can be predicted by the occupancy of a road segment, calculated as how much time vehicles take to pass over a detector. This time can also be derived as the sojourn time of vehicles with the RSU. According to the study conducted by Xiao et al. [25] , predicted computation capacity is higher than 650 Gflops with a probability of 60% when the range of vehicle clusters is set to be 5m, and throughout the day the computation capacity is above this value. When the range is 10m, the predicted capacity is 1800 Gflops. With the increasing number of smart vehicles, the number of sensors, video cameras, and computation capacity should increase significantly in the next decade. This means that the infrastructure will exist to collect data, process it on the resource pool of a vehicular cluster and send it to the cloud for further processing. However, this infrastructure cannot be exploited unless services can be placed on it in such a way that the overall service objectives are met. The potential computation capacity of a vehicle cluster is dependent on how dense the cluster is, in terms of the number of vehicles that are optimal for placement of a particular service request. The computation capacity is also based on how slow the vehicle cluster is, which can be predicted by the occupancy of a road segment, calculated as how much time vehicles take to pass over a detector. This time can also be derived as the sojourn time of vehicles with the RSU. According to the study conducted by Xiao et al. [25] , predicted computation capacity is higher than 650 Gflops with a probability of 60% when the range of vehicle clusters is set to be 5m, and throughout the day the computation capacity is above this value. When the range is 10m, the predicted capacity is 1800 Gflops. With the increasing number of smart vehicles, the number of sensors, video cameras, and computation capacity should increase significantly in the next decade; one estimate is for 150 million connected cars by the end of 2020 [1] . This means that the infrastructure will exist to collect data, process it on the resource pool of a vehicular cluster and send it to the cloud for further processing. However, this infrastructure cannot be exploited unless services can be placed on it in such a way that the overall service objectives are met. The utilization of the predictable vehicle trajectory and available processing capacity requires knowledge of both the microscopic behavior of individual vehicles as well as the overall macroscopic traffic flow dynamics. The microscopic trajectory of individual vehicles cannot be used because of privacy concerns over the use by third parties of user trajectory data. Therefore, to reduce privacy concerns, microscopic data can be considered at and between specific intersections, so there is no need to know the trajectory for the entire journey of a vehicle. This method can be predicted as the joint probability of vehicles starting at a road segment, say RS j , and ending at the road segment say RS k , expressed as: The macroscopic traffic data includes flow level variables like traffic flow rate, traffic density, and average velocity of the traffic stream. This data is easier to collect, using the vehicle counter and cameras commonly installed in cities for traffic management purposes. Macroscopic models also include deriving the relationship between traffic speed, flow rate, and density to estimate slow-moving vehicle traffic to initiate vehicle clusters. Most traffic estimation studies utilize both microscopic and macroscopic data to estimate vehicle trajectories. We have calibrated the microscopic carfollowing model, using the macroscopic vehicle flow data from the Dublin intersection based on the flow model in §3.1. For simulations, we extract the Dublin intersection road network using Open Street Map (OSM) and calibrate the simulation using the real-world Dublin traffic dataset. We generate the calibrated traffic in the Simulation for Urban Mobility (SUMO) simulator. The problem of deploying edge servers and utilizing the traffic density in urban centers can be resolved by introducing a Vehicular Fog marketplace, where vehicles can temporarily lease some of their video capturing, sensing, computing, and networking capabilities. This marketplace would include consumers in the form of service providers looking for reliable vehicular resources to capture and process information. The computational resources they seek can be used for applications that go beyond the motivating use case (for this paper) of crowdsourcing. Such additional use cases include intensive machine learning applications that can be implemented in a distributed manner. The producers in the form of participating vehicles offer to host applications that pay a fair price while leasing the least amount of resources. The service provider aims to process most of the This IoV marketplace has been explored in the context of implementing complex, distributed machine learning models [26] . The approach has been compared to job completion time with third party cloud providers. A similar marketplace needs to be studied for a moving cluster, in terms of monetary cost and task satisfaction. In this section we first describe the terminology of the system model; then we present the the network topology and the distributed service model. • Vehicle Clusters: We consider vehicle clusters as micro cloud-like entities [27] , whose members (vehicles) provide resources used to execute tasks that form a distributed service. • Control Node (CN): The CN is a vehicle in the cluster that acts as a gateway between the cluster and Roadside Units (RSUs); is elected based on its connectivity to the RSU and other cluster nodes (this election process is outside the scope of this paper). It collects status information about the cluster, including available resources at nodes, link capacities and it also receives service placement requests from the RSU/client. • Roadside Units (RSUs): The vehicle nodes in a cluster are supported by resource-rich base stations (RSUs), which connect the cluster to the Internet. The management of services between the RSU, Control Node (CN), and the vehicle cluster is depicted in Fig. 5 . The RSU knows the system state of the cluster, which is communicated to it by the CN. Fig. 6 : Service model depicting tasks and their interdependencies. The Type graph is scaled to the Instance Graph based on the resource state of the vehicle cluster. • Task: Tasks are data collection or processing functions that can be scaled out as multiple task instances (TIs) to realise a distributed service. For example, a distributed service to realise pedestrian counting may in its specification request as many vehicle cameras as possible monitoring a given stretch of road. The TIs are the smallest unit that a task can be split into and that can be mapped to a vehicle node • Service: We consider distributed services with unidirectional, acyclic control, and data-flows. These services are specified as hierarchies of different task types, each with different functionality. Each task is typically deployed as several TIs, which can be dynamically and flexibly scaled (in terms of size per TI (up) and number of TIs per task (out)) according to resource availability and stability of the vehicle cluster at a given instant. We assume a linear chain of data-dependent tasks represented as a Type graph, in Fig. 6 . This Type graph is sent as an input to the service placement function. Based on the Type Graph, an Instance graph is created, where each task of Type p (represented as s p in Fig. 6 ) can have multiple TIs of Type p and count j (represented as s pj ). Other works that leverage parked vehicles (PVs) also deploy similar service models, where a task with a large workload is split into several sub-tasks and assigned to multiple PVs for cooperative execution [28] . • Service Placement: The process of placing the scaled Instance graph (in Fig. 6 ) on a vehicle cluster, is called the service placement problem. Our approach is to first find an optimal Instance graph, considering both service and infrastructure constraints, as this decision cannot be taken independently of the infrastructure state. This is optimized based on minimizing the total number of hops in the path between each Type 1 TI and the CN. This step reduces the bandwidth usage and selects a dense service spread, which also reduces delay in service execution. We then map the optimized Instance graph onto the physical vehicle nodes. We jointly consider both TI mapping as well as the route/flow mapping [29] , between the placed TIs. We also take into account the predictable mobility pattern of these vehicles. We assume that I nodes participate in the formation of the vehicle cluster. We represent the cluster as a directed, connected graph, G = (V, E). The node i ∈ V represents the vehicle nodes, each with K resource types, where k ∈ {1...K} and i ∈ {1...I} denote resource type k on node i. The processing capacity of each vehicle node i in respect of resource type k is represented as C k (i). The directed edge, (i 1 , i 2 ) ∈ E, of the graph represents the link between any two vehicle nodes i 1 and i 2 . The link capacity limit is depicted as {B(i 1 , i 2 )} Kb/s between any two nodes i 1 and i 2 . If there is no direct connectivity, due to excessive range, line of sight difficulties and/or incompatible protocols then The mobility in the network is represented by the cluster cohesion probability (CCP) of each vehicle node (P (t1,t2) (i 1 )), which represents the probability of a vehicle to be in a certain segment of the road, in a particular period of time [t 1 , t 2 ]. We also consider the joint probability (P (t1,t2) (i 1 , i 2 )) of two nodes i 1 and i 2 to stay together on a given road segment over the time interval [t 1 , t 2 ], due to the inherent data dependency between two interacting task nodes, as specified in the service model. This makes it important to consider the combined probability of two nodes with data-dependent TIs to stay together until the completion of both TI tasks. We assume that this information regarding the mobility pattern, in terms of CCP of the nodes, is available at each road intersection. The service model is composed of tasks, denoted as s p , each with different functionality, to be deployed on different nodes of the cluster. The functions include video streaming, data compression/processing as well as application control, for the flexible management of infrastructure links and nodes. Each task can have any number of TIs, represented as s pj , to be mapped in an optimal configuration onto vehicle nodes. The number of TIs for a task s p is represented as N sp . Each TI s pj requires a minimum demanded amount of D pjk units of each resource of type k. Furthermore, the flow demand between task s p1 and task s p2 is provided as F (s p1 , s p2 ). Note that such flows might be point-to-point (between adjacent nodes) or might need to be routed via other nodes according to flow tables maintained by the CN. Both the per resource type k demand for TI s pj , labeled by {D pj,k }, and the inter-task demand {F (s p1 , s p2 ), s p1 = s p2 } need to be specified as input to the model. Each TI can support a maximum flow rate, which is derived from the processing requirement of the incoming flow, given as C (F (s p1j , s p2j ) ), i.e., the processing requirement for flow from TI s p1j to s p2j . We check that the target TI has enough processing capacity to process an incoming flow and also ensure that this leaving flow, after being streamed or processed at an TI, is directed to a single corresponding TI. Recall that each processing TI can have multiple incoming flows. We follow this rule to promote the collocation of processing nodes, whenever vehicle nodes have available resource capacity. This promotes a balanced service placement rather than over-provisioning the available infrastructure. We aim to minimize the cost of service execution, by favoring nodes with a higher probability of staying with the vehicle cluster and promoting a "narrower" service placement (just enough nodes for reliability in the presence of node mobility) to reduce resource bandwidth usage. The model can be used to optimize other resources like the increasing number of accepted requests on vehicle clusters, the number of nodes used or other performance metrics like latency or service bandwidth demand, based on the requirements of the application. The placement problem first scales the service type graph to an instance graph and then maps the service onto the vehicle cluster. Each resource type of a vehicle node is denoted as k, where k = 1 is CPU capacity, k = 2 is Memory capacity and k = 3 is sensing resource capacity. The minimum resource requirement (of type k) to host TI s pj on node i is given as D pj,k . This constraint 3 checks if the TI is mapped to node i which is denoted by the binary mapping variable M (p, j, i). The resource required by the placed TI must not exceed the availability of resource type k on the selected node. Since we are interested in using only spare resources for placing services on vehicular clusters, a minimum set of system resources must also be reserved for the operations required for the vehicles. Thus, the net available capacity for hosting collaborative services at every node i is represented as C k (i), which is the capacity of the node for such additional services. The resource constraint is formally presented as: . where the decision variable M (p, j, i) ∈ {0, 1} is set to 1 to indicate that TI s pj is placed on node i or 0 otherwise. The use of this indicator variable ensures that TI s pj requires resources from node i, if and only if it is placed on that node. The bandwidth requirement between two task s p1 and s p2 , where the latter requires data from the former, is represented by F (s p1 , s p2 ) Kb/s. We consider only onedirectional traffic, from task s p1 to s p2 . However, the model can easily be extended to consider duplex communication needs by adding extra constraints of the form 4. where i 1 = i 2 and B(i 1 , i 2 ) = 0. Constraint 4 ensures that, for each node pair labeled by i 1 and i 2 , the total bandwidth requirement, for all TI pairs s p1j and s p2j placed on nodes i 1 and i 2 respectively, is F (s p1 , s p2 ), which does not exceed the bandwidth limit B(i 1 , i 2 ) between the two nodes. In our model, two tasks that are mapped to two different vehicle nodes i 1 and i 2 , where i 1 = i 2 might not be linked directly to each other, but are connected over multiple hops. In the following bandwidth constraint, we consider the resource capacity of each link over the full path between tasks s p1 and s p2 . We consider another binary valued mapping variable m(p 1 , p 2 , j, i) which takes the value 1 for each node i that is mapped to forward the flow between TIs of type s p1j and s p2j and is part of the path between the two data dependent TIs. Thus, nodes can act as both processing nodes or forwarding nodes. The constraint 5 ensures that the bandwidth used for forwarding the flow between any connected pair of forwarding nodes should be less than the available bandwidth capacity between those two nodes. This constraint is formally presented as: where i 1 and i 2 belong to I (p1j)(p2j) , which is the set of all nodes on the path between TIs s p1j and s p2j . We now formulate the constraints for placing distributed TIs and the corresponding service data flow between these TIs. We ensure that the data flow is processed before reaching the CN and the order of TIs is maintained according to the service chain or service description. As we propose a distributed service model, it is crucial to ensure that the TIs have enough processing capacity for the incoming flow. The constraint 6 ensures that the flow rate entering a TI should not exceed the processing capacity of that TI. The processing capacity of TI s p2j is represented as C(F (s p1j , s p2j )), which is the function of incoming flow from s p1j to s p2j . This constraint is given as: ∀i1 ∈ {1, . . . , I}; i2 ∈ {1, . . . , I}; i1 = i2 ∀p 1 ,j 1 ;p 2 ,j 2 ;p 1 =p 2 m(p1, p2, j1, i1)C(F (sp 1 j , sp 2 j )) ≤ C(sp 2 j ) where C(s p2j ) represents the processing capacity of TI s p2j . This TI is placed on the node that receives the incoming flow to be processed, from TI s p1j . Here F (s p1j , s p2,j ) represents the flow that has been processed at TI s p1j or is forwarded from s p1j specifically for processing (not forwarding). Constraint 7 ensures that the incoming to outgoing flow rate ratio, at a node, is governed by the data processing factor of the TI. α pj represents the data reduction/processing factor for a task with Type p resource. The constraint is presented as: where 0 ≤ α pj1 ≤ 1 and F (s p1j , s p2j ) represents the incoming flow to be processed at TI s p2j . F (s p1j , s p2j ) represents the outgoing flow, that has been processed at the TI s p2j . This constraint ensures that all the necessary pre-processing is performed on the flow, at each TI before the flow reaches the CN. Since nodes in our model can be forwarding nodes, or processing nodes , or have both a processing and forwarding role, the data processing factor can lie in the range from [0,1]. Constraint 8 ensure that the flow traverses the task instance graph in the order specified by the service model, we require that once the flow is processed at one node, it is directed to the "next" node with at least one "subsequent" TI (according to the Type Graph), i.e., where the decision variable M (p, j, i 1 ) represents the TI mapped to node i 1 , F (s p1j , s p2j ) is the flow processed at the node i 1 . The right hand side of the equation employs mapping instance M (p + 1, j, i 2 ) to show that a subsequent TI of type s (p+1)j is mapped on the node i 2 , which has enough resource capacity. As forwarding nodes are introduced in constraint 4 to facilitate these multi-hop flows, it is crucial to preserve the order of tasks at the service level. To ensure that the flow is directed towards a subsequent TI, in case there is no direct path between two placed TIs, we also ensure that the forwarding node is on the path joining nodes (i 1 , i 2 ) with TIs s pj and s (p+1)j mapped on them. This is represented as constraint 9: ∀i1 ∈ {1, . . . , I}; i2 ∈ {1, . . . , I }; i1 = i2 ∀p,j;p+1,j 2 ;p =p+1 m(p, p + 1, j, i1)F (sp 1 j , sp 2 j ) ≥ m(p, p + 1, j, i2) (9) where m(p, p + 1, j, i 1 ) and m(p, p + 1, j, i 2 ) are mapping variables with 0 or 1 value. Here m(p, p + 1, j, i 1 ) represents node i 1 as a forwarding node for processed data flow F (s p1j , s p2j ), between TIs s pj and s (p+1)j , and m(p, p + 1, j, i 2 ) represents the next forwarding node for the same flow. In order to use the mobility of slow moving vehicles in our favor, it is crucial to incorporate mobility awareness in the infrastructure model. There are many ways to predict the mobility patterns of a group of vehicles. Here we consider all nodes that have a higher probability to chose a similar road segment (S i ), based on their historical mobility patterns, to be candidates for the cluster. We assume that each RSU maintains a table of known vehicle nodes, with their probability of taking a particular road segment (say S 1 ) at the next intersection. Vehicles that do not have entry in the table, but are willing to offer their resources, can be added to the table. However, they would be assigned the average road exit probabilities of known vehicles, with a low confidence score. As the history of a given vehicle builds up We have calibrated the microscopic car-following model, using the macroscopic vehicle flow data from the Dublin intersection based on the flow model in §3.1. For simulations, we extract the Dublin intersection road network, as depicted in Fig. 7 , using Open Street Map (OSM) and calibrate the simulation using the real-world Dublin traffic dataset. We generate the calibrated traffic in the Simulation for Urban Mobility (SUMO) simulator. The transition matrix stores the mobility behavior of every candidate vehicle, for a particular time period. This table can be updated over time to increase the accuracy of mobility awareness. Each RSU thus has many tables stored for different time stamps during the day. We model the mobility of vehicles as a Markov Model, where each road segment is a state. As mentioned in [30] , the vehicle node that moves from one road segment to the other represents a transition in the Markov process. But instead of considering the detailed trajectory of a single vehicle, the matrix stores all possible probabilities for a vehicle to stay at the segment or take another road segment with a certain probability. Thus, every intersection in the service zone maintains the probability of a vehicle that follows Markov memory-less property, wherein the node transitions from state i to i+1 and is independent of state i-1. Based on the mobility patterns, different vehicle clusters can be formed for the service execution. In this paper, we only consider the nodes with a high probability of going from road segment A to C (in Fig. 2) , as continuing to belong to the cluster. Therefore, the cluser cohesion probability (CCP) of a given vehicle node is the probability of that node going straight ahead at the next intersection. To incorporate the mobility of hosting nodes, we scale the resource capacity of each node in the vehicle cluster with a weighting factor, i.e., the probability of a node to stay with the cluster for the duration of service execution, i.e., from time t 1 to t 2 , which is given as P (t1,t2) (i). This is because a node with enough resource capacity might not have a high probability of staying with the vehicle cluster, so this needs to be considered when placing TIs on that node. Placing TIs on such nodes can waste computation and bandwidth resources if the node leaves the cluster prematurely, and can also cause the service to fail. Thus, we scale the vehicle node capacity with its CCP, such that the higher the CCP (probability of staying with the cluster), the lower the costs of TI execution on that node. The Node Cost is given as: where M (p, j, i) is the mapping function of TI s pj to node i, with node resource capacity of C k (i). To add the costs, we consider the ratio of required node capacity (D pj,k ) with the available node capacity (C i (k)). Similarly we scale the link capacity of any two nodes with data-dependent TIs, with the joint probability of the two nodes to stay together for the duration of service execution (t 1 to t 2 ), given as P (t1,t2) (i 1 , i 2 ). The total link cost for service execution is given as: where m(p, p + 1, j 1 , i 1 ).m(p, p + 1, j 2 , i 2 ) ∈ {0, 1} is an indicator that two nodes that form part of the path joining two TIs of task s p1j and s (p+1)j type. Similarly M (p 1 , j, i 1 ).M (p 2 , j, i 2 ) indicates that two nodes, one hosting TI s p1j at node i 1 and the other TI s p2j at node i 2 , have a direct link between them. For adding up the link cost and the operating cost on each node, we use the ratio of required bandwidth resource (F (s p1j , s p2j )) with the available bandwidth (B(i 1 , i 2 )) at each link that forms part of the service placement. The problem is formulated as a bi-objective optimization. We hierarchically solve the optimization with the first objective as: When placing tasks on nodes, it is more efficient to ensure that the placement plan takes account of both task dependencies and of inter-node network distances. For example, if s p2 depends on s p1 , it is advisable to ensure that each is placed either on the same node or on nodes that are one hop away from each other. However, this requirement could make it difficult to find a feasible placement. Hence, we seek to ensure that the network distance between any two selected nodes with data dependency is minimized for efficient service placement. The hop count between two placed TIs is minimized when: where H(i 1 , i 2 ) is the hop count between two nodes i 1 and i 2 for the flow F (s p1j , s p2j ) between tasks s p1 and s p2 . In the model, mapping variable m(p 1 , p 2 , j, i) applies to a forwarding node i along the path between TIs j of type p 1 and p 2 , in cases where there is no direct link between the nodes hosting these TIs. We then solve the model for the next objective function, which minimizes the Total Cost spent on service execution: where λ i are non-negative and sum to 1. When evaluating our model, we set λ 1 = λ 2 = 0.5, i.e., we give equal weight to node and link cost for simplicity. To come to this decision, we carry out a sensitivity analysis and generate random values for λ 1 (λ 2 = 1 -λ 1 ), and plot total cost for the same resource-poor and resource-rich clusters. In the event of low node capacity or low link capacity, the optimization takes care of the number of TIs deployed, with the objective of minimizing total cost. Thus, as depicted in Fig. 8 , we get total cost values in a similar range for almost every weight. We chose both λ 1 and λ 2 = 0.5, as it gives lower cost in both cases and other values do not significantly affect cost. Also, in hierarchical optimization, the first objective function effectively gets a higher priority than the next. We give an explanation of this choice in Section 6.2. Thus, minimizing the hop counts is the first priority of the optimization and then equal priorities are given to both node and link cost. The placement of a linear application graph on tree graph, for data center topology has been widely studied in the literature. In [10] , they aim to minimize the maximum weighted cost on each physical node and link, ensuring that no single element gets overloaded and becomes a point of failure. They prove that the placement of a tree application graph onto a tree physical graph for the objective function, with or without pre-specified junction node placement, is NP-hard. We first scale a linear Type graph to a tree graph (Instance Graph) and then map it to a general directed graph (vehicle cluster). The mobile-edge computing application placement problem does not consider the changes in resource state due to the movement of infrastructure. Thus, the initial placement of service chains on a vehicle cluster can be considered similar to the application mapping problem. The application or workload placement problem is a hard problem to solve, especially while considering the joint node and link mapping. We extended this problem from a traditional NFV service chaining problem, which has fixed source and destination nodes, with a fixed length of the service chain. In our case, due to the lack of knowledge of individual vehicle's mobility dynamics, and the need for a robust placement, we scale the linear chain to multiple data collection (Type 1) TIs. In our model, if the data collection TI is unable to find a processing placement instance on the vehicle cluster, it forwards the data to the RSU. Thus, the model includes both horizontal and vertical scaling of the service. We also place more than one application on the vehicle cluster to promote multi-tenancy, which improves resource efficiency but also makes it harder to find a solution. We highlight two different application types that are suitable for the model described in this paper. The type-based service for distributed video analytics is given as an input to the service placement problem. The service is described as a linear chain, with one task of Type 1 type, that is mapped to a vehicle with a dash camera or smart camera installed on it and the user is willing to lease their vehicle resources in exchange for some incentive. This data is streamed to a nearby vehicle that hosts a task of Type 2, followed by another vehicle hosting a task of Type 3. Such tasks execute lightweight video pre-processing like data compression or sub-sampling that reduces the size of the video data, based on the application requirement. Some examples include: • Modality based pre-processing [31] : multimedia data may have more than one modality, e.g., video data with image and speech. This requires data separation. • Data cleaning: only frames that have the required data can be separated from other redundant frames, especially in the case of more than one source of video data. This is relevant for a Fog computing scenario, where the computation and storage capacity is limited. • Data Reliability: Other application like detecting video from unreliable data sources which are not subscribed to the service can also be detected and filtered at this stage. Once the processing is complete at the cluster, this data is then sent to the CN which forwards the data to the Fig. 9 : Pedestrian Detection service concepts edge/cloud for further high computational processing, like vision-based processing for video crowd-sourcing applications and traffic density estimation using convolutional neural networks, etc. We specify two different applications, with different resource requirements, that we place together on the vehicle cluster: 6.1.1 Application I: High-processing video streaming applications The first application is a pedestrian detection application that can be used to study the popularity of a coffee shop or a gas station, based on the number of pedestrians detected in the stream of video data. This data is collected by vehicles standing at a traffic light or an intersection, close to the coffee shop, say. This data has local relevance/scope and hence, most of this data should be processed locally, based on the available resources on the vehicle cluster. Such applications can be considered compute-intensive and require higher processing capacity and so large amounts of unnecessary data should not be uploaded to the cloud before processing. For this application, 1 to 6 camera or Type 1 TIs are used in the Evaluation section (6.2), because more camera instances increase the richness of context data. The Type 2 TIs aggregate and process this video stream from different Type 1 TIs as depicted in the Concept Diagram of the application in Fig. 9 . This TI can aggregate the data from different sources based on content or location similarity. The functionality of Type 3 and Type 4 TIs is applicationspecific. In the compute-intensive application, lightweight video processing is performed on the video stream to transform it into other forms, e.g., capturing specific frames with license plates, or highlighting pedestrians or other objects of interest in each scene. We assume that the data is reduced to 40-50% of its size, by Type 2 instances and to 20% of its original size after processing by Type 3 TIs. This preprocessed data is then sent to the CN, which forwards it to the RSU. To validate the service model, we implement this applications on an existing simulator called Yet Another Fog Simulator (YAFS) [32] . It is a python-based discrete-event simulator that supports resource allocation and network design in Cloud, Fog or Edge Computing systems. We chose the simulator because it supports mobility of entities, which can act as both sources of data, called workloads or processing nodes. The simulator also provides a Distributed Data Flow based application model that allows task replicas and dynamic placement of tasks. The applications are represented as directed acyclic graphs (DAGs), where nodes represent service modules and links represent data dependency between modules. The simulator also incorporates strategies for dynamic service selection, placement and routing. Fig. 10 , we consider the average node utilization in the placement of service described as Application I. As suggested by the authors in [32] , we calculate the node utilization as the sum of the service times at each node divided by the total simulation time. We compare the average node utilization between: • Cloud placement: all task placed in Cloud • Edge/RSU placement: all tasks placed on edge/RSU • Mobile node/vehicle placement (unreplicated tasks): all tasks placed on mobile nodes/vehicles (without replicated TIs) • Mobile node/vehicle placement (replicated tasks) (our approach): all tasks placed as multiple TIs on mobile nodes/vehicle In Fig. 10 , for variable workloads that are generated using custom temporal distributions, we compare placement for three and six video collection TIs of Type 1. For three Type 1 TIs, only mobile node placement with unreplicated tasks result in better node utilization, compared to our approach. For six Type 1 TIs, our approach of replicating processing TIs of Type 2 and Type 3 on different mobile nodes, results in lesser average node utilization compared to all the other approaches. This validates that our service model of replicating tasks is efficient from node utilization point-of-view, as compared to other placement approaches. Application II uses vehicles as moving sensors for video collection. Applications of this category includes measuring the traffic density at an intersection in real-time, or surveying road conditions for road traffic mapping. Generally, the focus is on passive video collection; most processing does not happen in the cluster. Such applications perform minor pre-processing tasks on data in the vehicle cluster. Such pre-processing includes data sampling, segmentation or encoding and is carried out on Type 2 and Type 3 instances. Thus, the data is reduced to 80% of its original size before being sent to the cloud for executing compute-intensive tasks, possibly applying complex machine learning to the data. We solve the constrained optimization problem using the Gurobi solver, which is a powerful mathematical sover, on an Intel i7-6500U dual-core processor running at 2.50 GHz. The solver uses a Linear Programming (LP) based branch and bound algorithm to solve the Mixed Integer Programming (MIP) problem. We place Applications I and II together on a vehicle cluster with 10 nodes, since more nodes in a cluster increases the time and space complexity of the problem. The cluster is a directed, connected graph, where each node has either video capturing or data processing functionality. We consider two types of resource states of the cluster, based on the mix of vehicles with one of three resource profiles: 1) Large node type: 5 CPUs, 500Mb disk, 6MB/s bandwidth; 2) Medium node type: 3 CPUs, 250Mb disk, 4MB/s bandwidth; and 3) Small node type: 2 CPUs, 100Mb disk, 2MB/s bandwidth. A resource-rich cluster has 50% large, 25% medium and 25% small resource vehicle nodes. A resource-poor cluster has 25% large, 50% medium and 25% small vehicle nodes. We consider a service chain with 2 processing instances, which makes the chain length = 3, including Type 1 instances and the CN. We ran the optimization for the longer chain length, which takes a much longer time to find a solution, specially for a higher number of video generating instances, with higher data rate. The worst case scenario was for a service chain of length 6 with 5 Type 1 instances, which took more than 5 hours to find a solution. The 'type graph' is scaled as an 'instance graph', with data dependency and resource requirements. We use a service chain description similar to [33] , without making it bidirectional. We impose multi-tenancy in the model, as it is beneficial to share TIs between applications, especially when more than one task replica is placed on the vehicle cluster. For this paper, we consider that all nodes stop at an intersection and the RSU first selects a CN, which is one hop away from the RSU and is well connected to more than 70-80% of the nodes in the cluster. This CN needs to have ample communication and computation resources to manage the resource and cluster state. We also assume that the mobility behavior, in terms of the CCP is based on the mobility pattern of each vehicle, collected over its previous trips in this area. We derive the CCP by running the calibrated SUMO simulator, using the real vehicle density data from Dublin traffic, as explained in §5.3. We have broadly classified cluster states as stable and unstable. The stable clusters are formed when many vehicles follow a single trajectory, along with the CN. We consider two cluster states: stable with a CCP in the range [0.4,0.8] and unstable with a probability distribution between [0.2,0.6]. We consider three use cases for solving the optimization. For Case A, we take a resource-constrained cluster with low data rates of streaming video, and compare the node processing cost for stable and unstable cluster probabilities. We vary the number of Type 1 instances from 2 to 6, to study the effect of the amount of data on service placement and resource usage. When we use lower video data rates, we see that the stable cluster uses less resources than the unstable cluster. For Case B, resource-rich case (Fig. 11b) with lower data rates, the node cost is significantly less, compared to Case A (Fig. 11a) , as it is easier to place more than one TI on nodes having more processing resources, for both stable and unstable cluster, resulting in better resource utilization. But in this case, the stable cluster still used less resource than the unstable cluster. The solution time is also significantly less for a resource-rich cluster: to find the optimal placement for Case B takes an average of 86s, versus a resourceconstrained cluster (Case A: 300.7s). We also observed that weighting both objectives (adjacency TI placement and total cost of service placement) equally solves the problem faster than hierarchical solving, but the resulting placement uses more network resources. For link cost, the resource-constrained cluster (Case A) has significantly higher resource usage (Fig. 11d) . The nearby nodes might not have enough processing capacity, so dependent TIs need to be placed on farther nodes, leading to more link utilization. The link capacity is also less in the resource-constrained cluster which adds to the cost. The Link Cost in the resource-rich cluster (Case B) (Fig. 11e) is significantly less and, in both cases, stable clusters outperform unstable clusters. The variability in link cost is more in this case, as the amount of video data processing in both applications is significantly different. Application I reduces the data to approx. 20% whereas Application II reduces the data to 80%. Hence, the link cost varies based on the number of Type 1 TIs in each application. But as we double the data rate of the video data in a resource-rich cluster (Case C), the unstable cluster utilizes much more computation resource (Fig. 11c) . The difference between stable and unstable cluster node cost increases significantly as the Type 1 instances increase from 1 to 6. The unstable cluster uses slightly more resources, compared to the stable cluster in the low data rate case (Case B: Fig. 11b ). For the link cost in this case (Fig. 11f) , for fewer Type 1 TIs, stable and unstable cluster incur almost the same cost. The variability increases as the number of video instances increases. We compare the optimal solution of our model to a naive solution introduced in [34] . The Autonomous Vehicular Edge Computing + Naive solution selects combinations of nodes with the intention of minimising latency, i.e., they have the lowest processing time and transmission time. As we focus on data collection services, we do not focus on the time needed to send results to the requesting node (typically the CN). As described in [17] , they preferentially select nodes with the highest available link and node capacities. As seen in Fig. 12 , the node cost for the naive approach increases significantly as the number of Type 1 instances increases. We get a similar result for link cost in Fig. 13 where the cost doubles for 5 and 6 Type 1 TIs, in comparison to the optimal solution. The naive approach results in less latency compared to the optimal approach, but does not take account of node mobility, so is more likely to fail. By contrast, our objective reduces the cost of service execution and selects more reliable nodes that reduce the need for service reconfiguration. Of course, delay is a crucial parameter for safety-related services like lane changing, accident prevention and autonomous driving. However, delay can also be reduced by adding more resources and using them judiciously: by shortening service chains and placing many processing TIs of the same type in parallel. We introduce a Penalty function to reflect the cost of nodes hosting TIs leaving the cluster. This penalty is related to both link and node cost. If a TI-hosting node leaves the cluster, the node cost incurred by it does not contribute to the service requirement. In case of service reconfiguration, the leaving node will have to send the service state back to the CN, which requires bandwidth usage. We penalize placements where TIs are placed on nodes with a probability lower than the threshold probability (0.6). There will be another added cost on re-configuring the failing service, but we do not consider service reconfiguration cost in our current model. The Penalty function for selecting two nodes with a joint probability (to stay with the cluster) less than the threshold probability is given as: P (λ (i 1 ,i 2 ) ) = λ(P (t 1 ,t 2 ) (i1, i2) − P T hreshold ) (14) where λ can take values like 5,10,..,100, based on how strongly we want to penalize task placement on nodes with lower CCP. As shown in Fig. 14a , for a resource constrained cluster (Case A), the penalty cost added to the objective function for an unstable cluster is higher than the penalty for a stable cluster. For the resource-rich cluster (Case B), the model places very few TIs on nodes with low CCP, and hence the additional penalty cost is zero, in almost all the resource-rich test cases, for both stable and unstable clusters. This suggests that the model considers mobility in an intuitive way. We also plot the best and worst case hop count (Fig. 14b) , for the same resource-constrained cluster (Case A), when the total hop count is first minimized for service selection. It is observed that the hops increase significantly as the number of Type 1 instances increase. We emulate the scenario of a vehicle cluster with 10 nodes for Application II. We simulate two video streaming nodes that send 4 minutes long video in different resolutions (240p and 480p) and at different data rates. We use a SUMO-Mininet-WiFi [35] set-up, where the RSU receives a service monitoring request at the same Dublin intersection and forwards the request to the CN. We use the SUMO simulator to generate urban mobility at a busy intersection. Mininet-WiFi maps the cars to an emulated, software-defined network with virtualized WiFi station and access points. The video stream is forwarded to a participating node that aggregates the data before sending it to a CN that forwards it to the RSU. We monitor the bandwidth usage for the two collected streams and compare it to the bandwidth efficiency of the processed stream received at the RSU. As depicted in Fig. 15 , we get significantly better bandwidth efficiency at the RSU because of the data aggregation in the model. This paper focuses on the concept of scaling and placement of distributed services on vehicle clusters, harnessing the knowledge of mobility patterns. The novelty of the work is in considering urban road traffic as a potential site for deploying services. The services can be scaled dynamically, based on the resource and mobility state of the multihop cluster. We introduce a flow model for the traffic, study predictability in vehicular flow, and estimate communication capacity using real vehicular traffic data. We introduce a detailed mathematical model for the mobilityaware scaling of distributed services based on resource-rich and resource-poor as well as stable and unstable cluster states. We solve the constrained bi-objective optimization problem, introduce data collection and data pre-processing applications, and validate our model for different resource As part of the future work, a decentralized, mobilityaware task offloading algorithm will be introduced that solves the optimization problem in real-time. To make the service model more practical, we will introduce a distributed service reconfiguration scheme to send collected data or service state back to the vehicle cluster. We aim to use hyper-parameter optimization techniques to decide the number of TIs to be deployed in real-time, for satisfying the service placement requirements. We will focus on the replacement of concurrent, data-dependent tasks as part of the failure recovery scheme. Vehicular fog computing: Enabling real-time traffic management for smart cities Vehicular fog computing: Architecture, use case, and security and forensic challenges Resource allocation for vehicular fog computing using reinforcement learning combined with heuristic information Vehicular fog computing: A viewpoint of vehicles as the infrastructures Edgecare: Leveraging edge computing for collaborative data management in mobile healthcare systems Mobile edge computing-enabled internet of vehicles: Toward energy-efficient scheduling Efficient 3d road map data exchange for intelligent vehicles in vehicular fog networks A new vehicular fog computing architecture for cooperative sensing of autonomous driving Optimizing the placement of data collection services on vehicle clusters Online placement of multicomponent applications in edge computing environments Vehicular cloud computing Reinforcement learning based task offloading and take-back in vehicle platoon networks Computation offloading and resource allocation for cloud assisted mobile edge computing in vehicular networks Vehicular fog computing for video crowdsourcing: Applications, feasibility, and challenges Jamcloud: Turning traffic jams into computation opportunities -whose time has come Mobility dataset generation for vehicular social networks based on floating car data Folo: Latency and quality optimized task allocation in vehicular fog computing Cooperative fog computing for dealing with big data in the internet of vehicles: Architecture and hierarchical resource management Vehicular micro clouds as virtual edge servers for efficient data collection An application placement technique for concurrent iot applications in edge and fog computing environments Fogcomputing-enabled cognitive network function virtualization for an information-centric future internet Mobility increases the capacity of ad-hoc wireless networks Towards a simple relationship to estimate the capacity of static and mobile wireless networks Capacity of cooperative vehicular networks with infrastructure support: Multiuser case Quantitative analysis for capabilities of vehicular fog computing Deepmarket: An edge computing marketplace with distributed tensorflow execution capability How to keep a vehicular micro cloud intact Optimal task assignment with delay constraint for parked vehicle assisted edge computing: A stackelberg game approach Joint optimization of service function placement and flow distribution for service function chaining Social clustering of vehicles based on semi-markov processes Deployment of iov for smart cities: Applications, architecture, and challenges Yafs: A simulator for iot scenarios in fog computing Scaling and placing bidirectional services with stateful virtual and physical network functions Ave: Autonomous vehicular edge computing framework with aco-based scheduling From theory to experimental evaluation: Resource management in software-defined vehicular networks