Skip to main content

PyTorch Code for Simple Neural Networks for MNIST Dataset

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
http://greencloud.gforge.uni.lu/ftp/greencloud-v2.0.0.tar.gz. Execute the command as specified below.

--------------------------------CODE-----------------------------
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)

--------------------------------CODE-----------------------------

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)

--------------------------------CODE-----------------------------
#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)]
…...
--------------------------------CODE-----------------------------

--------------------------------CODE-----------------------------
#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/main.tr" w]

# Building data center topology
source "topology.tcl"
…......
--------------------------------CODE-----------------------------

Table 1: Simulation Data
Data center Architecture
Three tier debug
Core Switches
1
Aggregation Switches
2
Access Switches
2
Number of Servers
40
Users
1
Average Load/Server
0.3
Total tasks
688
Average Task/Server
17.2
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

--------------------------------CODE-----------------------------
if a file called cpu.cc 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 (newfile.cc and newfile1.cc) are added, those details have to be added to ~ns-2.35/Makefile.in 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 \

--------------------------------CODE-----------------------------

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.

Reference:


T S Pradeep Kumar

Comments

Popular posts from this blog

Installing ns3 in Ubuntu 22.04 | Complete Instructions

In this post, we are going to see how to install ns-3.36.1 in Ubuntu 22.04. You can follow the video for complete details Tools used in this simulation: NS3 version ns-3.36.1  OS Used: Ubuntu 22.04 LTS Installation of NS3 (ns-3.36.1) There are some changes in the ns3 installation procedure and the dependencies. So open a terminal and issue the following commands Step 1:  Prerequisites $ sudo apt update In the following packages, all the required dependencies are taken care and you can install all these packages for the complete use of ns3. $ sudo apt install g++ python3 python3-dev pkg-config sqlite3 cmake python3-setuptools git qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools 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 gsl-bin libgsl-dev libgslcblas0 wireshark tcpdump sqlite sqlite3 libsqlite3-dev  libxml2 libxml2-dev libc6-dev libc6-dev-i386 libclang-dev llvm-

Installation of NS2 (ns-2.35) in Ubuntu 20.04

Installation of NS2 (ns-2.35) in Ubuntu 20.04 LTS Step 1: Install the basic libraries like      $] sudo apt install build-essential autoconf automake libxmu-dev Step 2: install gcc-4.8 and g++-4.8 open the file using sudo mode $] sudo nano /etc/apt/sources.list Include the following line deb http://in.archive.ubuntu.com/ubuntu bionic main universe $] sudo apt update $] sudo apt install gcc-4.8 g++-4.8 Step 3:  Unzip the ns2 packages to home folder $] tar zxvf ns-allinone-2.35.tar.gz $] cd ns-allinone-2.35/ns-2.35 Modify the following make files. ~ns-2.35/Makefile.in Change @CC@ to gcc-4.8 change @CXX@ to g++-4.8 ~nam-1.15/Makefile.in ~xgraph-12.2/Makefile.in ~otcl-1.14/Makefile.in Change in all places  @CC@ to gcc-4.8 @CPP@ or @CXX@ to g++-4.8 open the file: ~ns-2.35/linkstate/ls.h Change at the Line no 137  void eraseAll() { erase(baseMap::begin(), baseMap::end()); } to This void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); } All changes made Step 4: Open a new termi

Installation of NS2 in Ubuntu 22.04 | NS2 Tutorial 2

NS-2.35 installation in Ubuntu 22.04 This post shows how to install ns-2.35 in Ubuntu 22.04 Operating System Since ns-2.35 is too old, it needs the following packages gcc-4.8 g++-4.8 gawk and some more libraries Follow the video for more instructions So, here are the steps to install this software: To download and extract the ns2 software Download the software from the following link http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.35/ns-allinone-2.35.tar.gz/download Extract it to home folder and in my case its /home/pradeepkumar (I recommend to install it under your home folder) $ tar zxvf ns-allinone-2.35.tar.gz or Right click over the file and click extract here and select the home folder. $ sudo apt update $ sudo apt install build-essential autoconf automake libxmu-dev gawk To install gcc-4.8 and g++-4.8 $ sudo gedit /etc/apt/sources.list make an entry in the above file deb http://in.archive.ubuntu.com/ubuntu/ bionic main universe $ sudo apt update Since, it&#