Running CPN Tools Simulator on a Remote Host

CPN Tools is a popular software application for creating, simulating and analysing Coloured Petri Nets. I've used it occasionally over the past 3 or 4 years, and also used its predecessor, Design/CPN, extensively during my PhD. There has always been a Linux and Windows version of CPN Tools, however the GUI in the Linux version has some bugs, and the developers have decided to concentrate only on the Windows GUI for future releases. Thats annoying for me, however all is not lost as the simulator process of CPN Tools (for simulations and state space analysis) will still run in Linux. That is, the GUI can run on one host, and it communicates via TCP/IP sockets to the simulator on another host. With the current external version (2.2.0) I had trouble setting up the remote simulator, but after trying with the latest internal version (2.3.5) I worked it out. There are some instructions spread across different posts in the Support Maillist, but for reference I give the precise commands I used here. The instructions are for running both the GUI and simulator under Linux, but can be modified for any combination of Windows and Linux. It turns out the version of CPN Tools didn't make any difference - these instructions will work for both versions 2.2.0 and 2.3.5. (2.3.5 also provides an option in the GUI to set the remote simulator, but I didn't use that). Install CPN Tools on both hosts, in the directory /home/user/CPNTools/. On the host that will run the simulator with example IP address, change into the install directory and run:
./cpnsim/cpnmld 7001 cpnsim/run.x86-linux
7001 is the example port number the simulator will listen on. You may choose another value (so long as it is not in use by another application. If you wanted to run the simulator under Windows, then replace run.x86-linux with run.x86-win32.exe (and of course use backslash instead of forward slash). On the host that will run the GUI with example IP address, change into the install directory and run:
./cpntools -remote -image cpnsim/cpn.ML.x86-linux -port 7001 -host
Of course set the host IP address to the actual IP address of your simulator host and use the appropriate port number. On the GUI host you should see output such as:
INFO: Using remote simulator (UNIX)
and the CPN Tools Gui should start. You can now open a CPN file. Once opened, on the simulator host you should see output such as:
Accepted connection from
login = cpn2000
path = ./
User login
Starting new session for user cpnsim/cpn.ML.x86-linux in ./
Starting new session
Child spawned with pid = 24935

Changing current path to ./
Executing: cpnsim/run.x86-linux @SMLload=cpnsim/cpn.ML.x86-linux @SMLcmdname=cpnsim/cpn.ML.x86-linux
GC #   (0 ms)
GC ...
and the GC output will continue as the simulator checks the syntax. This looks, and is easy. However it took me several hours to get it working. When opening a net I would get an error in the GUI: a red popup box saying something like "Could not start the simulator. You will not be able to simulate the net". It turned out my most significant problem was the permissions of my install of CPNTools on the simulator. All files were owned by the normal user except cpn.ML.x86-linux which was owned by, and only had read permissions for root. After changing the ownership/permissions of this file to be the same as all others, everything worked. I'm not sure what lead to this situation, but hopefully now others will not make the same time-wasting mistake as me.