  Clustering is an important research topic for wireless sensor networks
(WSNs). A large variety of approaches has been presented focusing on different
performance metrics. Even though all of them have many practical applications,
an extremely limited number of software implementations is available to the
research community. Furthermore, these very few techniques are implemented for
specific WSN systems or are integrated in complex applications. Thus it is very
difficult to comparatively study their performance and almost impossible to
reuse them in future applications under a different scope. In this work we
study a large body of well established algorithms. We identify their main
building blocks and propose a component-based architecture for developing
clustering algorithms that (a) promotes exchangeability of algorithms thus
enabling the fast prototyping of new approaches, (b) allows cross-layer
implementations to realize complex applications, (c) offers a common platform
to comparatively study the performance of different approaches, (d) is hardware
and OS independent. We implement 5 well known algorithms and discuss how to
implement 11 more. We conduct an extended simulation study to demonstrate the
faithfulness of our implementations when compared to the original
implementations. Our simulations are at very large scale thus also
demonstrating the scalability of the original algorithms beyond their original
presentations. We also conduct experiments to assess their practicality in real
WSNs. We demonstrate how the implemented clustering algorithms can be combined
with routing and group key establishment algorithms to construct WSN
applications. Our study clearly demonstrates the applicability of our approach
and the benefits it offers to both research & development communities.
