Coding for Distributed Fog Computing in Internet of Mobile Things

Internet of Mobile Things (IoMTs) refers to the interconnection of mobile devices, for example, mobile phones, vehicles, robots, etc. For mobile data, strong extra processing resources are normally required due to the limited physical resources of the mobile devices in IoMTs. Due to latency or bandwidth limitations, it may be infeasible to transfer a large amounts of mobile data to remote server for processing. Thus, distributed computing is one of the potential solutions to overcome these limitations. We consider the device mobility in IoMTs. Two situations of the movement position of the mobile devices, i.e., unpredictable and predictable, are considered. In addition, three possible relative positions between the two server sets which respectively correspond to the positions of a mobile device for computation tasks offloading and for output results receiving, i.e., within the same server sets, with two different server sets and with two adjacent server sets, are studied. Coded schemes with high flexibility and low complexity are proposed based on Fountain codes to reduce the total processing time and latency of the distributed fog computing process in IoMTs for the above different situations. The latency related performance, i.e., the computation, the communication and the transmission loads, is analyzed. We also compare of the Fountain code-based and the uncoded schemes and numerical results demonstrate that shorter total processing time and lower latency can be achieved by the Fountain code-based schemes.


INTRODUCTION
T HE number of connected mobile devices has increased with the development of communication and computing technologies at an unprecedented rate [1]. The connected mobile devices form a cyber-physical infrastructure, namely, the Internet of Mobile Things (IoMTs). Different from the Internet of Things (IoTs), device mobility is one of the most critical properties in IoMTs [2]. Mobility leads to the challenges in mobile data collection and analysis, resource and energy management, security and privacy protection, etc.
The potential application scenarios of IoMTs include healthcare, smart transportation, industrial automation, etc. In healthcare, mobile devices are exploited to collect the patient health-related parameters, e.g., brain activity, heartbeat, breath, position, etc. According to the analysis results of the collected data, IoMT may send a mild electric shock or make an emergency call, etc. For smart transportation, the driving status of the vehicular and the traffic information are collected by the embedded or wireless connected sensors. Decisions are made in real time at the control center according to the analysis results to manage and control the traffic. For industrial automation, the operating status of the industrial devices are sensed. The collected data is processed at servers.
Control information is sent back from servers to the actuators to adjust their operations.
In order to provide real-time services to the above timecritical applications, a great amount of data need to be processed timely. However in many scenarios, data processing cannot be performed by the mobile devices themselves because of their limited physical resources. Fog computing [3] is a potential solution to support the resource-constrained mobile devices [1]. In fog computing, data processing is distributed and close to the devices, and thus the high reliability and low latency [4] are achieved in time-critical applications.
In fog computing, the mobile devices offload their computation tasks into the fog network and exploit its powerful resources. Many works have been reported on task offloading and server migration [5], [6], [7], [8] in IoMTs. For data offloading, offloading decisions, e.g., whether, where and when to offload tasks, are made at the mobile devices according to the situation of their own resources and the computing resources of the servers available for them. The server migration problem is modeled as Markov decision process (MDP) in many researches. Migration decisions, e.g., when and where to migrate, are made at the servers to provide seamless services to the mobile devices. There are also some works focus on the challenges of distributed fog computing process, e.g., the problems that arise from straggling servers and multistage computations [9], [10], [11].
Recently, coding schemes were proposed for fog computing, i.e., minimum bandwidth codes [11], [12], minimum latency codes [13], [14], and the unified coding framework [10], [15]. These coded schemes were designed for solving the problem of straggling servers. Two extensions of the coded distributed computing framework were designed in [9] aiming to solve the problem of multistage computations in distributed computing. In most of the previous works, codes with maximum distance separable (MDS) properties are used [16], [17], [18], [19]. For example, MDS codes were utilized in [13], [14] to speed up distributed matrix multiplication and data shuffling. In [20] and [21], MDS codes were used to mitigate the effect of stragglers in distributed gradient descent. In [22], a scheme based on Reed-Solomon (RS) codes, which is also called a MDS code, was proposed to minimize the recovery threshold while allowing efficient decoding using polynomial interpolation. In [23], RS codes were applied to achieve load balance in every distributed machine.
However, for the application scenarios where the networks are composed of a large number of nodes and the channel parameters and network topology are time-varying, these MDS-based coding schemes become impractical because of high computation and communication costs associated with encoding and decoding procedures [24]. Thus, coded schemes with high flexibility and low complexity are needed to reduce the overall processing time of the distributed fog computing process in time-critical application scenarios.
It is provided in [25], [26] that the Fountain code-based scheme for distributed computing is one of the optimal choices for the applications with high reliability and low latency requirements. In [25], a Fountain code-based scheme was proposed to confront the problem of straggling servers. Fountain codes are capable of recovering the original information from any subset of output symbols with size slightly larger than the original information [27], [28]. In addition, Fountain codes are of low coding complexity. A coded scheme based on batched sparse (BATS) codes, which are enhanced rateless sparse random linear network codes, was proposed in [29] for the balance of communication and computation loads of the distributed fog computing process. Coded mobile edge computing architectures were proposed in [30] for offloading computation requests and reducing communication load from servers to mobile devices. However, to our best knowledge, coded distributed fog computing for IoMTs considering communications both between mobile devices and servers and among servers has not been extensively studied yet.
In this paper, we consider Fountain codes [31] for the code design of distributed fog computing in IoMTs. Different from [25], the mobility of the mobile devices and the time-varying channels in IoMTs are considered. In particular, we focus on the study of the computation task assign, 1 the intermediate result exchange, the reduce task assign, and the output result delivery, for distributed fog computing in IoMTs. Our main contributions are listed as follows, We consider the mobility of devices in IoMTs. Three possible situations of the relative positions between the two server sets, which respectively correspond to the computation tasks offloading and the output results receiving positions of a mobile device, are studied. The situations of unpredictable and predictable movement position and the networks with error-free and erasure channels are considered. We propose high flexibility and low complexity coded schemes based on Fountain codes for the above three possible relative positions to reduce the total processing time and latency of the distributed fog computing process in IoMTs under different situations and networks. We calculate the total processing time of the distributed fog computing process. The performance related to the processing time and latency, i.e., the computation load at each fog node, the communication load for exchanging intermediate results, and the transmission load for delivering the output results among fog nodes, is analyzed for the uncoded and the proposed Fountain code-based schemes, respectively. Finally, we give comparison results to show that by applying the Fountain code-based schemes, both the communication and the transmission loads can be reduced with relatively low complexity. The trade-off between the computation, the communication and the transmission loads is studied. Compared with the uncoded scheme, shorter processing time and lower latency for the distributed fog computing process can be achieved by the Fountain code-based schemes. Compared with the MDS code-based scheme, the Fountain code-based scheme has much lower coding complexity and is more flexible to varying scenarios. Different from the previous coded distributed computing schemes, we consider more practical scenarios where the computation tasks, e.g., the data in datasets, are generated continuously with time. That is, the dataset is not available for any predetermined operation before the distributed computing starts, e.g., computation task assign.
The remainder of the paper is organized as follows. The device mobility and the MapReduce model for distributed fog computing in IoMTs are introduced in Section 2. Then, Fountain code-based schemes for distributed fog computing in IoMTs are proposed in Section 3. Also in Section 3, the total processing time is calculated. After that, the latency related performance of the uncoded and the Fountain code-based schemes for the situations of unpredictable and predictable movement position is analyzed in Sections 4 and 5, respectively. Comparison and numerical results are given in Section 6. Finally, the conclusions are drawn in Section 7.

SYSTEM MODEL
We consider the mobility of devices in IoMTs. Assume that the geographical distributions of both mobile devices and servers (also known as fog nodes) follow an independent homogeneous poisson point process (HPPP) [36], [37]. A mobile device may observe F N nearby servers. A server is only accessible to the mobile device if a wireless connection can be established. That is, the mobile device can offload its data to the accessible servers for processing and the offloading decision can be made. The servers, which make the decision of accepting the offloading request from the mobile 1. In this work, we only consider linear Map functions and focus on the study of coded distributed computing for providing seamless service for mobile devices. For the nonlinear problems with higher complexity in many practical applications, there are mainly two methods to handle nonlinear problems in coded distributed computing. One is to calculate a number of independent functions or encoded dataset in parallel and aggregate the computation results to obtain the result of the corresponding nonlinear problem [32], [33], [34], and another one is to apply machine learning to train the encoding and decoding models for coded distributed computing design [35]. A further study of distributed computing for nonlinear problems is beyond the scope of our paper and will be studied in our future work. device, are called available servers for the mobile device. The processes of decision making for offloading at the mobile device and for accepting at the servers are beyond the scope of this paper. Here, we only take the effect of these decision processes into consideration through parameter f , i.e., the distribution density of available servers (fog nodes).
Without loss of generality, we focus on the study of an arbitrary mobile device in IoMTs. Let R denote the bidirectional communication distance between the mobile device and servers (fog nodes). The wireless connection area for a mobile device and its moving route are shown in Fig. 1. We use F to represent the number of available servers for the mobile device to offload its data for processing. Based on the HPPP assumption for the geographical distribution of servers, the probability that the device can access F servers in the current decision period can be calculated by the following probability mass function (PMF) of HPPP [5], [37] where F 2 f0; 1; 2; . . . ; F N g. P F N F ¼0 P r ðF Þ % 1, the error becomes arbitrarily small when F N is large.
Among the existing schemes for distributed fog computing, MapReduce [38] is the commonly used framework [39]. As shown in Fig. 2 Then, in Reduce stage, the final output results are calculated distributively at fog nodes using their designed Reduce functions [9]. The output results are finally sent back to the devices.
We assume the networks with error-free and erasure channels. Here, error-free networks mean that the links between the mobile devices and the fog nodes, and among the fog nodes, are lossless. Erasure networks mean that data may be lost during transmissions. We use e DF , e FF and e FD to represent the erasure probabilities of the links from the mobile devices to the fog nodes, among the fog nodes, and from the fog nodes to the mobile devices, respectively. Then we have e DF ¼ e FF ¼ e FD ¼ 0 for error-free networks and e DF ; e FF ; e FD > 0 for erasure networks. The connections among nodes in the networks are changing with time. We note that for erasure networks, the underline physical layer channel can be e.g., Rayleigh fading channels and error detection is used. That is, the network topologies are timevarying. Therefore, any predetermined operation, such as coding and task assign, etc., is impractical.
We define the computation load as the total number of fog nodes used for processing one common computation task. Communication load is defined as the ratio between the actual number of intermediate results exchanged and the total number of intermediate results needed at all the fog nodes. Transmission load is defined as the ratio between the actual number of delivered output results among fog nodes and the total number of output results required at all the fog nodes. Uncoded scheme means that no coding operation is performed neither on the computation tasks at mobile devices in Map stage nor on the output results at each fog node in Output Delivery stage.
We list the main parameters in an abbreviation table, i.e., Table 1, for reading convenience.

FOUNTAIN CODE-BASED SCHEMES FOR FOG COMPUTING IN IOMTS
All the available servers (fog nodes) in the wireless connection area of a mobile device form a set, called server set. We use V V o and V V r to represent the two server sets, which respectively correspond to the positions of a mobile device for computation task offloading and for output result receiving. In this section, three possible relative positions of the two server sets will be studied. We consider two different situations for the movement position of the mobile device, i.e., unpredictable and predictable. Coded schemes based on Fountain codes will be designed for the above different situations to reduce both the communication and the transmission loads of the distributed fog computing process in IoMTs. Finally, the total processing time will be calculated.

Relative Positions
For the two server sets V V o and V V r , their three possible relative positions are shown in Fig. 3. The three relative  positions are referred to within the same server set respectively. Here f f represents empty set. The situation V V o ¼ V V r is formed due to circle moving of the mobile device or very low moving speed, etc. In the beginning, the mobile device offloads its computation tasks to servers in set V V o . After time t, the mobile device starts to receive output results from servers (fog nodes) in set V V r . The servers in V V o and V V r are all the same, i.e., V V o ¼ V V r , as shown in Fig. 3a.
the mobile device moves to a adjacent server set after a duration of time t. In this situation, some of the servers (fog nodes) locate in both the two adjacent server sets V V o and V V r simultaneously, as shown in Fig. 3c.

Fountain Code-Based Schemes for Fog Computing
Due to the mobility of devices and the changes of relative positions of server sets in IoMTs, an additional stage for the coded scheme design for distributed fog computing, i.e., Output Delivery stage, should be taken into consideration. Therefore, the novel coded schemes we will design for IoMTs are composed of four stages, i.e., Map, Data Shuffling, Reduce and Output Delivery stages. The goal of the coded scheme design is to achieve shorter total processing time and lower latency of the distributed fog computing process in IoMTs through reducing the communication and the transmission loads. We consider the two situations for the movement position of a mobile device, i.e., unpredictable and predictable. In the following, Fountain code-based schemes are proposed for the above two different situations, respectively. Without loss of generally, we take the process in an arbitrary fog computing round as an example to illustrate the coded schemes. A fog computing round includes the processes of computation task assign at each mobile device in Map stage, computation task process at each fog node, intermediate result exchange among fog nodes in Data Shuffling stage, reduce task assign and process at each fog node in Reduce stage, output result delivery among fog nodes in Output Delivery stage, and output result send back from fog nodes to mobile devices. As shown in Fig. 4, is a block diagram to illustrate the entire computation process.
The number of available servers for a mobile device 0 F F N R The bidirectional communication distance between a mobile device and servers The distribution density of available servers The server set corresponds to the position of a mobile device for computation task offloading V V r The server set corresponds to the position of a mobile device for output result receiving K The number of computation tasks at a mobile device The number of coded computation tasks at a mobile device N ! 0 T I The length of each coded computation task (The length of each intermediate result) The length of each output The expending coefficient of the used Fountain codes in Map stage The degree distribution of the used Fountain codes in Map stage The number of intermediate results for each coded task Q ! 0 F I The number of fog nodes responsible for reducing outputs The number of times that each output is reduced at F I fog nodes The average number of reduce tasks assigned to each of the F I fog nodes The number of fog nodes responsible for transmitting the output results to a mobile device S o The number of output results for each of the F o fog nodes to transmit h 2 The expending coefficient of the used Fountain codes in Output Delivery stage The degree distribution of the used Fountain codes in Output Delivery stage The number of fog nodes in both of the two adjacent server sets V V o and V V r simultaneously The number of fog nodes already have partial output results before Output Delivery stage 0 a 1 d The distance of the offloading and the receiving positions of the mobile device F I ¼ a I F a I F fog nodes will be assigned reduce tasks 0 a I 1 Each of the F I fog nodes will be assigned b I Q reduce tasks b I > 0

Unpredictable Movement Position
Unpredictable movement position means that the moving route of a mobile device is unpredictable and unknown at the fog nodes. The four stages of the Fountain code-based scheme for the situation with unpredictable movement position are described as follows.
Computation Task Assign in Map Stage. Assume that there are K computation tasks at a mobile device in one round. At the mobile device, encoding operation is performed on the K computation tasks to form N coded computation tasks. The length of each computation task and each coded computation task is T I bits. We use h 1 to represent the expending coefficient of the used Fountain codes, where 1 þ h 1 ¼ N K and h 1 ! 0. The encoding process for the computation task assign is described in the following steps.
At first, the mobile device selects a number d i with probability C d i according to the degree distribution Then, the mobile device selects d i computation tasks uniformly at random from the K ones. The selected d i tasks are combined to form one coded computation task. 2 The same process continues on until N coded computation tasks are formed at the mobile device. Finally, the mobile device sends the N coded computation tasks to their respective fog nodes for processing. For the mobile device, there are F available servers (fog nodes). The number F is known at the mobile device. The N coded computation tasks will be assigned to the F servers for processing. The tasks assign in Map stage is as follows, -If N F , the coded computation tasks are assigned randomly to N different fog nodes. Then, we set F ¼ N. The number of coded tasks at each of the F fog node is Here, bÁc represents floor function. At first, t 1 F coded computation tasks are selected and divided into F groups. In each group there are t 1 coded tasks. Then, the rest t 2 ¼ N À t 1 F coded tasks are assigned to t 2 different groups among the F ones. After that, the F groups of coded tasks are assigned randomly to F different fog nodes. Thus, on average each fog node is assigned t o coded tasks. The computation task assign includes two steps, i.e., the encoding process for task assign and coded computation task assign. The two steps can be summarized as Algorithms 1 and 2, respectively.
At first, each of the F I fog nodes are assigned g 1 different reduce tasks. Then, the rest g 2 ¼ S I Q À F I g 1 reduce tasks are assigned randomly to g 2 different fog nodes. Thus, on average each of the F I fog nodes is assigned g o different reduce tasks.
Intermediate  2. We consider that all the computation tasks are with equal importance and use a classic encoding method of Fountain codes. That is, selecting a fix number of data uniformly at random from the whole dataset and combining the selected data to form a coded data.
transmit. Then, we have Q S o F o ð1 þ h 2 ÞQ, where h 2 ðh 2 ! 0Þ is the expanding coefficient of the Fountain codes used in Output Delivery stage.
That is, the fog nodes, which are responsible for reducing the outputs, are also responsible for transmitting its generated output results to the mobile device.
dÁe represents ceiling function. Then, each of the F I fog nodes deliveries its ð1 þ h 2 Þ% coded outputs to the F o fog nodes. Without loss of generality, we take an arbitrary one of the F I fog nodes as an example to illustrate the encoding process.
-At first, the fog node selects a number r i with probability m r i according to the degree distribution m mðxÞ ¼ P % i¼1 m r i x r i . -After that, the fog node selects r i output results uniformly at random from the g o ones. Then, the selected r i outputs are combined to form one coded output results. The same process continues on until ð1 þ h 2 Þ% coded output results are formed. -Finally, the fog node transmits its ð1 þ h 2 Þ% coded output results to the F o fog nodes.
The above encoding process at each of the F I fog nodes can be summarized as Algorithm 3.

Predictable Movement Position
Predictable movement position means that the moving route of a mobile device is predicable and the position of the mobile device after time t is known. The four stages of the Fountain code-based scheme for the situation with predictable movement position are described as follows.
Computation Task Assign in Map Stage. The computation tasks assign is the same as that for the situation with unpredictable movement position.
Reduce task assign in Reduce stage: reduce tasks assign is the same as that for the situation with unpredictable movement position.
As the movement position of the mobile device is predictable, the number of fog nodes that will be located in both the two adjacent server sets V V o and V V r , i.e., F oP , is also predictable. Then, there are two situations for the reduce tasks assign.
-If F I F oP , select F I ones from the F oP fog nodes and assign all the reduce tasks to the F I selected fog nodes. On average, each of the F I fog node is assigned g o different reduce tasks. -If F I > F oP , on average assign g o different reduce tasks to each of the F oP fog nodes at first. Then, randomly select F I À F oP fog nodes from set V V o and assign a number of g o different reduce tasks on average to each of them.
For the selection of fog nodes, several factors should be take into consideration, for example, the quality of channels among the fog nodes, the processing capability and the computation load of the fog nodes, etc.
Intermediate Result Exchange in Data Shuffling Stage. The intermediate result exchange is the same as that for the unpredictable situation.
Output result transmission in Output Delivery stage:

Total Processing Time and Latency
The total processing time includes the time for processing the computation tasks, exchanging intermediate results, and delivering the output results. For the coded scheme, the time for encoding should also be taken into consideration. Assume that the time for processing one computation task at each fog node is t c , for exchanging one intermediate result is t e , and for delivering one output result is t d . We use t ta and t od to represent the encoding time for computation tasks assign and for outputs delivery, respectively. Then, the total time for encoding is t co ¼ t ta þ t od . Assume that all the fog nodes process their assigned tasks or perform encoding operations simultaneously. For the uncoded and the Fountain code-based schemes, the total processing time T uncoded and T coded can be written as follows: (2) where r is the computation load of the uncoded scheme. h 1 and h 2 represent the expending coefficients of the Fountain codes used for computation tasks assign in Map stage and for reduce tasks assign in Reduce stage, respectively. In (3), 1 þ h 1 is used to represent the computation load of the Fountain code-based schemes.
The time for encoding is related with the coding parameters h 1 , h 2 , CðxÞ and m mðxÞ. Generally, only simple addition and multiplication operations are needed during the encoding process. Through proper degree distribution design, the total time for encoding, i.e., t co , can be reduced to a relatively small value. Thus, the difference in total processing time between the uncoded and the coded schemes is mainly determined by the parameters r, 1 þ h 1 , L uncoded ðrÞ, L coded ðh 1 Þ, D uncoded ðrÞ and D coded ðh 2 Þ, i.e., the computation, the communication and the transmission loads. Shorter total processing time means lower latency for the distributed fog computing process. Thus, lower latency can be achieved through reducing the communication and the transmission loads. For energy consumption of the system, the analysis process is similar to that for the total processing time. And thus, we expect that lower energy consumption can also be achieved through reducing the communication and the transmission loads. In the following, the latency related performances, i.e., the communication and the transmission loads, will be analyzed.

PERFORMANCE ANALYSIS WITH UNPREDICTABLE MOVEMENT POSITION
In this section, we consider three possible relative positions of server sets V V o and V V r . The communication and the transmission loads of the fog computing process by using the uncoded and the Fountain code-based schemes with unpredictable movement position under error-free and erasure networks will be calculated, respectively.

Error-Free Networks
where r is the computation load for the uncoded scheme and r 2 f1; 2; . . . ; F g.
The same as that for the uncoded scheme, to obtain one output by using the Fountain code-based scheme, K intermediate results generated from K different computation tasks is required. At each of the fog node, t o Q intermediate results is already known. Each fog nodes requires K À t o ð Þ g o intermediate results from the other fog nodes. Since the computation tasks are encoded in Map stage, and the coding expanding coefficient is 1 þ h 1 . Therefore, the communication load for the Fountain code-based scheme can be calculated by L coded ðh 1 Þ ¼ For the situation V V o ¼ V V r , the transmission load for delivering the output results is 0 for both the uncoded and the coded schemes.

The communication loads for the uncoded and the Fountain code-based schemes in the situation
In the following, we will calculate the transmission load for delivering the output results among fog nodes when

Two Adjacent Server Sets
The communication loads for the uncoded and the Fountain code-based schemes in the situation V V o 6 ¼ V V r and V V o T V r 6 ¼ f f are the same as that for the situation As shown in Fig. 5, F oP ¼ bF o fog nodes are located in the two adjacent server sets simultaneously. Among the F oP fog nodes, aF oP ones already have partial output results before Output Delivery stage starts.
Theorem 5. For the uncoded scheme in error-free networks, the transmission load for delivering the output results can be calculated by D uncoded ðrÞ ¼ max 0; min 1; where 0 a 1 and 0 b 1. where r 2 f1; 2; . . . ; F g. e DF and e FF are the erasure probabilities of the links from the mobile devices to the fog nodes, and among the fog nodes, respectively.
Proof 7. Each fog node requires K À rK F À Á g o intermediate results from the other fog nodes to complete its g o reduce tasks. Since transmission between the mobile device and the fog nodes and among the fog nodes are over erasure channels, the channel parameters e DF and e FF should be take into consideration. The probability for one computation task be successfully received at the fog node is ð1 À e DF Þ. That is, the computation task should be transmitted 1 where 1 þ h 1 is the expanding coefficient and 1 þ h 1 ¼ N K . Proof 8. The same as for the uncoded scheme, the channel parameter 1 ð1Àe DF Þð1Àe FF Þ should be take into account for calculating the communication load. Since the intermediated results are obtained from processing the coded computation tasks, the expanding coefficient of the Fountain codes used for encoding the computation tasks, i.e., 1 þ h 1 , should also be take into consideration. Therefore, the communication load can be written as t u For the situation V V o ¼ V V r , the transmission load for delivering the output results is 0 for both the uncoded and the coded schemes.

Two Different Server Sets
The communication loads for the uncoded and the Fountain code-based schemes in the situation Theorem 9. For the uncoded scheme in erasure networks, the transmission load for delivering output results among the fog nodes can be written as Proof 9. The channel parameter among the fog nodes, i.e., e FF , should be taken into account when calculating the transmission load. Therefore, the transmission load by using the uncoded scheme can be written as D uncoded ðrÞ ¼ where Q S o F o ð1 þ h 2 ÞQ and 1 þ h 2 is the expanding coefficient.
Proof 10. We omit the proof, which is relatively straightforward. t u

Two Adjacent Server Sets
The communication loads for the uncoded and the Fountain code-based schemes in the situation V V o T V V r ¼ f f are the same as that for the situation Theorem 11. For the uncoded scheme in erasure networks, the transmission load for delivering output results among the fog nodes can be written as where F o 2 f1; 2; . . . ; F g.
Proof 11. We omit the proof, which is relatively Theorem 12. For the Fountain code-based schemes in erasure networks, the transmission load for delivering output results among the fog nodes can be written as where Aða; b; F o ; F I ; S I Þ 2 abFoQ Proof 12. We omit the proof, which is relatively straightforward. t u

PERFORMANCE ANALYSIS WITH PREDICTABLE MOVEMENT POSITION
In this section, we consider that the moving route of a mobile device is predictable. Communication loads of the fog computing process by using the uncoded and the Fountain codebased schemes with predictable movement position in errorfree and erasure networks will be calculated, respectively.

Predictable Movement Position
If the movement position of the mobile device is predictable, the reduce tasks and the output tasks can be assigned according to the movement position of the device. For the focus on the study of predictable movement position in the Fig. 6,   Fig. 6. The common area of two adjacent server sets.
there is a common area of the two adjacent server sets, i.e., J. We use d to represent the distance of the offloading and the receiving positions of the mobile device. The angle u can be calculated by u ¼ arccos d 2R . The number of available fog nodes for a mobile device in the common area of sets V V o and V V r is F P . The corresponding PMF of HPPP is where f is the distribution density of fog nodes. AðJÞ represents the area of J, i.e., the common area of the two adjacent server sets, and it can be calculated by

Transmission Loads
The communication loads of the situation V V o 6 ¼ V V r and V V o T V V r 6 ¼ f f when the movement position is predicable are the same as that for the unpredictable situation. In the following, we will calculate the transmission loads for delivering output results among fog nodes by using the uncoded and the Fountain code-based schemes in error-free and erasure networks, respectively.

Error-Free Networks
Theorem 13. For the uncoded scheme in error-free networks, the transmission load for delivering output results among the fog nodes can be written as D uncoded ðr; F P Þ ¼ min where F P fog nodes are located at both the two adjacent server sets with probability P r ðF P Þ, and 0 F P F . The expectation of the transmission load D uncoded can be calculated by Theorem 14. For the Fountain code-based schemes in error-free networks, the transmission load for delivering output results among the fog nodes can be written as D coded ðh 2 ; F P Þ ¼ min where BðF P ; S I ; F I Þ represents the number of outputs already known at the F P fog nodes and BðF P ; S I ; F I Þ 2 ½b QF P F I c; minfQ; bg o F P cg.
F P fog nodes of the F o ones already known partial of the outputs, the number of required outputs is ðF o À F P ÞS o . There are ð1 þ h 2 ÞQ coded outputs at the F I fog nodes, and among which BðF P ; S I ; F I Þ ones are known. Therefore, the transmission load by using the Fountain codebased schemes can be calculated by t u The expectation of the transmission load D coded ðh 2 Þ can be calculated by

Erasure Networks
Theorem 15. For the uncoded scheme in erasure networks, the transmission load for delivering output results among the fog nodes can be written as D uncoded ðr; F P Þ ¼ min

NUMERICAL RESULTS AND DISCUSSION
In what follows, we shall provide a set of numerical results that cast further insights on the proposed Fountain codebased schemes for distributed fog computing. We will compare the communication and the transmission loads achieved by the uncoded and the Fountain code-based schemes. The comparison of the processing time between the uncoded and Fountain code-based schemes will also be given. Finally, the trade-off between the computation, the communication and the transmission loads will be discussed. The comparison of the MDS coded-based and the Fountain-code based schemes will also be discussed in this section. Fig. 7 shows the communication loads achieved by the uncoded and the Fountain code-based schemes with F ¼ 10, F I ¼ a I F ð0 a I 1Þ, S I ¼ b I F I ðb I > 0Þ, and computation load (r for the uncoded scheme and 1 þ h 1 for the coded schemes) varies from 1 to F . F I ¼ a I F means that a I F fog nodes will be assigned reduce tasks. S I ¼ b I F I means that each of the F I fog nodes will be assigned b I Q reduce tasks. For both the uncoded and the coded schemes, the communication load decreases with the increasing of the computation load. Compared with the uncoded scheme, the communication load can be reduced by using the Fountain code-based schemes. If more reduce tasks are assigned to fewer fog nodes, e.g., S I ¼ 2F I ; F I ¼ 0:5F , the communication load increases. If less reduce tasks are assigned to the fog nodes, e.g., S I ¼ 0:5F I ; F I ¼ F , the communication load decreases. Fig. 8 shows the communication loads achieved by the uncoded and the Fountain code-based schemes with different parameters F I and S I when F ¼ 10 and r ¼ 2 (or 1 þ h 1 ¼ 2). As shown in Fig. 8a, the communication load decreases with the increasing of a I . It means that the communication load can be reduced by assigning the reduce tasks to more fog nodes. As shown in Fig. 8b, the communication load increases with the increasing of S I . To reduce the communication load, the parameter S I should be set as small as possible.

Numerical Results
The transmission loads achieved by the uncoded and the Fountain code-based schemes for the situations of with two different server sets and with two adjacent server sets are given in Figs. 9a and 9b, respectively. The parameters are set as F ¼ 10, a ¼ 0:6, b ¼ 0:5, 1 þ h 2 varies from 1.0 to 3.0, S I changes from 1 to 3, F I ¼ F o ¼ F , and S o ¼ 10. The transmission load by using the coded scheme increases with the increasing of 1 þ h 2 . When the channel condition becomes worse, e.g., e F F changes from 0.2 to 0.4, the transmission load increases. If a > 0 and b > 0, the transmission load for the situation V a changes from 0.2 to 0.6, and b ¼ 0:5. Larger value of a means more fog nodes locate in both the two adjacent server sets are assigned reduce tasks. In Fig. 10b, b changes from 0.3 to 0.7, and a ¼ 0:6. As shown in Figs. 10a and 10b, the transmission load decreases with the increasing of a and b.
As shown in Fig. 11 are the transmission loads for the situ- position. The parameters are set as F ¼ 10, 1 þ h 2 varies from 1.0 to 10.0, S I ¼ 3, , and the distance between the center of the two adjacent server set d ¼ 20 m. The transmission load by using the Fountain code-based schemes is always lower than that of the uncoded scheme when the movement position of the mobile device is predictable. When the channel condition becomes worse, e.g., e FF changes from 0.2 to 0.4, the transmission load increases. The distance between the center of the two adjacent server set d varies from 10 to 30 m. As d increases, the common area between the two adjacent server sets decreases and the number of fog nodes in the common area decrease as well. Thus, the transmission load increases with the increasing of the distance d.
If set the computation load r ¼ 1 þ h 1 , the communication and the transmission loads by using the Fountain code-based scheme is always lower than the uncoded scheme. Therefore, the processing time using the coded scheme is always shorter than using the uncoded scheme, i.e., T coded < T uncoded . That is, the latency for distributed fog computing by using the Fountain code-based schemes is lower than the uncoded scheme. As shown in Fig. 13 is an example of the processing time reduction by using the Fountain code-based schemes for the situation with two adjacent server sets.
An example of the ratio of processing time reduction by using the coded scheme with different r ¼ 1 þ h 1 and 1 þ h 2 is given in Fig. 13a. The parameters are set as r ¼ 1 þ h 1 ¼ 1:2 and 2.0, 1 þ h 2 ¼ 1:2 and 2.0, R ¼ 20 m, f ¼ 0:01, d ¼ 20 m, and e DF ¼ e FF ¼ 0:1. When r ¼ 1 þ h 1 increases from 1.2 to 2.0, the ratio of reduced processing time for exchanging the intermediate results (corresponds to the communication load) by using the Fountain code-based schemes increases. When 1 þ h 2 changes from 1.2 to 2.0, the ratio of reduced processing time for delivering the output results (corresponds to the transmission load) by using the Fountain code-based schemes decreases. Therefore, by properly code design and carefully choosing the coding parameters h 1 and h 2 , the processing time by the Fountain code-based schemes would be much shorter than the uncoded scheme.
The ratio of reduced processing time by the Fountain code-based schemes with different distance d is given in Fig. 13b. The parameters are set as r ¼ 1 þ h 1 ¼ 1:2, 1 þ h 2 ¼ 1:2, R ¼ 20 m, f ¼ 0:01, d changes from 10 to 35 m, and e FF ¼ 0:1. As the distance d increases from 10 to 35 m, the ratio of reduced processing time by using the Fountain code-based schemes decreases. For example, when d ¼ 10 m, around 95 percent of the time for delivering the output results can be reduced by the coded scheme in the best case. When d ¼ 30 m, around 56 percent of the time can be reduced by the Fountain code-based schemes.

Discussion
As it is analyzed in Section 3.3, the total processing time is mainly determined by the computation, the communication, and the transmission loads. Shorter total processing time   means lower latency for the distributed fog computing process. To achieve shorter processing time and lower latency, the computation, the communication, and the transmission loads should be lower. According to the theorems given in Sections 4 and 5 and the numerical results in Section 6.1, to reduce the computation load at each fog node in Map stage, the parameters S I and h 1 should be chosen as small as possible, and the parameter F I should be as large as possible. To reduce the communication load for exchanging the intermediate results among fog nodes, the parameters F I and h 1 should be as large as possible, while S I should be chosen as small as possible. To reduce the transmission load for delivering the output results among fog nodes, the parameters a and b should be as large as possible, while h 2 should be chosen as small as possible.
There is a trade-off between the computation, the communication, and the transmission loads. On the one hand, the communication load decreases with the increasing of the computation load, i.e., increasing h 1 . The transmission load decreases with the decreasing of h 2 . On the other hand, if reliability is also considered, the parameters h 1 and h 2 should be large enough to ensure the transmission reliability in erasure networks. Thus, in order to balance the computation and the communication loads, and reduce the communication and the transmission loads, the parameters h 1 and h 2 should be chosen with properly values.
The main factors, which determine the value of h 1 and h 2 , include the degree distributions CðxÞ and m mðxÞ, the processing capability of fog nodes, the quality of channels, etc. The criteria for degree distribution design is: (1) Ensure the minimum possible number of encoded packets required to recover all original information successfully, and (2) Keep the average degree of all encoded data as low as possible. h 1 and h 2 should be with relative large value if the channel quality is worse, and with relative small value if the channel quality is good. For choosing h 1 , the processing capability of fog nodes should also be take into account. For example, when the processing capability of fog nodes is strong, h 1 should be with a relative large value. When the processing capability of fog nodes is weak, h 1 can be smaller. When 1 þ h 2 ¼ 1:0, the transmission load in Figs. 9, 10, 11, and 12 corresponds to the performance achieved by the MDS code-based schemes. In theoretic terms, MDS codes are able to achieve optimal performance. However, high complexity makes the MDS code-based schemes impractical in large-scale and time-varying networks. For example, device mobility causes the network parameters, such as the quality of communication links, the number of connected devices, the continuously generated computation tasks, etc., time-varying. Compared with the MDS code-based schemes, the Fountain code-based schemes have much lower complexity and is more suitable be used in large-scale and time-varying networks.

CONCLUSION
We considered the mobility of devices in IoMTs. Fountain code-based schemes with high flexibility and low complexity were proposed for the distributed fog computing process in IoMTs. The total processing time for the uncoded and the Fountain code-based schemes was calculated. The latency related performance, i.e., the communication load for exchanging intermediate results and the transmission load for delivering the output results among fog nodes, was analyzed. Comparison and numerical results showed that by applying the proposed Fountain code-based schemes, both the communication and the transmission loads can be reduced. That is, compared with the uncoded scheme, shorter total processing time and lower latency for the distributed fog computing process in IoMTs can be achieved by using the Fountain code-based schemes.