RU | EN

IPC Catalog

Description

The IPC Catalog is a set of applications for testing various means of interprocess communication. It represents two applications for testing different means of data exchange between threads of different processes.

The project was developed in C++ and QML in order to demonstrate various methods of interprocess communication (IPC).

The project contains two applications that interact with each other using user-selectable methods. The interaction is implemented in the form of messaging: after sending a message from the first application, the user can switch to the second application and see the received message, as well as send a response.

The following APIs are used in the application:

  • Basic: Qt Core (Basic functions of Qt), Qt QML, Qt GUI and Qt Quick (Graphical User Interface and Data Models);
  • Network: Qt Network (Network Connection Management);
  • System functions: Qt D-Bus (Messaging between processes);
  • Localization tools: Qt LinguistTools.

Non-system libraries used: protobuf (data serialization).

Build status

  1. example - pipeline status
  2. dev - pipeline status

Table of contents

  1. Detailed description
  2. Compatibility
  3. Build features
  4. Branches info
  5. Install and run
  6. Screenshots
  7. Use cases
  8. Project structure
  9. Terms of use and participation

Detailed description

FIFO Pipes The FIFO Pipes is a mechanism for interprocess communication. Unlike regular (unnamed) pipes, which are temporary and exist only as long as the process that created them is running, FIFO pipes provide a permanent communication channel between processes. The workflow is organized as follows:

  1. For the server:
    1. Calls connectToChat(true)
    2. Creates two named pipes in the temporary directory (/tmp/pipe1 and /tmp/pipe 2)
    3. Opens channels for reading/writing
    4. Waiting for the client to connect
    5. After connecting, it can exchange messages
  2. For the client:
    1. Calls connectToChat(false)
    2. Connects to existing channels (uses reverse names - pipe2 for input and pipe1 for output)
    3. After connection, it can exchange messages

DBus DBus is another interprocess communication system that allows applications to exchange messages. Basic principles of DBus:

  • Bus: The system bus for system-wide services (daemons, drivers) and the session bus for user applications (GUIs, utilities).
  • Objects, Interfaces, and Methods – DBus operates according to the RPC (Remote Procedure Call) model: Each application provides objects with interfaces containing methods (functions) and signals (events).
  • Services and unique Names – Each application registers a unique name so that others can access it.
  • Message types: Method invocation – one process invokes another's method and waits for a response (synchronously or asynchronously), call results, signals (broadcast events), errors.
  • Data serialization – DBus transmits data in binary format with support for types (strings, numbers, arrays, etc.).

DBus elements implemented in this example:

  • QDBusConnection – connection to the DBus session bus (sessionBus).
  • QDBusInterface – an interface for invoking methods and signal processing, provides access to the service on the bus.
  • DBusAdaptor Adapter – creates a service on the DBus bus, provides methods and signals for DBus.
  • Data models (m_workLogModel, m_messageModel) – logging and displaying messages.

Network socket (TCP/UDP) UNIX TCP/UDP network sockets are a software endpoint that provides bidirectional communication between processes. They allow communication between networks using the TCP/IP protocol stack. Simply put, it is sending data packets, each of which contains a socket address as a destination.

Each UNIX socket contains several important elements:

  1. Domain - defines the communication protocol
  2. Type - defines the interaction style, for example, SOCK_STREAM for reliable byte streams or SOCK_DGRAM for unreliable datagrams.
  3. A file descriptor is a unique identifier assigned to a socket, used to access and manage it.
  4. Address: Defines the value's IP address and port.

In this application, the use of network sockets is implemented as follows: after the user selects the TCP or UDP network protocol, the server is launched at 127.0.0.1 from one application and the client is launched that accesses this server (for TCP the server port is 22222, for UDP the server port is 22220 and client 22221).

File sharing This application also implements interprocess communication through shared files using two text files: messageSharingFile.txt – for exchanging messages between the client and the server. logSharingFile.txt – for logging events. The server creates files in a temporary folder, and the client connects to these files. If there are none, the connection is rejected.

The main IPC components implemented in this application:

  • FileManager class – manages files, reading/writing and synchronization.
  • QFileSystemWatcher – monitors file changes and automatically responds to updates.
  • connectToChat - checks for files for communication and calls a method for writing messages in them.

System V Message queues System V message queues are an interprocess communication mechanism that allows processes to exchange structured messages through the OS kernel.

Key features:

  • Unique identifier – Each queue has its own msqid, created by calling msgget().
  • Message structure – Data is transmitted as a structure containing the message type and the message text itself.
  • Message Queue – Messages are stored in the kernel as a linked list.
  • Access rights are managed via ipc_perm (similar to semaphores and shared memory).

In the IPC Catalog application, this type of messaging is implemented as follows:

  1. There are two classes of MessageQueueManager - producer, which ensures that messages are sent from one application to the second, and QueueListener - consumer, which listens and receives messages from the queue.
  2. The MessageQueueManager constructor establishes a connection with the consumer.
  3. The MessageQueueManager::serverCreateQueue and clientCreateQueue methods create a queue on the server or client, depending on the choice of the application for the server and client
  4. The MessageQueueManager::sendMessageToChat method sends a message from the parameter to the queue using the msgsnd method
  5. The QueueListener::startListen method changes the queue listening flag and starts listening to it by calling the QueueListener::listenQueue method
  6. The QueueListener::listenQueue method calls the msgrcv method once a second to retrieve a message from the queue.

System V Shared memory Shared memory can be described as a mapping of a section (segment) of memory that will be shared between more than one process.Interacting processes can connect to a memory segment (if they have permissions to access the segment) and access the data contained in the segment. Main components:

  1. SharedMemoryMessageBuffer is a structure that defines the format of messages in shared memory.
  2. Memory Listener - A class for listening to changes in shared memory, which checks changes in the buffer every 500 ms. When new messages are detected, it generates messageReceived signals when receiving a regular message and actionReceived signals when receiving a service action (connect/disconnect).
  3. SharedMemoryManager is a class that manages shared memory. Implements creation/connection to shared memory, handles sending and receiving messages, and manages the lifecycle of the MemoryListener.

Compatibility

The project is compatible with current versions of the Aurora OS.

Build features

The project is built in the usual way using the Aurora SDK.

To build the project it needs to increase the Build Engine virtaul machine RAM.
Allocate 500 MB RAM to the virtual machine for each processor core.
For example, if Build Engine has 4 processor cores, then its RAM must be at least 2000 MB.

To build the Protobuf library it uses CMake. The CMake running configuration is described inside the CMakeLists.txt file.
The shared libraries and include files of the Protobuf library will be built into the <build-project-dir>/dist/ directory.
The shared libraries files of Protobuf library will be installed into the /usr/share/ru.auroraos.IPCFirstGUIApplication/lib/ and /usr/share/ru.auroraos.IPCSecondGUIApplication/lib/ directories on the Aurora OS device.

Setup project for Windows

The repository has symbolic links for the common applications code. Windows Git requires one-time settings to enable Git symbolic links. It needs to:

  • Enable the "Developer mode" on Windows by following the link.
  • Set up tht Git global configuration to handle symlinks by following the link.
  • Clone the repository, because the changes are applied only to new cloned repositories.

If the steps are correct, symbolic links will be created. It was tested on Windows 11 Pro.

Branches info

Information about branches is provided at link.

Install and run

The application's installation and launching is according to the instructions Example assembly.

The first IPCFirstGUIApplication application needs to have permissions for Internet and ru.auroraos.IPCSecondGUIApplication@ru.auroraos.IPCSecondGUIApplication . These permissions are set in the .desktop file.

The second IPCSecondGUIApplication application needs to have permissions for Internet and ru.auroraos.IPCFirstGUIApplication@ru.auroraos.IPCFirstGUIApplication . These permissions are set in the .desktop file.

Screenshots

screenshots

Use cases

The applications has been tested for the following features:

  • Choosing an IPC to perform a communication.
  • Choosing a mode ("Server" or "Client") to perform a communication.
  • Sending and receiving messages using the FIFO pipes.
  • Sending and receiving messages using DBus.
  • Sending and receiving messages using the TCP network sockets.
  • Sending and receiving messages using the UDP network sockets.
  • Sending and receiving messages using the file system.
  • Sending and receiving messages using the SYSV message queues.
  • Sending and receiving messages using the SYSV shared memory.
  • Messages serialization and deserialization using the Protobuf 3.18.3 library.

The manual for interaction via DBus:

  1. open the first IPC Catalog application;
  2. select the "Server" mode and the "DBus" type;
  3. touch the "Start" and "Join the chat" buttons;
  4. open the second IPC Catalog application;
  5. select the "Client" mode and the "DBus" type;
  6. touch the "Start" and "Join the chat" buttons;
  7. a message written and sent in the first application will be displayed in the second and vice versa.

Project structure

The project has a standard structure of an application based on C++ and QML for Aurora OS.

  • common directory contains a common applications C++ and QML source code.
    • qml directory contains the QML source code and the UI resources.
      • cover directory contains the application cover implementations.
      • icons directory contains the custom UI icons.
      • pages directory contains the application pages.
      • IPCGUIApplication.qml file provides the application window implementation.
    • src directory contains the C++ source code.
      • controllers directory contains the source code of the Controller-classes.
      • dbus directory contains the source code classes to perform a comminication via DBus.
      • fifopipes directory contains the source code classes to perform a comminication via FIFO pipes.
      • filesharing directory contains the source code classes to perform a comminication via file system.
      • messagequeues directory contains the source code classes to perform a comminication via SYSV message queues.
      • networksockets directory contains the source code classes to perform a comminication via network sockets: TCP and UDP.
      • sharedmemory directory contains the source code classes to perform a comminication via SYSV shared memory.
      • main.cpp file is the application entry point.
  • IPCFirstGUIApplication directory contains a project of the first GUI application to test IPC comminications.
  • IPCSecondGUIApplication directory contains a project of the second GUI application to test IPC comminications.
  • protobuf directory contains the Protobuf library v3.18.3 source code.
    • CMakeLists.txt file describes the Protobuf library build configuration for the CMake build system.
    • chat_message.proto file describes the protobuf file to generate the data class to serialize and deserialize messages.
  • rpm directory contains the rpm-package build settings.

Terms of use and participation

The source code of the project is provided under the license, which allows it to be used use in third-party applications.

Contributor License Agreement CLA

The contributor agreement documents the rights granted by contributors of the Open Mobile Platform.

Information about the contributors is specified in the AUTHORS file.

Code of conduct is a current set of rules of the Open Mobile Platform which informs you how we expect the members of the community will interact while contributing and communicating.

This document in Russian / Перевод этого документа на русский язык