Examples

In the examples below it is supposed that there are no connections on hosts before examples execution, the user has rights to create connections and hosts can reach each other through the LAN they are connected to.

Example 1: Many-to-one raw connection

Classical client-server architecture

Let host A have a real serial port (/dev/ttyS0) and its IP address be 192.168.0.1 .
Other hosts (B1 and B2 in this example) can connect to it using SEC via a virtual port.

Execute these commands on host A in a console (or make it a shell script and run it):

    NODE="$(evesec call "/SEC" manager createConnection \
string:"/dev/ttyS0" boolean:false uint32:0 | \
tail -n 1 | sed 's,^ *string "\(.*\)"$,\1,' )"
# if NODE is an empty string it means that an error occurred and connection was not created.
# Possible explanation is that the serial port had been already shared.
# See system log for details.
if [[ "-${NODE}" == "-" ]] ; then exit 1 ; fi
evesec call "/SEC/${NODE}" connection start

Execute on hosts B1 and B2:

    NODE="$(evesec call "/SEC" manager createConnection \
string:"/tmp/virt0" boolean:true uint32:1 | \
tail -n 1 | sed 's,^ *string "\(.*\)"$,\1,' )"
# See note in the example above.
if [[ "-${NODE}" == "-" ]] ; then exit 1 ; fi
evesec call "/SEC/${NODE}/net" connection.net addServer \
string:192.168.0.1 uint16:5000 string:'' boolean:false
evesec call "/SEC/${NODE}" connection start

Example 2: Encrypted Telnet connection with authorization

The most secure Telnet connection

In case of Telnet connection, only one client can connect to a server.

As in the example above host A with IP 192.168.0.1 is a server, which shares its real serial port /dev/ttyS0. Host B is a client emulating a serial port.

Unfortunately, native Linux virtual serial ports do not support many real serial ports’ features like signal lines, words with length less than 8 bits (data bits), strict baud rate emulation, etc.
We are working on this issue in order to resolve it ASAP.

In this example authorization password is ‘secret’.
In real life, it is recommended to use passwords that are more complicated.

Execute on host A:

    evesec call "/SEC" manager createConnection \
string:"/dev/ttyS0" boolean:false uint32:0 | \
tail -n 1 | sed 's,^ *string "\(.*\)"$,\1,' )"
if [[ "-${NODE}" == "-" ]] ; then exit 1 ; fi
evesec set "/SEC/${NODE}/net" connection.net telnet \
boolean:true
evesec set "/SEC/${NODE}/net" connection.net encryption \
boolean:true
evesec call "/SEC/${NODE}/net" connection.net setAuthorisation \
string:'secret'
evesec call "/SEC/${NODE}" connection start

Execute on host B:

    NODE="$(evesec call "/SEC" manager createConnection \
string:"/tmp/virt0" boolean:true uint32:1 \
| tail -n 1 | sed 's,^ *string "\(.*\)"$,\1,' )"
if [[ "-${NODE}" == "-" ]] ; then exit 1 ; fi
evesec set "/SEC/${NODE}/net" connection.net telnet \
boolean:true
evesec call "/SEC/${NODE}/net" connection.net addServer \
string:192.168.0.1 uint16:5000 string:'secret' boolean:true
evesec call "/SEC/${NODE}" connection start

Example 3: Multicast messages

UDP usage

In this example there are no servers and clients – all hosts are identical.

Note that under certain circumstances hosts can receive their own messages.

Execute on any host:

    NODE="$(evesec call "/SEC" manager createConnection \
string:"/tmp/virt0" boolean:true uint32:2 | \
tail -n 1 | sed 's,^ *string "\(.*\)"$,\1,' )"
if [[ "-${NODE}" == "-" ]] ; then exit 1 ; fi
evesec call "/SEC/${NODE}" connection start