ICE
This page details the Internet Communications Engine (ICE) from ZeroC (http://www.zeroc.com). This is the infrastructure that powers Acorn.
ICE overview
ICE is middleware for a distributed system. It is a large piece of middleware, but not particularly hard to use at the API level. It has some comprehensive documentation. For detailed information it is better to look at the ZeroC site rather than me repeat it here. What is of more interest is why do I use it?
There are lots of software
implementations for SDR that follow a well trodden path. A single
application, albeit with some shared libraries, threaded, compiled with
a simple single click install or perhaps the slightly less easy
configure and make on Linux. Essentially though they are a GUI and a
back end which is more often than not the DttSp network enabled version
on Linux or a more tightly coupled version on Windows. These systems
all offer good performance and some have excellent functionality. Users
who primarily want to operate will probably always prefer these tight
coupled systems for their high functionality, performance and easy
install. People have also learnt how to successfully operate such
systems remotely using third party software. This does beg the
question, why bother with a distributed system.
Won't this simply
make for sub-optimal performance and make it harder to add serious
function. I have not made Acorn distributed from the ground up simply
because I want to use it across multiple machines or think everybody
else does. It's simply a way to make the parts of the system loosely
coupled and configurable as in a plug-in-architecture. It's components
I am primarily after, not distribution. The fact that it does
distribute easily is just a bonus.
Concentrating then on the component architecture, rather than the distributed architecture, why ICE? I have used a number of middleware RPC, messaging and component architectures such as CORBA, (D)COM, RMI, JMI, Web Services and some basic home grown sockets implementations plus some other language specific such as Pyro. It dosn't matter if you don't know what some of these are, just consider them ways to split functionality into processes. There is one I didn't mention, Erlang. Erlang is different because it is both a language and an infrastructure and I went a long way in implementing a system called erlink-sr. It was very difficult to stop development on that because so much effort had gone into it. In the end my mindset was having trouble coping with writing the general parts of the system such as the GUI in Erlang. I wanted to keep the system reasonably clean with Erlang and C. I experimented with browser based interfaces but it was too much code for too little function and I found it difficult to come up with a decent structure. ICE is not Erlang, it's not a language, it's a way to connect things together efficiently and I can use it across many languages. It suits my brain better so I'm sticking with it. I don't get the nice pattern matching features of a functional language which I do miss but its an imperfect world.
which languages, which platforms
Having said that ICE supports several language bindings, which languages does Acorn use and why? Currently ICE supports C++, Java, .NET, Python, PHP, and Ruby. This is quite impressive. It also supports a number of platforms depending on the language binding, in essence it supports most Windows platforms, Linux, Solaris and OS X, there is a full list at http://www.zeroc.com/platforms_3_3_1.html.
Bare in mind that the architecture splits the system into separate OS processes. To an extent this alleviates the need to thread any single process but some processes will still require threads. So this is how the system is split.
All nodes are Python at the service end. That is, all the interactions with ICE are through Python. Python is an excellent dynamic language but the emphasis is on expressiveness and usability, not on performance. Python is also not multi-core capable as its built-in threading time slices on a single OS thread and is unlikely to ever change due to the global interpreter lock.This might seem pretty much of a death knell when compared to Erlang with its multi-core capable light-weight processes. However, it's not that important for two reasons. Firstly, the node architecture can run each core function on a different process. This does depend on how functions are packaged however. Secondly, when functions are time critical or benefit from a separate thread of execution a Python C extension is used. The extension can multi-thread using real OS threads and this is how the Ozy driver and certain functions of DttSp are managed.
In the future there will very likely be pure C++ nodes which of course will be more performant and can thread all aspects of the implementation. It is unlikely that other languages will be used unless good reason is found.
installing
The first, and hopefully only barrier to Acorn is that it requires ICE and ICE is not correctly built with Ubuntu 8.04 - the Hardy Heron and therefore needs to be built. It is as far as I can tell correctly built with Ubuntu 9.04 and will install and work from the repository. Please don't take that as an indication to use 9.04. If you are on 8.x then take all the usual precautions before you commit to an upgrade.
building ice on ubuntu 8.x
The full build instructions from the Ice directories do look a but daunting and they are a little incomplete in places and a little wrong in other places and also deal with building on many platforms. I have extracted just the relevant pieces here so you don't need to refer to them at all.If you don't have them already then in a console type:
sudo apt-get install build-essential
these are pre-requisites for building anything.
Ice pre-requisites
Firstly download the third party sources from http://www.zeroc.com/download.html. You will find them at the bottom of the page.Extract the source anywhere you like.
This is an extract from the pre-requisites readme file. I have just taken the needed parts and added the missing pieces and corrected the mistakes. The instructions assume you don't move the default locations i.e. don't use the --prefix option. If you know what you are doing and want to install somewhere else then you may have to modify some of the other instructions.
======================================================================
Patches
======================================================================
mcpp
----
The files mcpp-2.7.patch and mcpp-2.7.patch2 in this archive contain
several important fixes required by Ice. We expect that all these
fixes will be included in mcpp 2.7.1.
After extracting the mcpp source distribution, change to the top-level
directory and apply the patches as shown below:
$ cd mcpp-2.7
$ patch -p0 < ../mcpp/mcpp-2.7.patch
$ patch -p0 < ../mcpp/mcpp-2.7.patch2
Follow the platform-specific instructions below for configuring and
building mcpp.
======================================================================
Instructions for Linux
======================================================================
Berkeley DB
-----------
Berkeley DB must be configured with C++ support enabled. If you intend
to use Ice for Java with Berkeley DB, you must also enable Java
support:
$ cd db-4.6.21.NC/build_unix
$ ../dist/configure --enable-cxx
(plus --prefix=<dir> and/or --enable-java if you like)
$ sudo make install
Installed in /usr/local
mcpp
----
If you have not already applied the patch for mcpp, please read the
"Patches" section above before continuing.
Ice requires the library version of mcpp, so configure mcpp as shown
below:
$ cd mcpp-2.7
$ ./configure CFLAGS=-fPIC --enable-mcpplib --disable-shared
(and --prefix=<dir> if you like)
$ sudo make install
Installed in /usr/local/lib
On 64-bit platforms, after installation it is necessary to rename the
library installation directory from $(prefix)/lib to $(prefix>/lib64.
bzip2
-----
If you prefer not to compile bzip2 yourself, a 32-bit binary
distribution is available from the "Software Porting And Archive
Centre for HP-UX" located at
http://hpux.cs.utah.edu
There are no special configuration requirements for building bzip2
from source.
$ cd bzip2-1.0.5
$ sudo make install
installed to /usr/local/lib
expat
-----
If you prefer not to compile expat yourself, a 32-bit binary
distribution is available from the "Software Porting And Archive
Centre for HP-UX" located at
http://hpux.cs.utah.edu
There are no special configuration requirements for building expat
from source.
$ cd expat-2.0.1
$ ./configure
$ sudo make install
installed to /usr/local/lib
}}}
Hopefully all the pre-requisites should now be safely installed.
== Installing Ice ==
Firstly download the Ice sources from http://www.zeroc.com/download.html. You want the source distribution Ice-3.3.0.tar.gz near the bottom of the page.
Extract the source anywhere you like.
I am only going to build the C++ part, which is required for everything else and the Python bindings. If you want other language bindings then follow the instructions in the appropriate directory.
If you installed BerkleyDB to the default directory then you need to change the directory in Ice-3.3.0/cpp/config/Make.rules.
Change this section to that shown:
#
# If Berkeley DB is not installed in a standard location where the
# compiler can find it, set DB_HOME to the Berkeley DB installation
# directory.
#
DB_HOME ?= /usr/local/BerkeleyDB.4.6
Add a couple of lines to the bottom of /home/whatever/.bashrc
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/BerkeleyDB.4.6/lib
export PATH=$PATH:/opt/Ice-3.3.0/bin/
This should ensure that libraries get found.
> cd .../Ice-3.3.0/cpp
> make
This should run through and build everything. It takes quite a while so go make a coffee.
If all goes well then install.
> sudo make install
By default the package installs to /opt.
Python
The default script has a little trouble because of how Ubuntu installs Python. If you don't have Python then install it through Synaptic etc. You need:* Python2.5
* Python2.5-dev
Edit Ice-3.3.0/py/config/Make.rules
This is not elegant but it is easy. I just replaced all the fiddle with hard paths to where the stuff was. When you find this section just replace it with the following.
#
# If you've built Python yourself then set PYTHON_HOME to contain
# the installation directory; the rest of the Python-related settings
# should be correct.
#
# If you've installed a distribution, or Python was included with
# your system, then you likely need to review the values of
# PYTHON_INCLUDE_DIR and PYTHON_LIB_DIR.
#
PYTHON_VERSION = python2.5
PYTHON_INCLUDE_DIR = /usr/include/python2.5
PYTHON_LIB_DIR = /usr/lib/python2.5/config
# Changed to fixed path directories for inc and lib
#ifneq ($(PYTHON_HOME),)
# PYTHON_VERSION = $(notdir $(wildcard $(PYTHON_HOME)/include/python2*))
# PYTHON_INCLUDE_DIR = $(PYTHON_HOME)/include/$(PYTHON_VERSION)
#
# The Python shared library is installed in $(PYTHON_HOME)/lib on HP-UX
# rather than $(PYTHON_HOME)/lib/$(PYTHON_VERSION)/config.
#
# PYTHON_LIB_DIR = $(PYTHON_HOME)/lib
#else
#
# If multiple versions of Python are installed and you want a specific
# version used for building the Ice extension, then set PYTHON_VERSION
# to "python2.3" or "python2.4".
#
# PYTHON_VERSION ?= $(word 1,$(notdir $(wildcard /usr/include/python2.[345]*)))
# ifeq ($(PYTHON_VERSION),)
# python_darwin_home = /System/Library/Frameworks/Python.framework/Versions/Current
# PYTHON_VERSION = $(word 1,$(notdir $(wildcard $(python_darwin_home)/include/python2.[345]*)))
# endif
# PYTHON_INCLUDE_DIR = /usr/include/$(PYTHON_VERSION)
# PYTHON_LIB_DIR = /usr/lib/$(PYTHON_VERSION)/config
#endif
#ifeq ($(PYTHON_VERSION),)
# ifneq ($(PYTHON_HOME),)
# $(error Unable to find a Python interpreter at PYTHON_HOME=$(PYTHON_HOME). See config/Make.rules)
# else
# $(error Unable to find Python 2.3, 2.4, or 2.5. See config/Make.rules)
# endif
#endif
PYTHON_FLAGS ?= -I$(PYTHON_INCLUDE_DIR)
PYTHON_LIBS ?= -L$(PYTHON_LIB_DIR) -l$(PYTHON_VERSION)
Then build:
> cd .../Ice-3.3.0/py
> make
If this runs through ok, takes only a moment.
> make install
You should now be done
Run up Python.
> python
> import Ice
If Ice imports without error you should be able to run acorn-sdr.