December 2007


Code in ocamerl (part of erlocaml) pass the node handshake. Hopefully nobody will read this code before I clean it up a bit … because right now it is a furious mess!!!

I spent some time (arg, that’s a lot in fact) on a stupid (as the bug’s author) bug. The (simplified) handshake is a follow:

  • the 2 nodes exchange a challenge which is 4 random bytes interpreted as a Int32;
  • each node computes the MD5 of (their own cookie + challenge);
  • each node compares its result with the digest of the other node.

My bug was to concatenate the cookie (string) with the raw 4 bytes of the challenge … where I had to concatenate the cookie with the string representation of the 32 bits long unsigned integer!

(in fact the handshake is done with 2 challenges: each node send a challenge to the other)

Anyway, the handshake pass correctly now, and ocaml node can receive the ping control message … but do not reply yet! after it reply, sure I clean the code!!!

As spotted in this blog post using Erlang in robotics seems a pretty good idea to implement robust systems and concurrent behaviours.

However I do not consider the subsumption architecture (Brooks, 1986) as the best example of action selection architecture for concurrent behaviours. As far as I remember, the subsumption architecture assumes predefined priorities on behaviours (hierarchy), and has a fix set of rules on how some behaviours can subsume others.

As far as reactive architectures are concerned, IMHO Erlang style of concurrency could be more effectively used on architecture using activation networks (Maes, 1989), or a voting mechanism a la DAMN (Rosenblatt, 1995), or a pertinence-based selection like Creature (Blumberg, 1997), or whatever architecture which enable a distribution of control.

But yes, Erlang seems quite a good match to implement autonomous entities (robots or software agents (MAS)).

Christmas is coming, and I found a new toy to play with: ocamerl. This is a very simple solution to exchange data between erlang and ocaml. In fact, this is mainly an ocaml implementation of the erlang external binary format (based on this discussion/code). I just added few tools to make a TCP connection to exchange those data.

On erlang side, I use 2 processes: the receiver process listen on a TCP port,read data and send it back to any erlang process meant to handle incoming data; the second process is busy transfering all data in its message queue to some TCP server (the ocaml part). On ocaml side, there are a couple a function to transform erlang forms in ocaml entities and vice versa.

I only wrote a very very simple exemple: an ocaml echo server, which multiply by 2 all integers sent in message (deep search in tuple).

Erlang side init:

1>Receiver = spawn(oe, print_mailbox, []).
2>Sender = oe:messenger(12345, 54321, Receiver).

Ocaml side init:

./ex/double -recv 12345 -send 54321

Then, any term sent to from erlang is sent back by ocaml.

3> Sender ! {true, 12, {1,2}}.
{true,12,{1,2}}
Sending data: <<131,104,3,100,0,4,116,114,117,101,97,12,104,2,97,1,97,2>>
Received binary: <<131,104,3,100,0,4,116,114,117,101,97,24,104,2,97,2,97,4>>
Converted to term: {true,24,{2,4}}
Received: {true,24,{2,4}}

Funny, isn’t it ? 🙂 This is an early stage of course. Code is part of erlocaml project (in lib/ocamerl). My goal is to write a hidden erlang node in ocaml. Not sure it is useful, but quite certain it is interesting 😉