Skip to content

mkindahl/libswim

Repository files navigation

SWIM Failure Detector for Embedding

An implementation of a SWIM (Das, Gupta and Motivala, 2002) failure detector that can be embedded into other application, for example, into IoT devices.

SWIM detects failed nodes through a ping / ping-req protocol. Each member periodically pings a random peer and, on timeout, asks other members to probe the target before declaring it suspect. A suspicion sub-protocol with incarnation numbers lets falsely suspected nodes refute the claim, so only persistently unreachable nodes are marked dead. All membership updates, such as joins, suspects, and failures, are disseminated by piggybacking them on the protocol messages themselves, avoiding the need for a separate broadcast channel.

Tools like Consul and Serf from HashiCorp also build on the SWIM protocol, but they ship as standalone services that applications communicate with over RPC. In contrast, libswim is a library designed to be embedded directly into an application, making it suitable for environments where running a separate daemon is impractical, such as IoT devices or resource-constrained systems.

Dependencies

  • CMake (>= 3.20)
  • Ninja (or another CMake-supported generator)
  • libuuid
  • ncurses (optional — needed for the TUI example)

On Ubuntu:

sudo apt install cmake ninja-build uuid-dev libncurses-dev

Building

To build:

cmake -B build -G Ninja
cmake --build build

To run the tests:

ctest --test-dir build

Linting

To run clang-tidy, configure with compile commands enabled and run the tidy target:

cmake -B build -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build build --target tidy

To format all source files with clang-format:

cmake --build build --target format

About

SWIM Failure Detector for Embedding

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors