0% found this document useful (0 votes)
25 views14 pages

Computer Networks 1-5 Experiment

This document describes two experiments related to discrete event simulation and network simulation tools. Experiment 1 introduces discrete event simulation, including key concepts like the event queue, animation handler, and time normalization. It also discusses common uses of simulation like diagnosing process issues, evaluating hospital workflows, and assessing capital investments. Experiment 2 introduces the network simulators NS3 and NS2. It describes the development history and features of each, including that NS3 was built from scratch in C++ while NS2 uses TCL scripting. A comparison notes some differences in the two simulators.

Uploaded by

Ayush Prakash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views14 pages

Computer Networks 1-5 Experiment

This document describes two experiments related to discrete event simulation and network simulation tools. Experiment 1 introduces discrete event simulation, including key concepts like the event queue, animation handler, and time normalization. It also discusses common uses of simulation like diagnosing process issues, evaluating hospital workflows, and assessing capital investments. Experiment 2 introduces the network simulators NS3 and NS2. It describes the development history and features of each, including that NS3 was built from scratch in C++ while NS2 uses TCL scripting. A comparison notes some differences in the two simulators.

Uploaded by

Ayush Prakash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

EXPERIMENT 1

AIM
Introduction to Computer Network laboratory, introduction to Discrete Event Simulation and
Discrete Event Simulation Tools.

THEORY
A discrete-event simulation (DES) models the operation of a system as a
(discrete) sequence of events in time. Each event occurs at a particular instant in time and
marks a change of state in the system. Between consecutive events, no change in the system
is assumed to occur; thus, the simulation time can directly jump to the occurrence time of the
next event, which is called next-event time progression.
In addition to next-event time progression, there is also an alternative approach,
called incremental time progression, where time is broken up into small time slices and the
system state is updated according to the set of events/activities happening in the time slice.
Because not every time slice has to be simulated, a next-event time simulation can typically
run faster than a corresponding incremental time simulation.
Both forms of DES contrast with continuous simulation in which the system state is changed
continuously over time on the basis of a set of differential equations defining the rates of
change of state variables.

Discrete Simulation Tools


In addition to the logic of what happens when system events occur, discrete event simulations
include the following:

 Priority queue,
 Animation event handler, and
 Time re-normalization handler (as simulation runs, time variables lose precision.
After a while all-time variables should be re-normalized by subtracting the last
processed event time).

State : A system state is a set of variables that captures the salient properties of the system to
be studied. The state trajectory over time S(t) can be mathematically represented by a step
function whose value can change whenever an event occurs.
Clock : The simulation must keep track of the current simulation time, in whatever
measurement units are suitable for the system being modeled. In discrete-event simulations,
as opposed to continuous simulations, time 'hops' because events are instantaneous – the
clock skips to the next event start time as the simulation proceeds.
Events list : The simulation maintains at least one list of simulation events. This is
sometimes called the pending event set because it lists events that are pending as a result of
previously simulated event but have yet to be simulated themselves. An event is described by
the time at which it occurs and a type, indicating the code that will be used to simulate that
event. It is common for the event code to be parametrized, in which case, the event
description also contains parameters to the event code. The event list is also referred to as
the future event list (FEL) or future event set (FES).
Random Number Generators : The simulation needs to generate random variables of
various kinds, depending on the system model. This is accomplished by one or
more Pseudorandom number generators. The use of pseudo-random numbers as opposed to
true random numbers is a benefit should a simulation need a rerun with exactly the same
behaviour.
Statistics : The simulation typically keeps track of the system's statistics, which quantify the
aspects of interest. In the bank example, it is of interest to track the mean waiting times. In a
simulation model, performance metrics are not analytically derived from probability
distributions, but rather as averages over replications, that is different runs of the
model. Confidence intervals are usually constructed to help assess the quality of the output.
Ending Condition : Because events are bootstrapped, theoretically a discrete-event
simulation could run forever. So, the simulation designer must decide when the simulation
will end. Typical choices are "at time t" or "after processing n number of events" or, more
generally, "when statistical measure X reaches the value x".
Three Phased Approach : Pidd (1998) has proposed the three-phased approach to discrete
event simulation. In this approach, the first phase is to jump to the next chronological event.
The second phase is to execute all events that unconditionally occur at that time (these are
called B-events). The third phase is to execute all events that conditionally occur at that time
(these are called C-events). The three-phase approach is a refinement of the event-based
approach in which simultaneous events are ordered so as to make the most efficient use of
computer resources. The three-phase approach is used by a number of commercial simulation
software packages, but from the user's point of view, the specifics of the underlying
simulation method are generally hidden.

COMMON USES
1. Diagnosing process issues
Simulation approaches are particularly well equipped to help users diagnose issues in
complex environments. The theory of constraints illustrates the importance of
understanding bottlenecks in a system. Identifying and removing bottlenecks allows
improving processes and the overall system. For instance, in manufacturing enterprises
bottlenecks may be created by excess inventory, overproduction, variability in processes
and variability in routing or sequencing. By accurately documenting the system with the
help of a simulation model it is possible to gain a bird’s eye view of the entire system.
A working model of a system allows management to understand performance drivers. A
simulation can be built to include any number of performance indicators such as worker
utilization, on-time delivery rate, scrap rate, cash cycles, and so on.
2. Hospital applications
An operating theater is generally shared between several surgical disciplines. Through
better understanding the nature of these procedures it may be possible to increase the
patient throughput. Example: If a heart surgery takes on average four hours, changing an
operating room schedule from eight available hours to nine will not increase patient
throughput. On the other hand, if a hernia procedure takes on average twenty minutes
providing an extra hour may also not yield any increased throughput if the capacity and
average time spent in the recovery room is not considered.

3. Lab test performance improvement ideas


Many systems improvement ideas are built on sound principles, proven methodologies
(Lean, Six Sigma, TQM, etc.) yet fail to improve the overall system. A simulation model
allows the user to understand and test a performance improvement idea in the context of
the overall system.
4. Evaluating capital investment decisions
Simulation modelling is commonly used to model potential investments. Through
modeling investments decision-makers can make informed decisions and evaluate
potential alternatives.
5. Network simulators
Discrete event simulation is used in computer network to simulate new protocols,
different system architectures (distributed, hierarchical, centralised, P2P) before actual
deployment. It is possible to define different evaluation metrics, such as service time,
bandwidth, dropped packets, resource consumption, and so on.
EXPERIMENT 2

Aim

Introduction to NS3 and its comparison with NS2.

Theory

Introduction to NS3
ns-3 is a discrete-event network simulator for Internet systems, targeted primarily for
research and educational use. ns-3 is free, open-source software, licensed under the
GNU GPLv2 license, and maintained by a worldwide community.
In 2003, a team led by Tom Henderson, George Riley, Sally Floyd, and Sumit Roy,
applied for and received funding from the U.S. National Science Foundation (NSF) to
build a replacement for ns-2, called ns-3. This team collaborated with the Planete project
of INRIA at Sophia Antipolis, with Mathieu Lacage as the software lead, and formed a
new open source project.
In the process of developing ns-3, it was decided to completely abandon
backward- compatibility with ns-2. The new simulator would be written from
scratch, using the C++ programming language. Development of ns-3 began in
July 2006.

Current status of the three versions is:

 ns-1 development stopped when ns-2 was founded. It is no longer developed


nor maintained.
 ns-2 development stopped around 2010. It is no longer developed nor
maintained.
 ns-3 is actively being developed and maintained.

ns-3 is built using C++ and Python with scripting capability. The ns library is wrapped
by Python thanks to the pybindgen library which delegates the parsing of the ns C++
headers to castxml and pygccxml to automatically generate the corresponding C++
binding glue. These automatically generated C++ files are finally compiled into the ns
Python module to allow users to interact with the C++ ns models and core through
Python scripts. The ns simulator features an integrated attribute-based system to manage
default and per-instance values for simulation parameters.

Introduction to NS2
Ns-2 began as a revision of ns-1. From 1997 to 2000, ns development was supported
by DARPA through the VINT project at LBL, Xerox PARC, UCB, and USC/ISI. In
2000, ns-2 development was supported through DARPA with SAMAN and through
NSF with CONSER, both at USC/ISI, in collaboration with other researchers
including ACIRI.
Features of NS2
1. It is a discrete event simulator for networking research.
2. It provides substantial support to simulate bunch of protocols like TCP, FTP, UDP,
https and DSR.
3. It simulates wired and wireless network.
4. It is primarily Unix based.
5. Uses TCL as its scripting languages.
6. Otcl: Object oriented support
7. Tclcl: C++ and otcl linkage
8. Discrete event schedule
Ns-2 incorporates substantial contributions from third parties, including wireless code
from the UCB Daedelus and CMU Monarch projects and Sun Microsystems.

Comparison NS2 Vs NS3

The two network simulators are compared on the basis of some factors as below.
1. Simulation result presentation:
in ns2 we use the nam package for present the simulation in the graphical mode
in ns3 we use the NetAnim package for present the simulation in the graphical
mode Graph genration:
in ns2 we use the Xgraph package for plot the result
graph in ns3 we use the gnuplot package for plot the
result graph Video Transmission:
in ns2 we perform the video transmission process based on the evalvid
package in ns3 we perform the video transmission process based on the
ffmpeg package

2. Supporting Languages
in NS3 written the main file using C++ , with the file extension of .cc
but in NS2 written the main file with the help of TCL and C++.
in NS3 Python is available for the scripting language , but in NS2 Only TCL can
be used as the scripting language
in NS3 .tr-> files used for trace analysis,.XML->files are used for network
Animation
,.csv-> files used for gnu plot. But in NS2 .tr-> files used for trace parameters ,
.nam -
> files used for Network Animation and .xg -> files used for graph
3. Modules
In ns3 ,we have a default modules, for routing AODV, DSR,DSDV and others.
For communication TCP, UDP and others. And the Mobility models with the
node moving configurations, antenna configurations and others. In NS3 we can
create a own models , by using the command suod ./create-module.py new-
modulename.
in ns2, we have a default modules , for routing AODV, DSR,DSDV and others.
For communication TCP, UDP, satellite and others. And the mobile with the node
moving configurations, antenna configurations and others. In NS2 we can create
a own models , by create a folder in ns-2.35 folder and call the new modules fiels
in the makefile.in
4. Supporting Domains
in the ns2 support the wifi,WPAN ,LTE, VANET with sumo and wireless
sensor networks,, multimedia video transmission and D2D and M2M
Communication process.
in the ns3 support the wifi,WPAN ,LTE, VANET with sumo and wireless sensor
networks and D2D and M2M Communication process,IoT,5G,6G Terasim,
FANET and Underwater sensor network , multimedia video transmission.
EXPERIMENT 3

Aim

Installation of NS3 on Linux.

THEORY

ns (from network simulator) is a name for a series of discrete event network simulators,


specifically ns-1, ns-2, and ns-3. All are discrete-event computer network simulators,
primarily used in research and teaching.
NS3
In 2003, a team led by Tom Henderson, George Riley, Sally Floyd, and Sumit Roy, applied
for and received funding from the U.S. National Science Foundation (NSF) to build a
replacement for ns-2, called ns-3. This team collaborated with the Planete project of INRIA at
Sophia Antipolis, with Mathieu Lacage as the software lead, and formed a new open source
project.
In the process of developing ns-3, it was decided to completely abandon backward-
compatibility with ns-2. The new simulator would be written from scratch, using the C+
+ programming language. Development of ns-3 began in July 2006.

Current status of the three versions is:

 ns-1 development stopped when ns-2 was founded. It is no longer developed nor
maintained.
 ns-2 development stopped around 2010. It is no longer developed nor maintained.
 ns-3 is actively being developed and maintained.
Following are the basic steps which must be followed for installing NS3

1. Install prerequisite packages

2. Download ns3 codes

3. Build ns3

4. Validate ns3

Downloading and Building

NS requires a modestly up-to-date installation of Tcl/Tk (with header files), and two
additional packages: tclcl and otcl. Most OS installations do not come with full Tcl/Tk
installations or with these other packages, so you will most likely need to install several
packages.
Generic Linux, BSD, OS X, and Solaris instructions There are two typical ways to build ns:
building each component individually ("from the pieces") or running a script that installs
them all in one shot ("allinone"). If you just want to try it out quickly, you might try the
allinone package. If you want to do C-level development, or save download time or disk
space, or have trouble with allinone, you should build it from the pieces.
Installing the allinone package: This package has an install script that handles installation of
Tcl/Tk, OTcl, tclcl, ns-2, nam-1 and other packages. Updating allinone: The "allinone"
package is only updated for every release. 

To Install NS3
Run the following commands on terminal:
1. wget -c https://www.nsnam.org/releases/ns-allinone-3.37.tar.bz2
2. tar -xvjf ns-allinone-3.37.tar.bz2

3.

cd ns-allinone-3.37/

4. ./build.py --enable-examples --enable-tests

5. cd ../netanim-3.108/

6. make clean && qmake-qt5 NetAnim.pro && make


or
7. make clean && qmake NetAnim.pro && make

8. cd ../ns-3.37

We have successfully installed NS3.


EXPERIMENT 4

Aim

Using Free Open Source Software tools ns3, design and implement two nodes topology.

SOURCE CODE

#include "ns3/applications-module.h"
#include "ns3/core-module.h"
#include "ns3/internet-module.h"
#include "ns3/network-module.h"
#include "ns3/point-to-point-module.h"

// Default Network Topology


//
// 10.1.1.0
// n0 -------------- n1
// point-to-point
//

using namespace ns3;


NS_LOG_COMPONENT_DEFINE("FirstScriptExample");

int
main(int argc, char* argv[])
{
CommandLine cmd(__FILE__);
cmd.Parse(argc, argv);

Time::SetResolution(Time::NS);
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);

NodeContainer nodes;
nodes.Create(2);

PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps"));
pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));

NetDeviceContainer devices;
devices = pointToPoint.Install(nodes);
InternetStackHelper stack;
stack.Install(nodes);

Ipv4AddressHelper address;
address.SetBase("10.6.6.0", "255.255.255.0");

Ipv4InterfaceContainer interfaces = address.Assign(devices);

UdpEchoServerHelper echoServer(9);

ApplicationContainer serverApps = echoServer.Install(nodes.Get(1));


serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));

UdpEchoClientHelper echoClient(interfaces.GetAddress(1), 9);


echoClient.SetAttribute("MaxPackets", UintegerValue(1));
echoClient.SetAttribute("Interval", TimeValue(Seconds(1.0)));
echoClient.SetAttribute("PacketSize", UintegerValue(1024));

ApplicationContainer clientApps = echoClient.Install(nodes.Get(0));


clientApps.Start(Seconds(2.0));
clientApps.Stop(Seconds(10.0));

Simulator::Run();
Simulator::Destroy();
return 0;
}
OUTPUT

EXPERIMENT 5

Aim

Using Free Open Source Software tools ns3, design and implement three nodes topology
considering one node as a central node.

SOURCE CODE

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"

using namespace ns3;

int main (int argc, char *argv[])


{
Time::SetResolution (Time::NS);
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);

NodeContainer nodes;
nodes.Create (3);

PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("5ms"));

PointToPointHelper pointToPoint1;
pointToPoint1.SetDeviceAttribute ("DataRate", StringValue ("20Mbps"));
pointToPoint1.SetChannelAttribute ("Delay", StringValue ("10ms"));

NetDeviceContainer devices, devices1;


devices = pointToPoint.Install (nodes.Get(0), nodes.Get(1));
devices1 = pointToPoint.Install (nodes.Get(2), nodes.Get(1));

InternetStackHelper stack;
stack.Install (nodes);

Ipv4AddressHelper address, address1;


address.SetBase ("10.1.1.0", "255.255.255.0");
address1.SetBase ("176.0.1.0", "255.255.255.0");

Ipv4InterfaceContainer interfaces = address.Assign (devices);


Ipv4InterfaceContainer interfaces1 = address1.Assign (devices1);

UdpEchoServerHelper echoServer (10);


UdpEchoServerHelper echoServer1 (20);

ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));


serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));

ApplicationContainer serverApps1 = echoServer1.Install (nodes.Get (1));


serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));

UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 10);


echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
echoClient.SetAttribute ("PacketSize", UintegerValue (4096));

ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));


clientApps.Start (Seconds (4.0));
clientApps.Stop (Seconds (10.0));

UdpEchoClientHelper echoClient1 (interfaces.GetAddress (1), 20);


echoClient1.SetAttribute ("MaxPackets", UintegerValue (1));
echoClient1.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
echoClient1.SetAttribute ("PacketSize", UintegerValue (4096));

ApplicationContainer clientApps1 = echoClient1.Install (nodes.Get (0));


clientApps1.Start (Seconds (5.0));
clientApps1.Stop (Seconds (10.0));

Simulator::Run ();
Simulator::Destroy ();
return 0;
}

OUTPUT

You might also like