  We propose a distributed algorithm for time synchronization in mobile
wireless sensor networks. Each node can employ the algorithm to estimate the
global time based on its local clock time. The problem of time synchronization
is formulated as nodes estimating their skews and offsets from noisy difference
measurements of offsets and logarithm of skews; the measurements acquired by
time-stamped message exchanges between neighbors. A distributed stochastic
approximation based algorithm is proposed to ensure that the estimation error
is mean square convergent (variance converging to 0) under certain conditions.
A sequence of scheduled update instants is used to meet the requirement of
decreasing time-varying gains that need to be synchronized across nodes with
unsynchronized clocks. Moreover, a modification on the algorithm is also
presented to improve the initial convergence speed. Simulations indicate that
highly accurate global time estimates can be achieved with the proposed
algorithm for long time durations, while the errors in competing algorithms
increase over time.
