Creating a CCN node for interuniversitary experiments on FITS

Print

Creating a CCN node for interuniversitary experiments on FITS


Virtual machine creation and configuration

Creating the Virtual Machine

We will start this tutorial with the cration of a basic virtual machine.

  1. Log into FITS Interface using OpenID.
  2. Go to "Create Virtual Network".
  3. Click on your host router - a green Virtual Machine shall appear.
  4. Select "Default Image" as the image type.
  5. Click "Create".
  6. A success message containing the new VM's name will be displayed.

Configuring the Virtual Machine

In order to properly configure your virtual machine, it is necessary to edit it's Xend configuration file, as well as some internal files.

Gaining access to Virtual machine terminal

Guacamole provide terminal access to a virtual machine using Xend VNC connection.

To access your virtual machine through Guacamole, follow these steps:

  1. Go to "VM Console" option in FITS interface.
  2. Click on the VM's name and a new window shall open with a Guacamole terminal.
  3. If your machine isn't listed, log out of Guacamole using the button in the upper left and open it again from FITS interface.

Configuring the Virtual Machine's internal files

Once in your virtual machine terminal, follow this basic configuration steps:

  1. Click on the black screen and press "Enter"
  2. Login with these credentials:
  3. user: root
  4. password: fits
  5. Edit the hostname file in order to give the VM an appropriate name of your choice:
    1. Type in the command: nano /etc/hostname
    2. Change the machine's hostname: Ex: CCN_TUTORIAL
    3. Save and close the file
  6. Prepare virtual machine for Internet connection:
    1. Type in the command: nano /etc/network/interfaces
    2. Configure eth0 as a static interface, with a selected gateway.
    3. Save and close the file
  7. This gateway will be assigned to a NAT brigde created in your Domain0 in a later step.
  8. Example interface configuration:
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
  iface eth0 inet static
  address 10.10.10.1
  gateway 10.10.10.254
  netmask 255.255.255.0

Configuring Virtual Machine's Xend configuration file

First, power off the virtual machine by issuing the "poweroff" command in guacamole terminal. Once the virtual machine is down, select "VM Config" option on FITS interface menu. Scrool down to your virtual machine in the virtual machine pane and click to select it, then click "Edit Selected VMs" in the control pane to edit it's configuration file.

First, scrool down to the "# Disks info" section of the configuration file, there will be a configuration block similar to this one:

disk	= [
			'file:/net/10.2.2.1//home/xen/domains/VM24cedro.ufc.br747/disk.img,xvda2,w',
			'file:/net/10.2.2.1//home/xen/domains/VM24cedro.ufc.br747/swap.img,xvda1,w',
	]"

Remove the "/net/10.2.2.1/" portion from both lines, as shown in the following example:

disk	= [
			'file:/home/xen/domains/VM24cedro.ufc.br747/disk.img,xvda2,w',
			'file:/home/xen/domains/VM24cedro.ufc.br747/swap.img,xvda1,w',
	]"

Than, scrool down to the "#Networking" section of the configuration file, there will be a line similar to this one:

vif	= 	['mac=00:16:3E:6A:74:CD, ip=192.168.254.53, bridge=dom0back']

Change it as follows:

Example:

vif	= 	['mac=00:16:3E:6A:74:CD, bridge=INTERNET']

At last, click the buttons in the lower left to save and close your configuration file.

Moving the virtual machine disk to your FITS node

As CCN depends on caching, CCN experiments on FITS may suffer from the latency and low bandwidth associated with the internet during disk access, as all virtual disks location default to Guanabara NFS server in order to enable virtual machine migration. To leverage this problem it's recomended to copy the virtual machine disk to your FITS node. To accomplish this, open a root terminal on your FITS node.

Then type in the following commands, replace "[VMNAME]" with your virtual machine name:

root@FITSNODE ~ # mkdir -p /home/xen/domains
root@FITSNODE ~ # cp -r /net/10.2.2.1/home/xen/domains/[VMNAME] /home/xen/domains/

Wait to the copying p´rocess to end, then move to the next section.

Resizing your image to accomodate CCNx installation

All CCNx dependencies don´t fit in the regular 2GB FITS image, so it will be necessary to add aditional space tou your virtual disk. To accomplish this, type in these commands on a root terminal on your FITS node:

root@FITSNODE ~ # cd /home/xen/domains/[VMNAME]
root@FITSNODE ~ # dd if=/dev/zero bs=1G count=2 >> disk.img
root@FITSNODE ~ # e2fsck -f the_disk_file
root@FITSNODE ~ # resize2fs the_disk_file

Virtual machine Internet setup

Still on the root terminal of your fits node, type in these commands to setup your virtual machine Internet conection, replace "eth0" with the name of the interface connected to Internet in your Domain0 and "10.10.10.254" with the one you set in virtual machine internal configuration step:

ovs-vsctl add-br INTERNET
ifconfig INTERNET up 10.10.10.254/24
iptables -A FORWARD -i eth0 -o INTERNET -j ACCEPT
iptables -A FORWARD -i INTERNET -o eth0 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Powering up your virtual machine

Back on FITS interface, select "VM Config" option on FITS interface menu. Scrool down to your virtual machine in the virtual machine pane and click to select it, then select your FITS node in the control pane and click "Start selected VMs". Your machine will be acessible again in guacamole terminal interface, and ready to continue with CCNx instalation.

CCNx 0.8.1 installation and testing

First step: Install dependencies

To install CCNx 0.8.1 dependencies, run the following commands as root:

apt-get install gcc make libc6-dev autoconf autotools-dev libtool
apt-get install libssl-dev libxml2-dev libxml2-utils libexpat1-dev libcrypto++9 expat libpcap-dev libxml2 athena-jot python-dev wireshark
apt-get install ant openjdk-6-jdk openjdk-6-jre

The first command accounts for gcc compiler and necessary common build tools. The second command accounts for CCNx C dependencies, note tha vlc is optional and will reuire about 600MB aditional disk space as it depends on some Gnome components. The third command accounts for CCNx Java dependencies and build environment, note that this version of CCNx is compatible with OpenJDK 6.

Second step: Install CCNx

To install CCNx, run the following commands:

wget http://www.ccnx.org/releases/ccnx-0.8.1.tar.gz
tar -xzf ccnx-0.8.1.tar.gz
cd ccnx-0.8.1
CFLAGS='-g -DCCN_URI_DEFAULT_ESCAPE=2' ./configure
make

After these steps, it's advised to run CCNx automated test suite, with the following command:

make test

If the aforementioned automated test failed for some reason, please recheck that all dependencies were installed sucefully.

Finally, after the test completes sucefully, install CCNx binaries in system folders and initialize CCNx keystore:

make install
ccninitkeystore -f -v 365

Note that these commands must be run as root user.

Runing CCNx: Sample script

To run CCNx, create a script based on the following sample:

#!/bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
export CCND_DEBUG=221
export CCNR_DIRECTORY=/root/repo
export CCND_LOG=/root/ccnd.log
mkdir -p /root/repo
ccndstart &
sleep 5
ccnr &
sleep 10
echo add ccnx:/gta.ufrj.br/ udp 192.168.1.1 > /root/ccnd_route.conf
echo add ccnx:/ udp 192.168.1.1 >> /root/ccnd_route.conf
ccndc -f /root/ccnd_route.conf

This script defines basic environment variables needed by CCNx daemons, and a repository folder. The last three lines create static routes for both CCNx keystore prefix and a custom one. You can change "ccnx:/gta.ufrj.br/" to other prefix of your liking, for example "ccnx:/fitsnode/".

Some basic usage commands

Creating a random content file and storing it in CCNx repository:

dd if=/dev/urandom bs=10MB count=1 > file1.rnd
ccnputfile -allownonlocal ccnx:/gta.ufrj.br/rnd10mb file1.rnd

Getting a file from repository:

ccngetfile ccnx:/gta.ufrj.br/rnd10mb file1_get.rnd

Listing repository contents:

ccnlsrepo ccnx:/gta.ufrj.br

Accessing CCNx web based status

Direct a web browser of choice in your FITS node to 'http://<VIRTUAL MACHINE IP IN INTERNET BRIDGE>:9695' URL.

If your node does not have a graphical environment enabled, you can use SSH to forward access to another machine in your network. To accomplish this, run this command on said machine to create a SSH tunnel:

ssh -L 9695:<VIRTUAL MACHINE IP IN INTERNET BRIDGE>:9695 root@<YOUR FITS NODE>

In the fisrt parameter ('-L local_port:remote_ip:remote_port'), remote_port and remote_ip must be given in respect to the virtual machine as seen by your FITS node. The second parameter is the usual 'user@host'.