What is Phantom?
Phantom is a loosely-coupled set of servers and communications protocols designed to supercede SPIRIT. The goal is not to produce a commercial/finalised offering but rather to deliberately leave things open-ended in order to facilitate research.
To this end, the design philosophy is such that you should be able to use phantom proided you have can use unicast and multicast on your network and machine. That is the only requirement: no client side libraries are required (although some may be produced). This allows embedded devices access to everything so integrating, say, an iPaq, should be very easy.
Persistent storage is through a postgres database which is attached to a server that, initially, executes SQL commands on belhalf of a client and returns the results (thereby allowing clients to execute SQL without needing any libraries). Users can access the database and change contents directly: all changes are multicast to a particular channel using database triggers.
The database presently resides wholly on firestoker. There is a documented multicast group where clients can ask for a database that knows about a certain table. Such a database respondes on the same channel with its contact details (IP address and TCP port ). The client may then connect to this server and send the SQL query as a string, receiving the results in a binary format as follows:
Byte 1 Number of fields in result (unsigned char), c Byte 2 Number of tuples (rows) in result (unsigned char), r Bytes 3 -- (3+r) Phantom type of each field (each an unsigned char -- see below) Varies Field names (concatenated and delimited by '\0') <Then each element of each row concatenated in binary format (strings null-terminated)>
The postgres data types are as follows:
Type Data (size in bytes) 1 bool (i) 2 char (1) 3 int2 (2) 4 int4 (4) 5 int8 (8) 6 float4 (4) 7 float8 (8) 8 abstime (8) 20 ALL string types (null-terminated char array)
Phantom uses the multicast groups 220.127.116.11 to 18.104.22.168
Unfortunately multicast groups have to be attached to a port so Phantom adopts a convention based on the group address 225.0.A.B, such that the port is 10000+A*256+B. Note that the database server uses a TCP channel for result delivery, and the IP address/port is available on a set multicast channel.
The allocated spaces are as follows:
225.0.0.* : System comms
22.214.171.124 Database request channel 126.96.36.199 Database change broadcast channel 188.8.131.52 Error channel
225.0.1.* : Sensor system (raw) events
184.108.40.206 Bat system events
225.0.2.* : Aggregated events
220.127.116.11 Location events 18.104.22.168 Spatial Indexer events
Phantom Message Structure
Multicast messages have a set header. We have allowed for future versions of the message header by including versioning data in the header. At present only version 1 exists and is 16 bytes in length:
Bytes C++ Type Description 1 unsigned char Message Version (1 at present) 2 short Phantom event id 1 unsigned char Sequence Number for Bat messages 4 long UNIX time (seconds) 4 long UNIX time (microseconds) 4 n/a Reserved
This format is to allow easy filtering of events that are not wanted.