CN_Lab program 1 and 2
CN_Lab program 1 and 2
3rd Year—5thSem
Batch 2022-2026
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
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:
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.
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
$cd Desktop
$cd ns-allinone-3.28
$cd ns-3.28
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
Network performance
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"
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);