/fdbus

Introduction to FDBus

Primary LanguageC++

Introduction

FDBus Documentation

image

image

FDBus is a middleware development framework targeting the following objectives:

  • Inter-Process Communication (IPC) within single host and cross the network
  • System abstraction (Windows, Linux, QNX)
  • Components based on which middleware is built (job, worker, timer, watch...)

It is something like DBus or SOME/IP, but with its own characteristic:

  • Distributed : unlike DBus, it has no central hub
  • High performance : endpoints talk to each other directly
  • Addressing by name : service is addressable through logic name
  • Address allocation : service address is allocated dynamically
  • Networking : communication inside host and cross hosts
  • IDL and code generation : using protocol buffer
  • Total slution : it is more than an IPC machanism. it is a middleware development framework

Its usage can be found in the following fields:

  • Infotainment; instrument cluster, TBox and other ECU with posix-compatible OS running
  • Inter VM communication between guest OSes in hypervisor
  • SOHO Gateway
  • Instrument for distributed industry control

Supported system

  • Linux
  • Windows
  • QNX

Dependence

  • cmake - 3.1.3 or above
  • protocol buffer
  • compiler supporting C++11

Download

https://github.com/jeremyczhen/fdbus.git

Documentation & Blog

https://blog.csdn.net/jeremy_cz/article/details/89060291

How to build

For Ubuntu host version (running at host machine)

Dependence:

  • cmake, gcc are installed
  1. build protocol buffer
  1. build fdbus

For cross compiling on Ubuntu (target version)

Dependence:

  • cmake, gcc and toolchain are installed

1 build protocol buffer

  1. build fdbus

For QNX

The same as cross compiling, but when building fdbus, should add the following option to cmake since QNX doesn't support peercred:

For Windows version

Dependence:

  • cmake, msvc are installed

1 build protocol buffer

  1. build fdbus

How to run

For single host

For multi-host

example of toolchain.cmake for cross-compiling

cmake options

Note

The following options can be specified with -Dfdbus_XXX=ON/OFF when running cmake. The status with * is set as default.

fdbus_BUILD_TESTS
*ON : build examples
OFF: don't build examples
fdbus_ENABLE_LOG
*ON : enable log output of fdbus lib
OFF: disable log output of fdbus lib
fdbus_LOG_TO_STDOUT
ON : send fdbus log to stdout (terminal)
*OFF: fdbus log is sent to log server
fdbus_ENABLE_MESSAGE_METADATA
*ON : time stamp is included in fdbus message to track delay of message during request-reply interaction
OFF: time stamp is disabled
fdbus_SOCKET_BLOCKING_CONNECT
ON : socket method connect() will be blocked forever if server is not ready to accept
*OFF: connect() will be blocked with timer to avoid permanent blocking
fdbus_SOCKET_ENABLE_PEERCRED
*ON : peercred of UDS (Unix Domain Socket) is enabled
OFF: peercred of UDS is disabled
fdbus_ALLOC_PORT_BY_SYSTEM
ON : socket number of servers are allocated by the system
*OFF: socket number of servers are allocated by name server
fdbus_SECURITY
ON : enable security
*OFF: disable security

Note

The following options can be specified with -DMACRO_DEF='VARIABLE=value;VARIABLE=value'

FDB_CFG_SOCKET_PATH
specify directory of UDS file
default: /tmp
CONFIG_SOCKET_CONNECT_TIMEOUT
specify timeout of connect() when connect to socket server in ms. "0" means block forever.
default: 2000

Security concept

Authentication of client:

1. server registers its name to name server;
2. name server reply with URL and token;
3. server binds to the URL and holds the token;
4. client requests name resolution from name server;
5. name server authenticate client by checking peercred (SO_PEERCRED option of socket), including UID, GID of the client
6. if success, name server gives URL and token of requested server to the client
7. client connects to the server with URL followed by sending the token to the server
8. server verify the token and grant the connection if pass; for unauthorized client, since it does not have a valid token, server will drop the connection
9. name server can assign multiple tokens to server but only send one of them to the client according to security level of the client

Authenication of host

TBD