How isc-projects/kea works
Project type and purpose
• Kea is a modular C++ network services suite providing:
• DHCPv4 and DHCPv6 server daemons
• A dynamic DNS update module (DDNS)
• A control agent exposing a REST management interface
• A NETCONF/YANG agent
• A DHCP benchmarking tool (perfdhcp)
• It’s designed as a back-end network services platform (not a typical web front end).
High-level file structure and architectural patterns
• Top-level “src/bin/…” directories define each executable component (dhcp4, dhcp6, agent, d2, netconf, keactrl, perfdhcp, shell, lfc).
• “src/lib/…” holds a large collection of reusable libraries (network I/O, HTTP/REST, TCP/UDP abstraction, configuration, hooks framework, database backends, DNS, crypto, logging, YANG translator, etc.).
• “share/api” contains JSON schemas for the REST API commands.
• Build is orchestrated by Meson build scripts (meson.build files at multiple levels).
• Configuration, dynamic loading (hooks), inter-process communication, and multi-threading are key design principles.
Main components
a. Executable services (each in its own process):
• DHCPv4 server
• DHCPv6 server
• DDNS update module (plugin or process)
• Control Agent (REST/HTTP interface)
• NETCONF/YANG Agent
• perfdhcp benchmarking tool
• Auxiliary tools (shell, lfc, keactrl)
b. Shared library layers:
• Network I/O layer (asiolink, asiodns)
• Protocol libraries (libdhcp++, dns, dhcp_ddns, dhcpsrv, d2srv)
• HTTP/REST layer (lib/http, HTTP command mgr in lib/config)
• Hooks framework (lib/hooks) for dynamic callouts
• Configuration and translation (lib/config, lib/yang)
• Database abstraction (lib/database, backends mysql/pgsql)
• Logging and metrics (lib/log, lib/stats)
• Utility libraries (cryptolink, util, exceptions, process)
c. External dependencies:
• Network clients (actual DHCP clients)
• Upstream DNS servers (for DDNS)
• Databases: MySQL or PostgreSQL for storing leases and state
• Sysrepo/YANG datastore (for NETCONF agent, if used)
Relationships and interactions
• DHCP servers listen on UDP sockets (asiolink) → parse packets (lib/dhcp) → pass to service engine (lib/dhcpsrv) → storage backends (lib/database/mysql or lib/database/pgsql) → respond on network.
• Control Agent receives HTTP/REST requests (lib/http, lib/config) → configuration manager updates server config via IPC or direct API calls → queries status via control socket.
• NETCONF Agent uses YANG modules (lib/yang) → interfaces to config manager via control socket → applies changes.
• Hooks framework loaded by servers to run custom callouts at defined hook points.
• perfdhcp generates and sends simulated DHCP traffic via network I/O libraries.
Important architectural patterns and principles
• Layered modular design: reusable libraries separated from executables.
• Plugin/hook architecture: lib/hooks provides dynamic extension.
• IPC and REST as management interfaces.
• Meson-based multi-project build orchestrating libraries and binaries.
• Separation of concerns: network I/O, protocol parsing, business logic, persistence.