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 Gateway IP address is Our network address is Netmask is Broadcast address is 

I need my DHCP server to assign IP addresses to requesters in the IP address range from to 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;  
 default-lease-time 86400;  
 max-lease-time 604800;  
 subnet netmask {  
     option subnet-mask;  
     option broadcast-address;  
     option routers;  

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 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.


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

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 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.


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.