Skip to content

4. Network configuration

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 modeCloud 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

4.1 Enable network-mode in ecal.ini

By default, eCAL is configured in local mode. To switch eCAL to cloud mode, edit your ecal.ini and change the following settings:

  • Windows: C:\ProgramData\eCAL\ecal.ini
  • Ubuntu: /etc/ecal/ecal.ini
[network]
network_enabled = true
multicast_ttl = 2

The multicast_ttl setting configures the time to live of the UDP datagrams, i.e. the number of hops a datagram can take before it is discarded. Usually, 2 is sufficient, but if you have a network with many routers, you may have to increase that number.

4.2 Multicast route configuration

Now that you have set eCAL to cloud mode, it will already start sending out UDP Multicast packages for detecting other eCAL Nodes. Your Operating System however has to send those Multicast packages to a proper network interface controller (NIC). This is not trivial, as the destination IP 239.0.0.1 does not “really” exist.

Therefore you have to create a route, i.e. a 239.0.0.x -> outgoing NIC mapping.

4.2.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. You will need the IP of your current machine you are setting the route on.

  2. Open a command prompt with administrator privileges

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

    Terminal window
    route -p add 239.0.0.0 mask 255.255.255.0 xx.xx.xx.xx
  4. Reboot

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

    Terminal window
    route print

    Windows route print

4.2.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:

    • Via netplan (Recommended for Ubuntu 18 and up. Even integrates into the GUI.)
    • Via GUI (Works well for desktop Ubuntu)
    • Via /etc/network/interfaces (Legacy, up to Ubuntu 18. Not supported in Ubuntu 20, any more.)
  2. Test the Configuration

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.

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

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

    Paste the following configuration:

    1
    # eCAL route for loopback (lo)
    2
    network:
    3
    version: 2
    4
    ethernets:
    5
    lo:
    6
    renderer: networkd
    7
    routes:
    8
    - to: 239.0.0.0/24
    9
    via: 0.0.0.0
    10
    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.

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

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

    1
    # Replace eth0 with your network adapter!
    2
    network:
    3
    version: 2
    4
    renderer: NetworkManager # GUI integration for desktop Ubuntu
    5
    ethernets:
    6
    7
    # Replace eth0 with your interface!
    8
    eth0:
    9
    10
    # Either use DHCP...
    11
    dhcp4: yes
    12
    dhcp6: yes
    13
    14
    # ... or configure a static address!
    15
    #addresses:
    16
    # - 192.168.178.42/24
    17
    18
    routes:
    19
    - to: 239.0.0.0/24
    20
    via: 0.0.0.0
    21
    metric: 1
  3. Apply the changes

    Terminal window
    sudo netplan apply

4.2.2.1 Test the configuration

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

Terminal window
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