Cooja
Learning outcomes
- Familiarity with Cooja basics
- Know how to run and save a simple simulation
What is Cooja?
- Java-based Contiki network simulation
- Allows simulation of small and large networks
- Two types of motes can be simulated:
cooja
motes run native codesky
motes emulate the hardware but simulation may be slower as a result
- You shouldn’t need to adjust your code to run in simulation
Getting started with Cooja
Prerequisites
- While compiling Contiki doesn’t require a windowing display, Cooja does
- Two options for this:
- use VNC
- install a desktop environment
- Try the instructions at https://github.com/contiki-ng/contiki-ng/wiki/Vagrant#provision-a-vm-with-a-desktop-environment
- Adjust the Vagrantfile to uncomment
vb.gui = true
config.vm.provider "virtualbox" do |vb| # Display the VirtualBox GUI when booting the machine vb.gui = true end
- Run the bootstrap script for setting up X packages
$ ./contiki-ng/tools/vagrant/bootstrap-vbox-with-x.sh
- Reboot after the install
- I found that this added some virtualbox-guest packages which were then removed by vagrant’s vbguest plugin
- If you don’t end up with a graphical login prompt, don’t worry—you can just run
startx
on the command line after logging in on the gui window. - You may need to download the cooja submodules if you haven’t already
$ cd ~/contiki-ng $ git submodule update --init --recursive
Create a new simulation
Follow the tutorial listed here: https://github.com/contiki-ng/contiki-ng/wiki/Tutorial:-Running-Contiki%E2%80%90NG-in-Cooja
If you encounter errors, try the fix suggested here: https://github.com/contiki-os/contiki/issues/2324
Simple UDP RPL simulation
RPL is the Routing Protocol for Low power and Lossy Networks
https://github.com/contiki-ng/contiki-ng/wiki/Tutorial:-running-a-RPL-network-in-Cooja
Next steps
- Try the other simulation tutorials out until you feel you have a good understanding about what’s going on.
- Review the code for the client and server and identify where messages are being sent and received.
Summary
- We’ve covered getting the simulation gui up and running and running a basic simulation
- This tool should come in handy when you write your own code