Name | Last modified | Size | Description | |
---|---|---|---|---|
Parent Directory | - | |||
examples/ | 2023-10-07 11:38 | - | ||
pubsub_admin_udp_mc/ | 2024-05-01 04:32 | - | ||
This subdirectory contains an implementation for a publish-subscribe remote services system, that use dfi library for message serialization. For low-level communication, TCP, UDP and ZMQ is used.
This publisher / subscriber implementation is based on the concepts of the remote service admin (i.e. rsa / topology / discovery pattern).
Publishers are senders of data, subscribers can receive data. Publishers can publish/send data to certain channels (called ’topics’ further on), subscribers can subscribe to these topics. For every topic a publisher service is created by the pubsub admin. This publisher is announced through etcd. So etcd is used for discovery of the publishers. Subscribers are also registered as a service by the pubsub admin and will watch etcd for changes and when a new publisher is announced, the subscriber will check if the topic matches its interests. If the subscriber is interested in/subscribed to a certain topic, a connection between publisher and subscriber will be instantiated by the pubsub admin.
The dfi library is used for message serialization. The publisher / subscriber implementation will arrange that every message which will be send gets an unique id.
For communication between publishers and subscribers TCP, UDP and ZeroMQ can be used. When using ZeroMQ it’s also possible to setup a secure connection to encrypt the traffic being send between publishers and subscribers. This connection can be secured with ZeroMQ by using a curve25519 key pair per topic.
The publisher/subscriber implementation supports sending of a single message and sending of multipart messages.
The publisher/subscriber implementation contains 3 different PubSubAdmins for managing connections:
The ZeroMQ pubsub admin can be enabled by specifying the build flag BUILD_PUBSUB_PSA_ZMQ=ON
. To get the ZeroMQ pubsub admin running, ZeroMQ and CZMQ need to be installed. Also, to make use of encrypted traffic, OpenSSL is required.
etcd
cd deploy/pubsub/pubsub_publisher_udp_mc
sh run.sh
cd deploy/pubsub/pubsub_subscriber_udp_mc
sh run.sh
Design information can be found at pubsub_admin_udp_mc/README.md
cd runtimes/pubsub/tcp
sh start.sh
Some properties can be set to configure the PSA-TCP. If not configured defaults will be used. These
properties can be set in the config.properties file (
PSA_IP The url address to be used by the TCP admin to publish its data. Default the first IP not on localhost
This can be hostname / IP address / IP address with postfix, e.g. 192.168.1.0/24
For ZeroMQ without encryption, skip the steps 1-12 below
touch ~/pubsub.keys
echo "aes_key:{AES_KEY here}" >> ~/pubsub.keys
. Note that AES_KEY is just a sequence of random bytes. To generate such a key, you can use the command cat /dev/urandom | hexdump -v -e '/1 "%02X"' | head -c 32
(this will take out of /dev/urandom 16 bytes, thus a 128bit key)echo "aes_iv:{AES_IV here}" >> ~/pubsub.keys
. Note that AES_IV is just a sequence of random bytes. To generate such an initial vector , you can use the command cat /dev/urandom | hexdump -v -e '/1 "%02X"' | head -c 16
(this will take out of /dev/urandom 8 bytes, thus a 64bit initial vector)touch ~/pubsub.conf
echo "keys.file.path=$HOME" >> ~/pubsub.conf
echo "keys.file.name=pubsub.keys" >> ~/pubsub.conf
pubsub/keygen/makecert pub_<topic_name>.pub pub_<topic_name>.key
pubsub/keygen/ed_file ~/pubsub.keys pub_<topic_name>.key pub_<topic>.key.enc
For ZeroMQ without encryption, start here
etcd
cd deploy/pubsub/pubsub_publisher_zmq
cat ~/pubsub.conf >> config.properties
(only for ZeroMQ with encryption)sh run.sh
cd deploy/pubsub/pubsub_subscriber_zmq
cat ~/pubsub.conf >> config.properties
(only for ZeroMQ with encryption)sh run.sh
Some properties can be set to configure the PSA-ZMQ. If not configured defaults will be used. These
properties can be set in the config.properties file (
PSA_IP The local IP address to be used by the ZMQ admin to publish its data. Default the first IP not on localhost
PSA_INTERFACE The local ethernet interface to be used by the ZMQ admin to publish its data (ie eth0). Default the first non localhost interface
PSA_ZMQ_RECEIVE_TIMEOUT_MICROSEC Set the polling interval of the ZMQ receive thread. Default 1ms