Research Article

Opportunistic Mobile Sensing in the Fog

Algorithm 1

FogletMessageHandler.
when is received from upper layer do
; ; ; ;
; ;
,
Broadcast();
end when
when is received from j do
if then
; ; ; ; ;
if then
Broadcast();
StartTimer();
else
if then
;
;
;
Unicast(parent)();
else
;
Unicast(parent)();
end if
end if
else
;
if then ;
end if
;
if then
;
if
then
if then
;
Unicast(parent)();
else SendUpperLayer();
end if
else
if then
Unicast(parent)();
elseSendUpperLayer();
end if
end if
end if
end if
end when