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.

11 comments:

  1. Hi im also doing a sensor network project which is developing a protocol for a low power sensor network.so i want to take some good advices from you.
    navoda54321@gmail.com

    ReplyDelete
  2. I'm so happy to hear that. What kind of protocol are you going to develop?

    ReplyDelete
  3. I did the things needed to be done to run the program as exactly which is on readme file. But when i am running TikiriDB it gives me this error. Please help me with this.

    user@instant-contiki:~/Desktop/0.2/test-apps$ make test-app.csc
    java -mx512m -jar /home/user/Desktop/Conti/contiki-2.4/tools/cooja/dist/cooja.jar -quickstart='test-app.csc' -contiki='/home/user/Desktop/Conti/contiki-2.4'
    log4j:ERROR Parsing error on line 1 and column 0
    log4j:ERROR unable to resolve external entity: "log4j.dtd"
    log4j:ERROR Could not parse input source [org.xml.sax.InputSource@577510].
    gnu.xml.dom.ls.DomLSException: unable to resolve external entity: "log4j.dtd"
    at gnu.xml.dom.ls.DomLSParser.doParse(libgcj.so.10)
    at gnu.xml.dom.ls.DomLSParser.parse(libgcj.so.10)
    at gnu.xml.dom.DomDocumentBuilder.parse(libgcj.so.10)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:672)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:602)
    at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:704)
    at se.sics.cooja.GUI.main(GUI.java:3032)
    Caused by: org.xml.sax.SAXParseException: unable to resolve external entity: "log4j.dtd"
    at gnu.xml.stream.SAXParser.parse(libgcj.so.10)
    at gnu.xml.dom.ls.DomLSParser.doParse(libgcj.so.10)
    ...7 more
    Caused by: javax.xml.stream.XMLStreamException: unable to resolve external entity: "log4j.dtd"
    at gnu.xml.stream.XMLParser.error(libgcj.so.10)
    at gnu.xml.stream.XMLParser.pushInput(libgcj.so.10)
    at gnu.xml.stream.XMLParser.readDoctypeDecl(libgcj.so.10)
    at gnu.xml.stream.XMLParser.next(libgcj.so.10)
    at gnu.xml.stream.SAXParser.parse(libgcj.so.10)
    ...8 more
    log4j:WARN No appenders could be found for logger (se.sics.cooja.GUI).
    log4j:WARN Please initialize the log4j system properly.
    GC Warning: Out of Memory! Returning NIL!
    Exception during event dispatch:
    java.lang.OutOfMemoryError
    <>


    GC Warning: Out of Memory! Returning NIL!
    Exception during event dispatch:
    java.lang.OutOfMemoryError
    <>
    make: *** [test-app.csc] Error 1

    ReplyDelete
  4. hello
    we dont find any link to download tikiridb
    please help me
    thanks

    ReplyDelete
  5. Hello Karim,
    Currently TikiriDB project is not running with continues developments. Therefore there's no any recent version of it. I will email you an older version which I have.

    ReplyDelete
    Replies
    1. thanks a lot asanka
      this is my email : fathallah.karim@gmail.com
      thanks a lot again :)

      Delete
  6. Hello Asanka,

    I would like to ask you if you could provide me tikiridb.
    This is my email : abdel.essefi@gmail.com

    Thank you in advance.




    ReplyDelete
  7. please email me the tikriDB & serial_forwarder to my email id :
    santoshsoni.77@gmail.com

    ReplyDelete