Sunday, February 21, 2016

Handling Segmentation Fault (Core Dumped) in ns-2

Programming c++ in ns-2 is a nightmare for beginners. It requires systematic planning and programming. Though the programming is systematically planned, even experienced programmers frequently encounter  bugs called "Segmentation fault (Core Dumped)" and Floating point exception (Core Dumped).  Generally, Floating point exception can be dealt with positive value in the denominator of an expression. This post explains how to debug these problem in ns2. The following procedure has been tested with ns-2.35.

Prerequisite: Your system should installed with gdb (GNU debugger).

Step 1: goto ns-allinone-2.35/ns-2.35, and edit the Makefile.in file

replace from
CCOPT    = @V_CCOPT@ 

to

CCOPT    = @V_CCOPT@ -g

Next, replace the following from

DEFINE    = -DTCP_DELAY_BIND_ALL -DNO_TK @V_DEFINE@ @V_DEFINES@ @DEFS@ -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=@CPP_NAMESPACE@ -DUSE_SINGLE_ADDRESS_SPACE -Drng_test

to

DEFINE    = -DTCP_DELAY_BIND_ALL -DNO_TK @V_DEFINE@ @V_DEFINES@ @DEFS@ -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=@CPP_NAMESPACE@ -DUSE_SINGLE_ADDRESS_SPACE -Drng_test -DNDEBUG -DDEBUG 

Step 2: Save the file and do the following

$ ./configure

$ make clean

$ make distclean

$ ./configure

$ make

$ sudo make install

Now debugging to your ns-2 is ready. If you have encountered the Segmentation fault bug while running any tcl file, then do the following

Step 3: goto the tcl folder and do the following

$ gdb ns

(gdb) run your_tcl_filename.tcl

TCL file runs with the above command and it stops at bug point showing the statement where the bug has present. 

 
 
 

Tuesday, October 20, 2015

Using AVRORA simulator with TinyOS

AVRORA is a popular AVR Simulation and analysis framework for simulating the programs developed for AVR micro controllers. This tool can be used to simulate the programs written in TinyOS environment with little modifications. This post explains how TinyOS programs can be simulated using AVRORA.

This was tested in UBUNTU 12.04 OS environment.

Save the files downloaded from the following steps to a folder. In my system it is
/home/prv/avrora

Step 1: Download the converter from http://compilers.cs.ucla.edu/avrora/jars/avrora-beta-1.7.091.jar

Step 2: Rename the downloaded file as avrora.jar

Step 3: Download the converter.sh file from https://drive.google.com/file/d/0B8u5Jm1ly3NYNm41UEU0ZjdzYkU/view?usp=sharing

Step 4: Open the bashrc file
            gedit ~./bashrc
            and add the following lines at the end of the file.

alias avrora='java -jar /home/prv/avrora/avrora.jar'
alias convert-avrora='sh /home/prv/avrora/converter.sh'

Step 5: Save the file and close all the consoles opened.

Now, to test the AVRORA setup, run any application programmed in TinyOS.

For example, go to the folder Blinks available in /opt/tinyos-2.1.2/tos/apps.

compile the program

make mica2

it creates a build folder in which you will find micaz2 sub folder. Move to it.
In micaz2 folder there exists a main.exe file. This file is the main file consists of  application and TinyOS environment.

convert it into avrora environment as follows

convert-avrora main.exe blink.od

Now, run the avrora

avrora -seconds=5.0 -platform=mica2 blink.od

This command runs the blink application for one sensor node. To do the same for multiple nodes use the following command

avrora -simulation=sensor-network -seconds=10.0 -nodecount=2 blink.od

The screen shot after running the command

avrora -simulation=sensor-network -seconds=2.0 -nodecount=1 blink.od

is as follows



References

[1] http://compilers.cs.ucla.edu/avrora/
[2] http://mythicalcomputer.blogspot.in


Saturday, September 12, 2015

Installing TinyOS in UBUNTU 12.04 LTS

This installation procedure was tested on UBUNTU 12.04 LTS

Requirements: An UNBTU 12.04 LTS 32-bit system with Internet connectivity

step 1: open command line and type

    sudo gedit /etc/apt/sources.list

step 2: add the following repository at the end of the list

    deb http://tinyos.stanford.edu/tinyos/dists/ubuntu lucid main

step 3: save the file and run

    sudo apt-get update

step 4: Install nesC compiler which is required for TinyOS programming. This step also install java environment.

    sudo apt-get install nesc

step 5: Install the cross tools (tool-chain), Debian MSP430 and Debian AVR using following

    sudo apt-get install msp430-tinyos avr-binutils-tinyos msp430-gcc-tinyos msp430-libc-tinyos

step 6: Install g++ compiler. (This step can be ignored if it is already installed on the system). Also install python development.


    sudo apt-get install g++

    sudo apt-get install  python-dev -y


step 7: Install automake tool

    sudo apt-get install automake

Step 8: Install tinyos operating system

    sudo apt-get install tinyos

    This command prompts for existing tinyos versions for download. Select a suitable version and download as shown below.

    sudo apt-get install tinyos-2.1.2
   
step 9: change the perimissions of tinyos installation folder

    sudo chmod -R 777 /opt/tinyos-2.1.2

step 10: create a file called tinyos.sh in /opt/tinyos-2.1.2

    sudo gedit /opt/tinyos-2.1.2/tinyos.sh

step 10: copy and past the following content in the tinyos.sh file

    # Here we setup the environment
    # variables needed by the tinyos
    # make system

    export TOSROOT=/opt/tinyos-2.1.2
    export TOSDIR=$TOSROOT/tos
    export MAKERULES=$TOSROOT/support/make/Makerules
    export CLASSPATH=$TOSROOT/support/sdk/java/tinyos.jar:.
    export PYTHONPATH=.:$TOSROOT/support/sdk/python:$PYTHONPATH
    export PATH=$TOSROOT/support/sdk/c:$PATH

    echo "setting up TinyOS on source path $TOSROOT"

step 11: open bashrc file

    sudo gedit ~/.bashrc

    and add the following content at the end of the file

    #Tinyos path
    source /opt/tinyos-2.1.2/tinyos.sh

step 12: close the terminal and reopen to see the tinyos path estalishment

   

Wednesday, March 4, 2015

Installing Lyx in UBUNTU

Lyx is a latex editor (WYSIWYM) which helps researchers and writers to edit their content. Latest version of the Lyx can be obtained as follows

$ sudo add-apt-repository ppa:lyx-devel/release
$ sudo apt-get update
$ sudo apt-get install lyx

Installing Remastersys in UBUNTU

Remastersys is a back up and recovery software that helps you to create custom/ boot able live CD/DVD of the entire UBUNTU distribution. This software can be installed as follows


$ sudo add-apt-repository "deb http://www.geekconnection.org/remastersys/repository karmic/"


$ sudo apt-get update
$ sudo apt-get install remastersys