4. Cloud configuration

Hint

If you don’t have two PCs at your hand or if you are just not interested in inter-machine-communication, just skip this topic. It is not essential for the next tutorials to use cloud communication.

Of course, you can use a virtual machine (e.g. with VMWare or VirtualBox) as second PC. Just add a host-only adapter to your VM.

Quite often you want data to flow between eCAL nodes on different machines. eCAL can run in two modes, that differ from each other: local mode and cloud mode.

Local mode vs. cloud mode

Local mode

Cloud mode

  • Uses localhost (127.0.0.1) for registration (-> e.g. telling others about new topics and subscribing to topics)

  • Uses Multicast (239.0.0.1) for registration

  • Uses shared memory to send actual data to other processes

  • Uses UDP multicast (239.0.0.x) to send data to other hosts

  • Uses shared memory to send data to processes on the same host

By default, eCAL already is configured in cloud mode, so you don’t have to change anything. You however have to configure your operating system, so it knows where to send that multicast traffic to. This is done by creating a multicast route.

See also

Please refer to the advanced section to learn about changing between local mode and cloud mode!

4.1. Multicast configuration on Windows

  1. Check the IPv4 address of the ethernet adapter you are using to connect your two PCs. You can do that by typing ipconfig in a command prompt.

  2. Open a command prompt with administrator privileges

  3. Enter the following line and replace xx.xx.xx.xx with your IP address

    route -p add 239.0.0.0 mask 255.255.255.0 xx.xx.xx.xx
    

    Tip

    If you made a mistake, you can delete your route/s with route delete 239.0.0.0. Your eCAL communication may not work, if you leave faulty routes in place.

  4. Reboot

  5. Check the result from a command prompt. It should show your route under IPv4 Route Table / Persistent Routes.

    route print
    
    Windows route print

Tip

It is recommended to assign a static IP, so your multicast route will not become outdated at some point.

4.2. Multicast configuration on Ubuntu

You can configure the multicast route in various ways, depending on your Ubuntu version.

Jump to your section of choice below:

  1. Choose how to create routes:

  2. Test the configuration

4.2.1. Multicast routes via Netplan

Netplan is used since Ubuntu 18 and should be used in favor of the legacy (but well known) /etc/network/interfaces file. While Ubuntu 18 supports both out of the box, for Ubuntu 20 this is the only file-based networking configuration method.

Tip

Netplan uses YAML files for configuration. YAML uses spaces (' ') as indentation and does not work with tabs ('\t'). When using gedit, it is recommended to configure it to use spaces instead of tabs.

Space indentation in gedit
  1. Configure the loopback multicast route (this will become active, if you disconnect from all networks).

    sudo gedit /etc/netplan/50-ecal-multicast-loopback.yaml
    

    Paste the following configuration:

    # eCAL route for loopback (lo)
    network:
      version: 2
      ethernets:
        lo:
          renderer: networkd
          routes:
            - to: 239.0.0.0/24
              via: 0.0.0.0
              metric: 1000
    
  2. Configure the external multicast route. This will get a lower metric and will thus become the preferred route once the interface is up.

    sudo gedit /etc/netplan/50-ecal-multicast.yaml
    

    Paste the following configuration and replace eth0 with your desired interface:

    # Replace eth0 with your network adapter!
    network:
      version: 2
      renderer: NetworkManager # GUI integration for desktop Ubuntu
      ethernets:
    
        # Replace eth0 with your interface!
        eth0:
    
          # Either use DHCP...
          dhcp4: yes
          dhcp6: yes
    
          # ... or configure a static address!
          #addresses:
          #  - 192.168.178.42/24
    
          routes:
            - to: 239.0.0.0/24
              via: 0.0.0.0
              metric: 1
    
  3. Apply the changes

    sudo netplan apply
    

4.2.2. Multicast routes via GUI

If you have a graphical network manager installed (-> Desktop Ubuntu), you can use it to configure the external route.

  1. Configure the external multicast route

    • System Settings -> Network -> Your Adapter -> Options -> IPv4 Tab -> Routes

    • Create a route:

      • Address: 239.0.0.0

      • Netmask: 255.255.255.0

      • Gateway: 0.0.0.0

      • Metric: 1

      Ubuntu multicast route
  2. Turn the interface off and on again

  3. Configure the loopback multicast route via netplan or /etc/network/interfaces. You can omit this, but then you will have to explicitly set eCAL to local mode, if you are not connected to any network.

4.2.3. Multicast routes via /etc/network/interfaces

The well known /etc/network/interfaces files is supported up to Ubuntu 18. It is not supported since Ubuntu 20, anymore. Please use netplan instead. If you are running Ubuntu 18, using netplan is still recommended, unless you want to manager other interfaces via /etc/network/interfaces.

Edit the file and add the content below.

sudo gedit /etc/network/interfaces
  1. Configure the loopback multicast route (this will become active, if you disconnect from all networks).

    Add the following lines beneath the iface lo inet loopback line:

    post-up ifconfig lo multicast
    post-up route add -net 239.0.0.0 netmask 255.255.255.0 dev lo metric 1000
    
  2. Configure the external multicast route. This will get a lower metric and will thus become the preferred route once the interface is up.

    Add the following lines and replace eth0 with your interface. You may want to replace the dhcp line with your desired configuration.

    # replace eth0 with your network adapter
    auto eth0
      allow-hotplug eth0
      iface eth0 inet dhcp
      post-up ifconfig eth0 multicast
      post-up route add -net 239.0.0.0 netmask 255.255.255.0 dev eth0 metric 1
    
  3. Restart your PC

4.2.4. Test the configuration

Check the result from a terminal. It should show routes for local and external communication:

route -n
Ubuntu route -n

4.3. eCAL Samples over network

Now start one ecal_sample_person_snd and one ecal_sample_person_rec, just as in the previous section. But on different machines! If you configured everything correctly, publisher and subscriber should connect almost immediately and exchange data.

person_snd and person_rec sample over network