How to Install CloudSim in Ubuntu (in 3 easy steps)

The contents of this DIY has been tested on Ubuntu 12.04 LTS x64 with CloudSim 3.0.3 beta and JDK8u11 x64. It should work similarly on other distros of Ubuntu and for different version of JDK as long as you use Java version 1.5 or newer. The text shown in RED in the DIY represents the values that will differ depending upon your JDK version and locations.

CloudSim is a framework for modelling and simulating cloud computing infrastructure and services. In this DIY we will see how to install CloudSim in Windows easily and efficiently. A more detailed description, APIs and research papers related to CloudSim can be found here. Let us begin.


Step 1: Setting up the Prerequisites

1. First of all we need to download the CloudSim and latest version of the Java Development Toolkit (JDK). CloudSim can be found here.

2. CloudSim requires a working Java installation. So, open up a terminal and run the following

1 sudo add-apt-repository ppa:webupd8team/java
2 sudo apt-get update && sudo apt-get install oracle-java8-installer

It will take some time to download and install so sit back and wait. Once it’s done then we have to add the JAVA_HOME to the Ubuntu environment. Run the following in a terminal to open up the /etc/environment file.

1 sudo gedit /etc/environment

Now, append the following at the end of the file and save it:

JAVA_HOME="/usr/lib/jvm/java-8-oracle"

3. Now its time to install the CloudSim. Unpack the downloaded 'CloudSim-3.0.3.tar.gz' or 'CloudSim-3.0.3.zip' (let the name of the unpacked folder be 'cloudsim-3.0.3'). As you can see there is no makefile or install file inside the folder so it doesn't need to be compiled. Later if you want to remove the CloudSim, just remove the whole 'cloudsim-3.0.3' directory.


Step 2: Setting up the Environment

Now comes the critical part, the most important part of the CloudSim setup is the setting up the paths to different classes and jar files correctly or you won't be able to run your programs efficiently.

We need to set the 'CLASSPATH' variable which will contain the location of the class files and will be used by the CloudSim while executing an application. So we have to set two consecutive locations first one is the location of gridsim.jar file provided in the CloudSim and is used exclusively by the CloudSim applications and second one is the location where we have stored our programs.

We will set the CLASSPATH in the .bashrc file of the current user so open a terminal and run the following

1 sudo gedit /home/dhyan/.bashrc

Provide the password and add the following lines at the end of the opened file and save it.

CLASSPATH=".:/home/dhyan/Desktop/cloudsim-3.0.3/jars/*:
/home/dhyan/Desktop/cloudsim-3.0.3/examples"
export CLASSPATH

Now we need to reload the .bashrc file so close the all opened terminals (if any) and run the following

1 source ~/.bashrc


Step 3: Testing the Setup (Compiling and Executing a CloudSim Application)

Finally now we can test whether our installation is successful or not. CloudSim includes some test example programs in the 'CloudSim\examples\gridsim\' folder that we can use to test our setup.

1. Compiling a CloudSim program: If you have followed this DIY then compiling a CloudSim program is pretty straightforward; the basic syntax for compilation is just similar to that of Java programs i.e. javac filename.java or javac file_location/filename.java. Let us compile the Example2.java included in 'CloudSim/examples/gridsim/example02/' folder. We will now run the following command in a new command prompt

1 javac /home/dhyan/Desktop/cloudsim-3.0.3/examples/org/cloudbus/cloudsim/examples/CloudSimExample1.java

2. Running the compiled program: The syntax for running a compiled CloudSim program is similar to that of running a program in Java i.e. java filename. In our case we have to type (see image 1)

1 java org.cloudbus.cloudsim.examples.CloudSimExample1

OR if you want to save the output of your program to a file you can use the following

1 java org.cloudbus.cloudsim.examples.CloudSimExample1 > output.txt

Note: The examples given in the CloudSim uses the concept of packages hence it is advisable to go through the basics of packages in Java for a better understanding of the above stated commands.

Image 1. Testing the Setup.


Some Important Points

  • It is important to set the CLASSPATH correctly, if you make any mistake you might get a class not found error and if you want to supply the classpath externally while compiling or executing using -cp or -classpath; then for some reason it might not work and you would still get the same errors.
  • Remember to change the 2nd and 3rd CLASSPATH values if you later decide to move the jar files of the CLoudSim or location of your own programs to some other location, respectively and accordingly.
  • You can also use CloudSim with the Eclipse IDE.
  • For more information kindly refer the readme.txt and examples.txt provided with the CloudSim.

Goodluck !
— * — * — * — * —

How to Install CloudSim in Windows (in 3 easy steps)

The contents of this DIY has been tested on Windows 7 Ultimate x64 with CloudSim 3.0.3 and JDK8u11 x64. It should work similarly on other Windows OS and for different version of JDK as long as you use Java version 1.6 or newer. The text shown in RED in the DIY represents the values that will differ depending upon your JDK version and locations.

CloudSim is a framework for modelling and simulating cloud computing infrastructure and services. In this DIY we will see how to install CloudSim in Windows easily and efficiently. A more detailed description, APIs and research papers related to CloudSim can be found here. Let us begin.


Step 1: Setting up the Prerequisites

1. First of all we need to download the CloudSim and latest version of the Java Development Toolkit (JDK). These can be found here:
Note: It is advisable that you must download the appropriate version of the JDK for your system i.e. x86 version for x86 systems and x64 version for x64 systems.

2. CloudSim requires a working JRE, so install the JDK.

3. Now its time to install the CloudSim. Unpack the downloaded 'CloudSim-3.0.3.tar.gz' or 'CloudSim-3.0.3.zip' (let the name of the unpacked folder be 'cloudsim-3.0.3'). As you can see there is no executable file inside the folder so there is no special program to install the CloudSim. Later if you want to remove the CloudSim, then remove the whole 'cloudsim-3.0.3' directory.


Step 2: Setting up the Environment

Now comes the critical part, the most important part of the CloudSim setup is the setting up the paths to different classes and jar files correctly or you won't be able to run your programs efficiently.

1. The first path to be set is the 'Path' variable which will contain the location of executable java files such as 'javac' and 'java' and will be used by the CloudSim while compiling and running a CloudSim or Java program.

2. The second path to be set is the 'CLASSPATH' variable which will contain the location of the class files and will be used by the CloudSim while executing an application. So we have to set three consecutive values first one for location of JDK executables, second one is the location of jar files provided in the CloudSim and is used exclusively by the CloudSim applications and third one is the location where we have stored our programs.

To set the paths go to the properties of 'My Computer' —> 'Advanced system settings' —> 'Advanced' tab —> 'Environment Variables...' —> under the 'System variables' —> 'New...' —> in the popped up box set the 'Variable name' and 'Variable Value' as shown and click 'OK'.

Variable name Variable value
1Path C:\Program Files\Java\jdk1.8.0_11\bin;
2CLASSPATH C:\Program Files\Java\jdk1.8.0_11\bin;
C:\Users\Dhyan\Desktop\cloudsim-3.0.3\jars\*;
C:\Users\Dhyan\Desktop\cloudsim-3.0.3\examples;

Note: We have to close all the opened command prompt windows, if any.


Step 3: Testing the Setup (Compiling and Executing a CloudSim Application)

Finally now we can test whether our installation is successful or not. CloudSim includes some test example programs in the 'CloudSim\examples\gridsim\' folder that we can use to test our setup.

1. Compiling a CloudSim program: If you have followed this DIY then compiling a CloudSim program is pretty straightforward; the basic syntax for compilation is just similar to that of Java programs i.e. javac filename.java or javac file_location\filename.java. Let us compile the Example2.java included in 'CloudSim\examples\gridsim\example02\' folder. We will now run the following command in a new command prompt

1 javac C:\Users\Dhyan\Desktop\cloudsim-3.0.3\examples\org\cloudbus\cloudsim\examples\CloudSimExample1.java

2. Running the compiled program: The syntax for running a compiled CloudSim program is similar to that of running a program in Java i.e. java filename. In our case we have to type (see image 1)

1 java org.cloudbus.cloudsim.examples.CloudSimExample1

OR if you want to save the output of your program to a file you can use the following

1 java org.cloudbus.cloudsim.examples.CloudSimExample1 > output.txt

Note: The examples given in the CloudSim uses the concept of packages hence it is advisable to go through the basics of packages in Java for a better understanding of the above stated commands.

Image 1. Testing the Setup.


Some Important Points

  • It is important to set the CLASSPATH correctly, if you make any mistake you might get a class not found error and if you want to supply the classpath externally while compiling or executing using -cp or -classpath; then for some reason it might not work and you would still get the same errors.
  • Remember to change the 2nd and 3rd CLASSPATH values if you later decide to move the jar files of the CLoudSim or location of your own programs to some other location, respectively and accordingly.
  • You can also use CloudSim with the Eclipse IDE.
  • For more information kindly refer the readme.txt and examples.txt provided with the CloudSim.

Goodluck !
— * — * — * — * —

How to Install GridSim in Ubuntu (in 3 easy steps)

The contents of this DIY has been tested on Ubuntu 12.04 LTS x64 with GridSim 5.2 beta and JDK8u11 x64. It should work similarly on other distros of Ubuntu and for different version of JDK as long as you use Java version 1.5 or newer. The text shown in RED in the DIY represents the values that will differ depending upon your JDK version and locations.

GridSim is a simulation toolkit for simulating resource modelling and application scheduling for parallel and distributed computing. Simulation is the only feasible way to analyse algorithms on large-scale distributed systems of heterogeneous resources. In this DIY we will see how to install GridSim in Ubuntu easily and efficiently. A more detailed description, APIs and research papers related to GridSim can be found here. Let us begin.


Step 1: Setting up the Prerequisites

1. First of all we need to download the GridSim and latest version of the Java Development Toolkit (JDK). GridSim can be found here.

2. GridSim requires a working Java installation. So, open up a terminal and run the following

1 sudo add-apt-repository ppa:webupd8team/java
2 sudo apt-get update && sudo apt-get install oracle-java8-installer

It will take some time to download and install so sit back and wait. Once it’s done then we have to add the JAVA_HOME to the Ubuntu environment. Run the following in a terminal to open up the /etc/environment file.

1 sudo gedit /etc/environment

Now, append the following at the end of the file and save it:

JAVA_HOME="/usr/lib/jvm/java-8-oracle"

3. Now its time to install the GridSim. Unpack the downloaded 'GridSim5-2.zip' (let the name of the unpacked folder be 'GridSim'). As you can see there is no makefile or install file inside the folder so it doesn't need to be compiled. Later if you want to remove the GridSim, just remove the whole 'GridSim' directory.


Step 2: Setting up the Environment

Now comes the critical part, the most important part of the GridSim setup is the setting up the paths to different classes and jar files correctly or you won't be able to run your programs efficiently.

We need to set the 'CLASSPATH' variable which will contain the location of the class files and will be used by the GridSim while executing an application. So we have to set two consecutive locations first one is the location of gridsim.jar file provided in the GridSim and is used exclusively by the GridSim applications and second one is the location where we have stored our programs.

We will set the CLASSPATH in the .bashrc file of the current user so open a terminal and run the following

1 sudo gedit /home/dhyan/.bashrc

Provide the password and add the following lines at the end of the opened file and save it.

CLASSPATH=".:/home/dhyan/Desktop/GridSim/jars/*:
/home/dhyan/Desktop/GridSim/examples"
export CLASSPATH

Now we need to reload the .bashrc file so close the all opened terminals (if any) and run the following

1 source ~/.bashrc


Step 3: Testing the Setup (Compiling and Executing a GridSim Application)

Finally now we can test whether our installation is successful or not. GridSim includes some test example programs in the 'GridSim\examples\gridsim\' folder that we can use to test our setup.

1. Compiling a GridSim program: If you have followed this DIY then compiling a GridSim program is pretty straightforward; the basic syntax for compilation is just similar to that of Java programs i.e. javac filename.java or javac file_location/filename.java. Let us compile the Example2.java included in 'GridSim/examples/gridsim/example02/' folder. We will now run the following command in a new command prompt

1 javac /home/dhyan/Desktop/GridSim/examples/gridsim/example02/Example2.java

2. Running the compiled program: The syntax for running a compiled GridSim program is similar to that of running a program in Java i.e. java filename. In our case we have to type (see image 1)

1 java gridsim.example02.Example2

OR if you want to save the output of your program to a file you can use the following

1 java gridsim.example02.Example2 > output.txt

Note: The examples given in the GridSim uses the concept of packages hence it is advisable to go through the basics of packages in Java for a better understanding of the above stated commands.

Image 1. Setup Test Successful.


Some Important Points

  • It is important to set the CLASSPATH correctly, if you make any mistake you might get a class not found error and if you want to supply the classpath externally while compiling or executing using -cp or -classpath then for some reason it might not work and you would still get the same errors.
  • Remember to change the CLASSPATH values if you later decide to move gridsim.jar file or location of your own programs to some other location; accordingly.
  • Running GridSim requires a lot of memory since there are many objects to be created. Therefore, it is recommended to have at least 512 MB RAM or increase JVM heap size when running Java for large simulation experiments. For example to set max. heap size as 300 MB:

1 java -Xmx300m gridsim.example02.Example2

  • You can also use GridSim with the Eclipse IDE, JBuilder or JCreator. For more instructions you might want to head here.
  • For more information kindly refer the readme.txt and faq.txt provided with the GridSim.

Goodluck !
— * — * — * — * —

How to Install GridSim in Windows (in 3 easy steps)

The contents of this DIY has been tested on Windows 7 Ultimate x64 with GridSim 5.2 beta and JDK8u11 x64. It should work similarly on other Windows OS and for different version of JDK as long as you use Java version 1.5 or newer. The text shown in RED in the DIY represents the values that will differ depending upon your JDK version and locations.

GridSim is a simulation toolkit for simulating resource modelling and application scheduling for parallel and distributed computing. Simulation is the only feasible way to analyse algorithms on large-scale distributed systems of heterogeneous resources. In this DIY we will see how to install GridSim in Windows easily and efficiently. A more detailed description, APIs and research papers related to GridSim can be found here. Let us begin.


Step 1: Setting up the Prerequisites

1. First of all we need to download the GridSim and latest version of the Java Development Toolkit (JDK). These can be found here:
Note: It is advisable that you must download the appropriate version of the JDK for your system i.e. x86 version for x86 systems and x64 version for x64 systems.

2. GridSim requires a working JRE so install the JDK.

3. Now its time to install the GridSim. Unpack the downloaded 'GridSim5-2.zip' (let the name of the unpacked folder be 'GridSim'). As you can see there is no executable file inside the folder so there is no special program to install the GridSim. Later if you want to remove GridSim, then remove the whole 'GridSim' directory.


Step 2: Setting up the Environment

Now comes the critical part, the most important part of the GridSim setup is the setting up the paths to different classes and jar files correctly or you won't be able to run your programs efficiently.

1. The first path to be set is the 'Path' variable which will contain the location of executable java files such as 'javac' and 'java' and will be used by the GridSim while compiling and running a GridSim or Java program.

2. The second path to be set is the 'CLASSPATH' variable which will contain the location of the class files and will be used by the GridSim while executing an application. So we have to set three consecutive values first one for location of JDK executables, second one is the location of gridsim.jar file provided in the GridSim and is used exclusively by the GridSim applications and third one is the location where we have stored our programs.

3. The third path 'GRIDSIM' is optional, it will specify the location of our GridSim programs. You can set this to avoid typing the lengthy location of your programs again and again.

To set the paths go to the properties of 'My Computer' —> 'Advanced system settings' —> 'Advanced' tab —> 'Environment Variables...' —> under the 'System variables' —> 'New...' —> in the popped up box set the 'Variable name' and 'Variable Value' as shown and click 'OK'.

Variable name Variable value
1Path C:\Program Files\Java\jdk1.8.0_11\bin;
2CLASSPATH C:\Program Files\Java\jdk1.8.0_11\bin;
C:\Users\Dhyan\Desktop\GridSim\jars\*;
C:\Users\Dhyan\Desktop\GridSim\examples; 
3GRIDSIM C:\Users\Dhyan\Desktop\GridSim  

Note: We have to close all the opened command prompt windows, if any.


Step 3: Testing the Setup (Compiling and Executing a GridSim Application)

Finally now we can test whether our installation is successful or not. GridSim includes some test example programs in the 'GridSim\examples\gridsim\' folder that we can use to test our setup.

1. Compiling a GridSim program: If you have followed this DIY then compiling a GridSim program is pretty straightforward; the basic syntax for compilation is just similar to that of Java programs i.e. javac filename.java or javac file_location\filename.java. Let us compile the Example2.java included in 'GridSim\examples\gridsim\example02\' folder. We will now run the following command in a new command prompt

1 javac C:\Users\Dhyan\Desktop\GridSim\examples\gridsim\example02\Example2.java

Alternatively you can also run the following command if you have set the 'GRIDSIM' variable in the previous step.

1 javac %GRIDSIM%\examples\gridsim\example02\Example2.java

2. Running the compiled program: The syntax for running a compiled GridSim program is similar to that of running a program in Java i.e. java filename. In our case we have to type (see image 1)

1 java gridsim.example02.Example2

OR if you want to save the output of your program to a file you can use the following

1 java gridsim.example02.Example2 > output.txt

Note: The examples given in the GridSim uses the concept of packages hence it is advisable to go through the basics of packages in Java for a better understanding of the above stated commands.

Image 1. Testing the Setup.


Some Important Points

  • It is important to set the CLASSPATH correctly, if you make any mistake you might get a class not found error and if you want to supply the classpath externally while compiling or executing using -cp or -classpath; then for some reason it might not work and you would still get the same errors.
  • Remember to change the 2nd and 3rd CLASSPATH values if you later decide to move gridsim.jar file or location of your own programs to some other location, respectively and accordingly.
  • Running GridSim requires a lot of memory since there are many objects to be created. Therefore, it is recommended to have at least 512 MB RAM or increase JVM heap size when running Java for large simulation experiments. For example to set max. heap size as 300 MB:

1 java -Xmx300m gridsim.example02.Example2

  • You can also use GridSim with the Eclipse IDE, JBuilder or JCreator. For more instructions you might want to head here.
  • For more information kindly refer the readme.txt and faq.txt provided with the GridSim.

Goodluck !
— * — * — * — * —

How to Integrate Mannasim with NS-2.35

The Mannasim framework is a third party Wireless Sensor Network Simulation environment based on the Network Simulator (NS). In this DIY we will learn how we can integrate the Mannasim with the NS-2.35. You can learn more about the Mannasim here.


Step 1: Prerequisites

1. First of all we need a working NS-2.35, installed on Ubuntu-12.04/13.10/14.04. You can find the DIY on installation of NS-2.35 in Ubuntu-12.04 here and in Ubuntu-13.10/14.04 here.

2. Second, we need the Mannasim patch files for NS-2.35, which can be downloaded from here. I assume you have downloaded the "mannasim-NS-2.35.tar.gz" in '/home/user_name/Documents' and have your NS-2.35installed in '/home/user_name/Documents/ns-allinone-2.35/'.


Step 2: Integrating Mannasim with NS-2.35

1. Extract the downloaded Mannasim patch either using the right click context menu "Extract here" or using the following command from a terminal:

1 tar -xvzf /home/user_name/Documents/ns-allinone-2.35.tar.gz

2. Go to the directory where you have extracted the package, in our case its '/home/user_name/Documents'. Now move the extracted "mannasim" folder inside the already installed "ns-allinone-2.35/ns-2.35".

3. Inside the mannasim folder there will be a "ns-modified-folder" that contains set of files to be pasted to different locations (image 1).

Image 1. ns-modified-files

Copy these files and paste (replace) them in following locations:

File Copy to
udp.cc ns-allinone-2.35/ns-2.35/apps/
ns-process.h ns-allinone-2.35/ns-2.35/common/
packet.cc ns-allinone-2.35/ns-2.35/common/
packet.h ns-allinone-2.35/ns-2.35/common/
ns-default.tcl ns-allinone-2.35/ns-2.35/tcl/lib/
ns-lib.tcl ns-allinone-2.35/ns-2.35/tcl/lib/
Makefile.in ns-allinone-2.35/ns-2.35/

4. Once everything is done, go to the terminal and move to the "ns-allinone-2.35/ns-2.35" directory. Now run the following commands one by one:

1 ./configure
2 make clean
3 make


Step 3: Test the Integration

To test Mannasim installation two simulation scripts are provided below. The first one simulates a flat network of homogeneous sensors and the second a hierarchical network composed of two different classes of sensor nodes.

Click on the links to get the TCL code:
1. Flat homogeneous network TCL Script.
2. Hierarchical heterogeneous network TCL Script.

You can run these files using:

1 ns mannasim-rede-plana.tcl
2 ns mannasim-rede-hierarquica.tcl

You should get output as shown in image 2.

Image 2. Testing the Integration.

You have successfully integrated the Mannasim with NS-2.35. Congratulations !! Have fun !

— * — * — * — * —

Source

How to Install NS-2.35 in Ubuntu-13.10 / 14.04 (in 4 easy steps)

In this DIY we will learn how to install Network Simulator (NS)-2.35 in Ubuntu 13.10 OR Ubuntu 14.04. If you found yourself here then I assume you already know about the NS, so I will skip the introduction part. And if you don't then you may want to follow this link.


Step 1: Setting up the Prerequisites

1. First of all, download Network Simulator (NS-2.35) from here.I assume you have downloaded it into your '/home/user_name/Documents' directory.

2 [Optional]. Now we have to update the Ubuntu with its latest components. Open up a terminal and run these commands:

1 sudo apt-get update
2 sudo apt-get dist-upgrade
3 sudo apt-get update

Make sure that your Ubuntu is fully updated ( i.e. there should be no pending updates in your Ubuntu Software Center and in Software Updater).

3. Before installing the NS we have to install some essential packages required by the NS. So run the following commands:

1 sudo apt-get install build-essential autoconf automake
2 sudo apt-get install tcl8.5-dev tk8.5-dev
3 sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev
4 sudo apt-get install gcc-4.4


Step 2: Extract and Install NS

1. Extract the downloaded NS package either using the right click context menu "Extract here" or using the following commands from a terminal:

1 cd /home/user_name/Documents
2 tar -xvzf ns-allinone-2.35.tar.gz

2. After extracting the "ns-allinone-2.35" folder, open up the file "/ns-allinone-2.35/ns-2.35/linkstate/ls.h" in an editor. You can do it either from the terminal or from the file explorer (Nautilus). We have to make some changes in the ls.h file else it will show an error while installing the NS. Once you have opened the file move to the line 137 and replace the erase (image 1) with this—>erase (image 2) and save the file.

Image 1. Replace erase.

Image 2. With this->erase.

NOTE: If you don't make the above stated change then you will see an error while installing the NS (image 3).

Image 3. Error (Please Follow the Previous Step).

3. Now its time to finally install the NS. Open up a terminal and move to the directory where you have extracted the package, in our case its '/home/user_name/Documents' and install NS using the following commands (image 4):

1 cd /home/user_name/Documents/ns-allinone-2.35
2 sudo ./install

It will take around 15 minutes so have patience.

Image 4. Installation in Progress.


Step 3: Set the Environment Variables

1. Assuming everything went well in the previous step and you have successfully installed your NS. Now that NS is installed, there are some environment variables that need to be added to your profile. This can be done by editing the .bashrc file. Open a new terminal and open the file using:

1 sudo gedit .bashrc

NOTE: You may want to create a backup of the .bashrc before editing, the easiest way is to copy the file to a different location. Later you can replace the edited .bashrc with the copied one in case something goes sideways or if you want to remove the NS.

2. Add the following lines AT THE END of the file. Be sure to change "/path_to" to the path of where you have extracted the NS (e.g. '/home/user_name/Documents').

# LD_LIBRARY_PATH
OTCL_LIB=/path_to/ns-allinone-2.35/otcl-1.14/
NS2_LIB=/path_to/ns-allinone-2.35/lib/
USR_Local_LIB=/usr/local/lib/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$USR_Local_LIB

# TCL_LIBRARY
TCL_LIB=/path_to/ns-allinone-2.35/tcl8.5.10/library/
USR_LIB=/usr/lib/
export TCL_LIBRARY=$TCL_LIBRARY:$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/path_to/ns-allinone-2.35/xgraph-12.2/:/path_to/ns-allinone-2.35/bin/:/path_to/ns-allinone-2.35/tcl8.5.10/unix/:/path_to/ns-allinone-2.35/tk8.5.10/unix/
NS=/path_to/ns-allinone-2.35/ns-2.35/
NAM=/path_to/ns-allinone-2.35/nam-1.15/
export PATH=$PATH:$XGRAPH:$NS:$NAM

Save the file and restart the system, alternatively you can just reload the .bashrc as:

1 source ~/.bashrc


Step 4: Validate the Installation

You need to validate NS to check if everything is OK but keep in mind that it will take a lot of time (about 1:30 hrs). Open up a terminal and move to the directory ‘/home/user_name/Documents/ns-allinone-2.35/ns-2.35/' and run:

1 ./validate

And That is it ! You can now run ns from a terminal window by executing: ns
If you received the "%" sign, it means that NS is running (image 5). Congratulations !!

Image 5. Installation Successful.


* Uninstalling the NS

If you want to remove the NS from your system then follow these steps:

1 Delete the directory 'ns-allinone-2.35'.
2 Delete the ns related files from '/user/local/bin'.
3 Edit the '.bashrc file' and remove the paths that you have added during the installation.
4 Restart the system and run following commands one by one:
5 sudo apt-get autoremove
6 sudo apt-get clean


* Some Common Problems

1. Many people are getting the following error when they run the ns after the installation:

Image 6. Error: 'ns' is currently not installed.

If you get this error then kindly ensure that you have set the path (as in step 3) correctly and try restarting the system. If the error persists then try running the ns from '/ns-allinone-2.35/ns-2.35/bin/'.


You can start working on NS now, the standard Marc Greis' tutorial on NS can be found here. Another tutorial is 'NS by example' by Jae Chung and Marc Claypool, and is available here.


P.S.

I am not working on ns anymore, if you face any problems then feel free to contact, comment but it's guaranteed that I would be able to help you. Also go through the comments before making your query. Thank you!

Have Fun !!
— * — * — * — * —

How to Install NS-2.35 in Ubuntu-12.04 (in 4 easy steps)

In this DIY we will learn how to install Network Simulator (NS)-2.35 in Ubuntu 12.04. If you found yourself here then I assume you already know about the NS, so I will skip the introduction part. And if you don't then you may want to follow this link.


Step 1: Setting up the Prerequisites

1. First of all, download Network Simulator (NS- 2.35) from here.I assume you have downloaded it into your '/home/user_name/Documents' directory.

2. Now we have to update the Ubuntu with its latest components. Open up a terminal and run these commands:

1 sudo apt-get update
2 sudo apt-get dist-upgrade
3 sudo apt-get update

Make sure that your Ubuntu is fully updated ( i.e. there should be no pending updates in your Ubuntu Software Center and in Software Updater).

3. Before installing the NS we have to install some essential packages required by the NS. So run the following commands:

1 sudo apt-get install build-essential autoconf automake
2 sudo apt-get install tcl8.5-dev tk8.5-dev
3 sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev


Step 2: Extract and Install NS

1. Extract the downloaded NS package either using the right click context menu "Extract here" or using the following command from a terminal:

1 cd /home/user_name/Documents
2 tar -xvzf ns-allinone-2.35.tar.gz

2. Now its time to finally install the NS. Open up a terminal and move to the directory where you have extracted the package, in our case its ‘/home/user_name/Documents’ and install NS using the following command (image 1):

1 cd /home/user_name/Documents/ns-allinone-2.35
2 ./install

It will take around 15 minutes so have patience.

Image 1. Installation in Progress.


Step 3: Set the Environment Variables

1. Assuming everything went well in the previous step and you have successfully installed your NS. Now that NS is installed, there are some environment variables that need to be added to your profile. This can be done by editing the ".bashrc" file. Open a new terminal and open the file using:

1 sudo gedit .bashrc

NOTE: You may want to create a backup of the .bashrc before editing, the easiest way is to copy the file to a different location. Later you can replace the edited .bashrc with the copied one in case something goes sideways or if you want to remove the NS.

2. Add the following lines AT THE END of the file. Be sure to change "/path_to" to the path of where you have extracted the NS (e.g. '/home/user_name/Documents').

# LD_LIBRARY_PATH
OTCL_LIB=/path_to/ns-allinone-2.35/otcl-1.14/
NS2_LIB=/path_to/ns-allinone-2.35/lib/
USR_Local_LIB=/usr/local/lib/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$USR_Local_LIB

# TCL_LIBRARY
TCL_LIB=/path_to/ns-allinone-2.35/tcl8.5.10/library/
USR_LIB=/usr/lib/
export TCL_LIBRARY=$TCL_LIBRARY:$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/path_to/ns-allinone-2.35/xgraph-12.2/:/path_to/ns-allinone-2.35/bin/:/path_to/ns-allinone-2.35/tcl8.5.10/unix/:/path_to/ns-allinone-2.35/tk8.5.10/unix/
NS=/path_to/ns-allinone-2.35/ns-2.35/
NAM=/path_to/ns-allinone-2.35/nam-1.15/
export PATH=$PATH:$XGRAPH:$NS:$NAM

Save the file and restart the system, alternatively you can just reload the .bashrc as:

1 source ~/.bashrc


Step 4: Validate the Installation

You need to validate NS to check if everything is OK but keep in mind that it will take a lot of time (about 1:30 hrs). Open up a terminal and move to the directory '/home/user_name/Documents/ns-allinone-2.35/ns-2.35/' and run:

1 ./validate

And That's it ! You can now run ns from a terminal window by executing: ns
If you received the "%" sign, it means that NS is running (image 2). Congratulations !!

Image 2. Installation Successful.


* Uninstalling the NS

If you want to remove the NS from your system then follow these steps:

1 Delete the directory 'ns-allinone-2.35'.
2 Delete the ns related files from '/user/local/bin'.
3 Edit the '.bashrc file' and remove the paths that you have added during the installation.
4 Restart the system and run following commands one by one:
5 sudo apt-get autoremove
6 sudo apt-get clean


P.S.

Many people are getting the following error when they run the ns after the installation:

Image 3. Error: 'ns' is currently not installed.

If you get this error then kindly ensure that you have set the path (as in step 3) correctly and try restarting the system. If the error persists then try running the ns from '/ns-allinone-2.35/ns-2.35/bin/'.


You can start working on NS now, the standard Marc Greis' tutorial on NS can be found here. Another tutorial is 'NS by example' by Jae Chung and Marc Claypool, and is available here.

Have Fun !!
— * — * — * — * —

Running a MapReduce Job (WordCount) on Hadoop Single-Node Cluster

In the previous post we’ve seen how to install Hadoop on Ubuntu, now it’s time to run our first Hadoop MapReduce job. We will use the WordCount example job which reads text files and counts how often words occur. The input is text files and the output is text files, each line of which contains a word and the count of how often it occurred, separated by a tab.


1. Download example input data
We will use three ebooks from Project Gutenberg for this example:

Download each ebook and store the files in a local temporary directory of choice, for example ‘/tmp/gutenberg’. Now we have tochange the file ownership to hduser. Open a terminal and run:

1 sudo chown –R hduser:hadoop /tmp/gutenberg


2. Restart the Hadoop cluster
Open a new terminal and restart your Hadoop cluster if it’s not running already

1 su - hduser
2 /usr/local/hadoop/bin/start-all.sh


3. Copy local example data to HDFS
Before we run the actual MapReduce job, we first have to copy the files from our local file system to Hadoop’s HDFS.

1 cd /usr/local/hadoop
2 bin/hadoop dfs –copyFromLocal /tmp/gutenberg /user/hduser/gutenberg

We can also check whether our files are copied correctly (see image 1).

1 bin/hadoop dfs –ls /user/hduser
2 bin/hadoop dfs –ls /user/hduser/gutenberg

Image 1. Files Copied Successfully.


4. Run the MapReduce job
Now, we actually run the WordCount example job (image 2).

1 bin/hadoop jar hadoop*example*.jar wordcount /user/hduser/gutenberg /user/hduser/gutenberg-output

This command will read all the files in the HDFS directory '/user/hduser/gutenberg', process it, and store the result in the HDFS directory '/user/hduser/gutenberg-output'.

Image 2. Running WordCount.

Check if the result is successfully stored in HDFS directory '/user/hduser/gutenberg-output' (image 3):

1 bin/hadoop dfs –ls /user/hduser
2 bin/hadoop dfs –ls /user/hduser/gutenberg

Image 3. Results Stored Successfully.

If you want to modify some Hadoop settings on the fly like increasing the number of Reduce tasks, you can use the "-D" option:

1 bin/hadoop jar hadoop*example*.jar wordcount –D /user/hduser/gutenberg mapred.reduce.tasks=16 /user/hduser/gutenberg-output

Note: Hadoop does not honor mapred.map.tasks beyond considering it a hint. But it accepts the user specified mapred.reduce.tasks and doesn’t manipulate that. You cannot force mapred.map.tasks but you can specify mapred.reduce.tasks.


5. Retrieve the job result from HDFS
You can use the command

1 bin/hadoop dfs –cat /user/hduser/gutenberg-output/part-r-00000

to read the file directly from HDFS. Or alternatively you can copy it from HDFS to the local file system

1 mkdir /tmp/gutenberg-output
2 bin/hadoop dfs –getmerge /user/hduser/gutenberg-output /tmp/gutenberg-output

Note: The command dfs -getmerge will simply concatenate any files it finds in the directory you specify. This means that the merged file might (and most likely will) not be sorted.

Now we can view the whole output file by opening it in any editor, open a new terminal and run:

1 sudo gedit /tmp/gutenberg-output/gutenberg-output


6. Hadoop Web Interfaces
Hadoop comes with several web interfaces which are by default (see conf/hadoop-default.xml ) available at these locations:


These web interfaces provide concise information about what’s happening in your Hadoop cluster. You might want to give them a try.


I. NameNode Web Interface (HDFS layer)
The name node web UI shows you a cluster summary including information about total/remaining capacity, live and dead nodes. Additionally, it allows you to browse the HDFS namespace and view the contents of its files in the web browser. It also gives access to the local machine’s Hadoop log files.

By default, it’s available at http://localhost:50070/.


II. JobTracker Web Interface (MapReduce layer)
The JobTracker web UI provides information about general job statistics of the Hadoop cluster, running/completed/failed jobs and a job history log file. It also gives access to the ‘‘local machine’s’’ Hadoop log files (the machine on which the web UI is running on).

By default, it’s available at http://localhost:50030/.


III. TaskTracker Web Interface (MapReduce layer)
The task tracker web UI shows you running and non-running tasks. It also gives access to the "local machine's" Hadoop log files.

By default, it’s available at http://localhost:50060/.

— * — * — * — * —

Sources