Sunday, May 24, 2015

Expeditions with Software Defined Radios (SDRs)

I have been working with wireless networks and related stuff for several years. However, in all those works, I was working with radio transceivers which are dedicated to a particular standard or a protocol specification. Such a radio transceiver covers the communication protocol stack from the physical layer up to some significant parts of the data-link layer in many systems. Software implementations cover the rest of the protocol stack and has a very little control over the hardware controlled bottom most functionality. That is why we have to change the radio transceiver hardware in every time we need to switch from one wireless standard to another. Simple changes in software does not help in most cases. This is where, software defined radios (SDRs)  comes into play a role.

Scientists and engineers who are working in developing new wireless communication technologies and standards have to continuously perform experiments with their designs in order to evaluate and fine tune them. They cannot fabricate a new radio transceiver chip in every time they want to test a slightly changed design. They need something easier to change and play with that gives the same functionality as real and technology specific radio transceivers. A software defined radio (SDR) is a combination of a special radio hardware and a software tool which completely revolutionize the way we play with wireless medium. SDRs have moved many of the hardware oriented functionality into the software layer in such a way that makes the user to switch between different wireless technologies easily. We can easily configure an SDR to use a specific frequency, modulation technique and various other things making it whatever we want. Hardware part of an SDR simply perform ADC and DAC conversions of the wireless signals and let the software to handle everything else making it extremely flexible.

When considering SDRs, we have to discuss about two things that are SDR hardware and various available SDR software. One of the most important software toolkit for SDR works is GNURadio. It is a free and opensource tool which supports various SDR hardware devices which we can find in this list. Among those, USRP devices from Ettus research are the most expensive but most powerful hardware according to what I have read. The simplest and easy to acquire devices are rtl-sdr dongles which are widely available as digital TV receivers. HackRF is a device which provide great functionality for most SDR based experiments which has a moderate price than USRP devices. Recently, we received a HackRF One device to our lab which significantly increased our capability to perform wireless research works. I would like to leave this article with a little note on the steps I followed on my first experience with HackRF One device. I created a simple FM radio receiver and was able to listen to FM radio stations. I learnt about this example from Michael Ossmann, the inventor of HackRF device who has a very nice website that provide so many useful information and learning materials.


Here is how I did it. First of all, I need to have GNURadio running in my system. Since I found installing GNURadio on a Linux system very complicated and tiresome, I decided to use a GNURadio pre-installed live Linux image to boot my computer and work. Various options are available to this end as you can find from the following link. I downloaded an Ubuntu 14.04 image with GNURadio version 3.7.6.1 pre-installed and then made my USB drive bootable with it by using the Ubuntu Statup Disk Creator tool available on my Ubuntu machine. After booting the system with the USB we are good to go. It's time to open the provided configuration file for an FM radio receiver using GNURadio Companion (GRC) tool. You can download the configuration file from here. After opening it from GRC tool, plugin the HackRF One device via the USB connector and simply click the play button to execute the flow graph. Now, you should be able to listen to FM radio stations by tuning with the slider.

I have a long way to go to be able to use this combination of hardware and software for advanced SDR works. I'm already impressed by these wonderful gadgets and I can't wait to see what I can do with them more.

~****~

Creating a password protected directory in Apache2 server

While working on some assignment preparation for a networking course, I wanted to create a password protected directory inside Apache2 server's webroot directory. Even though this is something straightforward and many people have documented it, still I faced many difficulties while trying to configure it. Therefore I decided to note down the steps for my own future use. So, here we go.

Login to the web server and take the following steps.

cd /var/www/
sudo mkdir test-directory
cd test-directory/
sudo nano protected-file.txt

This is the file which we will protect. For the moment, just enter some text inside this file and save it. Now we create another important file inside this directory as follows.

sudo nano .htaccess

The content of this file should be as shown below. The path should be placed according to where we will place the .htpasswd file in later steps.

AuthUserFile /path/to/our/password/.htpasswd
AuthType Basic
AuthName "My restricted Area"
Require valid-user

Now let's move out and change some access privileges.

cd ../
sudo chmod 777 -R test-directory/

Now we should go to the place we decided to create the password file.

cd /path/to/our/password/
sudo nano .htpasswd

Enter the uname  and password line inside this file. We can use some online tool to generate the content of this file based on the username and password we are going to use. One such an online tool is this. Then let's provide permission for this directory too. Finally we should restart the apache2 server.

chmod 777 -r /path/to/our/password/
sudo /etc/init.d/apache2 reload

Now we can go to the password protected directory using the web browser which will prompt for the username and password before allowing to view the content of that directory.

References:
[1] https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles
[2] http://www.web2generators.com/apache-tools/htpasswd-generator


Saturday, May 2, 2015

Listening to the Giants

Our infra-sonic recording setup
Elephants are very important type of animals in our world as they are the giant mammals living on the surface of the Earth. I'm so lucky to have elephants in my country which is not an opportunity everybody get. Some people in this world have to visit a zoo to see this kind of a giant mammal while we have a lot of them in our wildlife reservoirs. In addition to the wild elephants, there are many domesticated elephants owned by different people. The most popular national event that features elephants is the Kandy Perahera where many elephants walk along the traditional dancers and other cultural displays.

We, as a research group, developed our interest on elephants due to their involvement in very important problems in our society. Wild elephants have become an unavoidable factor in the daily life of a lot of rural people in Sri Lanka as they experience conflicts between humans and elephants very often. Such events have resulted in deaths of both humans and elephants in addition to huge financial losses created by elephant attacks to crops and human habitats. Another important thing that draws our attention is the collisions between wild elephants and locomotives that carry passengers and goods through rural areas specially in the northern and central part of the island. All these things highlight the importance of studying elephants to find smart ways to mitigate their problems. In particular, we are interested on the communication of elephants based on infra-sounds which is not sensitive to the human ear. If we gain a capability to detect their communication, we might be able to do to various useful things such as locating them in the jungle, protecting humans from their raids, etc.

Preparing for the experiment
Aligned with this goal, we have conducted several studies on infra-sound emitted from wild elephants and last Thursday we made another step along this path. We received an opportunity to perform a recording near a domesticated elephant. Unlike any other elephant which we may have encountered, our recent visit was to the single most important elephant of our country. That is the Tusker which holds the Tooth Relic at the Kandy Perahera. They call it Nedungamuwe Raja which lives near its owners house in the village called Nedungamuwa in Gampaha District. As we heard, this one is the tallest domesticated elephant in South Asia. It was born in India and handed to a monk in Sri Lanka by a Maharaja. Currently it belongs to an Ayurvedic physician.

Well, that's me :)
Three people from our lab that is Poshitha, Chathura and me joined for this visit. We carried our infra-sonic recorder device with a video camera and a laptop. The two persons who are in-charge of taking care of the elephant was so helpful during our work. We set up the infra-sonic recorder and video camera on a tripod and connected it to the laptop near the elephant. We waited for about an hour to collect as much data as possible. Since we were just recording the sound and taking video, we didn't have to disturb the elephant on its daily routine. It was eating all the time during the recordings. We bought some fruits from a nearby shop and offered to the elephant too. After the recordings, the owners family offered us some refreshments with sweets and cold beverages at their house. Their kind help was so important to us to get this work done. It was a wonderful experience since it's usually not easy to see the tusker which carries the Tooth Relic in this form outside the Perahera in Kandy.

We still don't know whether the recorded data has some indication of the presence of infra-sonic emitted by the elephant. Poshitha will need more time to analyze those data and extract what we want. Whatever the result would be, I'm so happy about this field visit which was a very nice experience that makes research more interesting than sitting in a lab in front of a computer.

~******~