0% found this document useful (0 votes)
6 views

CN_Lab program 1 and 2

The Computer Networks Lab Manual outlines the objectives, outcomes, and requirements for a laboratory course designed to provide hands-on experience with computer networking concepts using simulation tools like NS3, NetAnim, Wireshark, Packet Tracer, and Nmap. It includes various programming exercises aimed at understanding network performance and protocols through practical applications. The manual is intended for students in the School of Computer Science and Engineering, specifically for the 3rd Year, 5th Semester batch of 2022-2026.

Uploaded by

Amann Adil
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)
6 views

CN_Lab program 1 and 2

The Computer Networks Lab Manual outlines the objectives, outcomes, and requirements for a laboratory course designed to provide hands-on experience with computer networking concepts using simulation tools like NS3, NetAnim, Wireshark, Packet Tracer, and Nmap. It includes various programming exercises aimed at understanding network performance and protocols through practical applications. The manual is intended for students in the School of Computer Science and Engineering, specifically for the 3rd Year, 5th Semester batch of 2022-2026.

Uploaded by

Amann Adil
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/ 12

Computer Networks Lab Manual

(Course Code: B22EF0506)

3rd Year—5thSem
Batch 2022-2026

SCHOOL OF COMPUTER SCIENCE AND


ENGINEERING

CONTENTS
S.NO PROGRAMS Page No.
I Lab description 3
II Lab objectives 3
III Lab outcomes 3
1V Lab requirements 4

PROGRAMS TO BE PRACTICED
1. Introduction to: (a) discrete event simulation, (b) ns3, (c)
5
ns3 Installation, (d) NetAnim.
2 Write a NS3 program to connect two nodes with a point to
point link, which have unique interface. Analyze the network 8
performance using UDP client server.
3. Write a NS 3 program to demonstrate bus topology.
11
Analyze the performance using UDP based applications.
4. Write a NS 3 program to demonstrate star topology.
15
Analyze the performance using UDP based applications.
5. Write a NS3 program to implement FTP using TCP bulk
transfer, Analyze the performance 19

6 Write a NS3 program to connect two nodes with a point to


point link, which have unique interface. Analyse the traffic 23
control using TCP by changing suitable parameters.

7 Write NS 3 Program to configure two nodes on an 802.11b


physical layer, with802.11b NICs in adhoc mode, and by
default, sends one packet of 1000 (application) bytes to the
other node. The physical layer is configured to receive at a
fixed RSS (regardless of the distance and transmit power); 30
therefore, changing position of the nodes has no effect.
Analyze the performance.

8 Install wireshark, and analyze the packets using it on a


selected interface. Apply filters and check the packets. 38

9 Install packet tracer, and consider a topology and configure


VLAN 40
10. Install NMAP, and execute atleast 10 commands to
demonstrate the scanning of networks hosts and ports. 43

I. Lab DESCRIPTION
This laboratory course supplements the material taught in the theory course
Computer Networks. The objective of this lab is to get hands-on experience in
Computer Networks concept using simulation tools Viz. NS3, NetAnim,
Wireshark, Packet Tracer and Nmap. Laboratory exercises will normally be
conducted on UNIX Operating system. The students will be exposed to
simulating and analyzing concepts.
II. LAB OBJECTIVES
The objectives of this lab course are to make students to:
 Understand Computer Network Concepts.
 Install simulation tools like NS3,NetAnim,Wireshark,Packet Tracer and
Nmap
 Analyze the Network performance concepts and Traffic flow analysis for
wired and wireless protocols.
 Build virtual LAN’s using NS3 and Packet Tracer.
III. LAB OUTCOMES
On successful completion of this course; the student will be able to:

CO1: Describe the knowledge of the basic protocols involved in wired/wireless


communication process.

CO2: Identify the key issues for the realization of errors detection and
correction in Packets.

CO3: Analyse different network performance concepts and traffic issues for
Quality of Service (QoS) in communication.

CO4: Implement concepts of classical computer and network security


paradigms for Real world Applications.

IV. LAB REQUIREMENTS

Followingarethe requiredhardwareandsoftwareforthislab, which is availableinthelaboratory.


 Hardware: Desktop system or Virtualmachine in a cloud with OS installed.Presently in
the Lab, i3Process or having 4GBRAM and 250GB HardDisk is available.Desktop
systems are dual boot having Windows as well as LinuxOS installed on them.
 Software: NS3 compiler with other tools viz. NS3, NetAnim, Wireshark, Packet Tracer
and Nmap.

Program 1
1 Problem Statement
Introduction to: (a) discrete event simulation, (b) NS3, (c) NS 3 Installation, (d) NetAnim.
2 Student Learning Outcomes
After successful completion of this lab, the student shall be able to

 Understand the meaning of dicrete event simulatior like NS3


 Gain knowledge to install the ns3 software in Ubuntu.
 Understand NetAnim and its installation.

(a) Introduction to dicrete event simulation


System: A collection of entities that act and interact together toward the
accomplishment of some logical end.
Discrete system: State variables change instantaneously at separated point
in time, e.g., a bank, since state variables - number of customers, change
only when a customer arrives or when a customer finishes being served and
departs
Continuous system: State variable change continuously with respect to time,
e.g., airplane moving through the air, since state variables - position and
velocity change continuously with respect to time
Why Simulation?
 Many systems are highly complex, precluding the possibility of analytical
solution
 The analytical solutions are extraordinarily complex, requiring vast
computing resources
 Thus, such systems should be studied by means of simulation
Numerically exercising the model for inputs in question to see how they
affect the output measures of performance
“Simulation is the process of designing a model of a real system and
conducting experiments with this model for the purpose either of
understanding the behavior of the system or of evaluating various strategies
(within the limits imposed by a criterion or set of criteria) for the operation of
a system.”

What is Discrete-Event Simulation (DES)?


A discrete-event simulation models a system whose state may change only
at discrete point models a system whose state may change only at discrete
point in time.
System:is composed of objects called entities that have certain properties
called attributes.
State:a collection of attributes or state variables that represent the entities
of the system.
Event:an instantaneous occurrence in time that may alter the state of the
system

(b) Introduction to ns3


ns-3 is a discrete-event network simulator, targeted primarily for research and educational use.
ns-3 is free software, licensed under the GNU GPLv2 license, and is publicly available for
research, development, and use.
The goal of the ns-3 project is to develop a preferred, open simulation environment for
networking research: it should be aligned with the simulation needs of modern networking
research and should encourage community contribution, peer review, and validation of the
software.

(c) ns3 installation

Download the ns3 package (ns-allinone-3.28 or any other version) from


https://www.nsnam.org and follow following steps:

$cd Desktop

$cd ns-allinone-3.28

$./build.py --enable-examples --enable-test

$cd ns-3.28

$./waf --build-profile=debug --enable-examples --enable-test configure

once all the configuration is done NS-3 is installation is completed.

To check whether NS-3 is successfully installed verify with this:

$./waf --run hello-simulator

U will see the output as hello-simulator

(d) NetAnim Installation


$ Sudo apt install qt4-default qt4-make
$ cd NetAnim
$ qmake NetAnim.pro
$ make

Execution of NetAnim
$ Cd to NetAnim from ns3.28...
$ ./NetAnim

Program 2
1 Problem Statement
Write a NS3 program to connect two nodes with a point to pint link, which
have unique interface. Analyze the network performance using UDP client
server.
2 Student Learning Outcomes
After successful completion of this lab, the student’s shall be able to

 Understand to establish point to point network.


 Create an interface to point to point link
 Anylize the Network performance using client server

3 Design of the Program


3.
Theory
1
Point to Point Network

Fig:Point to Point Network

This type of network consists of many connections between individual


pairs of machines. To go from the source to the destination, a packet of
information on this type of network may have to first visit one or more
intermediate machines. Often multiple routes, of different length are possible,
so routing algorithms play an important role in point-to-point networks.

Network performance

Network Performance refers to measures of service quality of a


network

UDP: User Datagram Protocol

The User Datagram Protocol (UDP) is the simpler of the two


standard TCP/IP transport protocols. It is a process-to-process protocol that
adds only port addresses, checksum error control, and length information to
the data from the upper layer.

3.
Coding using C++ Language
2
#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"
#include "ns3/netanim-module.h"

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");

int
main (int argc, char *argv[])
{
CommandLine cmd;
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.1.1.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));
AnimationInterface anim ("first.xml");
anim.SetConstantPosition(nodes.Get (0), 10.0, 10.0);
anim.SetConstantPosition(nodes.Get (1), 20.0, 30.0);
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
3.3 Expected Results

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy