Thursday, October 27, 2016

Emulating Networks using CORE Network Emulator

I've been using Mininet in practical sessions for undergraduate computer networking courses for a while. The tool has great features and provided the required capabilities for our course works. However, Python scrips required to model a network topology was a trouble at some points because some students who were not good at Python programming faced difficulties in understanding networking concepts using Mininet. Meanwhile, I had a requirement to setup an IPv6 based network in a recent demonstration and found that Mininet is not capable of building IPv6 based networks.

After searching for a while on other available options, I found another interesting network emulator called CORE network emulator. This tool provided me easy setup of different network topologies by visually dragging and dropping components on a canvas. Setting IP addresses for each host and router interface could be done by either filling information on a graphical window or by using command line. It seems the features of the emulator are very intuitive and I believe that a student can easily self-learn how to model a network and test different things he/she learned using the emulator.

On a Ubuntu GNU/Linux 16.04 LTS machine, I was able to install the emulator by using the apt repositories easily as follows.

sudo apt-get update
 
sudo apt-get install core-network

We can start the emulator from the command line by using the following command which will bring up the emulator window.

core-gui

There are nice tutorials and resources to learn about how to use this emulator in the web. I will list some of them in the references list below.

References:




Thursday, October 20, 2016

Running a simple C program with Linux kernel

HelloWorld program as the init process
In this post, I'm writing down the steps I followed to compile Linux kernel and run it with a simple C program I wrote. First of all, we need to get some packages. I tried this on a 64-bit Ubuntu 16.04 machine.

sudo apt-get update
sudo apt-get install build-essentials libncurses5-dev libncursesw5-dev
sudo apt-get install gcc-multilib
sudo apt-get install qemu

After installing the required packages, let's create a directory for our working environment and then continue the rest there.

mkdir mylinux
cd mylinux
vim init.c

Inside the newly created C source file, insert the following code which will print the text "Hello World!" once compiled and run.

#include <stdio.h>
 
void main() {
  printf("Hello World!\n");
  while(1);
}

Now, run the following commands to compile the program and create a ram disk which will be used by the Linux kernel later. The selection of the file name init.c is special here because that is the name of the first process created by Linux kernel after booting up.

gcc -static init.c -o init
echo init|cpio -o --format=newc > initramfs


It's time to get the source code of the Linux kernel. Download it into the directory we created previously and build it by following the commands shown below.

wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.8.1.tar.xz
tar xvJf linux-4.8.1.tar.xz
cd linux-4.8.1/
make defconfig
make


The above operation will take a significant time since the Linux kernel is a huge source code base which need to be compiled one by one and brought together to build the executable monolithic image. After the build process completed, you should be able to find the compiled kernel image in the following location.

linux-4.8.1/arch/x86_64/boot/bzImage

Now, let's run our program with the Linux kernel image on QEMU emulator using the following command.

qemu-system-x86_64 -kernel linux-4.8.1/arch/x86_64/boot/bzImage -initrd initramfs -append "console=tty1"

You should be able to see that the Linux kernel boots up and then it runs our init program at the end. Our program prints the "Hello World!" message and then hangs inside the infinite loop.

Saturday, October 15, 2016

An Ariticle in APNIC Blog

Few days ago, I received a chance to write an article in the official APNIC blog. APNIC is the registry organization of IP addresses in the Asia and Pacific regions. Recently they held their APNIC-42 conference in Colombo, Sri Lanka and as a part of it, they help various workshops. Dr. Kasun de Zoysa from UCSC got an opportunity to participate as a resource person in a workshop and there he presented some of our recent research works to minimize human-elephant conflict in Sri Lanka using IoT technologies.

At the end of the workshop, Dr. Kasun invited his colleague of the workshop Mr. Jonathan Brewer to see our SCoRe lab and the things we are doing there. Finally, he introduced us to the editors of the APNIC blog and invited us to write an article about our research work. The result was the article I wrote to them. Actually, it is not the original content I wrote to them but an edited one by the experienced editors.

Wednesday, October 5, 2016

An Unexpected Visit to Kandy

Last weekend became a traveling weekend unexpectedly. There was a website launching event as a part of the Elders Day celebration in Polgolla, Sri Lanka. This website was created by Mr. Anura Kasthoori who works with us partially attached to our lab. Since he is currently taking rest at home after a road accident he faced more than a month ago, he could not attend to this event. Therefore, Dr. Kasun asked me to participate to the ceremony on behalf of Mr. Kasthoori. Initially I had a plan to go to my home town in Matara in this weekend but due to this unexpected ceremony, I had to change my plans. Therefore, I decided to goto Polgolla with my wife to make this journey more interesting.

Last Saturday early morning, we started the journey from a van provided by the organizers of the ceremony who are a part of the Social Welfare Ministry. It was about 4.30am when we started from the university and we reached Polgolla before 8.00am. Even though the original agenda was to start the ceremony at 8.30am, it an extra 30minutes when it gets started. There was several interesting events in the ceremony such as distributing prizes and awards to some senior citizens and different musical and dancing performances. Since I was nervous about the launching of the website, I tested my laptops Internet connection and checked everything time to time until the website launching time arrives. Finally it came around 12.00pm and the website was launched by the hand of a minister of the parliament who attended to the ceremony.

At the end of the ceremony, the organizers distributed lunch packets to the attendees. Me and my wife collected our meal and came out of the conference hall. Even though we were offered to get transport facility to come back to Colombo in the same van we came in the morning, we refused since we decided to stay in Kandy till the next day. So, we took a bus from Polgolla to Kandy and then from the Kandy town, we took a taxi to get to a small hotel. Even though the place we found was not very good, we didn't have any option since we couldn't select and reserve a good hotel before we leave Colombo. So, we decided to manage with the limited things we had.

In the evening we walked from the hotel to the Temple of the Tooth. The walk was a little bit tiresome from the hotel to the temple but the nice view of the lake made us relaxed. We had dinner at a nearby Pizza Hut because I always love to enjoy pizza. It was about 9.00pm when we finish our dinner and start walking back to the hotel. I thought there would be crowd on the road but surprisingly the road around the lake was almost empty and looked not safe. So, we rushed to the hotel without waiting to see anything around. We couldn't visit any nearby places other than the Temple of the Tooth due to the limitations of time.

The next day early morning, which was a Sunday, we checked-out from the hotel and took a train from the Kandy railway station at 6.30am to Colombo Fort. I think this train journey was the most interesting part of this unexpected visit to Kandy. The sceneries of the mountains while traveling in the train made me so glad that we came there. We arrived to Colombo Fort railway station around 9.45 am without delays. It was a great unexpected journey.