Skip to main content

TINYOS AND NS2 IN UBUNTU-BASED SYSTEMS

 TinyOS is an open source software component-based operating system and platform targeting wireless sensor networks (WSNs). TinyOS is an embedded operating system written in the nesC programming language as a set of cooperating tasks and processes. It is intended to be incorporated into smartdust. TinyOS started as a collaboration between the University of California, Berkeley in co-operation with Intel Research and Crossbow Technology, and has since grown to be an international consortium, the TinyOS Alliance.


INSTALL TINY OS

To get a copy of TinyOs and its dependencies.
sudo apt-add-repository "deb http://tinyos.stanford.edu/tinyos/dists/ubuntu natty main"
apt-get update
apt-get install tinyos-2.1.2 python-dev automake subversion g++

Now we have the dependencies we can get a more up-to-date version.
cd ~
mkdir -p local/src
cd local/src
svn checkout http://tinyos-main.googlecode.com/svn/trunk/ tinyos-2.x

cd tinyos-2.x/tools
./Bootstrap
./configure --prefix=$HOME/local
make all
make install

Add to bottom of .profile
export PATH=$HOME/local/bin:$PATH
export TOSROOT=$HOME/local/src/tinyos-2.x
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
export MOTECOM=serial@/dev/ttyUSB0:115200

For AODV
Extract system and interfaces from NST-AODV.tar.gz into ~/local/src/tinyos-2.x/tos
Extract libraries into ~/local/src/tinyos-2.x/tos/system

Copy over modified files
To reject packets with failed CRC errors
Modify $TOSROOT/support/sdk/python/tos.py
if crc != packet_crc:
    print "Warning: wrong CRC! %x != %x %s" % (crc, packet_crc, ["%2x" % i for i in packet])
    return None

For permission to write to the USB port
sudo usermod -a -G dialout USERNAME

Errors

Fatal error: Python.h
If you get /opt/tinyos-2.1.1/tos/lib/tossim/tossim_wrap.cxx:139:20: fatal error: Python.h: No such file or directory compilation terminated.
Change PYTHON_VERION from 2.5 to 2.7 in /opt/tinyos-2.1.1/support/make/sim.extra

No permissions to write to the USB port
Either just chmod 777 the USB port, however this needs to be done each time the device is plugged in or you can add the current user to the dialout group.

NST-AODV
In AODV.h put "#include <message.h>"
Make sure the code you are compiling has "component PrintfC"

Contiki

Install guide

Summary of https://github.com/g-oikonomou/contiki-sensinode/wiki/Prepare-your-System
Grab the latest tarball of the SDCC source from http://sourceforge.net/projects/sdcc/files/snapshot_builds/sdcc-src/ and extract the folder somewhere. Now do the following.
cd SDCC
wget https://github.com/g-oikonomou/contiki-sensinode/wiki/contiki-sdcc.patch
patch -p0 < contiki-sdcc.patch
sudo apt-get install libboost-graph-dev flex bison
./configure --disable-gbz80-port --disable-z80-port --disable-ds390-port --disable-ds400-port --disable-pic14-port --disable-pic16-port --disable-hc08-port --disable-r2k-port --disable-z180-port --disable-sdcdb --disable-ucsim
make
sudo make install
cd ..
git clone https://github.com/g-oikonomou/contiki-sensinode.git
cd contiki-sensinode/examples/cc2530dk/
make

All done!

NS-2

I have currently implemented a Ns-2 application, aimed to connect Ns-2 which is written in C++ and Tcl to Python in order to provide a simple way to develop scenarios.

Ubuntu 10.10 Installation
If it cant find sources add 'deb-src http://uk.archive.ubuntu.com/ubuntu/ oneiric universe' to '/etc/apt/sources.list'.
sudo apt-get build-dep ns2
apt-get source ns2
cd ns2-2.35~RC6
gedit ./common/mobilenode.cc
gedit Makefile.in
./configure
make

Self-Defined Packets
Some programming tips for applications which are defining their own packet structures is to include 'agent_->set_pkttype(PT_CBR);' into the body of the application. I think this is only needed if the underlying agent is UDP, as this will tag all the packet types as UDP, which are classified as non-data packets, and thus will not cause routing protocols such as AODV to attempt route recovery.
802.15.4 Broadcast Bug
Another interesting bug that I found was when causing 20 nodes in the same proximity to broadcast at the exact same instant, whilst using the 802.15.4 physical layer.
This causes a 'Program received signal SIGFPE, Arithmetic exception' error, which is at 'lq = (int)(tmpf * 128);' in 'wpan/p802_15_4phy.cc:499'.
The line before this calculates tmpf which is 'tmpf = p->txinfo_.RxPr/RXThresh_;', with RxPr being in watts (according to here).
Normally this is around 0.000192w, but in this case jumps to 0.281838w, which then causes an error when later cast to an integer. This could perhaps be fixed by checking the overflow condition first, however simply removing the highly unlikely simultaneous broadcasting should do the trick.
802.15.4 AODV Sending Limit
So all seems well, however after some time my simulations just stopped receiving packets. This was interesting as it's the same sequence of data being sent at the same time intervals every period. After some investigation I found a way to make the simulation work, but I'm not sure of the side effects.
In p802_15_4phy.cc, on line 509 do a check to see if HDR_LRWPAN(p)->rxTotPower == 0 and if it is set lq2 to 255. This is due to the following step sometimes causing a division by 0 error on this line.
In the same file, on line 772 override the "else if (p != rxPkt)" by putting && false in the if, or similar. According to the comment this section checks if the packet is corrupted or un-detectable, so this modification will most likely have side effects, but for now it works.
Other Fixes
For the random TCL error below when using 802.11 comment out 'tcl.evalf("%s reset-state", str);' at common/mobilenode.cc:205
_o1725 off
ns: _o1728 reset-state: 
(_o1728 cmd line 1)
invoked from within
"_o1728 cmd reset-state"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o1728" line 2)
(SplitObject unknown line 2)
invoked from within
"_o1728 reset-state"
Still working on the remaining 802.15.4 errors.
Quick install guide
apt-get source ns2
apt-get package-dep ns2
gedit ns.../common/mobilenode.cc
gedit Makefile.in
./configure
make

For More: Click here
For TinyOS Programming, Click here

Comments

Popular posts from this blog

Link State Routing Protocol

Link state routing is a method in which each router shares its neighborhood’s knowledge with every other router on the internetwork. In this algorithm, each router in the network understands the network topology and then makes a routing table depending on this topology. Each router will share data about its connection to its neighbor, who will, consecutively, reproduce the data to its neighbors, etc. This appears just before all routers have constructed a topology of the network. In LSP, each node transmits its IP address and the MAC to its neighbor with its signature. Neighbors determine the signature and maintain a record of the combining IP address and the MAC. The Neighbor Lookup Protocol (NLP) of LSP derives and maintains the MAC and IP address of every network frame accepted by a node. The extracted data can support the mapping of MACs and IP addresses. The link-state flooding algorithm prevents the general issues of broadcast in the existence of loops by having every node mainta...

Matter: A next generation home standard

The smart home is evolving. To date, if you've wanted to get into developing a smart home, you've had to deal with the multitude of smart home ecosystems, and making sure that each device you buy is compatible. That, however, may soon change — thanks to new smart home standard called Matter. Matter isn't available just yet, but when it is finally released, it could completely change how you buy smart home products, for the better. All of the best smart home devices could soon support the standard, helping them all work together nicely, and ensuring that no matter what products you buy, you'll be able to use them. Matter is basically the name of a new smart home connectivity standard . But this standard is a little unlike others. That's because of the fact that it's being developed by the Connectivity Standards Alliance, which counts hundreds of companies as members. That includes the likes of Google, Alexa, and Apple. So, whether you prefer to use Google Assista...

New interactive stickers for Stories

Instagram has introduced several new features to Stories, offering interactive ways to share music, photos, and videos. One of the most interesting additions is a feature called Reveal , which blurs the content of a story post and requires viewers to DM the person who shared it in order to see it. Instagram's head, Adam Mosseri, has emphasized the importance of direct messages on the platform, with stories and DMs driving most of Instagram's growth. Requiring a DM to view content represents the next step in boosting engagement, and creators are likely to use it as a tactic to increase their stories' engagement. Another new feature, Frames, adds a Polaroid overlay to images that initially appear gray. Users can shake their phone to reveal the photo, resembling the process many people associate with Polaroid pictures, despite the fact that shaking Polaroids is not recommended by the company during development. Instagram has also introduced a music-based template feature calle...