Monday, September 24, 2012

Running Linux on a Raspberry Pi

Raspberry Pi is a modern single board computer which can run Linux on it. No need to explain the advantages of Linux comparing to any other operating system that can run on low resourced embedded platforms. Unlike other embedded platforms where Contiki or TinyOS can run, this new platform Raspberry Pi with Linux provides almost all the capability we can have on a standard computer.

Recently we received a Raspberry Pi to our lab for a project work and I received the opportunity to work with it. It is a product of Raspberry Pi Foundation in UK. There are different customised distributions of Linux available for Raspberry Pi device. We boot this device from a live SD card. It has ports to connect different peripherals like audio and video devices, keyboard and mouse. However most prominent way to use this device is to connect it to a LAN via the Ethernet port and then log in to the device remotely from a SSH terminal.
 In addition to the standard ports available in the board, Raspberry Pi contains some more GPIO pins which can be used to connect different other external devices to the Raspberry Pi. By searching on the Internet I found various interesting applications and projects  done by using Raspberry Pi devices. Therefore it seems like Raspberry Pi is going to dominate the embedded systems world.


Friday, September 21, 2012

Configuring a DHCP server on Ubuntu 11.04

In our LAN we add a static IP address to our machines and access the network. However yesterday we received a newer device to the lab which is preconfigured for DHCP. So, I wanted to connect it to our LAN for testing without changing it's configurations. Actually to change this devices configurations I have to login to it via SSH that means it has to be connected to the network. Therefore the only way I had was to temporarily set up a DHCP server in our lab so that our new device can acquire a IP address from the DHCP server.

I had to search the web to find how to do it since I hadn't done such a thing before. To avoid forgetting what I did, I'm writing it down here. The machine I used to set up the DHCP server is running Ubuntu 11.04. So, here's the steps I followed.

1. Open a terminal and issue the following commands to install the DHCP server.

      sudo apt-get update
      sudo apt-get install dhcp3-server

At the end of the installation it will show an error message saying it couldn't start the DHCP server. This is OK since we haven't still configured the server. After configuring we can start it manually.

2. Now issue the following command to open the configuration file of the DHCP server.

      sudo nano /etc/dhcp/dhcpd.conf

3. It's time to add our configuration details of the DHCP server. Here's the information I have about my requirement. The IP address of the DNS server is 192.248.16.91. Gateway IP address is 10.16.79.254. Our network address is 10.16.68.0. Netmask is 255.255.255.0. Broadcast address is 10.16.79.255. 

I need my DHCP server to assign IP addresses to requesters in the IP address range from 10.16.68.60 to 10.16.68.65. So, remove the current content in the opened file and add the following content. I have included my configurations and therefore anyone else have to put their correct information.

 ddns-update-style none;  
 option domain-name-servers 192.248.16.91;  
 default-lease-time 86400;  
 max-lease-time 604800;  
 authoritative;  
 subnet 10.16.68.0 netmask 255.255.255.0 {  
     range 10.16.68.60 10.16.68.65;  
     option subnet-mask 255.255.255.0;  
     option broadcast-address 10.16.79.255;  
     option routers 10.16.79.254;  
 }  

After adding the content, save and exit from the nano editor.

4. Its time to start the server. You can start it by issuing the following command.

      sudo /etc/init.d/isc-dhcp-server start

5. Now we can check whether the DHCP server works. For that I connected another computer to the LAN and put it on DHCP mode. So, this second computer should acquire a IP address from my DHCP server. By issuing a 'ifconfig' command on this second machine I realised that it has acquired the IP address 10.16.68.62 which is between the rage I mentioned in the DHCP server. So it works.

We can see what is going on from the DHCP server running machine by issuing the following command.

      sudo tail /var/lib/dhcp/dhcpd.leases

It showed the details of the second machine which acquired a IP address from the DHCP server. Additionally following command can be used to see the activities of the DHCP server.

      tail -n 100 /var/log/syslog

So, now our DHCP server works fine. The actual reason for setting up a DHCP server in our lab was we recently received a Raspberry Pi single board computer. The operating system I used to boot it is preconfigured for DHCP. So, that's why I needed a DHCP server to test our Raspberry Pi.




Thursday, September 6, 2012

Simulating Wireless Networks With GloMoSim

During my research seminar days I came across two important research papers which introduced me to a wireless network simulator which I hadn't use before. First paper was "Hierarchical Geographic Multicast Routing for Wireless Sensor Networks" presented by Ravinda while the other one was "Design and analysis of a leader election algorithm for mobile ad hoc networks" presented by Chathuranga. In both of these papers, the evaluations of their solutions are performed using the simulator called GloMoSim. So, I wanted to try this tool.

GloMoSim is an even-driven, packet-level simulator. It is written using a language called PARSEC. The reason to use PARSEC is it is a language specially designed to implement simulators. GloMoSim comes with various implementations of routing protocols, MAC protocols, etc. Therefore it is pretty easy to setup a network and simulate different scenarios. In addition to those default features GloMoSim can be easily extended by adding our own protocols and applications for our research purposes.

In this article I will write down the steps I followed to run a simple simulation starting from downloading GloMoSim source code. This article which I found while searching on the web helped me a lot. I installed and worked with GloMoSim on an Ubuntu 10.10 machine. So, here we go.

1) Go to GloMoSim download page and download the  2.03 version which was the latest one available by the time I write this. Then extract the compressed directory to get the directory named as glomosim-2.03. Let's say you have extracted it to your desktop.

2) Now open a terminal and go on to this uncompressed directory. Inside this directory there's a separate directory named as parsec which contains the PARSEC compiler which is used to compile GloMoSim. For Ubuntu, we use redhat-7.2 version of it. So go to this directory located at "~/Desktop/glomosim-2.03/parsec/redhat-7.2/bin".

  cd ~/Desktop/glomosim-2.03/parsec/redhat-7.2/bin

This directory contains two files parsecc and pcc. Copy them to /usr/bin directory.

  sudo cp parsecc /usr/bin/
  sudo cp pcc /usr/bin/

3) Now we need to add the directory path to the environmental variable. So, open the .bashrc file by issuing following command.

  gedit ~/.bashrc

Add the  following content to the end of this file.

  PCC_DIRECTORY=~/Desktop/glomosim-2.03/parsec/redhat-7.2
  export PCC_DIRECTORY

Now you have to restart the machine. To avoid restarting the machine, you may add that on the terminal instead of adding to the .bashrc file.

4) It's time to compile GloMoSim. So, do the following.

  cd ~/Desktop/glomosim-2.03/glomosim/main
  make

If every things are done properly, you will see the compilation process. You have to wait until it completes. Then our initial works are over.

5) Now we can run a sample simulation on GloMoSim. For that go to bin directory as follows.

  cd ~/Desktop/glomosim-2.03/glomosim/bin

There's a file named as config.in which contains the configurations of a simulation. Another file called app.conf contains the configurations of each node in the simulated network. You can find these two files in this current directory. GloMoSim use those configurations to simulate a network. Now lets run the default simulation configured in these files. So, issue the following command.

  ./glomosim config.in

You will see an output like the following on the terminal when the simulation runs.





















For our evaluation purposes, the statistics of the simulation is written to a file named as glomo.stat which we can open and view the data statistics.

  cat glomo.stat

Contents of the file may look like the following.


















More details of the simulator can be found by reading through the GloMoSim website. Additionally those two configuration files I previously mentioned contains lot of comments which are pretty much self documenting. Therefore it's worth reading through all these things.

I'm hoping to write another article about adding a new application layer functionality to simulated nodes in GloMoSim. Until then, that's all I got for now.

Friday, August 10, 2012

Myna's Struggle, Two Girls and Computer Science


Today morning I could just come closer to the main entrance of UCSC building complex. I heard a huge noise. There were three birds on the ground in front of the auditorium. Two were Crows and the other one was a Myna. The crows were pulling the Myna from two sides and Myna tried it's best to escape from this trouble. I didn't think twice even though I could be interrupting some natural event happening in the environment everyday. I didn't care. I just wanted to save the Myna.

When I run towards them, the two crows flew away while the Myna was still on the ground. One leg of the Myna was trapped in some kind of a nylon string. Because of that it was in trouble. I think the Crows were trying to take the advantage of it. Anyway I tried my best to remove that string but it was not that easy. And also the bird seemed so weak and I thought it was going to die. At this time a good idea came to my mind. The Department of Zoology in University of Colombo has lot of bird lovers. I have seen some events they organise every year about birds and different kinds of other animals. I thought they could do something. So I took the bird and walked towards the Department of Zoology.

Near the department, there were two girls having a chat and I talked to them. When they saw the bird they quickly responded by taking it from my hand. They said they can fix that nylon string problem and take care of the bird. Then they ran into their department building. So, there was nothing left for me to do about the bird.

While I was walking back to our UCSC building, some nice things came into my mind. When I was doing Mathematics back in my A/Ls, I felt like Mathematics is the greatest thing in this world and any other subject is just nothing in front of it. When I started to do Computer Science in university I felt like CS is the most powerful collection of knowledge within the human knowledge boundary. Sometimes it felt like we know a huge part of human knowledge base when I approach my final year. Today I learnt the lesson of the importance of experts in different fields thanks to the Myna, two Crows and the two girls. If we didn't had people with different interests and passions on different subjects this world would have become so different than today. Thanks to this diversity of passions, humans are still ahead of any living being we know in this universe.

Friday, August 3, 2012

An Unforgettable Collaboration

About a year ago I received the opportunity to work with a wonderful person on a wonderful research journey which is now about to end. Lakmal Weerawarne (for me, Lakmal Aiya) worked as a research assistant at WASN lab playing a leading role in our most of the research works in Sustainable Computing Research (SCoRe) group. He is now leaving us to work for his Ph.D at University of Binghamton. I closely worked with him in most of the project works throughout past time period producing lot of unforgettable memories which will last a life time. All those moments of challenges, difficulties and happiness move around my head just like everything happened today. This is my personal memoir of that wonderful collection of life experiences I earned working with him.

    During my third year first semester at university everybody in my batch were so busy finding a place to do their internship training in the second semester. I didn't had any rush or uncertainty in my mind since I had decided how and where I should spend my internship period. It is Wireless Ad-hoc Sensor Networks (WASN) laboratory at UCSC. I had been voluntarily contributing to some of research works at WASN lab since my second year and therefore it wasn't a new place to me. I knew that if I need a semester full of research, WASN is where I should be. In this way I became a member of WASN lab in my internship started in March, 2011.



    From the beginning Dr. Kasun, my supervisor assigned me to different project works where I played a supportive role to the research assistants who were mainly working on those projects. He had a plan to start a new project of deploying the database abstraction of sensor networks on a smart home application. This work goes beyond the conventional sensor network hardware platforms we were working with those days since we needed lot of specialized hardware and related low level software components to make this new project a success. Dr. Kasun said that a new research assistant will join with the lab to work on this project from the Physics department of University of Colombo. I was supposed to work with him in this project after this recruitment.



After about a month, Lakmal joined with us. Even though he was not coming from a computer science background, he seemed a quick learner. He easily understood everything we were working on our sensor network projects and immediately jumped into the subject matter. He was really passionate on embedded and ubiquitous systems related works making him the main contributor in this smart home project. We become good friends from the beginning. The early days of the project went smoothly without any issues and we were generally easy going. Later on, unbelievable challenges and tough times occurred in our works and when I look back about those days, I feel we would not get through those tough times if both of us didn't had the required amount of patience and the trust on the capabilities of each other.

    A typical day starts with some particular part of our problem and we work on it carefully. Lakmal set up hardware components and write low level drivers for them while I work on the high level database abstraction layer works. When we integrate all these things and program our applications to MCU in sensor nodes, unexpected results come out. Sometimes it takes several hours or even worse several days to figure out which went wrong in which component. We missed our lunch so many number of days since both of us didn't wanted to stand up from our seats to go for the meals leaving our mind blowing problem alone in the lab. When we felt too tired, we went to the canteen at about 4 or 5pm and ate something while drinking tea. However our typical days didn't end here. We usually left university at about 8.00pm after struggling with our project works. If the university does not close at 8.00pm, I'm pretty sure we would have even stayed all the time working on our project. There's a nice array of words which can explain our situation in those days briefly. "When the going gets tough, the tough get going" That's exactly what happened. The more the problems got tough, the more we got encouraged to fix them.



    A different kind of a task was done during this time period adding another set of experiences. A school in Ampara district had received some grants to buy few computers for their school. The principal of that school had heard about our Linux based PokuruPC project where a single computer system unit can be used by 4 people with 4 monitors, 4 mouses and other peripheral devices. Even though they had money to buy about 5 ordinary computers, if they use PokuruPCs they could have 12 computers. Dr. Kasun asked our research group to visit that school in Ampara to set up their computer lab. So our group including Lakmal and me went their and stayed at Ampara for about 2 days and we did a little workshop for the school kinds to make them familiar with computers and Linux. I wrote an article about this journey those days which you can find here.

After my internship period I started my 4 year at university and therefore I couldn't be at the WASN lab all the time. However still our collaboration on the project works continued. Another nice thing was the WASN course in the 4th year first semester. While Dr. Kasun handles the lectures of that course, Lakmal was the person who carried out all the practical stuff. When comes to course works I think he is a little bit tough guy. All the reports and other stuff had to be properly prepared and after each practical in every week he asked questions from the students which were not that easy to get through sometimes. We couldn't do some serous work together after I started my 4th year since I had my own works to do. But after some new interns from my junior batch started working at WASN lab we all did some more improvements to the smart home project making it much more usable.

In my short life time in research works at university, I have been working with different people on different projects and I can honestly state that Lakmal is the best research colleague I ever had. I learned a lot from him and he improved my enthusiasm towards research works and academic life to a great extent. So, even though I'm losing a great research colleague I ever had, I wish him success in every step he move towards his Ph.D and the rest of his life and moreover I wish one day we will again get a chance to work on a tough research work and publish together.
"When the going gets tough, the tough get going"


Monday, July 23, 2012

Talk On Enix Operating System

Today in our research seminar, I did a presentation on a research paper. The paper I selected was "Enix: A Lightweight Dynamic Operating System for Tightly Constrained Wireless Sensor Platforms" [link] which is published in year 2010 at ACM SenSys conference. Since Operating Systems is one of my favourite courses I learnt in university, I wanted to present an OS related paper in the research seminar. Additionally, since this Enix OS is intended for wireless sensor network platforms it is related to my final year research too. Therefore I picked this paper.











Enix is currently implemented to run on an experimental platform called EcoSpire nodes. However according to the authors it can be easily ported to other platforms too. Among the features provided in Enix, the most significant work they contribute according my point of view is the virtual memory implementation.

Virtual memory functionality in Enix


Enix supports virtual code memory with the assistance of the compiler. Library functions are compiled in to position independent code (PIC) segments and stored in the Micro-SD card. All the user application calls to these functions are directed to a special run-time loader in the kernel space. This loader finds the required functions in the Micro-SD card and load it to an empty space in memory. Since these functions are compiled in position independent manner, no run-time relocations required. Copied functions can just start running from wherever they loaded. This is how the overhead of run-time relocation is removed in Enix with the assistance of compiler. However I think position independent codes introduce some computational overhead than normal executable codes. In  addition to the virtual memory, Enix provides an it's own file system called EcoFS. 

After my presentation we had a nice discussion where we talked about different aspects in particular Enix and in general about WSN operating systems. Even though I was a little bit nervous before the presentation, I think I could do it without any issue. :) I'm feeling so much happy about it.

Thursday, July 5, 2012

Dr. Erik Billing is here



















Dr. Erik Billing from UmeĆ„ University of Sweden visited here. As I heard he just defended his Ph.D in last January. Even though he writes his name as "Erik", it is pronounced like "Earik" or something. Anyway we were allowed to call him "Erik" just like we pronouns an English name. :)  I received few opportunities to attend to his lectures conducted during this visit. He is mainly interested at artificial intelligence and intelligent robotics like stuff. He is a nice guy.

His Ph.D dissertation


The title of his Ph.D dissertation is Cognition Rehearsed - Recognition and Reproduction of Demonstrated Behavior. Since he gave some copies of his dissertation to some other people, I got a little chance to take a look at it and it was the first time I saw a Ph.D dissertation. Unlike the thesis we are writing for our B.Sc degree, this Ph.D thesis have a very nice professional look. I don't know whether usually doctoral thesis's of any other person is like that. However this one is good.







During his lectures, he discussed about different theoretical aspects mainly in Robotics area. Additionally he did some demonstrations with robotics simulators. He said that he will stay here for few weeks more, so I hope I will get more chances to talk with him and learn something.
There's an article with his idea's here (English translation).