Argot, Colony and stuff about internet protocol stacks.

Tuesday, March 16, 2010

Argot meets Contiki (Part 2)

Back in October last year I wrote about building an example of using Argot on Contiki. After releasing Argot recently under a BSD licence, I've been working on preparing that small project for release. I'm happy to say that release is now done. It builds on Argot, Colony and the newly released Argot MCG (Micro Code Generator) which generates C code from Argot dictionary files. You can find all the project files at

At a high level the Contiki Argot project shows embedding a protocol meta data description in a small Contiki device. The meta data is used by a client to verify the definition of a protocol before sending a request to the device. Placing Argot meta data on the device allows each part of an interface to be versioned and allows clients to perform full protocol discovery on devices with only a few kb of read only memory. On the client side, a developer is able to use java interfaces which bind to the protocol description allowing fast development of clients. This form of protocol discovery allows tight binding between client and server while still maintaining loose coupling. For details of what the example shows you can read the details in the post from October.

If you're interested in trying out the example, I suggest downloading the instant contiki vmware development environment. From a command shell in Contiki get the project:
cd argot-contiki
To build the server a small change needs to be made to the Contiki build system (applies to contiki-2.4). The following command will patch the makefile with the required changes:
patch -d /home/user/contiki-2.4
In these instructions the server is being built to be run using the minimal-net configuration which is run on the unix host. This is useful for debugging and as a demonstration of the code. The Contiki minimal-net configuration uses the tap0 unix networking driver to put the host into a different network. This is configured in the “contiki-2.4/platform/minimal/contiki-main.c” file. I use ip, netmask, gateway In the “contiki-2.4/cpu/native/net/tapdev.c” the tap0 configuration needs to be adjusted for your selected IP address. Around line 107, change the line “ifconfig tap0 inet” to match your configuration.

Following configuring the network components of the example you can build the server:
cd examples/test
To run the server:
sudo ./argot-server.minimal-net
Leave the server running and open a different shell. To build the Java client code, two jar files need to be copied into the Apache Ant build libraries. This is a one off task:
cp lib/junit.jar /usr/share/ant/lib
cp lib/ant-junit.jar /usr/share/ant/lib
You can then build the java client by calling ant at the base of the project:
After the client has been successfully built, you can call the simple test code:
java -jar lib/contiki-argot-1.0.0.jar
If everything is successful you should have an output that ends with “doSomething returned: 30”.

Obviously, this example is still quite rudimentary. However, it does demonstrate calling a Contiki based service which uses only a few kb of memory. It also shows a client which only requires a Java Interface to be coded to make the call. Next steps are to improve the functionality of the test and look further into the transport protocols used in this environment.