Chapter 5. Technology behind NetworkManager

Contents

5.1. D-BUS
5.2. Hardware Abstraction Layer (HAL)
5.3. For More Information

NetworkManager uses advantages of D-BUS and hardware abstraction layer (HAL) technologies. D-BUS is used internally for communication between NetworkManager daemon, NetworkManager parts, and HAL, which provides the ability to learn about existing and new hardware. Externally, D-BUS is used for broadcasting information about various state changes.

5.1. D-BUS

D-BUS is a system for interprocess communication (IPC) written in C. It makes it possible for applications to communicate to one another. It was started in 2002 by Havoc Pennington, Alex Larsson, and Anders Carlsson as part of the freedesktop.org project to standardize around one messaging platform for the desktop.

D-BUS was designed for two specific cases—communication between desktop applications in the same desktop session and communication between the desktop session and the operating system.

D-BUS has nice clear architecture. It consists of the three basic layers:

libdbus

Low-level library for connecting applications to each other and exchanging messages. It supports one-to-one connections only.

message bus daemon

Executable to which multiple applications can connect. The daemon can route messages from one application to zero or more applications.

wrapper libraries

Wrapper libraries, also known as bindings, wrap the standard low-level library D-BUS to provide a better environment for developers. Wrapper libraries include libdbus-qt and libdbus-glib.

Because D-BUS is a message bus system, it does not send byte streams but messages. Messages have a header with type identification and a body including data. They are binary in format. There are different built-in types of messages, for example, for error messages or event notification. Information about the message type is stored in the header of the message. The header also includes information about the path and interface of the message.

The bus daemon, which acts like a server for messages, normally has multiple instances. The first is global and mostly is similar to classic daemons, like httpd or sendmail. This instance has a lot of security restrictions and it is used for systemwide communication. The other instances are created one per user login session. These instances are used for communication among applications in the user session.

Before a connection is established and communication starts, applications must authenticate. For this purpose, a simple plain-text protocol based on SASL is used. To deliver the right message to the right application, addresses in a special format and message bus names are used. This means that every connection has at least one name. When a connection is closed, all the names that it owns are deleted.

The core low-level D-BUS API is written in C and is not intended for developing application frameworks. D-BUS provides various bindings to languages for this purpose. Among others, you can choose:

  • GLib

  • Qt

  • Python

  • .NET

  • Java

  • Perl

  • C++

  • Ruby