Skip to main content

GreenCloud Simulator using NS2

Introduction to GreenCloud Simulator
GreenCloud is a packet level simulator that uses the existing Network Simulator 2 (NS2) libraries for energy-aware data centers for cloud computing. It models the various entities of cloud such as servers, switches, links for communication and their energy consumption.
It can be helpful in developing solutions for resource monitoring and allocation, scheduling workloads for number of users, optimizing the protocols used for communication and also provide solutions for network switches. The data center upgradation or extension may be decided using this tool.
NS2 uses two languages C++ and Otcl (Tool Command Language). The commands from TCL are usually passed to C++ using an interface TclCL. GreenCloud uses 80% of the coding is done using C++ (TclCL Classes) and remaining 20% coding is implemented using Tcl scripts (Commands are sent from Tcl to C++).
GreenCloud is developed by University of Luxembourg and released under the General Public License (GPL).

Installation of GreenCloud
GreenCloud Tool is developed mainly for debian based systems like (Ubuntu, Debian, Linux Mint, etc). The tool will be comfortably work with Ubuntu 12.x and afterwards with a kernel of 3.2+. GreenCloud also comes with a preconfigured VM which includes Eclipse to debug ns, modifying the source code and to start/run simulations.

Here is the instructions for GreenCloud on a Non VM machine. Download the software from this url Execute the command as specified below.

Unzip or untar the software using the command

pradeep@localhost $] tar zxvf greencloud-v2.0.0.tar.gz
pradeep@localhost $] cd greencloud-v2.0.0
pradeep@localhost greencloud-v2.0.0 $] ./configure
pradeep@localhost $] ./install-sh

(This will install almost as 300MB of software with the dependencies. You need to press “Enter” manually for fewer number of times during the installation, If the installation is unsuccessful, correct the dependencies)
Execute the script by running (This command will pop out a window in a browser with a test simulation data)


Sample Simulation
The GreenCloud comes with a default test simulation with 144 Servers with one Cloud User. All of the parameters can be varied and tested based on the inputs given to the Tcl file.

The Tcl files are located under the ~greencloud/src/scripts/ directory. There are many scripts that specifies the functionality of the cloud environment
main.tcl - specifies the data center topology and simulation time
topology.tcl – create the network topology
dc.tcl – creates the servers and VMs
setup_params.tcl – general configuration like servers, switches, tasks, etc
user.tcl – defines the users and their behaviors
record.tcl – reporting the results
finish.tcl – prints the statistics.

The output can be viewed using the browser using the show-dashboard.html file by running the ./run scripts.
The ./run scripts consists of the following parameters Data center load, Simulation Time and Memory requirement. The Data center load specifies the value from 0 to 1 (the values near 0 indicates the idle data center and while the load closer or greater than 1 indicates the saturation of data center). The simulation time specifies the task that can be scheduled under a VM or a single host based on the deadlines of the task.

The simulation results are processed in the ~greencloud/traces/ directory. There are various trace files that records the information from data center load, main tasks, switch tracing, loading, etc.

Changing the Cloud parameters
The parameters of the data center can be changed using the Tcl files that were shown in the previous section. Here a simple change is shown below. Two files (main.tcl and topology.tcl) are modified caters to 40 servers and single user cloud data center with a average load capacity of 0.3 (as shown in the Table 1)

#topology.tcl, where the network topology is been set
switch $sim(dc_type) {
"three-tier high-speed" {
set top(NCore) 2 ;# Number of L3 Switches in the CORE network
set top(NAggr) [expr 2*$top(NCore)] ;# Number of Switches in AGGREGATION
set top(NAccess) 256 ;# Number switches in ACCESS network
set top(NRackHosts) 3 ;# Number of Hosts on a rack
"three-tier debug" {
set top(NCore) 1 ;# Number of L3 Switches in the CORE network
set top(NAggr) [expr 2*$top(NCore)] ;# Number of Switches in AGGREGATION
set top(NAccess) 2 ;# Number switches in ACCESS network per pod
set top(NRackHosts) 20 ;# Number of Hosts on a rack
# three-tier
default {
set top(NCore) 8 ;# Number of L3 Switches in the CORE network
set top(NAggr) [expr 2*$top(NCore)] ;# Number of Switches in AGGREGATION
set top(NAccess) 64 ;# Number switches in ACCESS network
set top(NRackHosts) 3 ;# Number of Hosts on a rack

# Number of racks is set as 2 * 1
set top(NRacks) [expr $top(NAccess)*$top(NCore)]

# Number of servers is set to 2 * 20 (40 servers)
set top(NServers) [expr $top(NRacks)*$top(NRackHosts)]

#main.tcl, where the simulation information and data center load information is specified
# Type of DC architecture
set sim(dc_type) "three-tier debug"

# Set the time of simulation end
set sim(end_time) [ expr 60.1 + [lindex $argv 1] ] ;# simualtion length set to 60 s + deadline of tasks

# Start collecting statistics
set sim(start_time) 0.1

set sim(tot_time) [expr $sim(end_time) - $sim(start_time)]

set sim(linkload_stats) "enabled"

# Set the interval time (in seconds) to make graphs and to create flowmonitor file
set sim(interval) 0.1

# Setting up main simulation parameters
source "setup_params.tcl"

# Get new instance of simulator
set ns [new Simulator]

# Tracing general files (*.nam & *.tr)
set nf [open "../../traces/main.nam" w]
set trace [open "../../traces/" w]

# Building data center topology
source "topology.tcl"

Table 1: Simulation Data
Data center Architecture
Three tier debug
Core Switches
Aggregation Switches
Access Switches
Number of Servers
Average Load/Server
Total tasks
Average Task/Server
Total Energy Calculated
322.7 Watt Hour
Server Energy
164.1 Wh
Total Switch Energy
158.6 Wh

GreenCloud using NS2
Simulation Summary

GreenCloud using NS2
Data Center characteristics

GreenCloud using NS2
Data Center Network Characteristics

GreenCloud using NS2
Energy consumption details

The graph in the browser shows 4 parts, Simulation summary as shown in Table 1, Data center characteristics as shown in Figure 3, DC Network characteristics as shown in Figure 4 and Energy consumption details as shows in Figure 5.

Multiple simulations can be performed using a single run script. In these case, the results are plotted in as a tabbed pane.

To modify the existing source code
The above sections shows the parameter changes in the existing network and to analyse the results. However, if a researcher is trying to configure a CPU, HPC Cluster, Cache Memory alteration, handling of Virtual Machines, etc, then there should be code modification in the source files (.cc and .h).
The location of these files are in the ~greencloud/build/ns-2.35/greencloud/ directory. Already these files are compiled as object files. Any changes to these files needs a compilation as specified below

if a file called is modified and have to be recompiled using the make command as shown below.

~pradeep@localhost $] cd /home/pradeep/greencloud/build/ns-2.35/
~pradeep@localhost ns-2.35 $] make

If new set of files ( and are added, those details have to be added to ~ns-2.35/ as specified below in the OBJ_CC variable. For each .cc file, there need to be a .o file to be added.

OBJ_CC = \
greencloud/newfile.o \
greencloud/newfile1.o \


GreenCloud is a best open source tool that analyse the performance of a data center by varying parameters of the cloud and also gives a provision to add or modify existing source code to define new metrics for a cloud. Any questions on installation or tuning the GreenCloud are always welcome.


T S Pradeep Kumar


Popular posts from this blog

Installation of ns2 in Ubuntu 18.04 - NS2 Tutorial # 2

ns2 installation in Ubuntu 18.04

Unlike earlier version of ubuntu, the 18,04 version does not support the direct installation of ns2, because of the latest C/C++ compiler (7.x), but the latest C/C++ compiler supported by ns2 is gcc-4.8. So this post and video tells you about the installation of gcc-4.8 version, then ns2 and then configuration.
Here are the steps, Please follow the video given below for more information.

$] tar zxvf ns-allinone-2.35.tar.gz

$] sudo apt install gcc-4.8 g++-4.8

if you have installed ubuntu just now, you can try these commands also in the beginning

$] sudo apt update
$] sudo apt install build-essential autoconf automake libxmu-dev

$] cd ns-allinone-2.35/ns-2.35
$] gedit
$] gedit linkstate/ls.h

line number 137, change erase to this->erase
$] cd ..
$] ./install

export PATH=$PATH:/home/pradeepkumar/ns-allinone-2.35/bin:/home/pradeepkumar/ns-allinone-2.35/tcl8.5.10/unix:/home/pradeepkumar/ns-allinone-2.35/tk8.5.10/unix

ns3 installation in Ubuntu 16.04

This post serves the installation instructions of ns3 in ubuntu 16.04 version. Some of my students are working in ns3, this post will benefit them in installing ns3.

OS Used: Ubuntu 16.04.4
ns3 version: ns3 version 3.27

The same procedure will be applied for OS like Debian, Linux Mint.

Fresh installation of Ubuntu 16.04 Let you try the fresh installation of ubuntu in your hard disk along with windows.
Installation of ns3 dependencies ns3 needs so many dependencies, developmental libraries, drivers, etc. so install all those
$] sudo apt update  $] sudo apt upgrade
$] sudo apt-get install build-essential autoconf automake libxmu-dev python-pygoocanvas python-pygraphviz cvs mercurial bzr git cmake p7zip-full python-matplotlib python-tk python-dev python-kiwi python-gnome2 python-gnome2-desktop-dev python-rsvg qt4-dev-tools qt4-qmake qt4-qmake qt4-default gnuplot-x11 wireshark
The above command make take some time to download, compile and install it, Be Patient. 
Installing ns3 Download the…

AWK Scripts for NS2 to process data from Trace Files

AWK Scripts are very good in processing the data from the log (trace files) which we get from NS2. If you want to process the trace file manually, here is the detailHere is a sample of trace file from NS2 (However ns2 supports a new type of trace file also), but this post will make you understand the old trace format only.r 0.030085562 _0_ MAC  --- 0 message 32 [0 ffffffff 1 800] ------- [1:255 -1:255 32 0] r 0.030110562 _0_ RTR  --- 0 message 32 [0 ffffffff 1 800] ------- [1:255 -1:255 32 0] s 1.119926192 _0_ RTR  --- 1 message 32 [0 0 0 0] ------- [0:255 -1:255 32 0]
AWK Scripts are very good in processing the data column wise. For example
the first column in the above trace file represents r, s which indicates receive, sent respectively. If we want to trace the entire r and s alone from this trace file we can represent it as $1
$1 represents ACTION
$2 Time
$3 Node ID
$4 Layer
$5 Flags
$6 seqno
$7 type
$8 Size
$14 Energy (if the network nodes includes EnergyModel)To run the awk script in Li…