Part 1: How to Install Cooja on UCSC Compute Servers
This how to assumes you have access to UCSC compute servers. At the time of writing this git and java were already installed on the compute servers and the default shell scripting language was tcsh (so the commands are assuming tcsh). I performed all my tests on the slamdance compute server. I am also assuming that you run all commands starting in your home directory.
WARNING: Many of these paths are relative, so use this as a guideline, not as an absolute.
Login to the compute servers: Login to the compute servers with tunneling enabled, you may need to install XQuartz on a Mac for this to work, I don’t know about Linux or Windows:
$ ssh -X email@example.com
Download Cooja from git: Cooja is bundled into the contiki project. Use one of the following commands to download the contiki project into ~/contiki.
$ git clone firstname.lastname@example.org:contiki-os/contiki.git
$ git clone https://github.com/contiki-os/contiki.git
Note: After running one of the commands above, you may need to run the following commands, too:
$ cd contiki
$ git submodule update --init
Download and setup ant: Cooja uses ant to compile and run. These instructions used to mention version 1.9.6 of ant, but at the time of this update, the current version is 1.9.13.
To install ant use the following commands:
$ wget https://www.apache.org/dist/ant/binaries/apache-ant-1.9.13-bin.tar.bz2
$ tar -xvf apache-ant-1.9.13-bin.tar.bz2
After downloading ant, the following path variables must be set (I recommend putting these command in your .cshrc file). Confirm that the path for JAVA_HOME exists. It may omit “.x86_64”.
$ setenv ANT_HOME ~/apache-ant-1.9.13
$ setenv JAVA_HOME /usr/lib/jvm/java-1.7.0-openjdk.x86_64
$ set path=( $path $ANT_HOME/bin )
At this point you should verify that ant is installed by running the following command and verifying the output:
$ ant -version
Verify Cooja: Cooja can now be run. After running the following commands a gui should pop up in your tunneled visualizer.
$ cd ~/contiki/tools/cooja
$ ant run
Download and setup msp430-gcc: There are two folders of msp430-gcc compilers that must be downloaded and added to the path in order to compile msp430 nodes in simulation. The way I did this is a little roundabout, but these were the steps I took:
- Download Instant Contiki and set it up as a virtual machine (reference).
- Run the command
echo $PATH. Notice where the folders CodeSourcery and msp430 are located and where the PATH points to.
- Copy the folders /home/user/CodeSourcery and /usr/local/msp430 to the UCSC server. (e.g.
$ ssh -r /home/user/CodeSourcery email@example.com:~).
- Set the paths on the UCSC server:
$ set path=( $path ~/CodeSourcery/Sourcery_G++_Lite/bin ~/msp430/bin )
Done: Congratulations, you have setup Cooja on the UCSC servers.
Part 2: How to Automate Cooja Simulations
There are two steps to automate Cooja Simulations. First you have to setup the simulation inside the Cooja GUI (This isn’t really necessary, but this is how I did it, and how the reference I used described the process), then you can run Cooja via the command line.
Setup the Simulation: (reference)
- Run Cooja, using the standard ant run command in the ~/contiki/tools/cooja directory and either open an existing simulation or create a new one.
- Click on the menu item Tools->Simulation script editor…
- A window should pop open. In the new window click on the menu item File->Load example script->Just log all printf()’s and timeout. You can modify this script, but this should give you the basic idea of how to setup a simulation script.
Run Cooja via the Command Line: Use the following command to run Cooja via the command line.
- ant run_nogui -Dargs=absolute/path/to/simlation.csc