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

Installing ns-3.34 in Ubuntu 20.04

This post shows how to install ns 3.34 in Ubuntu 20.04 LTS Prerequisites: Fresh installation of Ubuntu Version 20.04 LTS  ns3.34 can be downloaded from here Follow the video link for complete step by step instructions on the installation.  This version fixes the compilation issues of (bug in ns3.33)  Issue the following commands after opening a terminal  $ sudo apt update $ sudo apt install g++ python3 python3-dev python-dev pkg-config sqlite3 python3-setuptools git qt5-default gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 openmpi-bin openmpi-common openmpi-doc libopenmpi-dev autoconf cvs bzr unrar openmpi-bin openmpi-common openmpi-doc libopenmpi-dev tcpdump wireshark libxml2 libxml2-dev Unzip or untar the ns-allinone-3.34.tar.bz2 in the home folder (in my case its /home/pradeepkumar) $ cd ns-allinone-3.34/ $ ./ --enable-examples --enable-tests  Once the installation is completed, you may get an output show

Installation of ns3 in Windows 10 and Windows 11 OS using WSL (Windows Subsystem for Linux)

This post shows how to install ns-3.33 in Windows 10 through WSL (Windows Subsystem for Linux) This posts works for Windows 11 also (I have tested it on a Windows 11 ISO and it works the Same way as mentioned in the following post.) This post will work for ns-3.3x version. Prerequisites : Install Windows Subsystem for Linux with GUI: Please refer the following video  System Information: OS used: Windows 10 and WSL (Ubuntu 20.04) GUI: XServer for Windows NS3 Version: ns-3.33 See the following complete video on how to install ns3 in Windows 10 Step 0 : Open XLaunch Step 1 :  Open WSL using PowerShell and open it as Administrator Command:/  wsl $ xfce4-session The GUI of Ubuntu Opens within Windows 10 OS. Step 2 : Download ns3 from website through Mozilla Firefox browser Step 3: Open a Terminal  $ sudo apt update $ sudo apt install build-essential autoconf automake libxmu-dev python3-pygraphviz cvs mercurial bzr git cmake p7zip-full python3-matplotlib python-tk python3-dev qt5-q

Installing NS-3.32 in Ubuntu 20.04

This is about installing ns version 3.32 in Ubuntu 20.04 LTS. #ns3 #ns3 .32 #networksimulation The commands used in the video are given here. $] sudo apt update $] sudo apt install build-essential autoconf automake libxmu-dev python3-pygraphviz cvs mercurial bzr git cmake p7zip-full python3-matplotlib python-tk python3-dev qt5-qmake qt5-default gnuplot-x11 wireshark Download the ns-allinone-3.32.tar.bz2 package from and copy it to /home/ folder See the full video for detailed instructions Extract it either in GUI or using command $] tar jxvf ns-allinone-3.32.tar.bz2 $] cd ns-allinone-3.32/ $] ./ --enable-examples --enable-tests The above command will take some time to install all the packages  You can see the output as shown below ns3 To check whether ns3 installed successfully, use the following commands. $] cd ns-3.32/ $] ./waf --run hello-simulator You should get the output as Hello Simulator $] ./waf --run first This is the example from the ns-3.32/exa