Recent Changes - Search:

PmWiki

pmwiki.org

edit SideBar

CERTI for Ptolemy federates

About jcerti

CERTI is written in C++ and its installation is enough if the federates are also writen in C++. As Ptolemy is written in Java, it is necessary to also use the jcerti library, shipped with Ptolemy at $PTII/lib. The current version (on April, 2019) is on branch br_ptII_berkeley at the . The main change is related to the way the fed file is passed to the rtig process when creating a federation.

git clone -b br_ptII_berkeley https://git.savannah.nongnu.org/git/certi/jcerti.git
cd jcerti
make

Installing CERTI on Linux or Mac

Here a receipe for installing in $HOME/pthla (as of 02/16/17, the last version was 3.5.1):

mkdir $HOME/pthla
cd $HOME/pthla
tar xvfz CERTI-3.5.1-Source.tar.gz
mv CERTI-3.5.1-Source certi
mkdir $HOME/pthla/certi-tools
cd $HOME/pthla/certi
mkdir $HOME/pthla/certi/build-certi
cd $HOME/pthla/certi/build-certi
cmake -DCMAKE_INSTALL_PREFIX=$HOME/pthla/certi-tools ../
make
make install
  • CERTI is now compiled and installed in the $HOME/pthla/certi-tools folder defined as $CERTI_HOME folder. CERTI provides a script to set the environment (global variables, binaries, etc) to allow the correct launch of RTIG process, RTIA process and federates. To set the CERTI environment properly in a terminal run the command:
source $HOME/pthla/certi-tools/share/scripts/myCERTI_env.sh

or put the above command in your /.bash_profile file (Mac) or /.bashrc file (Linux).

Remark (from https://chess.eecs.berkeley.edu/ptexternal/wiki/Main/HLA): System Integrity Protection (SIP) was introduced in El Capitan in an effort to increase the security of the Mac OS. On a machine where SIP is Enabled (to check reboot, hold Command-R, run csrutil status. See How to modify system integrity protection in El Capitan.) it can have problems with the dynamic libraries.

Main CERTI Environment Variables (see also CERTI doc)

  • CERTI_HOME: the directory where CERTI is installed, e.g. $HOME/pthla/certi-tools. It is used by the RTIG in order to look for FOM (Federation Object Model) files.
  • CERTI_FOM_PATH: the CERTI search path. It is used by the RTIG in order to look for FOM files. The variable may contain a list of paths separated by ":".
  • CERTI_HOST: the machine where the RTIG is running. As soon as it starts the RTIA will try to connect to the RTIG running on CERTI_HOST (or "localhost" if the variable is not defined or void).

When running

source $HOME/pthla/certi-tools/share/scripts/myCERTI_env.sh

The default values (when CERTI was installed as suggested above) are the following ones:

CERTI_HOME=$HOME/pthla/certi-tools, CERTI_FOM_PATH=$CERTI_HOME/share/federations and CERTI_HOST=localhost.

When CERTI Environment Variables must be changed?

  • CERTI_HOST: If the federation will run in your computer, but the RTIG will run in another computer named otherComputer, you need to set (in your computer) CERTI_HOST to the otherComputer or to its IP number:
export CERTI_HOST=otherComputer
  • CERTI_FOM_PATH: You can add the absolute-path (where the FED file is located) to CERTI_FOM_PATH variable:
export CERTI_FOM_PATH="absolute-path:$CERTI_FOM_PATH"

Remarks:

  • When all the federates of a federation are running in the same computer as the rtig (as in Figure 1), you must leave the default value CERTI_HOST=localhost. You do not need to set this variable to the computer name or to the IP number (but you can if you want).
  • Let be host-rtig the name of the computer where the rtig run. When some (or all) federates run in other computer(s), as in Figure 2, then all these other computers must set CERTI_HOST=host-rtig.
  • For knowing the name of a computer, type the command line hostname in a terminal:
dupont$ hostname
aComputerName

It can happen that (FIXME because of the LAN, or firewall??) the name obtained by executing the command hostname is not known. In this case, in all the computers running a federate (from a same federation) try to set CERTI_HOST to the IP number of host-rtig.

Where does the RTIG seek for the FED file?

As explained in CERTI doc CERTI seeks for a FED file in this order:

  1. In the directory where the RTIG is launched
  2. In the directories whose paths are provided by CERTI_FOM_PATH
  3. In $CERTI_HOME/share/federations directory
  • As the $CERTI_HOME/share/federations directory is the path by default in CERTI, the simplest way is always copy your .fed files in this directory.
  • If you cannot write in $CERTI_HOME/share/federations directory then add the path to the directory where the .fed file is contained to CERTI_FOM_PATH.

Remark: When using a federate writen in Java, the API jcerti is needed. See section here for the issue concerning the FED file name.

Testing CERTI in one computer (localhost)

CERTI provides a C++ billard demo for testing a HLA federation in $HOME/pthla/certi/test/Billard/ folder. In some Linux

  • Open 3 terminals. If you did not sourced myCERTI_env.sh in your ~/bash_profile (~/.bashrc on Linux), run in each terminal the command above
  • Notice that after running myCERTI_env.sh, $CERTI_HOST=localhost
  • Go to the first terminal and execute the middeware RTIG:
  • Go to second terminal and call a billard federate named "1" (-n name) and HIT ENTER only once. A small white graphical interface representing a billard table pops out. If it does not appear, replace billard by billard-nogui in the commands below:
billard -n1 -fTest -FTest.fed -t10
  • Do not HIT ENTER yet when the following message appears:
CERTI Billard 3.5.1 (...) Press ENTER to start execution...
  • Go to the third terminal and call a billard federate named "2" (-n name) and HIT ENTER.
billard -n2 -fTest -FTest.fed -t10
  • The following message appears:
CERTI Billard 3.5.1 (...) Synchronization...
  • Go back to second terminal (where federate "1" was launched) and now press "ENTER".

If the demo works, the "billard table" shows the movement of two billard balls; In Terminal 3 you have several new messages including this one showing that an object instance of class Bille named "1" was discovered:

Discovered object handle = 2, name = 1

And in Terminal 2, this message showing that an object instance of class Bille named "2" was discovered:

Discovered object handle = 1, name = 2

There is also a Ptolemy billiard demo in $PTII/org/hlacerti/demo/Billard.

Remark: The rtig can run for different lauchings of a same simulation. But if a federation is not ended properly (destroyed) then a new run can provoke an error. In this case, you need to kill the rtig process, looking for his process number:

cardoso$ ps -ax | grep rtig
84699 ttys000 0:00.00 grep rtig
84695 ttys001 0:00.01 rtig
cardoso$ kill -9 84695
cardoso$ ps -ax | grep rtig
84727 ttys000 0:00.00 grep rtig

Testing CERTI in two computers

HLA standard targets distributed simulation, and so do CERTI, a HLA compliant tool.

  • In each computer, run in a terminal the command line ifconfig for having the name of the computer and/or its IP address.
  • Check if the two computers C1 and C2 are connected to a same LAN. Let us call their IP address IP1 and IP2, respectively. Notice that you can also use a ssh -X host-name.

Scenario 1: Launch the rtig in IP1, and all C++ billard federates in IP2.

  • Check if there is a firewall on port 60400 (PORT_TCP_RTIG) on each computer. The first command below is a succesfull test:
telnet host-name 60400
Trying ip-host-name...
Connected to host-name. Escape character is '^]'.
  • This message indicates there is a firewall that must be removed:
telnet host-name 60400
Trying ip-host-name...
telnet: connect to address ip-host-name: Connection timed out
  • If both computers succed to the test above, go to C2 and set CERTI_HOST as C1 (where the rtig run):
export CERTI_HOST=IP1
  • On C1: launch the rtig
  • On C2: Open two terminal, and launch the two C++ billard federates following the procedure above, except the first one (Launch RTIG in first terminal) since you already launched the rtig on C1.

If the simulation does not work, check the issue discussed here.

Scenario 2: Launching the rtig and a federate in IP1, and the other C++ billard federates in IP2.

  • On C1: Open 2 terminals. If you did not sourced myCERTI_env.sh in your ~/bash_profile (~/.bashrc on Linux), run in each terminal the command above
  • Notice that after running myCERTI_env.sh, $CERTI_HOST=localhost
  • Go to the first terminal and execute the middeware RTIG:
  • Go to second terminal on C1 and call a billard federate named "1" (-n name) and HIT ENTER only once. A small white graphical interface representing a billard table pops out. If it does not appear, replace billard by billard-nogui in the commands below:
billard -n1 -fTest -FTest.fed -t10
  • Do not HIT ENTER yet when the following message appears:
CERTI Billard 3.5.1 (...) Press ENTER to start execution...
  • On C2: open a terminal, set CERTI_HOST and call a billard federate named "2" (-n name) and HIT ENTER.
export CERTI_HOST=IP1
billard -n2 -fTest -FTest.fed -t10
  • The following message appears:
CERTI Billard 3.5.1 (...) Synchronization...
  • Go back to the second terminal on C1 (where federate "1" was launched) and now press "ENTER".

If the demo works, the "billard table" shows the movement of two billard balls; In C2 you have several new messages including this one showing that an object instance of class Bille named "1" was discovered:

Discovered object handle = 2, name = 1

And in C1, Terminal 2, this message showing that an object instance of class Bille named "2" was discovered:

Discovered object handle = 1, name = 2

If the simulation does not work, check the issue discussed here.

Problem: Gethostbyname gave NULL answer

In the message below, RTIA cannot resolve the name of the host computer. You should check if your hostname is correct and if the environment variable CERTI_HOST is correctly set to this computer:

RTIA:: RTIA has thrown NetworkError exception.
RTIA:: Reason: gethostbyname gave NULL answer for hostname <blablabla> with error <Undefined error: 0>
RTIA:: End execution.

This problem has been seen under Mac OS connected to the internet via a cable modem where the Mac has an address like 192.168.2.6 and hostname returns something like ealmac23.local.

One possibility is to run sudo hostname localhost, though this will cause problems with sharing, see macOS Sierra: Change your computerís local hostname

Edit - History - Print - Recent Changes - Search
Page last modified on April 08, 2019, at 01:39 AM