Showing posts with label cooja. Show all posts
Showing posts with label cooja. Show all posts

Monday, March 21, 2011

Compiling and running tikiridb-0.2 for Cooja Simulator

Cooja is a network simulator that comes with the Contiki operating system. When we're working on sensor network applications that runs with Contiki operating system we always have to compile, run and check whether it works. For this purpose it's not a good idea to burn the application and OS to real hardware motes over and over again because the re-writability of the memory modules of the hardware may be limited. Therefore it's a good idea to use Cooja simulator as a pre-testing tool of our application programs. Here I write down the way to compile tikiridb to run on cooja simulator.


    We begin from downloading tikiridb 0.2 version from http://score.ucsc.lk and the daily snapshot code of the contiki from http://www.sics.se/contiki/. We create a new directory somewhere in our Ubuntu machine and put the two downloaded source directories ("0.2" and "contiki-2.x") in that directory side by side. Now it's time to follow a sequence of instructions to reach our goal.

1) Open the file "0.2/node/platform-modified/cooja/packetizer-arch.c" and put this function to the end of it.

    void packetizer_arch_writeb(unsigned char c) {
        rs232_send(c);
    }

2) Copy the "serial_forwarder" directory in "0.2/cooja/plugins/" to the "contiki-2.x/tools/cooja/apps/" directory.

3) open file "contiki-2.x/tools/cooja/build.xml",
    1. As a child element of , add the following
          <ant antfile="build.xml" dir="apps/serial_forwarder" target="clean" inheritAll="false"/>  

    2. As a child element of add the following
 
         <ant antfile="build.xml" dir="apps/serial_forwarder" target="jar" inheritAll="false"/>

4) open file "contiki-2.x/tools/cooja/config/external_tools_linux.config" and  replace the variable "DEFAULT_PROJECTDIRS" with,
    DEFAULT_PROJECTDIRS = [CONTIKI_DIR]/tools/cooja/apps/mrm;[CONTIKI_DIR]/tools/cooja/apps/mspsim;[CONTIKI_DIR]/tools/cooja/apps/avrora;[CONTIKI_DIR]/tools/cooja/apps/serial_forwarder

5) Install additional packages that are needed to compile tikirisql(TikiriDB client).
   In the terminal type:
   # apt-get install flex bison

6) Compile tikirisql client
   In the terminal type:
   # cd 0.2/gateway/tikirisql
   # make

7) Open the file "0.2/test-apps/Makefile" with your favorite
   text editor and set the path to Contiki directory appropriately.

8) Go to "contiki-2.x/tools/cooja" directory and type,
    ant clean
    ant run
   This will open the cooja simulator. Close it.

9) Go to the directory "0.2/test-apps" and issue the command,
    make test-app.cooja TARGET=cooja

10) Now our cooja simulator will start and get ready to run tikiridb. In the GUI of the opened cooja, we should follow the precedure as follows. In the dialog box for create new simulation, click "Create button". In the next create mote type window, click "Compile". when it's done click on "Create". Now in the add motes window enter 2 for number of motes and then click "Create and add" button.Now in the "simulation visualizer" window, right click on a mote and "open mote plugin for contiki" &gt;&gt; serial forwarder. Then in the serial forwarder window, keep the default port value it has and click "start". Then in the control panel, click "start". A simulation error window will come. Close it and goto the menu bar,
        file &gt;&gt; reload simulation &gt;&gt; keep random seeds. Now the serial forwader will be running. Start the control panel also.

11) Go to the directory "0.2/gateway/tikirisql" and issue the command,
    ./tikirisql -H localhost -P 25601
   when you issue an sql query in the prompt and if it hangs without printing the data, there should be something wrong. Check whether the motes in the simulation are in within each others radio range. If not, drag them to closer.

Tuesday, June 15, 2010

Installing Contiki and Cooja Simulator in UBUNTU

About a week ago, I thought to install TikiriDB and tryout it. To use it I have to install Contiki operating system and the cooja simulator which are the platform to run TikiriDB. Started from reading the tikiriDB home page (http://score.ucsc.lk/projects/tikiridb). There's a link provided in that page which shows how to install contiki and cooja in Ubuntu 8.10 (installing contiki/cooja). However I'm running Ubuntu 10.04 Lucid and it works. The only issue is if your going to install netsim simulator provided with contiki, your in trouble because the required package (libgtk1.2-dev) is not supporting to Ubuntu 9.04 and 10.04 as I know. By the way, I forget netsim and advanced to all the other things.
Here we go,

1. I had to install CVS to get the CVS version of Contiki,

sudo apt-get install cvs

2. Got the contiki source,

cvs -z3 -d:pserver:anonymous@contiki.cvs.sourceforge.net:/cvsroot/contiki co contiki-2.x

3. There is an example directory in the Contiki source which contains some example codes. To compile the hello-world example,

cd contiki-2.2.2/examples/hello-world

make TARGET=native

./hello-world.native

4. After testing that hello world example I cleaned the temporary files during the compilation,

make clean

5. Now contiki is ok. Then I needed java, since the cooja is a java based simulator,

sudo apt-get install sun-java6-jdk

6. To compile cooja I needed ant which is a compile tool,

sudo apt-get install ant

7. To compile and start cooja I gave the commands,

cd tools/cooja

ant run

8. To remove all the temporary files created during the compilation,

ant clean

After these steps cooja was started and I was exited by the facilities given in cooja. Then I stopped working on it and hope to complete the further configuration steps of cooja later.