Research Article

An Architecture of IoT Service Delegation and Resource Allocation Based on Collaboration between Fog and Cloud Computing

Algorithm 2

Finding IoT services delegation/management in fog/Cloud based on three conditions (service size, completion time, and VMs capacity) for cases 3 and 4.
Input: // service size (small or large), // service completion time (now or later), VMc // VM capacity
   (occupied = not enough or not occupied = enough)
Output: service delegation/management location // fog or cloud
(1) If (Service Size = Large) && (Service completion time = now) && (VMs capacity = enough)
(2) THEN
(3) Process the requested service at current location (fog environment)
(4) Divide requested services to small chunks
(5) Calculate the required no. of VMs
(6) Assign these chunks to the assigned VMs for processing
(7) else if (Service Size = Large) && (Service completion time = now) && (VMs capacity = not enough)
(8) THEN
(9) Divide requested services to small chunks
(10) Calculate the required no. of VMs
(11) Obtain list of available VMs capacity in other fog/cloud environment from Services Monitor Server in cloud.
(10) Reserved the VMs and assign the chunks to VMs for processing
(11) else if (Service size = Large) && (Service completion time = later) && (VMs capacity = not enough) &&
   (Services in Queue = yes)
(12) THEN
(13) this services will be delegated to other fog/cloud environment
(14) Divide requested services to small chunks
(15) Calculate the required no. of VMs
(16) Assign these chunks to assigned VMs for processing.
(17) end if
(18)  end if
(19)   end if
(20) After completion the processing of all chunks,
(21) return the chunks to broker for combining them and send the result to users IoT devices.