Matching IoT Devices to the Fog Service Providers: A Mechanism Design Perspective†

In the Internet of Things (IoT) + Fog + Cloud architecture, with the unprecedented growth of IoT devices, one of the challenging issues that needs to be tackled is to allocate Fog service providers (FSPs) to IoT devices, especially in a game-theoretic environment. Here, the issue of allocation of FSPs to the IoT devices is sifted with game-theoretic idea so that utility maximizing agents may be benign. In this scenario, we have multiple IoT devices and multiple FSPs, and the IoT devices give preference ordering over the subset of FSPs. Given such a scenario, the goal is to allocate at most one FSP to each of the IoT devices. We propose mechanisms based on the theory of mechanism design without money to allocate FSPs to the IoT devices. The proposed mechanisms have been designed in a flexible manner to address the long and short duration access of the FSPs to the IoT devices. For analytical results, we have proved the economic robustness, and probabilistic analyses have been carried out for allocation of IoT devices to the FSPs. In simulation, mechanism efficiency is laid out under different scenarios with an implementation in Python.


Introduction
With the the ever-increasing growth of Internet of Things (IoT) devices across the globe [1] (CISCO has put forward a figure that shows we could have 50 billions devices ready to be linked by the year 2020 with multiple devices belonging to a person on average [2]); vast amounts of data are to be stacked and handled. This study reveals that, one of the prime factors with IoT devices is of limited processing power and storage. These limitations of the IoT devices give rise to several issues such as reliability, security, performance, and privacy [3]. In order to overcome these issues, one of the potential options However, one can think for the more general scenario of the problem considered in [23] by relaxing the constraint that each of the available IoT devices (or users) will be ranking all the available FSPs or the subset of available FSPs in strict sense. Some of the IoT devices may be indifferent among the FSPs, so that the preference lists may have ties. Given this setup, the goal is to allocate FSPs to the IoT devices. However, in this paper, the above discussed problem is studied in two different directions: (1) an IoT device is assigned to the FSP for exclusive use for a longer duration (afterwards, it is termed t i = ∞), (2) an IoT device is assigned to the FSP for a shorter duration (afterwards, it is termed t i = ∞). This case where an access of shorter duration is required is more challenging than the case of long duration access. In these contexts, the truthful (or incentive compatible) mechanisms are proposed, motivated by [24,25]. In addition to the truthfulness, all the mechanisms that are sifted here run in polynomial time, which make our proposed mechanisms scalable. Also, the mechanisms support the case of duration without deadlines and duration with the deadlines for allocating IoT devices to the FSPs and thereby making our mechanisms amenable to address the time bar.
It should be noted that the allocation problem considered in this paper arises more each time in many real-life applications and projects, especially with the emergence of 5G technologies, such as from smart cities and smart transportation systems. For instance, the C-Roads Spain project (with participation of IMP-Information Modeling Processing research group InLab of Universitat Politècnica de Catalunya, Spain), which is part of the European project C-Roads, includes the deployment of intelligent transport systems in five pilot projects throughout the Spanish geography. The aim is to offer warning services to drivers about the potential risks that can be found on the roads such as road works, stationary vehicle, adverse weather conditions, etc. to evaluate the effectiveness of these services. As a second example, a joint EPSRC/Jaguar LandRover funded project with participation of the University of Surrey, UK is developing an innovative architecture for the dynamic migration of workloads across edge/Fog nodes to support a wide range of use cases for connected and autonomous vehicles.

Our Contributions
The main contributions of this paper are the following: • The proposed mechanisms in this paper are amenable to address the long and short duration access of the FSPs to the IoT devices in a more general setting as the t i = ∞ situation is extended in a framework that supports the case where the IoT devices posit their demand that encompasses deadline. (The work done in this paper is an extension of the preliminary version of the paper [23] that appeared in The 14th International Conference on P2P, Parallel, Grid, Cloud and Internet Computing (3PGCIC-2019). November 7-9, University of Antwerp, Antwerp, Belgium.) The comparison table comparing the previous framework and the framework presented in this paper is depicted in Figure 2.
In Figure 2, the comparison between the previous framework and the framework presented in this paper is discussed. In the framework presented in this paper, each of the tasks also have a deadline and the processing time associated with it, whereas in the previous framework, the tasks had only processing time associated with them. In this paper, the makespan resulting after scheduling all the tasks using Further Modified Truthful Mechanism for Fog Service Allocation (FMTM-FSA; the mechanism proposed in the framework presented in this paper) is less as compared to the makespan achieved when scheduled using the Modified Truthful Mechanism for Fog Service Allocation (MTM-FSA; the mechanism proposed in a previous framework).
In this paper, the truthful mechanism is proposed for the setup consisting of multiple IoT devices and FSPs, where the tasks associated with the IoT devices have both processing time and deadline. Further in this paper, the proof of the lemmas are presented in detailed manner and the extensive probabilistic analysis is carried out. In this paper, the simulation presented in Section 8 is carried out on a large data set, whereas for the previous framework, it is carried out on a small data set. Also, an additional simulation is carried out, where FMTM-FSA and MTM-FSA are compared on the basis of maximum lateness. − Economic robustness (strategy-proofness and Pareto optimality) − Probabilistic analysis that envisage the allocation in connection with the preferences furnished by the IoT devices.
• Detailed experimental analysis is carried out based on the following important parameters by considering all cases regarding the availability of FSPs and IoT devices: The remaining sections of the paper are described as follows. The prior works are discussed in Section 2. In Section 3, we describe the system model and formulate the problem. The proposed mechanisms for the case t i = ∞ are illustrated in Section 4. In Section 5, analysis of the TM-FSA is carried out. The algorithm for the extended version of the problem is depicted in Section 6. The discussed model is further extended in Section 7. The experimental results are discussed in Section 8. Finally, the conclusion and future work are highlighted in Section 9.
Allocating the available best resources considering the time demand, so that more IoT device get their available best Considers IoT devices with deadline and processing time.
Considers available best but the order in which IoT devices are accessed is based on the deadline that minimizes the lateness.

Related Work
As the background of the IoT + Fog + Cloud framework, in the IoT+ Cloud architecture, several works have been done in the direction of modeling the problem of resource allocation through the concept of mechanism design with money (mainly auctions) and mechanism design without money, as the participating agents are strategic in nature. In the scenario where money is involved, in [26], an auction is utilized to allocate the computing capacity of a computer to the users. Based on the demand of the computation time by the users, the payment of the users are decided. In [27], a novel model called Zenith is proposed for allocating computing resources in an edge computing platform that allows service providers to establish resource sharing contracts with edge infrastructure providers apriori.
A similar line of thinking is still relevant in today's Cloud computing market and will be discussed in many subsequent papers. As the participating agents are rational, they can manipulate their private information to have some extra incentives. In order to tackle such a situation, some truthful mechanisms are discussed [17]. Other potential directions that are significantly important for Fog computing research include data caching and service offloading [20,21], rendering Qos/QoE guarantees for achieving the desired objective in Fog computing as efficiently as possible, incorporating machine learning to efficiently allocate the users to the FSPs and to maximize the revenue of the FSPs. The data caching and service offloading that are discussed in [20,21] mainly discuss how the Fog nodes can be used as a repository to provide a local access to the data or service being accessed repetitively instead of accessing the Cloud infrastructures multiple times for the same and thereby avoiding congestion in the network. The data caching techniques that are rendered in [20,21] can be used in our model to have fair allocation where the assignments that are happening could be stored (as a data cache) and a proportional assignment of the IoT devices to the FSPs could be proffered.
The guarantee regarding QoS/QoE is another facet of Fog computing. By structure, Fog computing is potentially viable to inject QoS/QoE guarantees by providing local accesses to the users rather than communicating every time to the Cloud. In literature, various issues like energy-efficient design, latency, and minimizing congestion as a whole are explored in a reactive (as and when demand comes) or a proactive (in hindsight) manner in general [21,28,29] or considering particular application in mind [30,31].
Moving on to the case where money is not involved in any sense, in the setup of [32], there are multiple users (here, users and IoT devices terms are used interchangeably) and multiple service providers, say n, and users provide preference ordering over the available service provider. Here, the goal is to allocate the best available service provider to each of the user. The truthful mechanism is proposed for this discussed setup. Further in [33], the setup discussed in [32] is extended to the case where both the users and the service providers provide strict preference ordering (full or partial preference) over the members of the opposite community. A truthful mechanism is proposed to allocate the services to the users (each user receives a single service).
Coming back to our IoT + Fog + Cloud framework, currently, there are few existing works on the concept of Fog computing [7,34]. For a detailed overview of Fog computing and the research challenges, the readers can go through [3,7,34,35]. In the past, several works have been done that consider the problem of resource allocation in the context of Fog computing but in a nonstrategic setting [9,11]. In [36], in Fog computing, the set of participating agents report the bundle of resources along with the bid values. Given this, the goal is to assign available resources to the participating agents in a conflict-free manner. In [37], in order to schedule the tasks of IoT devices, the idea of data mining is utilized. For this, in order to classify the tasks, a mechanism is proposed named I-apriori (an improved version of the apriori association rules algorithm). In [38], in Fog environment, the problem of scheduling delay-critical IoT devices service is formulated using game theory. For this purpose, an intelligent matching algorithm is proposed that matches the Fog nodes to the IoT devices. The above discussed papers in Fog computing have mainly considered the problems from a monetary perspective.

System Model
In this section, we present the formal statement of our problem. We consider n FSPs and m IoT devices. It is considered that m = n. However, for the simulation purpose, we have also considered that m = n (m > n and m < n). The FSPs are present all the time in order to impart their services on a demand basis. In this model, it is considered that the FSPs and IoT devices are heterogeneous in nature. By heterogeneity, we mean that the FSPs may vary in terms of services provided (some FSPs may provide CPU-related services, some may provide data analytic related facilities, and so on) and IoT devices may vary in terms of type of services requested (CPU related services, data analytic related services, and so on).
Based on the type of services provided by the FSPs and the demand of services by the users, the users and the FSPs are categorized into k different categories. Here, the categorization is done on the simple search techniques and given k different parameters. k-Means clustering or single link clustering using Kruskal's algorithm or any other clustering (fulfilling some optimization criteria) could also be used depending on the situation and objective we have. The set of k different categories is given as C = {c 1 , c 2 , . . . , c k }.
In any category c i , the set of FSPs is given as . . , f n i i }; here, n i is the number of FSPs in the ith category. In our case, n i n and ∑ ∀c i n i = n. The set of all the FSPs in k different categories is given . . , f k }. In any category c i , one of the components that is preserved for any FSP f j i is the amount of time it is available to provide its service and is denoted by e  (2) the time required to complete the desired job of the IoT device I j i (here, job means the desired processing of its collected data) represented by the symbol t j i . Now, considering the first parameter, each user has a preference ordering over the subset of member of f i . The strict preference ordering of tth IoT device I t i ∈ I i in ith category over the set f i is denoted by t i . More formally, f 1 The ties in the preference list of tth IoT device in c i category over the set f i is denoted by = t i , where f 1 i = t i f 2 i means that, in ith category, the IoT device I t i prefers equally to f 1 i and f 2 i . In our setup, = { 1 , 2 , . . . , k } represents a set consisting of the preferences given by the IoT devices in k different categories. The symbol i represents the preference list of the IoT devices in category c i and is given as For the second parameter, for any category c i , t j i ∈ . It means that it is just a number, say 10, that depicts the completion time from when it is getting allocated. The unit of the number may be second, minute, hour, etc. depending on the applications.
Given the preference list of the IoT devices, the goal is to allocate at most one FSP to each of the IoT devices. Let us say the resulting allocation vector for all the k categories is given as α = {α 1 , α 2 , . . . , α k }, in which α i is the allocation set of the participating agents that belong to the category c i and is denoted as

Required Definitions
In this section, we state the definitions that are relevant to our work in this paper.

Definition 1 (Blocking coalition).
Instead of participating in the mechanism, if a subset of the IoT devices and the FSPs form a coalition, reassign them and improve their allocation in terms of the preferences they get; then, the coalition formed is thereby termed a blocking coalition.
Definition 2 (Core allocation). Allocations where the agents (IoT devices and the FSPs) cannot improve by reassigning them without participating in the mechanism. In other words, a core allocation ensures an allocation without blocking coalition.

Definition 3 (Truthful or Incentive compatible).
A mechanism is truthful if the agents cannot gain by misreporting their true preference ordering.
Definition 4 (Pareto optimal outcome). An outcome (allocation) where we cannot make anyone better off without making someone else worse off.

Proposed Mechanisms: RM-FSA and TM-FSA (for t i = ∞ Case)
In this section, we present and discuss the two proposed mechanisms, namely, RM-FSA and TM-FSA, for the problem under consideration. The idea behind proposing the RM-FSA for our problem is to better understand the truthful mechanism called TM-FSA motivated by [24,25].

Random Mechanism for Fog Service Allocation (RM-FSA)
In this section, RM-FSA is discussed. First, the underlying idea of RM-FSA is presented. After that, RM-FSA is discussed and presented in a detailed manner.

Outline of RM-FSA
The central idea of RM-FSA is that, for each category c i , an IoT device is picked up randomly and an FSP is assigned randomly from the preference list of the IoT device under consideration. Notice that, once the allocation is done, both the IoT device and the FSP are removed from the market. The process iterates until the list of available IoT devices gets exhausted. For any arbitrary category c i : 1. In a random order, choose an unassigned IoT device. 2. Go through the preferences of the newly chosen IoT device.
(a) If the list is not empty, then randomly pick an FSP from the selected IoT device preference list and allocate it. Remove the IoT device along with the allocated FSP from the market. (b) Else, remove the unallocated IoT device from market.
3. Until all the IoT devices are not processed, keep repeating the above two steps.

Details of RM-FSA
RM-FSA is a two-phase mechanism: main routine (Algorithm 1) and RM-FSA routine (Algorithm 2). The core allocation property which is defined in Section 3.1 is not guaranteed for RM-FSA. The main reason for constructing the main routine is to perform an allocation process for all the k categories. In lines 2-5 of the main routine, for each iteration of the for loop of Algorithm 1, the RM-FSA routine is called as depicted in line 3. α maintains the IoT device-FSP pairs for each category in line 4. In line 6, the final allocation α is returned.
In the RM-FSA routine of Algorithm 2, line 3 is checked for stopping conditions. Lines 4 and 5 choose which IoT device to be processed next. The condition is checked on whether the preference ordering of the selected IoT device is empty in line 6. In line 7, an FSP is randomly picked up from the IoT device k's preference list and is held inḟ . The selected IoT device-FSP pairs of the c i category is maintained in α i . Using line 9 of the algorithm, the selected IoT device is removed from the market. Similarly, in line 10, the selected FSA is removed from the market. Line 11 removes the selected FSA from the preference ordering of the remaining IoT devices. In line 12,ḟ andI are set to φ. Next, if the stopping condition in line 6 fails, then lines 14-17 of Algorithm 2 gets executed. Line 15 removes the selected IoT device from the IoT devices list. In line 16,I is set to φ. The RM-FSA routine returns the final allocation vector α i in line 19. Hence, the running time of RM-FSA for all the k different categories will be O(km 2 n). If m = n, then the running time of RM-FSA will reduce to O(kn 3 ). In this section, first, the underlying idea of the TM-FSA is elaborated. After that, TM-FSA is discussed and presented in detail.

Outline of TM-FSA
The main observation of TM-FSA is that, for each category c i , first, the distinct random numbers will be generated between 1 to m i and will be assigned to the IoT devices. Now, based on the random numbers assigned, each time an IoT device will be picked up and will be assigned the best available FSP from its preference list. Once the allocation is done, both the IoT device and the FSA are removed from the market. The process iterates until the IoT devices list gets exhausted. The idea of TM-FSA is depicted below. For any arbitrary category c i : 1. IoT devices are numbered with a randomizer. 2. Each of the IoT devices is processed in a non-decreasing order of the number generated by the randomizer. 3. When processed, the match between an FSP and the IoT device is fixed with the most favored FSP available at that time for IoT device.

Detailing of TM-FSA
TM-FSA is a two-phase mechanism: main routine and TM-FSA routine. The main routine performs the allocation process for all the k categories. In lines 2-5, for each iteration of the for loop of Algorithm 3, the TM-FSA routine is called as depicted in line 3. α maintains the IoT device-FSP pairs that have to be announced finally, and this implementation is done in lines 4 and 6.
The TM-FSA routine is mainly implemented with the outline presented above with the three steps. IoT devices numbering with a randomizer is provided with lines 3-12. Each of the IoT devices is processed in a non-decreasing order of the number generated by the randomizer and is presented in line 13. Whether the list is exhausted is implemented with line 14. IoT devices are selected sequentially based on the random number assigned in the next line. In line 16

Illustrative Example
The detailed functioning of TM-FSA for category c 1 is depicted in Figure 4. The number of FSPs is 3 (i.e., n 1 = 3), and the number of IoT devices is 4 (i.e., m 1 = 4). The preference ordering reported by the IoT devices is shown in Figure 4a. Following lines 3-13 of Algorithm 4, the random numbers are generated and assigned to the IoT devices, and based on that, the IoT devices are sorted in ascending order as shown in Figure 4b. From the sorted ordering, first, the IoT device I 2 1 is picked up and assigned the most preferred FSP, i.e., /* Sequentially picks an IoT device based on the random number assigned. */ : : [3] [4] (b) Random numbers assigned and sorted. : : [3] [4] (c) Resulting allocation.

Analysis of TM-FSA
Now, we will prove some theoretical results about the proposed TM-FSA. It should be noted that, before applying the concept of the draw [25], to which category each IoT device belongs, the duration with which the demand is put forward, and the preferences imparted by it had been sifted and thereby makes our mechanism a two-step process. The two-step process is designed when an exclusive access of the FSP to an IoT device for a longer duration (t i = ∞ case) is required and when a flexible access in terms of time is required. For the former case, without changing, the draw can be used to match the FSPs to the IoT devices, but for the later case with flexible time requirement, Draw is applied with little modification. The two-step process of the mechanism entices us to prove that our mechanisms assure truthfulness and Pareto optimality. As we are applying the Draw in our two-fold mechanism, the proof will be similar in nature to that of [25,40]. Proposition 1. The draw is truthful [25,40]. Theorem 1. TM-FSA mechanism is truthful.
Proof. Fix a category c i . The truthfulness of the TM-FSA algorithm depends on the way that every user i gets the most ideal decision from the detailed preferences, independent of the classification i ∈ 1, 2 . . . k of the user i. Notice that the outsider (or the Fog platform) makes a segment for the accessible users and the service providers into various sets in view of their classification. The partitioning of the FSPs set . . , f k } is independent of the partitioning of the accessible users into the set I = {I 1 , I 2 , . . . , I k }. Hence, we demonstrate that, for any user I i ∈ I i , misreporting the private data (for this situation, strict preference over f i ) will not make the user I i better off.
Each user I i ∈ I i is assigned a random number and is processed according to that number. It may seem at first that the randomization may adversely affect the truthfulness, but a deeper insight will suggest that it is not. We prove the truthfulness by the induction on j. When j = 1, the first user (after randomization, we sort the list) in category c i (note that the users belonging to c i are not included in any other category c k , and hence, any other category considered will not be affected by this user and vice-versa) will be processed, and according to the algorithm, the best available service provider will be allocated to them. Since no other allocation is done, they will get the first choice. At this point, if they would have given any other rank list, the first preference may come later in rank and would not be the optimal choice. Therefore, the base case holds. Assume it is true up to jth users. Now, consider the (j + 1)th user. The allocation of the (j + 1)th user is independent of the allocation of users that have been allocated before. Therefore, if some preferences of the (j + 1)th user have already been allocated to the users processed before, they cannot do anything. Now note that, out of the remaining preferences (if it is not already exhausted), the (j + 1)th user gets the best available one by the flow of the algorithm. If, at this point, they alter their preference list, like j = 1, the best available choice may be pushed down the line of the rank list and they may not get the best available one, yielding no gain in terms of allocation.
This proves our claim that TM-FSA is truthful.

Theorem 2. The allocation computed by TM-FSA is Pareto optimal.
Proof. The proof is by a "greedy stays ahead" kind of argument. Assume that any arbitrary algorithm called ANY is running in parallel with TM-FSA. We will prove that, in any arbitrary iteration, if ANY does not take the policy of TM-FSA, then the user will be worse-off, violating the Pareto optimality condition. Say upto the ith iteration, the TM-FSA and ANY output the same allocation. Now, consider the (i + 1)th iteration for allocation of the (i + 1)th user (note that the (i + 1)th user represents a particular category and no user from other category will compete with the (i + 1)th user). TM-FSA will allocate, by definition, the best available option to the (i + 1)th user. If ANY chooses other policy than this, then the (i + 1)th user may not get the best available service provider and definitely will get a lower ranked service provider. Therefore, we can infer that, in any ith iteration, TM-FSA will give the best allocation, considering the fact that allocation of the (i + 1)th user is independent of allocation of the other users of categories. Therefore, the allocation given by TM-FSA is Pareto optimal.
In the context of allocation mechanisms, it would be interesting to estimate the expected number of IoT devices getting their first preference allocated. For TM-FSA, we prove the following result. Proof. Fix a category c j . Let us define the event B as the ith agent's first preference already consumed by any of the (i − 1)th agents. In that case, they will not get the best allocation. Further, let us define the event B k as any agent 1 ≤ k < i having the same best preference as the ith agent. We can then write Equation (1) signifies the fact that whether ith agent's first preference is consumed by the first agent already considered or by the second agent already considered and so on up to the (i − 1)th agent, and because of this, we are summing up the probability. One agent's preference is randomly picked. Therefore, the probability that the ith agent's first preference will become the first preference of any prior agent is 1 m j , as the ith agent's first preference being the first preference is equally likely. Now, from Equation (1): In Equation (2), we plug the probability that is calculated for the event of any B i , and with algebraic manipulation, we get the result. Let us define the event A as the ith agent's first preference surviving.
Equation (3) is obtained by the complementary event property. Now, let us define the indicator random variable as X ji = I{ith IoT device of jth category being allocated the best preference } Let us denote the random variable X j as the total number of agents getting their first preference in category c j .
Taking the expectation pf both sides, we get By linearity of expectation, we get For instance, if m j = 100, then the value of E[X j ] will be approximately 50. It means that approximately half of the IoT devices will be getting their most preferred FSP.

Proposed Mechanism: MTM-FSA (for t i = ∞ Case)
In this section, Modified TM-FSA (MTM-FSA) is discussed. We will first make an observation that will help develop the algorithm in this setting. After that, the underlying idea of the MTM-FSA is elaborated. Next, MTM-FSA is discussed and presented in a detailed manner.

Observation
When a flexible time requirement is put forward by the IoT devices to access the FSPs, then a little care is to be taken for allocating the IoT devices to the FSPs; otherwise, one IoT device will get an entire access to the FSP, excluding others. In the t i = ∞ case, if we take some care, then more than one IoT devices may be accommodated to the same FSP if they impart the same preference. In this case, we have modified the TM-FSA to accommodate more users to a particular service provider if IoT devices have the same preference. We call this algorithm Modified TM-FSA (MTM-FSA).

Outline of MTM-FSA
In this mechanism, initially, randomizer IoT devices belonging to an arbitrary c i are numbered when they are to be processed. Now, based on the random numbers assigned, each time an IoT device is selected, it is checked whether the preference list of the IoT device is empty. If not, then a check is made on whether the time needed to complete the job of the selected IoT device is less than or equal to the available time of the FSP under consideration. If yes, then the FSP is allocated to the IoT device. Otherwise, the FSP is removed from the list. The process is repeated until the preference list of the IoT device becomes empty, or an allocation is made to the IoT device under consideration. On the other hand, if the preference list of the IoT device is empty, remove the IoT device from the market. Repeat this process until the list of available IoT devices does not get exhausted. Let us have a look at the outline of the proposed mechanism, i.e., MTM-FSA depicted below. For any arbitrary category c i : 1. First, m i distinct random numbers are generated and assigned to IoT devices. 2. Next, the IoT devices are sorted in ascending order of the random numbers assigned to them.

Detailing of MTM-FSA
MTM-FSA is a two-phase mechanism: main routine and MTM-FSA routine. The main reason for constructing the main routine is to perform the allocation process for all k categories. In lines 1-4, for each iteration of the for loop of Algorithm 5, MTM-FSA routine is called as depicted in line 3. α maintains the IoT device-FSP pairs for each category in line 3. In line 5, the final allocation α is returned.

Algorithm 5:
Main routine ( f , I, C, , e, t) How, with a randomizer, IoT devices are to be numbered and to be accessed one after the other is discussed in lines 3-17 after initializing the required variables in line 2. In lines 18-28, each time, the best available FSP is selected from the preference ordering of I i and the check is made on whether the time needed to complete the job of the selected IoT device is less than or equal to the available time of the FSP under consideration. If yes, then allocate the FSP to the IoT device and reduce the available time of FSP by the amount of time needed to complete the job of the selected IoT device. Otherwise, remove the FSP from the list of IoT devices under consideration. The while loop terminates once the stopping condition in line 18 becomes false. Line 30 removes the considered IoT device from the IoT devices list. Line 31 setsI andḟ to φ. The MTM-FSA returns the final IoT device-FSP pairs set α i .

Illustrative Example
The detailed functioning of MTM-FSA for category c 1 is depicted in Figure 5a. The number of FSPs is assumed to be 3 (i.e, n 1 = 3), and the number of IoT devices is 4 (i.e., m 1 = 4). The preference ordering reported by the IoT devices is shown in Figure 5a. For the running example, it is considered that each FSP will provide its service for 8 h. The times required to complete the jobs of the IoT devices I 1 1 , I 2 1 , I 3 1 , and I 4 1 are 4 h, 5 h, 3 h, and 4 h, respectively. Following lines 3-12 of Algorithm 6, the random numbers are generated and assigned to the IoT devices, and based on that, the IoT devices are sorted in ascending order, as shown in Figure 5b. From the sorted ordering, first, the IoT device I 2 1 is selected and it is seen that FSP f 3 1 is the most preferred FSP, so a check is made on whether that job requested time is 5 ≤ 8 h.

Algorithm 6: Modified Truthful Mechanism for Fog Service Allocation
If the answer is yes, then the most preferred FSP, i.e., f 2 1 , is assigned to I 2 1 for 5 h. Now, the remaining available time of FSP f 2 1 is 3 h. Next, the IoT device I 3 1 will be picked up and it can be seen that the most preferred FSP is f 2 1 . Now, the check is made on whether 3 ≤ 3 h. If the condition is true, f 2 1 will be assigned to I 3 1 . Next, the IoT device I 1 1 is picked up and a test is made on whether 4 ≤ 8 h. If the condition is true, f 1 1 will be assigned to I 1 1 . Finally, we are left with the IoT device I 4 1 . The time required to complete the job of I 4 1 is 4 h. From the preference list of I 4 1 , it can be seen that the FSP f 1 1 is the most preferred one. Now, a check is made on whether 4 ≤ 4 h. If the condition is true, f 1 1 is allocated to I 4 1 . The final allocation is shown in Figure 5d.

Analysis of MTM-FSA
We now prove that MTM-FSA possesses some interesting economic properties such as truthfulness and Pareto optimality, in Theorem 3 and Theorem 4, respectively.

Theorem 3. MTM-FSA is truthful.
Proof. Fix a category c i , and consider the ith user being processed. The question is whether they should provide the preference list truthfully. Our claim is yes. First observe that all the users 1, 2, . . . , i − 1 being processed independently of the preference list provided by the ith user and the processing is done sequentially. This ensures that no further processing will be made to users 1, 2, . . . , i − 1. Some of the choices that are common to i s preference may be taken away by the earlier users processed before the ith user and the ith user cannot do anything. Now, the proof reduces to whether the ith user gets the best available choice when it is their turn in the processing. By construction of the algorithm, i s preference list will be scanned from top to bottom in that order and they will get the next choice when and only when the previous list has been exhausted. Therefore, we can infer that they will always get the best available choice. Therefore, they should report the privately held preference list in a truthful manner. Any possible lie will allocate him a service provider which is not better than the current best. Hence, MTM-FSA is truthful.

Theorem 4. MTM-FSA is Pareto optimal.
Proof. In MTM-FSA, a user is allocated their first choice as long as possible. Otherwise, they are allocated the best available option. At any ith stage, if we consider allocating a user by any other algorithm, they have to chose the strategy of the MTM-FSA; otherwise, it will lead to a sub-optimal allocation in terms of choice (the user will be getting a lower ranked service provider than the current best, a worsening effect, and hence violating the Pareto optimal property). Therefore, we conclude that MTM-FSA is Pareto optimal.
Again, we are interested in estimating the expected number of allocations of first preferences. Lemma 2. The following inequality holds: Proof. In the summation m j −1 ∑ i=0 i k , i k is a monotonically increasing function, so we can approximate it with the integral as follows: In Equation (5), the summation is approximated by the integral with the standard inequality ∑ n Next, the result obtained in the above lemma is used for proving the result of Lemma 3.

Lemma 3.
In MTM-FSA, for any category c j , the expected number of allocations of the first preference of all the agents will increase based on the number of slots, say k, available to an FSP.
Proof. Let us first fix slot k for a service provider. At the end, we can vary k and explore several possibilities of the expected number of allocations of the first preference of all the agents. First, consider the case that the ith agent will not get their first preference when being considered for allocation. This will happen when all k slots of their preferred service providers are occupied while allocating (i − 1) agents prior to that ith agent. Let us define event O j as the jth slot of the preferred service provider being occupied ∀j and j = 1, . . . , k. When j = 1, all (i − 1) agents are available and anyone can be allocated to the first slot, i.e., j = 1. By Lemma 1, we get Pr{O 1 } = (i−1) m j . When j = 2, anyone from (i − 2) agents may be mapped at the second slot, i.e., j = 2. As the first allocation and second allocation are independent, following the standard result, we can write the probability that both the first and second slots are occupied [39]: By plugging the probabilities of O 1 and O 2 in Equation (6), we get In a similar manner, we can infer the probability that the k slots of the preferred service provider of the ith agent being occupied is as follows: Equation (8) is obtained by extending Equation (6) in a general setting. Now, we define event M as the event that all the k slots of the preferred service providers are not allocated and, in that case, the ith agent will get the first preference.
Now, define the indicator random variable X i = I{theith agent will get their first preference} Therefore, X = m j ∑ i=1 X i counts the number of agents being allocated to their first preference. Taking expectation on both sides, we get By linearity of expectation, we have Using Lemma 2, we can write If we put k = 1, i.e., only one slot, then it is the case of Lemma 1. If k = 2, then E[X] ≥ m j − m j 3 = 2m j 3 . Therefore, the expected number of allocations of first preference increases. It can even be observed that, with a small k, many of the agents will get their first preference, as we will see in next section.

Further Extension of Model
In this section, we provide the variant of our proposed model discussed in Section 6. The setup consists of multiple IoT devices and multiple Fog service providers. Each of the IoT devices have a task that is to be done by utilizing the services provided by FSPs. Here, each of the tasks have a deadline along with processing time. The IoT devices provide preference ordering over the FSPs. Given this setup, the goal is to allocate tasks to the service providers in such a manner that minimizes the maximum lateness. In the setup discussed in Section 6, given the preference list of the IoT devices, the order in which the IoT devices will be given a chance for executing their tasks is decided by the random number assigned. The IoT devices are sorted in increasing order of the random number assigned. From the sorted ordering, each time, an IoT device is picked up and the most preferred FSP is assigned for performing the task. However, following the above discussed approach, a problem that may arise is that the IoT devices may not be able to complete their tasks before the deadline of the tasks. Let us understand the problem that may arise with the help of an example. Let us say we have two users with the same first preference for a service provider. The first user needs 2 h to complete the job with a deadline of 3, and second user needs 3 h to complete the job with a deadline of 5. Now, random numbers are generated and are assigned to the IoT devices. Let us say the first user and second user are assigned the random numbers as 2 and 1, respectively. Following the MTM-FSA (discussed in Section 6), first, the second user will be processed and then the first user. In this case, the second user takes 3 h to complete the assigned job, so it will be finished by 3 (starting from 0). It can be seen that a job is completed within the deadline. Next, as the deadline of the first user is 3, starting from 0, it should complete by 3. However, it can be seen that the job of first user started at 3 and will take 2 h. Therefore, it will be finished by 5. Here, both IoT devices completed their jobs, but the first user faces a lateness of 2 h. Now the question is can we reduce the lateness faced by users? The answer to this question is yes, by utilizing the idea of earliest deadline first (see Section 7.1). For the above discussed situation, in this part, we have proposed a truthful mechanism namely Further Modified Truthful Mechanism for Fog Service Allocation (FMTM-FSA).

Proposed Mechanism: FMTM-FSA
Here, the underlying idea of FMTM-FSA is discussed. After that, FMTM-FSA is presented and discussed in a detailed manner.

Outline of FMTM-FSA
In this paper, we have provided the underlying idea of the proposed mechanism. The key idea of FMTM-FSA is that, for each category c i , the IoT devices are sorted in increasing order of the deadline of the jobs associated with them. From the sorted ordering, each time, an IoT device will be selected and will be checked on whether the preference list of the IoT device is empty. If not, then the check is made on whether the time needed to complete the job of the selected IoT device is less than or equal to the available time of the FSP under consideration. If yes, then the FSP is allocated to the IoT device. Otherwise, the FSP is removed from the list. The process is repeated until the preference list of the IoT device becomes empty or an allocation is made to the IoT device under consideration. On the other hand, if the preference list of the IoT device is empty, the IoT device is removed from the market. Repeat this process until the list of available IoT devices does not get exhausted. For any category c i : 1. First, sort the IoT devices based on the increasing order of the deadline of the jobs associated with them.
2. In each iteration, an IoT device is selected from the sorted ordering.
-If its preference list is not void, then Repeat: (a) Check whether the time needed to complete the job of the selected IoT device is less than or equal to the available time of the FSP under consideration. Output In Algorithm 8, the main trick is applied in line 3 where the IoT devices list I i is sorted based on the deadline of the tasks assigned to them. From line 4, it is clear that the mechanism terminates once the IoT devices list becomes empty. In lines 5-7, selection of the IoT device and availability of its preference list is inquired. In lines 8-18, each time, the best available FSP is selected from the preference ordering of I i and a check is made on whether the time needed to complete the job of the selected IoT device is less than or equal to the available time of the FSP under consideration. If yes, then the FSP is allocated to the IoT device and the available time of FSP is reduced by the amount of time needed to complete the job of the selected IoT device. Otherwise, the FSP is removed from the list of IoT device under consideration. The while loop terminates once the stopping condition in line 8 becomes false. Line 20 removes the considered IoT device from the IoT devices list. Line 21 setsI andḟ to φ. FMTM-FSA returns the final IoT device-FSP pairs set α i .

Illustrative Example
Detailed functioning of FMTM-FSA for category c 1 is depicted in Figure 6. The number of FSPs is assumed to be 3 (i.e, n 1 = 3), and the number of IoT devices is 4 (i.e., m 1 = 4).
The preference ordering reported by the IoT devices is shown in Figure 6a. For the running example, it is considered that each FSP will provide its service for 8 h. In Figure 6a, the first value represents the time required to complete the jobs of the IoT devices and the second value represents the deadline of the jobs associated with the IoT devices. Following lines 3 of Algorithm 8, the IoT devices are sorted in ascending order of the deadline of the jobs, as shown in Figure 6b. From the sorted ordering, first, the IoT device I 4 1 is selected and it is seen that FSP f 1 1 is the most preferred FSP, so a check is made on whether that job requested time is 1 ≤ 8 h. As the answer is yes, then the most preferred FSP, i.e., f 1 1 , is assigned to I 4 1 for 5 h. Now, the remaining available time of FSP f 1 1 is 7 h. Next, the IoT device I 3 1 will be picked up, and it can be seen that the most preferred FSP is f 2 1 . Now, the check is made on whether 1 ≤ 8 h. If the condition is true, f 2 1 will be assigned to I 3 1 . Next, the IoT device I 1 1 is picked up and a test is made on whether 2 ≤ 7 h. If the condition is true, f 1 1 will be assigned to I 1 1 . Finally, we are left with the IoT device I 2 1 . The time required to complete the job of I 2 1 is 3 h. From the preference list of I 2 1 , it can be seen that the FSP f 2 1 is the most preferred one. Now, a check is made on whether 3 ≤ 7 h. If the condition is true, f 2 1 is allocated to I 2 1 . The final allocation is shown in Figure 6d.

Experiments and Results
Here, the experimental results are provided regarding TM-FSA (where full exclusive access is given) and MTM-FSA (for the case t i = ∞) via simulations (the simulations are done using Python). Considering the first case, TM-FSA is compared with the carefully crafted benchmark mechanism called RM-FSA that is non-truthful in nature. The manipulative behavior of the IoT devices in case of RM-FSA can be seen in the simulation results. On the other hand, the proposed mechanism for the second case, namely MTM-FSA, is compared with the TM-FSA on the ground of number of users getting the most preferred FSP among the available ones. For this case, TM-FSA is considered the benchmark mechanism.

Simulation Setup
We have done simulations for the 5 different categories of the FSPs and the IoT devices. In each category, a substantial number of FSPs and IoT devices are considered for providing and taking the services. Here, for both cases, the simulations are performed by considering three different scenarios: (1) the total number of IoT devices and FSPs are the same (m = n), (2) the total number of IoT devices is less than the total number of FSPs (m < n), and (3) the total number of IoT devices is greater than the total number of FSPs (m > n). Here, the simulations are accomplished by considering a large data set where the users (IoT devices) could be at most 5000. The preference lists of the users are generated randomly. In the case of extended setup, the processing time and deadline of the tasks are generated using random distribution and normal distribution. Here also, the preference lists of the users are generated randomly. The table shown in Figure 7 depicts the data used for comparing TM-FSA and RM-FSA.
The table shown in Figure 8 depicts the data used for comparing FMTM-FSA and MTM-FSA.

Performance Evaluation Criteria
Execution of the proposed systems is estimated under the standard of three vital parameters: • Efficiency Loss (EL): Efficiency loss can be calculated by the difference between the index of the allocated service provider from the user preference list and the index of the most preferred service provider by the user from their preference list. • Best Allocation (BA): It evaluates the number of the users getting their most preferred service provider from their provided preference list over the accessible number of service providers. • Lateness: Lateness of the task is defined as the length of time past the deadline of the task. The lateness criteria is considered for the extended setup.
The experimental results according to these performance evaluation criteria are graphically shown in Figures 9-12.

Discussion
In order to analyze the manipulative nature of the agents, the simulation is performed in two different directions: (1) when all the agents are reporting their true preference ordering and (2) when part of the total available agents are misreporting their true preference ordering.
Considering the scenario pointed out in point 2 above, for our simulation purpose, we have considered the following: 1. Small variation (S-var): 1 8 of the total available users are manipulating their true preference ordering. 2. Medium variation (M-var): 1 4 of the total available users are manipulating their true preference ordering. 3. Large variation (L-var): 1 2 of the total available users are manipulating their true preference ordering.

Analysis of the Results
In this section, the analyses of the results obtained for two different cases, i.e., t i = ∞ and t i = ∞, are discussed. In the first case, the comparative results of TM-FSA and RM-FSA are depicted in Figure 9a-f.
On the other hand, in the second case, the results obtained on comparing MTM-FSA and TM-FSA are given in Figure 10a-c.

•
Case 1: t i = ∞. In Figure 9a-c, it can be seen that the total efficiency loss in case of RM-FSA is more as compared to the total efficiency loss in case of TM-FSA. This is due to the reason that, in contrast to the RM-FSA, TM-FSA allocates the best possible FSP to each of the IoT devices present in the system. In Figure 9a-c, where the IoT devices are not truthfully providing the list that consists of their preferences, then (i) the total efficiency loss of the users in case of TM-FSA-L-var is increased compared to TM-FSA-M-var, (ii) is more than the total efficiency loss of the users in case of TM-FSA-S-var, and (iii) is more that the total efficiency loss of the users in case of TM-FSA. This nature of TM-FSA comes from its construction. Considering the second parameter, i.e., best allocation, in Figure 9d-f, it can be seen that the best allocation of the system in case of RM-FSA is less than the best allocation in the case of TM-FSA. This is due to the reason that TM-FSA allocates the best possible FSP to each of the IoT devices as compared to RM-FSA. In Figure 9d-f, where the list announcement is not done truthfully, we have that the best allocation of the users in the case of TM-FSA-L-var (i) is less than the best allocation of the users in case of TM-FSA-M-var, (ii) is less than the best allocation of the users in the case of TM-FSA-S-var, and (iii) is less than the best allocation of the users in the case of TM-FSA. Again, this is natural from the construction of TM-FSA. • Case 2: t i = ∞. In Figure 10, MTM-FSA is compared with TM-FSA based on the second parameter, i.e., Best allocation. In Figure 10, it can be seen that the number of best allocations made in the case of MTM-FSA is more as compared to that of TM-FSA in all three different scenarios. This is due to the reason that, in the case of MTM-FSA, no FSP is exclusively given access to a particular user and a single FSP can be allocated to multiple users. If this is the case, then the number of users getting their best preference among the available FSPs gets increased as depicted in Figure 10. Also, these simulation results are supporting the claim made in Lemma 3 that the expected number of allocation of the first preference of all the agents will increase as the available number of slots is increased.
In Figures 11a and 12b, the comparison between MTM-FSA and FMTM-FSA is done on the basis of lateness incurred on scheduling the tasks of the users. The x-axis represents the number of users, and the y-axis represents the total maximum lateness (in hours). In Figure 11a,b, the simulations are performed on a small data set, whereas in Figure 12a,b, the simulations are performed on a large data set. In the case of MTM-FSA, it can be seen that the tasks of the users are scheduled based on the random number assigned to the users. On the other hand, in the case of FMTM-FSA, the tasks of the users are scheduled based on the earliest deadline first. The simulations are done for two different distributions, namely random distribution (RD) and normal distribution (ND). In Figure 11a, for the ND case, the mean (µ) and standard deviation (σ) for the processing time are 5 and 2, respectively. The mean and standard deviation for the deadline are taken as 8 and 3, respectively. In Figure 11b, for the RD case, the processing time and deadline are generated randomly between [3,10] and [5,12], respectively. In Figure 11a,b, it can be seen that the total maximum lateness in the case of FMTM-FSA is less as compared to MTM-FSA. This is due to the reason that, in the case of FMTM-FSA, the tasks of the users are scheduled based on the earliest deadline first, whereas in the case of MTM-FSA, the tasks of the users are scheduled based on the random number assigned to the users. Therefore, it can be inferred that FMTM-FSA performs better than MTM-FSA on the basis of maximum lateness. In Figure 12a, for the ND case, the mean and standard deviation for the processing time are 75 and 10, respectively. The mean and standard deviation for the deadline are taken as 85 and 10, respectively. In Figure 12b, for the RD case, the processing time and deadline are generated randomly between [50, 100] and [75,110], respectively. In Figure 12a,b, it can be seen that the total maximum lateness in the case of FMTM-FSA is less as compared to MTM-FSA due to same reason as above.

Conclusions and Future Work
In this paper, we have studied the problem of allocating Fog Service Providers (FSPs) to IoT devices in a game-theoretic environment. Here, the FSPs are ranked by the IoT devices in some order and it is not required that all FSPs are ranked. This gives flexibility to the environment. We have considered that the IoT devices provide preference ordering over the subset of available FSPs. We have designed a truthful and Pareto optimal mechanism for allocating at most one FSP to each of the IoT devices. In this case, once the allocation is done, an FSP is exclusively given to a user for a longer period of time. Here, the proposed mechanism, i.e., TM-FSA, is compared with the benchmark mechanism, i.e., RM-FSA, and it is found that TM-FSA performs better than RM-FSA in terms of efficiency loss and number of best allocations. Further, we have extended the setup by considering the case that the participating IoT devices need the FSPs for a specific duration of time from when they are allocated and the demand from the IoT devices for executing the task comprising a deadline along with a processing time. For this setup, we have again designed a truthful and Pareto optimal mechanism. In this case, the proposed mechanism, i.e., FMTM-FSA is compared with MTM-FSA and found that FMTM-FSA performs better than MTM-FSA on the basis of lateness. For all the discussed mechanisms, polynomial time solutions are proposed that signify our mechanisms are scalable.
Till now, we have investigated the case where, given the preference ordering of the IoT devices, each IoT device requests a single FSP. However, in the future, one can consider the case where each IoT device may request for multiple FSPs from its preference list among the available FSPs. Further, in our model, money is not involved. However, by incorporating money in our model, one can prioritize the IoT devices during assignment to the FSPs. A hybrid model can be developed where some assignments may be based without money and some assignments may be based on the priority that could have been imposed to the IoT devices in terms of money.