# An Actor-Based Formal Model and Runtime Environment for Resource-Bounded IoT Services +
## 5 The Proximity Model
### Fine-Grained Resource Model for IoT Services  
Our model assumes that IoT services are owned by their initiator. This capability can also inform the pricing of using services. The directory service can set the price of creating a new service, and the initiator service can charge the cost of using its services. **Property 1**. : _For an accepted request \(\rho\), the time delay to send any aggregated update \(\theta\) in \(\zeta\) to a client \(\sigma\) does not exceed the max-delay of the client tuple, \(d_{\zeta}\), specified by \(\sigma\)._  
Proof. : For the same client tuple \(\zeta\), the max delay of the contributor tuples \(\Xi_{\zeta}\) mean it is limited by the oldest tuple in the aggregate. This is assuming that the sensed data in any contributor tuple \(\zeta\), including the oldest feed, must be collected and sent to the server no later than \(d_{\zeta}-\delta\), where \(\delta\) is the maximum time delay between the sensing time and sending data to the server. Therefore, \(\theta\) is sent to \(\sigma\) no later than \(d_{\zeta}\). This proves the property. **Property 2**. : _There are no wasted contributions in the system._  
Proof. : Assume that a request \(\rho\) is accepted in the system. According to Axiom 1, if a request \(\rho\) is accepted in the system, there must be at least one set \(\rho_{i}\in\rho\) that can be served by the server. According to Axioms 2 and 5, there must be a set of contributors \(C_{(\rho_{i})}\) which have unconditionally committed to serve a set of client tuples, \(Z_{(\rho_{i})}\), which is exactly equal to the set \(\rho_{i}\) so that each and every member in \(Z_{(\rho_{i})}\) is a member in \(\rho_{i}\). Therefore, there are no wasted contributions in the system. This proves the property. A contributor context sampling is a process of obtaining a contributor context by the mobile device. To quantitatively describe the consumption of resources, particularly the energy consumed by sensors involved in the sampling, in the proposed IoT system, we adopt the following energy model. Each of the sampling methods supported by the mobile device is associated with a resource cost \(\omega\) required for its invocation for context sampling and is determined by the following function:  
\[\omega=f_{cost}(E,s) \tag{22}\]  
A total cost of the IoT system functioning is determined by costs of the individual contributor context samplings and is represented as the sum of their individual costs:  
\[\Omega_{sampling}=\sum_{i=0}^{|\epsilon|}\omega_{i} \tag{23}\]  
Given a service list, the goal of the IoT system is to define the function \(f_{sampling}\) that maximizes the number of IoT services that are hosted at the contributor's device, and minimizes the total cost \(\Omega\) of consumed resources. We use a sliding-window concept to aggregate the most recently collected sensor data from contributors as input to the aggregation function. We collect a series of sensor feeds from different contributors at the same time, denoted as \(\Xi=\{\xi_{1},\xi_{2},\ldots\xi_{n}\}\). Each service consumes \(\epsilon\) computational resource units from each contributor during data acquisition. The total computation cost can be expressed by:  
\[\Omega_{comp}=\sum_{i=0}^{\Theta^{*}}\epsilon_{i} \tag{24}\]  
We define \(\beta\) to denote the communication cost of unit data, and the total communication cost can be expressed by:  
\[\Omega_{comm}=\beta\sum_{i=0}^{\Theta^{*}}d_{i} \tag{25}\]  
where \(d_{i}\) is the size of the sensing data. We consider three types of overhead costs in the IoT system: context sampling, computation, and communication. The total cost within a long time period \([1,T]\) can be calculated by:  
\[\Omega_{total}=\sum_{t=1}^{T}\Omega_{sampling}(t)+\Omega_{comp}(t)+\Omega_{comm}(t) \tag{26}\]  
Our objective is to calculate the amount of resources \(\Omega_{total}\) a service uses. We represent the availability of each resource (e.g., sensor sampling, CPU cycles, network utilization, etc.)