Saturday, March 2, 2013

Entered to Kyungpook National University (KNU)

About a week ago I left my country and my work place and moved to a new place to start another chapter of my life. Now I'm a graduate student at Kyungpook National University (KNU) in Daegu city, South Korea. I will be staying here several years until I complete my masters and doctoral studies.

I arrived in the beginning of the Spring season and therefore it's still cold everywhere. There are some Sri Lankan students who are studying here including a past student of University of Colombo School of Computing (UCSC). Their existence made my life easier since they knew all the necessary things  to survive here before I arrive.

I'm staying in a dormitory of KNU and therefore it's much easier to carry on my work. Dormitory has all the facilities and it's very comfortable. The three meals for a day is provided by the dormitory cafeteria. I'm working with Professor Dongkyun Kim and he is my academic adviser. He is leading the Wireless & Mobile Internet Laboratory (MoNet) in the department of computer science and engineering where I'm involved with his research work. The other members of the MoNet lab includes some graduate students from Korea and also Pakistan. All of them are so friendly to me.

By any mean KNU is a beautiful university. It is so huge and has almost all the components of a university such as medical, engineering, humanities, etc. Still I got only few chances to go around the university. There are so many things to explore. Until this article all the previous articles I've written are don while staying in Sri Lanka. But from now on I will be writing about various things from here in my new place.  

Tuesday, February 5, 2013

My Love Over A Noisy Channel


    I'll tell you the story first.

    There's a beautiful valley in between two mountains. An armed force called Red army have settled their camp in this valley. They have a man power of 700 soldiers. There's another armed force called White army which resides in the mountains. One part of the White army resides in one mountain having 500 soldiers while the other part of the White army resides in the other mountain also having 500 soldiers. Therefore altogether White army has 1000 man power. Let's call the two mountains as mount-1 and mount-2.

    Now here's the rules of this world. In any battle the victory is on the hand of the party who have highest man power on the battle field. The loser's whole man power in the battle field gets wiped out while the winner's soldiers don't get any casualty. Therefore the victory in a war is just a matter of having more man power in the field than the enemy in this imagined world. Additionally in this world there's no any distance communication like wireless communication, birds who bring letters, smoke messages, etc.

    OK, back to the battle field. Now the commander who is in-charge of mount-1 of the White army want to destroy the whole Red army who have occupied the valley. But he has only 500 soldiers which is not enough to face the 700 soldiers in Red army. However there's another battalion of the White army in mount-2 with 500 more soldiers. So, the obvious solution is to ask for help from the other White army battalion. If both White forces attack at the same time, according to the rules whole Red army will get wiped out and the White army wins.

    The commander in the mount-1 is really happy about his brilliant idea. Now he should pass his battle plan to the mount-2 commander since they both have to attack the Red army at the same time. Suppose the battle plan message says "Let's attack Red army on next Friday morning at 5.34am". The commander of mount-1 chose a soldier and gave him the message and ordered to go to mount-2 to give the message to that commander. There's only one way to get to mount-2 from mount-1. The poor soldier goes through the enemy lines putting his life in danger. What a brave man. If he gets captured by the Red army definitely they will kill him.

    OK, so now we have some theoretical questions. On next Friday at 5.34am can mount-1 commander launch his attack ? How does he know that the soldier he sent has successfully delivered the message ? If the message hasn't delivered, the complete White army battalion in the mount-1 is going to be wiped out by the Red army. Now suppose the message is actually delivered by that brave man to the mount-2 commander. So, on next Friday at 5.34am can mount-2 commander launch his attack ? How does he make sure that mount-1 commander will do it as mentioned in the battle plan since he still doesn't know whether mount-2 commander got the message ? This is a risky situation.

    So, mount-2 commander writes an acknowledgement massage saying that "OK, my battalion too will attack on next Friday morning at 5.34am". Now again a solder is sent from mount-2 to mount-1 in the same routine with the acknowledgement message. Okay, then next Friday at 5.34am can mount-2 commander launch his attack ? How does he know whether his acknowledgement message has reached the mount-1 commander ? If the soldier with the acknowledgement message has got killed on the enemy line, the mount-2 force might get wiped out if they attack alone in next Friday. So, now what should happen ? The mount-1 commander has to acknowledge the acknowledgement message. When will this message loop end ?

    I heard this story two times from a very impressive lecturer I've met in my undergraduate university life. He's Dr. Chamath Keppitiyagama. For the first time he mentioned the story at the 'Operating Systems' lecture back in my second year. Then again he mentioned the story in my fourth year during 'Communication Networks' lecture.

    This story about the two armies is a very good way to explain the situation of sending data over noisy communication mediums like copper cables, radio signals and even fibre optics. The data we are sending might get lost or get altered while they are travelling through such mediums. Therefore it's a huge challenge to make sure that whatever the data we're sending has arrived the destination safely.

    Coding Theory is the field in Computer Science which deals with this challenge. We use various error detecting and error correcting codes to make sure what we have received from a sender over a noisy channel is exactly what he or she has sent from that side. When the Internet data traffic goes through the complex networking infrastructures, it's absolutely necessary to detect and correct possible errors that occur. Otherwise the communication networks we're using today for our everyday purposes may not become usable at all.

    Anyway we have to face the reality. All the kinds of error detecting and correcting codes we are using today in Coding Theory can only reduce the probability of errors to some extent but they can not reduce error probability to zero. That means having all these sophisticated mechanisms, we are still exposed to the risk of data loss and data alteration during communication. This is all due to the availability of noise in our communication mediums. When we are using networked communication, errors can occur any time if noise is there.

    Due to these reasons, if you send an SMS or email to someone saying "I love you!" there's a probability for it to reach your partner's computing device as "I hate you!!". Of course the probability is very smaller. Remember the probability for a tsunami to occur in Indian ocean which can affect Sri Lanka was mathematically ignorable. But it happened.


Tuesday, January 22, 2013

Converting OGV files to AVI on Linux

Recently when I was presenting a research work I wanted to show a video on how to do it practically. For this purpose I used Record My Desktop tool. However the video output from this tool were in OGV file format which is not that commonly used outside Linux environments. Therefore I wanted to convert these video files in OGV format to some commonly used video file format.

After searching on the web I found that the command line tool mencoder can be used to convert between different video file formats. It seems this tool comes as a support program for the video player called MPlayer. Therefore when we do "man mencoder" in the terminal, the manual pages gives details about both Mencoder tool and MPlayer.



For example consider we have file called my_video.ogv and we need to convert it to the AVI format so that the resulting file should be my_video.avi. We do the conversion by issuing the following command with the given parameters.

mencoder my_video.ogv -o my_video.avi -oac mp3lame -lameopts fast:preset=standard -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=4000

I have no clear understanding on what each parameter represent in the command. However this is the way I found it in the web somewhere.

Friday, December 14, 2012

Memories of ICTer 2012 Conference

Title slide of my presentation
Yesterday I attended to ICTer 2012 conference since one of the papers I co-authored is in the proceedings of the conference. Our paper title was TikiriPower – Using TikiriDB abstraction on Smart Home systems. This research was done by the SCoRe research group some time back. First author of the paper was Mr. Lakmal Weerawarne who worked with us for a considerable amount of time. However since now he has left for studying for his Ph.D, I was the person next in the line to conduct the presentation at ICTer 2012.

Our paper was scheduled to be in the Systems and Performance Evaluation session. Prof. Sudhir Dixit from HP labs India was the invited speaker of the session. Even though initially I was a little bit excited since that was the first time I was presenting a paper in this kind of a huge event, after few minutes I gained the confidence to move ahead in the latter part of the presentation. In the Q & A session after my presentation, Prof. Athula Ginige raised some questions but luckily I managed to provide him explanations.

In addition to presenting a paper, there were more benefits of attending the conference. Besides listening to other presentations, I tried my best to talk to other attendees of the conference as much as I could. Among other attendees, three people were so much friendlier to me. Dr. Gordon Hunter had visited with his Ph.D student Mr. Dilaksha Attanayake from Kingston University, London. Both of them were so nice people. Both of them along with few more co-authors had published a paper titled "A Novel Web-Based Tool to Enhance Learning of Mathematical Concepts" in ICTer 2012. So, they were here to present it. Another interesting person I met is  Dr. George Weir from University of Strathclyde, Glasgow. He didn't present any paper but he delivered a keynote speech and conducted an interesting workshop.

Altogether I'm sure the people I met, the experiences and knowledge I gained will leave a footprint in my memory for a long time.

UPDATE:

Mr. Dilaksha from Kingston university had taken some pictures at the conference during my presentation. He emailed me the pictures later.

Tuesday, December 11, 2012

Disable kernel messages and getty loggin through UART port in Raspberry Pi

When we are going to use the UART Rx and Tx pins of Raspberry Pi device for some purpose like communicating with an external device, we face a little problem. Linux operating systems send it's kernel messages in boot time to the serial port. Additionally it allows the user to login to the system though a serial console provided though the UART pins. Therefore when we use the UART pins for some other purpose we may get data belongs to the operating system.

After searching the web, the solution I found is to disable this Linux kernel messages coming to the UART port and also the serial console login facility. Here's how I did that.

To disable kernel messages coming to the UART port, open the following file by issuing the command,

sudo nano /boot/cmdline.txt

Edit the content of the file by removing all the parameters which involve ttyAMA0 device. So, the resulting content would look like the following.

dwc_otg.lpm_enable=0 rpitestmode=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait

Now save and exit from the nano editor.

To disable the serial console through the UART port, open the following file by issuing the command,

sudo nano /etc/innitab

Find the following line in that file.

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Now add a '#' character in front of that like to comment that out so that it looks as follows.

# T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Now save and exit from the nano editor. After editing these two files we are done. When the next time you reboot the Raspberry Pi, you will be able to use the UART port without any disturbance from system level.


Thursday, December 6, 2012

Boot-Repair did the trick !!! :)


In my laptop I had Ubuntu 10.10 for a long time. Recently I wanted to use Ubuntu 12.04 LTS version and therefore I installed it in a separate partition in my machine. So, when I start the machine Grub shows up with the options to select either Ubuntu 10.10 or Ubuntu 12.04 to boot.

However after few days I lost my interest on the new interface in Ubuntu 12.04. Therefore I moved back to use my previously used Ubuntu 10.10 version. Since I didn't need Ubuntu 12.04 installation any further, I formatted that partition where Ubuntu 12.04 is installed. I did that while working on Ubuntu 10.10 version. However when the next time I start my computer I got a prompt which shows 'Grub Rescue>' text.

As I understand, when I format my Ubuntu 12.04 partition the Grub has been damaged. Because of this I couldn't even access my Ubuntu 10.10. At first I thought I would have to do so many configurations to fix this problem. However after searching the web for a while I finally found the solution.


There's a free tool called Boot-Repair which can fix frequent boot issues. This page (https://help.ubuntu.com/community/Boot-Repair) provides all the necessary information to use this tool which has very few steps. So, according to the instructions given I created a live USB stick with an Ubuntu image and then booted the laptop with it. When live Ubuntu USB is booted I went to the 'try ubuntu' option without installing it. After this live Ubuntu desktop is loaded, I installed Boot-Repair tool on this live version. Then I ran the Boot-Repair tool and had to just click a single button. When I restart the machine without using the live USB stick, the Grub showed up providing me the option to go to my ever loving Ubuntu 10.10 version.

That's it. Thanks to Boot-Repair tool I could solve the issue.

Monday, November 12, 2012

Started to use Google App Engine !

Today I did some readings about Google App Engine and started learning to develop applications for it. There are three languages supported in the Google App Engine which are Python, Java and Go. Since I'm a Python lover, I directly moved in to learn about what I can do with Python on Google App Engine.

There are lot of resources available in the web and therefore it is not a necessary to write about it. So I'm directly writing down what are the things I learned today by exploring Google App Engine. First of all I downloaded the Google App Engine SDK from here. Since I'm using Linux, I downloaded the version for the Linux platform which comes as a Zipped archive.

After uncompressing the Zipped folder, we can see different Python based tools available on this source code. So, now I'm writing a simple program which prints some text on the web browser.

1) Create a new directory in some where in the file system. Say we created it in desktop naming as my-application.

mkdir my-application

2. Now create a file named as app.yaml inside that directory and add the following content to it. Please note that application name is given as my-application. You have to give a unique name for this application.

 application: my-application  
 version: 1  
 runtime: python27  
 api_version: 1  
 threadsafe: yes  
 handlers:  
 - url: .*  
  script: helloworld.app  
 libraries:  
 - name: webapp2  
  version: "2.5.1"  

3. Now create another file named as helloworld.py which will contain the codes of our application. Add the following content to that file.

 #!/usr/bin/env python  
 import cgi  
 import datetime  
 import webapp2  
 class MainPage(webapp2.RequestHandler):  
  def get(self):  
           self.response.out.write('<html><body><h4>My First Google App Engine Application</h4>')  
           self.response.out.write('</body></html>')  
 app = webapp2.WSGIApplication([  
  ('/', MainPage)  
 ], debug=True)  

4. Now our source codes are ready. We have to test this app. Google App Engine SDK comes with a server which can be used to test our application before actually deploying the application on Google cloud. To use this server, go into the uncompressed Google App Engine SDK source folder. There's a tool named as dev_appserver.py. Run this python script giving the path to our new application as follows.

python dev_appserver.py /path/to/my-application

Then this server will start. Now open a web browser and go to the following URL.

http://localhost:8080/

The text "My First Google App Engine Application" will be printed on the browser. That means our application is ready.

5. Now we can try deploying our simple app on the Google cloud. To do that we have to go to the this URL (https://appengine.google.com/) and sign in. Then click on the "Create Application" button. As the application identifier you have to give a unique name for the application. This name should be defined as the application name in app.yaml file. For example we might use my-application as the name if nobody has used that name for an application on Google App Engine.

The give some Application title and then click on "Create Application" button. Now google is ready to host our application.

6. To upload our application codes to the Google cloud, we can use appcfg.py tool which also came with the Google App Engine SDK. We run it giving the path to our application as follows.

python appcfg.py update /path/to/my-application

After this tool completes running your application is gone to the Google cloud. You can see it from the appspot.com domain name with the application name in front of it. For example if the application name is my-application then you can access your app by typing the following URL on the web browsers address bar.

http://my-application.appspot.com/
  
If every thing is fine, you will see the text "My First Google App Engine Application" on the web browser again.