Download as pdf or txt
Download as pdf or txt
You are on page 1of 115

LAB MANUAL

OF

MACHINE LEARNING LAB ECE-350P

DEPARTMENT OF ELECTRONICS AND


COMMUNICATION

Maharaja Agrasen Institute of Technology, PSP Area,


Sector-22, Rohini, New Delhi - 110085
(Affiliated to Guru Gobind Singh Indraprastha University, New Delhi)
MAHARAJA AGRASEN INSTITUTE OF TECHNOLOGY

VISION
To nurture young minds in a learning environment of high academic value
and imbibe spiritual and ethical values with technological and management
competence.

MISSION
The Institute shall endeavor to incorporate the following basic
missions in the teaching methodology:
Engineering Hardware – Software Symbiosis
Practical exercises in all Engineering and Management disciplines shall be
carried out by Hardware equipment and the related software enabling a
deeper understanding of basic concepts and encouraging inquisitive nature.
Life – Long Learning
The Institute strives to match technological advancements and encourage
students to keep updating their knowledge for enhancing their skills and
inculcating their habit of continuous learning.
Liberalization and Globalization
The Institute endeavors to enhance the technical and management skills of
students so that they are intellectually capable and competent
professionals with Industrial Aptitude to face the challenges of
globalization.
Diversification
The Engineering, Technology, and Management disciplines have diverse
fields of study with different attributes. The aim is to create a synergy of the
above characteristics by encouraging analytical thinking.
Digitization of Learning Processes
The Institute provides seamless opportunities for innovative learning in all
Engineering and Management disciplines through the digitization of learning
processes using analysis, synthesis, simulation, graphics, tutorials, and
related tools to create a platform for a multi-disciplinary approach.
Entrepreneurship
The Institute strives to develop potential Engineers and Managers by
enhancing their skills and research capabilities so that they become
successful entrepreneurs and responsible citizens.
DEPARTMENT OF ELECTRONICS AND COMMUNICATION
VISION
To Produce “Critical Thinkers of Innovative Technology”

MISSION
To provide an excellent learning environment across the computer science discipline to inculcate
professional behavior, strong ethical values, innovative research capabilities, and leadership abilities
which enable them to become successful entrepreneurs in this globalized world.

1. To nurture an excellent learning environment that helps students to enhance their problem-
solving skills and to prepare students to be lifelong learners by offering a solid theoretical
foundation with applied computing experiences and educating them about their professional, and
ethical responsibilities.

2. To establish Industry-Institute Interaction, making students ready for the industrial


environment and be successful in their professional lives.

3. To promote research activities in the emerging areas of technology convergence.

4. To build engineers who can look into the technical aspects of an engineering solution thereby
setting the ground for the production of successful entrepreneurs.

5. To build engineers who can look into the technical aspects of an engineering solution thereby
setting the ground for the production of successful entrepreneurs.
INDEX OF THE CONTENTS

1. Introduction to the lab

2. Lab Requirements (details of H/W & S/W to be used)

3. List of Experiments as per GGSIPU

4. List of Experiments beyond the syllabus

5. Format of the Lab record to be prepared by the students

6. Marking Scheme for the Practical Exam

7. Instructions for each Lab Experiment

8. Sample Viva-Questions
1. Introduction to the LAB

Lab Objective
 To analyze various computer network protocols and components of computer networks.

 To design and evaluate the challenges in building networks as per the requirement of an
organization.

Lab Outcomes
 Design and analyze network protocols using state of art simulation tools (open-sourced).

 Design, analyze and evaluate network services for homes, data centers, IoT, LANs, and
WANs.
2. LAB REQUIREMENTS

Hardware Details
● Intel i3/C2d Processor/ 2GB RAM/ 500GB HDD/MB/Lan Card/Keyboard/
Mouse/CD Drive/ 15’’ Colour Monitor/UPS/

● LaserJet Printer

Software Details
● Cisco Packet Tracer - Simulation Software used to create complicated network typologies, as
well as to test and simulate abstract networking concepts
● NS3 – NS3 helps to create various virtual nodes (i.e., computers in real life) and with the help of
various Helper classes it allows us to install devices, internet stacks, application, etc to our nodes.
MACHINE LEARNING LAB

(Department of ECE)
Paper Code: ECE-350P

Faculty Name Student Name:

Roll No.:

Semester:

Maharaja Agrasen Institute of Technology, PSP Area,


Sector – 22, Rohini, New Delhi – 110085

ML Lab (ECE-350P)
Lab Assessment Sheet

Student Enrollment No: Student Name:

S. Experiment Date of Experiment Sign


No.

Jddjjskaksndnsjdjsjjsjdjdjdj

Faculty Name :-

Signature :-
LIST OF EXPERIMENTS
1. Installation of Cisco Packet Tracer.

2. Installation of NS3.
3. Installation of NS2
4. (A) Introduction to Data Communication Network laboratory, Introduction to Discrete Event
Simulation and Discrete Event Simulation Tools.
(B) Introduction to Software NS2 and NS3. Also State the differences between both
5. (A) To stimulate peer to peer network
(B) Connect computer using given topology
6. To simulate and measure the round-trip time of communication between an echo client and server
over a point-to-point network link in an NS-3 network simulation.
7. To simulate a basic point-to-point network scenario with two nodes, where an echo client on one
node sends a single 1024-byte packet to an echo server on the other node over a 5 Mbps link with a 2
ms delay.
8. To simulate a network topology with a combination of point-to-point, CSMA, and Wi-Fi
connections and measure the performance of UDP echo communication between various nodes.
9. To demonstrate how to create a custom object in NS-3 that can be traced, and it connects a trace
function to monitor changes in an integer value within that object.
10. To simulate and analyze the behavior of an ns-3 TCP connection, focusing on monitoring changes
in the congestion window and handling packet drops.
11. To stimulate and observe changes in ns-3 TCP congestion window and packet drops in a network
with a point-to-point connection and custom applications.
12. To simulate and analyze the changes in the ns-3 TCP congestion window, monitor packet drops,
and create graphs of packet byte counts over time in a network with a point-to-point connection and
custom applications.
13. Wireless router configuration using cisco packet
14. Connection of two different network using cisco packet
15. Running and using services/commands like ping, trace, route, nslookup, arp, ftp etc.
16. Connect two networks using router in cisco packet tracer
17. Connection two networks using switch in cisco packet tracer
18. To stimulate hybrid model network in cisco packet tracer
Beyond the syllabus
19.(A) Stimulate routing information protocol using cisco packet tracer
(B) Stimulate dynamic routing from routing protocol information using cisco packet tracer
20.Stimulate college campus network design using cisco packet tracer
MARKING SCHEME FOR PRACTICAL EXAMS

There will be two practical exams in each semester

1. Internal Practical Exam


2. External Practical Exam

INTERNAL PRACTICAL EXAM


It is taken by the respective Faculty of the batch

MARKING SCHEME FOR THIS EXAM IS


Total Marks: 40

Division of 10 marks per practical is a s follows:


Rubrics for Laboratory (General)
Experiment Max Grading Rubrics
S.No. Component Marks
2 Marks 1 Marks
Completeness of Practical, exhibits Incomplete practical,
Practical
1 2 proficiency in using different types unformatted, lacks comments,
Performance
of inputs demonstrates no proficiency
Output and Output contains few logical
Output is free of errors and output
Validation errors and/or no output is
is obtained. Demonstrates
obtained. Demonstrates
2 2 excellent understanding of the
partial understanding of
concepts relevant to the
the concepts relevant to
experiment.
the experiment.
1. Four Marks for answering more than 75% questions
Attendance 2. Three marks for answering more than 60% questions
3 and Viva 4 3. Two marks for answering more than 50% questions
Questions
4. One mark for answering less than 50% questions

Timely
Submissio
4 2 On Time submission Late submission
n of Lab
Record
Each experiment will be evaluated out of 10 Marks. At the end of the semester average of 8 best performed
practical will be considered as marks out of 40.

EXTERNAL PRACTICAL EXAM


It is taken by the concerned lecturer of the batch and by an external examiner. In this exam student needs to
perform the experiment allotted at the time of the examination, a sheet will be given to the student in which
some details asked by the examiner needs to be written and at the last viva will be taken by the external
examiner.

MARKING SCHEME FOR THIS EXAM IS:

Total Marks: 60

Division of 60 marks is a follows


1. Sheet filled by the student: 20
2. Viva Voice: 15

3. Experiment Performance: 15

4. File Submitted: 10
NOTE:

● Internal Marks + External Marks = Total marks given to


students (40 Marks) (60 Marks) (100
Marks)

● Experiments given to perform can be from any section of the lab.

Experiment –1
Aim: Installation of Cisco Packet Tracer.

Theory
Cisco Packet Tracer is a network simulation and visualization tool developed by Cisco Systems.
It is primarily used for teaching and learning networking concepts, allowing users to create
virtual network environments and simulate network behaviours. Packet Tracer provides a
graphical interface that enables users todesign, configure, and troubleshoot networks without the
need for physical hardware.

Key features of the Cisco Packet Tracer include:

1. Network topology creation: Users can create network topologies by dragging and dropping
devices such as routers, switches, PCs, servers, and more onto a virtual workspace.

2. Device configuration: Users can configure the devices in the network, including setting IP
addresses, enabling routing protocols, configuring security features, and implementing advanced
network configurations.

3. Network simulation: Packet Tracer simulates network behaviors and allows users to observe
the flow of data packets, inspect network traffic, and analyze network performance.

4. Protocols and technologies: Packet Tracer supports a wide range of networkingprotocols and
technologies, including Ethernet, TCP/IP, routing protocols (e.g., OSPF, EIGRP), switching
protocols (e.g., VLANs, STP), wireless networking, and security features (e.g., firewalls, VPNs)

5. Collaboration and learning: Packet Tracer offers collaborative features that enable users to
work together on network projects and share their work. It is widely
used in educational institutions to teach networking concepts and facilitate hands- on learning
experiences.

6. Assessment and evaluation: Packet Tracer includes built-in assessment tools that allow
instructors to create and distribute activities, quizzes, and exams to evaluate students'
understanding of networking concepts and their ability to configure and troubleshoot networks.

7. Multi-platform support: Cisco Packet Tracer is available for Windows, macOS, and Linux
operating systems, making it accessible to a wide range ofusers.

Packet Tracer is widely used by networking students, instructors, and professionals to gain
practical experience in designing, configuring, and troubleshooting networkenvironments. It
helps users develop their networking skills in a virtual, risk-free environment before working
with physical network equipment.

Installing Packet Tracer on Linux

1. Download Packet Tracer: Visit the Cisco Networking Academy website


(https://www.netacad.com/) and log in with your account. Navigate to the Packet Tracer
download page and download the Linux version of Packet Tracer. Ensure you select the
appropriate version for your Linux distribution.

2. Open the terminal: Launch the terminal application on your Linux system. Youcan usually
find it in the applications menu or by pressing Ctrl+Alt+T.

3. Navigate to the directory: Use the `cd` command to navigate to the directory where the
downloaded Packet Tracer file is located. For example, if it's in the Downloads folder, you can
use the following command:

cd ~/Downloads
4. Extract the archive: Extract the downloaded Packet Tracer archive using the
`tar` command. Replace `PacketTracer.tar.gz` with the actual name of the
downloaded file.

tar -xvzf PacketTracer.tar.gz

5. Navigate to the extracted directory: Use the `cd` command to navigate to the
extracted Packet Tracer directory.

cd PacketTracer

6. Run the installation script: Execute the installation script with administrative
privileges using the `sudo` command.

sudo ./install

Enter your password when prompted.

7. Follow the on-screen prompts: The installation script will guide you through the
installation process. Read and accept the end-user license agreement, andfollow the
prompts to complete the installation.

8. Launch Packet Tracer: After the installation completes successfully, you can launch
Packet Tracer from the applications menu or by running the following command:
packet
tracer
This will start Cisco Packet Tracer on the Linux system.
EXPERIMENT – 2
AIM : Installation of NS3.

THEORY
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
Prerequisite packages for Linux are as follows:

1. Minimal requirements for Python: gcc g++ python


2. Debugging and GNU Scientific Library (GSL) support: gdbpython-dev
3. valgrind gsl-bin libgsl0-dev libgsl0ldbl Network Simulation Cradle (nsc): flex bisonReading pcap
packet traces: tcpdump

4.Database support for statistics framework: sqlite sqlite3


5. Xml-based version of the config store: libxml2
6.A GTK-based configuration system: libgtk2.0-0
7. Experimental with virtual machines and ns-3: vtun lxc

STEPS FOR INSTALLATION


A. Open linux and go to terminal.
B. Type ‘cd Downloads’ to get to the location of the NS3 package and PressENTER.
C. Type ‘ls’ to list items available in Folder and Press ENTER.
D. Type ‘cd ns-allinone-3.29’ to get location of the Folder and Press ENTER.
E. Type ‘ls’ to list items available in Folder and Press ENTER.
F. Type ‘cd ns-3.29’ to get location of the Folder and Press ENTER.
G. Type ‘./waf --run (file name)’ to run the program already written in python.
OUTPUT
EXPERIMENT – 4 (A)

Introduction to Data Communication Network laboratory, Introduction to Discrete EventSimulation and


Discrete Event Simulation Tools.

THEORY
To understand the concepts of Data Communications Lab some of the terminologies areexplained
below:
System - A collection of entities that act and interact together toward the accomplishment of some logical
end.

Types of System:-
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 acustomer finishes being
served and departs.
Continuous system:
State variable change continuously with respect to time, e.g., airplane moving throughthe air,
since state variables - position and velocity change continuously
with respect to time.

Fig 1. Ways to Study System


Fig 2. Model Taxinomy
Simulation

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 behaviour 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.

Why Simulation?
 Many systems are highly complex, precluding the possibility of analytical solution.
 The analytical solutions are extraordinarily complex, requiring vast computingresources.
 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.
Discrete-Event Simulation (DES)
A discrete-event simulation models a system whose state may change only at discrete point in time.
System is composed of objects called entities that have certain propertiescalled attributes. State is a
collection of attributes or state variables that represent the entities of the system. Event is an
instantaneous occurrence in time that may alter the state of system.
EXPERIMENT – 4(B)
AIM

Introduction to Software NS2 and NS3. Also State the differences between both

THEORY

A. NS2 stands for Network Simulator Version 2. It is an open-source event-driven simulatordesigned


specifically for research in computer communication networks.
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 language.
6. Otcl: Object oriented support
7. TclCL: C++ and otcl linkage
8. Discrete event scheduler

Basic Architecture of NS2


NS2 consists of two key languages: C++ and Object-oriented Tool Command Language (OTcl). While
the C++ defines the internal mechanism (i.e., a backend) of the simulationobjects, the OTcl sets up
simulation by assembling and configuring the objects as well asscheduling discrete events. The C++
and the OTcl are linked together using TclCL

B. NS3 stands for Network Simulation 3. We use NS3, which is a discrete event network simulator for
Internet. NS3 helps to create various virtual nodes (i.e., computers in reallife) and with the help of
various Helper classes it allows us to install devices, internet stacks, application, etc to our nodes.
Using NS3 we can create point-to-point, Wireless, CSMA, etc connections between nodes. Point-to-
point connection is same as a LAN connected between two computers. Wireless connection is same as
Wi-Fi connection between various computers and routers.CSMA connection is same as bus topology
between computers. After building connections we try to install NIC to every node to enable network
connectivity.
When network cards are enabled in the devices, we add different parameters in the channels (i.e., real
world path used to send data) which are data-rate, packet size, etc. Now we use Application to generate
traffic and send the packets using these applications.
Features of NS3
1. Tracing of the nodes : NS3 allows us to trace the routes of the nodes which helps usto know how
much data is send or received. Trace files are generated to monitor these activities.
2. NetAnim : It stands for Network Animator. It is an animated version of how network will look
in real and how data will be transferred from one node to other.
3. Pcap file : NS3 helps to generate pcap file which can be used to get all informationof the packets
(e.g., Sequence number, Source IP, destination IP, etc). These pcapscan be seen using a software
tool known as wireshark.
4. GnuPlot: GnuPlot is used to plot graphs from the data which we get from trace file of NS3.
Gnuplot gives more accurate graph compare to other graph making tools and also it is less
complex than other tools.
DIFFERENCE BETWEEN NS2 and NS3

DIFFERENCE
NS3 NS2
CATEGORY
Application level Difference NS3 can be act as the NS2 cannot be act as the
between NS2 emulator that it can emulator.
and NS3: connect to the real world
Some of the NS2 modelscan NS3 scripts cannot runin
be imported to NS3 NS2 environment
Programming Language NS3 is written using C++ NS2 is written with the
level Difference between help of TCL and C++.
Ns2
and NS3:
Compilation time is not a C++ recompilation takes
matter more time more than TCL
so most of the scripts are
written using
TCL

A Simulation script canbe Simulation script is not


written in ns3 possible with NS2
Python is available for the Only TCL can be used as
scripting language the scripting language
Packets difference in Information needed to send The header part of the
NS2 and NS3: through the packet can be NS2 includes all the
information of header
added at the header, trailer,
buffer, etc.
parts in the specified
protocol
NS3 frees the memory NS2 never reuse or re
that used to store the allocate the memory until
packets it get terminated.
The packet of ns3 consist The packet of ns2 has
of single bufferand small headers and data for
tags. payload.
File Format Difference .tr-> files used for trace . tr-> files used for trace
between NS2 and NS3: analysis parameters
.XML->files are used for .nam -> files used for
network Animation Network Animation
.csv-> files used for gnuplot .xg -> files used for
graph
Visualization Difference Python visualizer, Network Nam animator is
between NS2 and NS3: Animator visualization is available for
available visualization.
Performance level Memory allocation is Memory allocation isnot
difference between NS2and good good as NS3
NS3:
System prevents Unnecessary parameters
unnecessary parameters tobe cannot be prevented.
stored.
Total computation is less Total Computation timeis
when compared to NS2 high when compared to
NS3

Table:- 2
Fig :- Difference of NS2 and NS3
EXPERIMENT – 3
AIM
Installation of NS2

Steps is to install NS2


1. Download NS2 from following link: https://www.isi.edu/nsnam/dist/ns-allinone-2.28.tar.gz
2. Decompress the file use winrar. Copy the decompressed folder the Cygwin installation directory under the
subdirectory home. It will be C:\cygwin\home\system_name : where system_name is name of your system in above
Cygwin installation this path will be C:\Cygwin\home\sys27

3. Run Cygwin from desktop and change the directory to folder you copied just now in step 2 command to change
directory:cd /home/sys27/ns-allinone-2.28

NOTE: please change sys27 to name of your system


4. To start installation type following command:"./install"(WITHOUT qoutes)

This will began the installation process if any Cygwin package is missing it will be reported to you if so the run
Cygwin setu.exe and install the missing package and start again from step 2.

Installation is a long process and take quite some time once it is finished you will get a screen as shown below:
5. Add following lines to the .bashrc

export NS_HOME=/home/sys27/ns-allinone-2.28
export PATH=$NS_HOME/nam-
1.11:$NS_HOME/tcl8.4.5/unix:$NS_HOME/tk8.4.5/unix:$NS_HOME/bin:$PATH
export LD_LIBRARY_PATH=$NS_HOME/tcl8.4.5/unix:$NS_HOME/tk8.4.5/unix:$NS_HOME/otcl-
1.9:$NS_HOME/lib:$LD_LIBRARY_PATH
export TCL_LIBRARY=$NS_HOME/tcl8.4.5/library

NOTE: replace sys27 with your system name

6. To check if NS2 is installed correctly you can run one sample example given in ns-tutorials folder

To run the example change the directory to examples folder: cd ./home/sys27/ns-allinone-2.28/ns-tutorial/examples

Then type following command:


EXPERIMENT – 5(A)
AIM
To stimulate peer to peer network

Peer to Peer network


1.A peer-to-peer (P2P) network is type of decentralized and distributed network architecture in which individual
nodes in the network i.e. computer (called "peers") act as both suppliers and consumers of resources.

2. It differs from client-server networking, where certain devices have responsibility for providing or “serving" data
and other devices consume or otherwise act as "clients" of those servers.

3. Computers in a peer to peer network run the same networking protocols and software. peer networks are also
often situated physically near to each other typically in homes, small businesses or schools. Peer-to-peer networks
are generally simpler, but they usually do not offer the same performance under heavy loads.

Concept structure

Fig :- Peer to peer network model


Diagram :-
1. A set of computers with NIC card installed in it.
2. Transmission media and connector

Stepwise procedure
1.Install and configure TCP/IP :
2.Click Start->Control Panel->Network and Internet-> View network status and tasks or Network and sharing
Center, Click on Change adapter settings.
3. Select the connection, right click it and select properties.

4 Click Install then. Click Protocol, and then click Add. Click Have Disk. Type the location as
c:\windows\inf and then click OK. On the list of available protocols, click Internet Protocol (TCP/IPv4),
and then click OK. And it would be installed on your computer.

5 There are two ways to configure the TCP/IP Properties, Assigned by DHCP server automatically or manually.
6 Assigned by DHCP Server :-Select Obtain an IP address automatically and Obtain DNS. Server address
automatically, if necessary, then click OK to Save the settings.
7. Assigned manually :
Select Use the following IP address, type address, subnet mask and default gateway IP address into
it. Select Use the following DNS server

addresses, type your local area DNS server IP addresses into it, if
necessary, then click OK to save the settings.
8 Click OK to save and apply your
settings :
Let following are configuration details for
both computers :

Configuration Computer A Computer B


IP address 192.168.10.100 192.168.10.110

Subnet mask 255.255.255.0 255.255.255.0

Computer Name Prl-01 Prl-02

Workgroup PRL-LAB PRL-LAB

9 For computer A and Computer B open control panel > Network and Internet > Network and Sharing center
> Change adapter settings.
10. Assigned IP address to both computers using TCP/IP configuration explained in previous procedure.

Computer Computer
A B

11 .Then turn off windows Firewall, so connections can be monitored using cmd. to do this open, Control
Panel
> System and security > Windows Firewall > Turn Windows ON or OFF.

12 In Order both computers can connect to each other, the workgroup of both computers must be the
same. Change its by, Start > Computer > Properties > Advanced system Settings. Then Select the
Computer Name tab > Change. Use the same name between Computer A and Computer B.

Computer Computer
A B

13.To know both computers are connected open command prompt and type ping ip address.
For Computer A

For Computer B

14.You will get four replies back from the ping message. If you receive foru lines of information
showing successes, then Connection is successful.
15.Resources required
 A set of computers with NIC card installed in it.
 Transmission media and connector.
Precautions
 Follow safety practices.
 Handle network devices carefully.
Results :
Student shall install configure TCP/IP and configure peer to peer network in laboratory and write the
information in the following table
EXPERIMENT – 5(B)

AIM
Connect computer using given topology
Theoretical Background
Proposition 1. Protocol
 It is the physical layout or fashion in which computers of a small area are connected to each other.
 There are two types of the topology

Physical topology :-
It refers to the placement of the various network's components, including device location and cable installation.
The shape of the cabling layout used to link devices is called the physical topology of the network. This refers to the
layout of cabling, the locations of nodes, and the interconnections between the nodes and the cabling.
Logical topology :
It shows how data flows within a network, regardless of its physical design.
If often closely associated with Media Access Control methods and protocols. Logical topologies are able to be
dynamically reconfigured by special types of equipment such as routers and switches

Concept structure
Network topology

Physical Logical
Components Data flows
arrangements in network

Proposition2. TCP/IP
Transmission Control protocol/Internet Protocol, used to connect computers on the internet or network.
TCP/IP is built into the UNIX operating system and is used by the Internet, making it

Proposition 2. Topology types


 Following are different types of topology which mainly used to connect computers with each other to forma
network.
Bus topology
A bus topology consists of main System Bus with a terminator at each end in which allcomputers (node) are
connected to the cable.
A signal from the source travels in both directions to all computers connected on the bus cable until it finds the
intended recipient. If the computer address does not match the intended address for the data, the computer ignores
the data.

Concept structure

Bus topology (Refer color picture 32

Ring topology
In this all the computers (nodes) are connected to each-other in such a way that they make a closed loop.
Each computer is connected to two other components on either side, and it communicated with these two
adjacent neighbors. Data is sent around the ring until it reaches its final destination.

Concept structure :

Bus topology (Refer color picture 32)


Mesh topology
 This topology employs either or two schemes, called full mesh and partial mesh.
 In the full mesh topology, each computer is connected directly to each of the others. In the partial mesh
topology. some computers are connected to all the others, and some are connected only to those other nodes
with which they exchange the most data.
 If there are n computers, there will be (n x (n-1)) ¸ 2 cables in the network. For examples, if you have five
computers in a mesh network, it will use 5 x (5 - 1) ¸ 2, which equals 10 cables.
Concept structure

Bus topology (Refer color picture 32)

Star topology
 In this every node (computer workstation or any other peripheral) is connected to central node or device called hub or
switch)
 All the data on the star topology passes through the central device before reaching the intended destination.
 a hub forwards data packets to all the ports. A switch is more intelligent. It recognizes which computer is connected
to which port based on the MAC address and saves this information in a table. When a switch receives a data packet,
it determines the recipient and forwards the packet to the correct computer.
 An advantage of the star topology is the simplicity of adding additional nodes. The primary disadvantage of the star
topology is that the hub/switch represents a single point of failure.
 Extended Star topology uses the star topology to be created. It links individual stars together by linking the
hubs/switches. this will extend the length of the network.

Concept structure

NODE HUB
Fig :- Star topology
Stepwise procedure

 Teacher shall explain structure, advantage and disadvantage of each topology.


 Physical formation of star topology :
 Power on the computers that want to connect in star topology and confirm whether operating system and NIC
card is properly worked.
 Power on the central device i.e. switch or hub.
 Take cable and connect one end of one cable to port of the switch or hub and connect the other end of the same
cable to computer's NIC port.
 The lights on port of the switch or hub and computer's NIC port should turn on. (On somedevices, the lights
will flicker on and off; this is normal activity.)
 This is the physical formation of star topology.

Resources Required
 A set of computers with updated configuration.
 Switch / Hub
 Transmission media and connector
Precautions
 Handle carefully network devices.
 Follow safely Practices
 Check workgroup of computer or write name of workgroup under which all computers are connected to each
other.

 Assign IP address to computer using TCP/IP configuration.


Results
 Student shall connect computer in star topology in a laboratory and write the information for following things in
the given table as per observations
Experiment-6

Aim
To simulate and measure the round-trip time of communication between an echo client and server over a
point-to-point network link in an NS-3 network simulation.

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;

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

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

Result
We have simulate and measure the round-trip time of communication between an echo client and server over a
point-to-point network link in an NS-3 network simulation.
Experiment- 7
Aim
To simulate a basic point-to-point network scenario with two nodes, where an echo client on one node sends a
single 1024-byte packet to an echo server on the other node over a 5 Mbps link with a 2 ms delay.

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;

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

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

Result
We have simulate a basic point-to-point network scenario with two nodes, where an echo client on one node
sends a single 1024-byte packet to an echo server on the other node over a 5 Mbps link with a 2 ms delay.
Experiment-8
Aim
To simulate a network topology with a combination of point-to-point, CSMA, and Wi-Fi connections and
measure the performance of UDP echo communication between various nodes.

Code
#include “ns3/core-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/network-module.h”
#include “ns3/applications-module.h”
#include “ns3/mobility-module.h”
#include “ns3/csma-module.h”
#include “ns3/internet-module.h”
#include “ns3/yans-wifi-helper.h”
#include “ns3/ssid.h”

// Default Network Topology


//
// Wifi 10.1.3.0
// AP
// * * * *
// | | | | 10.1.1.0
// n5 n6 n7 n0 -------------- n1 n2 n3 n4
// point-to-point | | | |
// ================
// LAN 10.1.2.0

Using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“ThirdScriptExample”);

Int
Main (int argc, char *argv[])
{
Bool verbose = true;
Uint32_t nCsma = 3;
Uint32_t nWifi = 3;
Bool tracing = false;
CommandLine cmd;
Cmd.AddValue (“nCsma”, “Number of \”extra\” CSMA nodes/devices”, nCsma);
Cmd.AddValue (“nWifi”, “Number of wifi STA devices”, nWifi);
Cmd.AddValue (“verbose”, “Tell echo applications to log if true”, verbose);
Cmd.AddValue (“tracing”, “Enable pcap tracing”, tracing);

Cmd.Parse (argc,argv);

// The underlying restriction of 18 is due to the grid position


// allocator’s configuration; the grid layout will exceed the
// bounding box if more than 18 nodes are provided.
If (nWifi > 18)
{
Std::cout << “nWifi should be 18 or less; otherwise grid layout exceeds the bounding box” << std::endl;
Return 1;
}

If (verbose)
{
LogComponentEnable (“UdpEchoClientApplication”, LOG_LEVEL_INFO);
LogComponentEnable (“UdpEchoServerApplication”, LOG_LEVEL_INFO);
}

NodeContainer p2pNodes;
P2pNodes.Create (2);

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

NetDeviceContainer p2pDevices;
P2pDevices = pointToPoint.Install (p2pNodes);

NodeContainer csmaNodes;
csmaNodes.Add (p2pNodes.Get (1));
csmaNodes.Create (nCsma);

CsmaHelper csma;
Csma.SetChannelAttribute (“DataRate”, StringValue (“100Mbps”));
Csma.SetChannelAttribute (“Delay”, TimeValue (NanoSeconds (6560)));

NetDeviceContainer csmaDevices;
csmaDevices = csma.Install (csmaNodes);
NodeContainer wifiStaNodes;
wifiStaNodes.Create (nWifi);
NodeContainer wifiApNode = p2pNodes.Get (0);

YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();


YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
Phy.SetChannel (channel.Create ());

WifiHelper wifi;
Wifi.SetRemoteStationManager (“ns3::AarfWifiManager”);

WifiMacHelper mac;
Ssid ssid = Ssid (“ns-3-ssid”);
Mac.SetType (“ns3::StaWifiMac”,
“Ssid”, SsidValue (ssid),
“ActiveProbing”, BooleanValue (false));

NetDeviceContainer staDevices;
staDevices = wifi.Install (phy, mac, wifiStaNodes);

mac.SetType (“ns3::ApWifiMac”,
“Ssid”, SsidValue (ssid));

NetDeviceContainer apDevices;
apDevices = wifi.Install (phy, mac, wifiApNode);

MobilityHelper mobility;

Mobility.SetPositionAllocator (“ns3::GridPositionAllocator”,
“MinX”, DoubleValue (0.0),
“MinY”, DoubleValue (0.0),
“DeltaX”, DoubleValue (5.0),
“DeltaY”, DoubleValue (10.0),
“GridWidth”, UintegerValue (3),
“LayoutType”, StringValue (“RowFirst”));

Mobility.SetMobilityModel (“ns3::RandomWalk2dMobilityModel”,
“Bounds”, RectangleValue (Rectangle (-50, 50, -50, 50)));
Mobility.Install (wifiStaNodes);

Mobility.SetMobilityModel (“ns3::ConstantPositionMobilityModel”);
Mobility.Install (wifiApNode);

InternetStackHelper stack;
Stack.Install (csmaNodes);
Stack.Install (wifiApNode);
Stack.Install (wifiStaNodes);

Ipv4AddressHelper address;

Address.SetBase (“10.1.1.0”, “255.255.255.0”);


Ipv4InterfaceContainer p2pInterfaces;
P2pInterfaces = address.Assign (p2pDevices);

Address.SetBase (“10.1.2.0”, “255.255.255.0”);


Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces = address.Assign (csmaDevices);

address.SetBase (“10.1.3.0”, “255.255.255.0”);


address.Assign (staDevices);
address.Assign (apDevices);

UdpEchoServerHelper echoServer (9);

ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));


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

UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);


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

ApplicationContainer clientApps =
echoClient.Install (wifiStaNodes.Get (nWifi – 1));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));

Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

Simulator::Stop (Seconds (10.0));

If (tracing == true)
{
pointToPoint.EnablePcapAll (“third”);
phy.EnablePcap (“third”, apDevices.Get (0));
csma.EnablePcap (“third”, csmaDevices.Get (0), true);
}

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

OUTPUT

Result
We have simulate a network topology with a combination of point-to-point, CSMA, and Wi-Fi connections and
measure the performance of UDP echo communication between various nodes.
Experiment 9
Aim
To demonstrate how to create a custom object in NS-3 that can be traced, and it connects a trace function to
monitor changes in an integer value within that object.

Code
#include “ns3/object.h”
#include “ns3/uinteger.h”
#include “ns3/traced-value.h”
#include “ns3/trace-source-accessor.h”

#include <iostream>

Using namespace ns3;

Class MyObject : public Object


{
Public:
/**
* Register this type.
* \return The TypeId.
*/
Static TypeId GetTypeId (void)
{
Static TypeId tid = TypeId (“MyObject”)
.SetParent<Object> ()
.SetGroupName (“Tutorial”)
.AddConstructor<MyObject> ()
.AddTraceSource (“MyInteger”,
“An integer value to trace.”,
MakeTraceSourceAccessor (&MyObject::m_myInt),
“ns3::TracedValueCallback::Int32”)
;
Return tid;
}

MyObject () {}
TracedValue<int32_t> m_myInt;
};

Void
IntTrace (int32_t oldValue, int32_t newValue)
{
Std::cout << “Traced “ << oldValue << “ to “ << newValue << std::endl;
}

Int
Main (int argc, char *argv[])
{
Ptr<MyObject> myObject = CreateObject<MyObject> ();
myObject->TraceConnectWithoutContext (“MyInteger”, MakeCallback (&IntTrace));

myObject->m_myInt = 1234;
}

OUTPUT

Result
We have demonstrated how to create a custom object in NS-3 that can be traced, and it connects a trace
function to monitor changes in an integer value within that object.
Experiment-10
Aim
To simulate and analyze the behavior of an ns-3 TCP connection, focusing on monitoring changes in the
congestion window and handling packet drops.

Code
#include <fstream>
#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;

NS_LOG_COMPONENT_DEFINE (“FifthScriptExample”);

// ===========================================================================
//
// node 0 node 1
// +----------------+ +----------------+
// | ns-3 TCP | | ns-3 TCP |
// +----------------+ +----------------+
// | 10.1.1.1 | | 10.1.1.2 |
// +----------------+ +----------------+
// | point-to-point | | point-to-point |
// +----------------+ +----------------+
// | |
// +---------------------+
// 5 Mbps, 2 ms
//
//
// We want to look at changes in the ns-3 TCP congestion window. We need
// to crank up a flow and hook the CongestionWindow attribute on the socket
// of the sender. Normally one would use an on-off application to generate a
// flow, but this has a couple of problems. First, the socket of the on-off
// application is not created until Application Start time, so we wouldn’t be
// able to hook the socket (now) at configuration time. Second, even if we
// could arrange a call after start time, the socket is not public so we
// couldn’t get at it.
//
// So, we can cook up a simple version of the on-off application that does what
// we want. On the plus side we don’t need all of the complexity of the on-off
// application. On the minus side, we don’t have a helper, so we have to get
// a little more involved in the details, but this is trivial.
//
// So first, we create a socket and do the trace connect on it; then we pass
// this socket into the constructor of our simple application which we then
// install in the source node.
// ===========================================================================
//
Class MyApp : public Application
{
Public:

MyApp ();
Virtual ~MyApp();

Void Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate
dataRate);

Private:
Virtual void StartApplication (void);
Virtual void StopApplication (void);

Void ScheduleTx (void);


Void SendPacket (void);

Ptr<Socket> m_socket;
Address m_peer;
Uint32_t m_packetSize;
Uint32_t m_nPackets;
DataRate m_dataRate;
EventId m_sendEvent;
Bool m_running;
Uint32_t m_packetsSent;
};

MyApp::MyApp ()
: m_socket (0),
M_peer (),
M_packetSize (0),
M_nPackets (0),
M_dataRate (0),
M_sendEvent (),
M_running (false),
M_packetsSent (0)
{
}

MyApp::~MyApp()
{
M_socket = 0;
}

Void
MyApp::Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate
dataRate)
{
M_socket = socket;
M_peer = address;
M_packetSize = packetSize;
M_nPackets = nPackets;
M_dataRate = dataRate;
}

Void
MyApp::StartApplication (void)
{
M_running = true;
M_packetsSent = 0;
M_socket->Bind ();
M_socket->Connect (m_peer);
SendPacket ();
}

Void
MyApp::StopApplication (void)
{
M_running = false;

If (m_sendEvent.IsRunning ())
{
Simulator::Cancel (m_sendEvent);
}

If (m_socket)
{
M_socket->Close ();
}
}

Void
MyApp::SendPacket (void)
{
Ptr<Packet> packet = Create<Packet> (m_packetSize);
M_socket->Send (packet);

If (++m_packetsSent < m_nPackets)


{
ScheduleTx ();
}
}

Void
MyApp::ScheduleTx (void)
{
If (m_running)
{
Time tNext (Seconds (m_packetSize * 8 / static_cast<double> (m_dataRate.GetBitRate ())));
M_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this);
}
}

Static void
CwndChange (uint32_t oldCwnd, uint32_t newCwnd)
{
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << “\t” << newCwnd);
}

Static void
RxDrop (Ptr<const Packet> p)
{
NS_LOG_UNCOND (“RxDrop at “ << Simulator::Now ().GetSeconds ());
}

Int
Main (int argc, char *argv[])
{
CommandLine cmd;
Cmd.Parse (argc, argv);

NodeContainer nodes;
Nodes.Create (2);

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

NetDeviceContainer devices;
Devices = pointToPoint.Install (nodes);

Ptr<RateErrorModel> em = CreateObject<RateErrorModel> ();


Em->SetAttribute (“ErrorRate”, DoubleValue (0.00001));
Devices.Get (1)->SetAttribute (“ReceiveErrorModel”, PointerValue (em));

InternetStackHelper stack;
Stack.Install (nodes);

Ipv4AddressHelper address;
Address.SetBase (“10.1.1.0”, “255.255.255.252”);
Ipv4InterfaceContainer interfaces = address.Assign (devices);

Uint16_t sinkPort = 8080;


Address sinkAddress (InetSocketAddress (interfaces.GetAddress (1), sinkPort));
PacketSinkHelper packetSinkHelper (“ns3::TcpSocketFactory”, InetSocketAddress (Ipv4Address::GetAny (),
sinkPort));
ApplicationContainer sinkApps = packetSinkHelper.Install (nodes.Get (1));
sinkApps.Start (Seconds (0.));
sinkApps.Stop (Seconds (20.));

Ptr<Socket> ns3TcpSocket = Socket::CreateSocket (nodes.Get (0), TcpSocketFactory::GetTypeId ());


Ns3TcpSocket->TraceConnectWithoutContext (“CongestionWindow”, MakeCallback (&CwndChange));

Ptr<MyApp> app = CreateObject<MyApp> ();


App->Setup (ns3TcpSocket, sinkAddress, 1040, 1000, DataRate (“1Mbps”));
Nodes.Get (0)->AddApplication (app);
App->SetStartTime (Seconds (1.));
App->SetStopTime (Seconds (20.));

Devices.Get (1)->TraceConnectWithoutContext (“PhyRxDrop”, MakeCallback (&RxDrop));

Simulator::Stop (Seconds (20));


Simulator::Run ();
Simulator::Destroy ();

Return 0;
}

OUTPUT
Result
We have simulate and analyze the behavior of an ns-3 TCP connection, focusing on monitoring changes in the
congestion window and handling packet drops.

Experiment-11
Aim
To stimulate and observe changes in ns-3 TCP congestion window and packet drops in a network with a point-
to-point connection and custom applications.

Code
#include <fstream>
#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;

NS_LOG_COMPONENT_DEFINE (“SixthScriptExample”);
// ===========================================================================
//
// node 0 node 1
// +----------------+ +----------------+
// | ns-3 TCP | | ns-3 TCP |
// +----------------+ +----------------+
// | 10.1.1.1 | | 10.1.1.2 |
// +----------------+ +----------------+
// | point-to-point | | point-to-point |
// +----------------+ +----------------+
// | |
// +---------------------+
// 5 Mbps, 2 ms
//
//
// We want to look at changes in the ns-3 TCP congestion window. We need
// to crank up a flow and hook the CongestionWindow attribute on the socket
// of the sender. Normally one would use an on-off application to generate a
// flow, but this has a couple of problems. First, the socket of the on-off
// application is not created until Application Start time, so we wouldn’t be
// able to hook the socket (now) at configuration time. Second, even if we
// could arrange a call after start time, the socket is not public so we
// couldn’t get at it.
//
// So, we can cook up a simple version of the on-off application that does what
// we want. On the plus side we don’t need all of the complexity of the on-off
// application. On the minus side, we don’t have a helper, so we have to get
// a little more involved in the details, but this is trivial.
//
// So first, we create a socket and do the trace connect on it; then we pass
// this socket into the constructor of our simple application which we then
// install in the source node.
// ===========================================================================
//
Class MyApp : public Application
{
Public:
MyApp ();
Virtual ~MyApp ();

/**
* Register this type.
* \return The TypeId.
*/
Static TypeId GetTypeId (void);
Void Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate
dataRate);

Private:
Virtual void StartApplication (void);
Virtual void StopApplication (void);

Void ScheduleTx (void);


Void SendPacket (void);

Ptr<Socket> m_socket;
Address m_peer;
Uint32_t m_packetSize;
Uint32_t m_nPackets;
DataRate m_dataRate;
EventId m_sendEvent;
Bool m_running;
Uint32_t m_packetsSent;
};

MyApp::MyApp ()
: m_socket (0),
M_peer (),
M_packetSize (0),
M_nPackets (0),
M_dataRate (0),
M_sendEvent (),
M_running (false),
M_packetsSent (0)
{
}

MyApp::~MyApp ()
{
M_socket = 0;
}

/* static */
TypeId MyApp::GetTypeId (void)
{
Static TypeId tid = TypeId (“MyApp”)
.SetParent<Application> ()
.SetGroupName (“Tutorial”)
.AddConstructor<MyApp> ()
;
Return tid;
}

Void
MyApp::Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate
dataRate)
{
M_socket = socket;
M_peer = address;
M_packetSize = packetSize;
M_nPackets = nPackets;
M_dataRate = dataRate;
}

Void
MyApp::StartApplication (void)
{
M_running = true;
M_packetsSent = 0;
M_socket->Bind ();
M_socket->Connect (m_peer);
SendPacket ();
}

Void
MyApp::StopApplication (void)
{
M_running = false;

If (m_sendEvent.IsRunning ())
{
Simulator::Cancel (m_sendEvent);
}

If (m_socket)
{
M_socket->Close ();
}
}

Void
MyApp::SendPacket (void)
{
Ptr<Packet> packet = Create<Packet> (m_packetSize);
M_socket->Send (packet);

If (++m_packetsSent < m_nPackets)


{
ScheduleTx ();
}
}

Void
MyApp::ScheduleTx (void)
{
If (m_running)
{
Time tNext (Seconds (m_packetSize * 8 / static_cast<double> (m_dataRate.GetBitRate ())));
M_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this);
}
}

Static void
CwndChange (Ptr<OutputStreamWrapper> stream, uint32_t oldCwnd, uint32_t newCwnd)
{
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << “\t” << newCwnd);
*stream->GetStream () << Simulator::Now ().GetSeconds () << “\t” << oldCwnd << “\t” << newCwnd <<
std::endl;
}

Static void
RxDrop (Ptr<PcapFileWrapper> file, Ptr<const Packet> p)
{
NS_LOG_UNCOND (“RxDrop at “ << Simulator::Now ().GetSeconds ());
File->Write (Simulator::Now (), p);
}

Int
Main (int argc, char *argv[])
{
CommandLine cmd;
Cmd.Parse (argc, argv);

NodeContainer nodes;
Nodes.Create (2);

PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“5Mbps”));
pointToPoint.SetChannelAttribute (“Delay”, StringValue (“2ms”));
NetDeviceContainer devices;
Devices = pointToPoint.Install (nodes);

Ptr<RateErrorModel> em = CreateObject<RateErrorModel> ();


Em->SetAttribute (“ErrorRate”, DoubleValue (0.00001));
Devices.Get (1)->SetAttribute (“ReceiveErrorModel”, PointerValue (em));

InternetStackHelper stack;
Stack.Install (nodes);

Ipv4AddressHelper address;
Address.SetBase (“10.1.1.0”, “255.255.255.252”);
Ipv4InterfaceContainer interfaces = address.Assign (devices);

Uint16_t sinkPort = 8080;


Address sinkAddress (InetSocketAddress (interfaces.GetAddress (1), sinkPort));
PacketSinkHelper packetSinkHelper (“ns3::TcpSocketFactory”, InetSocketAddress (Ipv4Address::GetAny (),
sinkPort));
ApplicationContainer sinkApps = packetSinkHelper.Install (nodes.Get (1));
sinkApps.Start (Seconds (0.));
sinkApps.Stop (Seconds (20.));

Ptr<Socket> ns3TcpSocket = Socket::CreateSocket (nodes.Get (0), TcpSocketFactory::GetTypeId ());

Ptr<MyApp> app = CreateObject<MyApp> ();


App->Setup (ns3TcpSocket, sinkAddress, 1040, 1000, DataRate (“1Mbps”));
Nodes.Get (0)->AddApplication (app);
App->SetStartTime (Seconds (1.));
App->SetStopTime (Seconds (20.));

AsciiTraceHelper asciiTraceHelper;
Ptr<OutputStreamWrapper> stream = asciiTraceHelper.CreateFileStream (“sixth.cwnd”);
Ns3TcpSocket->TraceConnectWithoutContext (“CongestionWindow”, MakeBoundCallback (&CwndChange,
stream));

PcapHelper pcapHelper;
Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (“sixth.pcap”, std::ios::out, PcapHelper::DLT_PPP);
Devices.Get (1)->TraceConnectWithoutContext (“PhyRxDrop”, MakeBoundCallback (&RxDrop, file));

Simulator::Stop (Seconds (20));


Simulator::Run ();
Simulator::Destroy ();

Return 0;
}

OUTPUT
Result
We have stimulate and observe changes in ns-3 TCP congestion window and packet drops in a
network with a point-to-point connection and custom applications.

Experiment-12
Aim
To simulate and analyze the changes in the ns-3 TCP congestion window, monitor packet drops, and create
graphs of packet byte counts over time in a network with a point-to-point connection and custom applications.

Code
#include <fstream>
#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/stats-module.h”
Using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“SeventhScriptExample”);

// ===========================================================================
//
// node 0 node 1
// +----------------+ +----------------+
// | ns-3 TCP | | ns-3 TCP |
// +----------------+ +----------------+
// | 10.1.1.1 | | 10.1.1.2 |
// +----------------+ +----------------+
// | point-to-point | | point-to-point |
// +----------------+ +----------------+
// | |
// +---------------------+
// 5 Mbps, 2 ms
//
//
// We want to look at changes in the ns-3 TCP congestion window. We need
// to crank up a flow and hook the CongestionWindow attribute on the socket
// of the sender. Normally one would use an on-off application to generate a
// flow, but this has a couple of problems. First, the socket of the on-off
// application is not created until Application Start time, so we wouldn’t be
// able to hook the socket (now) at configuration time. Second, even if we
// could arrange a call after start time, the socket is not public so we
// couldn’t get at it.
//
// So, we can cook up a simple version of the on-off application that does what
// we want. On the plus side we don’t need all of the complexity of the on-off
// application. On the minus side, we don’t have a helper, so we have to get
// a little more involved in the details, but this is trivial.
//
// So first, we create a socket and do the trace connect on it; then we pass
// this socket into the constructor of our simple application which we then
// install in the source node.
// ===========================================================================
//
Class MyApp : public Application
{
Public:
MyApp ();
Virtual ~MyApp ();

/**
* Register this type.
* \return The TypeId.
*/
Static TypeId GetTypeId (void);
Void Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate
dataRate);

Private:
Virtual void StartApplication (void);
Virtual void StopApplication (void);

Void ScheduleTx (void);


Void SendPacket (void);

Ptr<Socket> m_socket;
Address m_peer;
Uint32_t m_packetSize;
Uint32_t m_nPackets;
DataRate m_dataRate;
EventId m_sendEvent;
Bool m_running;
Uint32_t m_packetsSent;
};

MyApp::MyApp ()
: m_socket (0),
M_peer (),
M_packetSize (0),
M_nPackets (0),
M_dataRate (0),
M_sendEvent (),
M_running (false),
M_packetsSent (0)
{
}

MyApp::~MyApp ()
{
M_socket = 0;
}

/* static */
TypeId MyApp::GetTypeId (void)
{
Static TypeId tid = TypeId (“MyApp”)
.SetParent<Application> ()
.SetGroupName (“Tutorial”)
.AddConstructor<MyApp> ()
;
Return tid;
}

Void
MyApp::Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate
dataRate)
{
M_socket = socket;
M_peer = address;
M_packetSize = packetSize;
M_nPackets = nPackets;
M_dataRate = dataRate;
}

Void
MyApp::StartApplication (void)
{
M_running = true;
M_packetsSent = 0;
If (InetSocketAddress::IsMatchingType (m_peer))
{
M_socket->Bind ();
}
Else
{
M_socket->Bind6 ();
}
M_socket->Connect (m_peer);
SendPacket ();
}

Void
MyApp::StopApplication (void)
{
M_running = false;

If (m_sendEvent.IsRunning ())
{
Simulator::Cancel (m_sendEvent);
}
If (m_socket)
{
M_socket->Close ();
}
}

Void
MyApp::SendPacket (void)
{
Ptr<Packet> packet = Create<Packet> (m_packetSize);
M_socket->Send (packet);

If (++m_packetsSent < m_nPackets)


{
ScheduleTx ();
}
}

Void
MyApp::ScheduleTx (void)
{
If (m_running)
{
Time tNext (Seconds (m_packetSize * 8 / static_cast<double> (m_dataRate.GetBitRate ())));
M_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this);
}
}

Static void
CwndChange (Ptr<OutputStreamWrapper> stream, uint32_t oldCwnd, uint32_t newCwnd)
{
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << “\t” << newCwnd);
*stream->GetStream () << Simulator::Now ().GetSeconds () << “\t” << oldCwnd << “\t” << newCwnd <<
std::endl;
}

Static void
RxDrop (Ptr<PcapFileWrapper> file, Ptr<const Packet> p)
{
NS_LOG_UNCOND (“RxDrop at “ << Simulator::Now ().GetSeconds ());
File->Write (Simulator::Now (), p);
}

Int
Main (int argc, char *argv[])
{
Bool useV6 = false;

CommandLine cmd;
Cmd.AddValue (“useIpv6”, “Use Ipv6”, useV6);
Cmd.Parse (argc, argv);

NodeContainer nodes;
Nodes.Create (2);

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

NetDeviceContainer devices;
Devices = pointToPoint.Install (nodes);

Ptr<RateErrorModel> em = CreateObject<RateErrorModel> ();


Em->SetAttribute (“ErrorRate”, DoubleValue (0.00001));
Devices.Get (1)->SetAttribute (“ReceiveErrorModel”, PointerValue (em));

InternetStackHelper stack;
Stack.Install (nodes);

Uint16_t sinkPort = 8080;


Address sinkAddress;
Address anyAddress;
Std::string probeType;
Std::string tracePath;
If (useV6 == false)
{
Ipv4AddressHelper address;
Address.SetBase (“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces = address.Assign (devices);
sinkAddress = InetSocketAddress (interfaces.GetAddress (1), sinkPort);
anyAddress = InetSocketAddress (Ipv4Address::GetAny (), sinkPort);
probeType = “ns3::Ipv4PacketProbe”;
tracePath = “/NodeList/*/$ns3::Ipv4L3Protocol/Tx”;
}
Else
{
Ipv6AddressHelper address;
Address.SetBase (“2001:0000:f00d:café::”, Ipv6Prefix (64));
Ipv6InterfaceContainer interfaces = address.Assign (devices);
sinkAddress = Inet6SocketAddress (interfaces.GetAddress (1,1), sinkPort);
anyAddress = Inet6SocketAddress (Ipv6Address::GetAny (), sinkPort);
probeType = “ns3::Ipv6PacketProbe”;
tracePath = “/NodeList/*/$ns3::Ipv6L3Protocol/Tx”;
}

PacketSinkHelper packetSinkHelper (“ns3::TcpSocketFactory”, anyAddress);


ApplicationContainer sinkApps = packetSinkHelper.Install (nodes.Get (1));
sinkApps.Start (Seconds (0.));
sinkApps.Stop (Seconds (20.));

Ptr<Socket> ns3TcpSocket = Socket::CreateSocket (nodes.Get (0), TcpSocketFactory::GetTypeId ());

Ptr<MyApp> app = CreateObject<MyApp> ();


App->Setup (ns3TcpSocket, sinkAddress, 1040, 1000, DataRate (“1Mbps”));
Nodes.Get (0)->AddApplication (app);
App->SetStartTime (Seconds (1.));
App->SetStopTime (Seconds (20.));

AsciiTraceHelper asciiTraceHelper;
Ptr<OutputStreamWrapper> stream = asciiTraceHelper.CreateFileStream (“seventh.cwnd”);
Ns3TcpSocket->TraceConnectWithoutContext (“CongestionWindow”, MakeBoundCallback (&CwndChange,
stream));

PcapHelper pcapHelper;
Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (“seventh.pcap”, std::ios::out, PcapHelper::DLT_PPP);
Devices.Get (1)->TraceConnectWithoutContext (“PhyRxDrop”, MakeBoundCallback (&RxDrop, file));

// Use GnuplotHelper to plot the packet byte count over time


GnuplotHelper plotHelper;

// Configure the plot. The first argument is the file name prefix
// for the output files generated. The second, third, and fourth
// arguments are, respectively, the plot title, x-axis, and y-axis labels
plotHelper.ConfigurePlot (“seventh-packet-byte-count”,
“Packet Byte Count vs. Time”,
“Time (Seconds)”,
“Packet Byte Count”);

// Specify the probe type, trace source path (in configuration namespace), and
// probe output trace source (“OutputBytes”) to plot. The fourth argument
// specifies the name of the data series label on the plot. The last
// argument formats the plot by specifying where the key should be placed.
plotHelper.PlotProbe (probeType,
tracePath,
“OutputBytes”,
“Packet Byte Count”,
GnuplotAggregator::KEY_BELOW);

// Use FileHelper to write out the packet byte count over time
FileHelper fileHelper;

// Configure the file to be written, and the formatting of output data.


fileHelper.ConfigureFile (“seventh-packet-byte-count”,
FileAggregator::FORMATTED);

// Set the labels for this formatted output file.


fileHelper.Set2dFormat (“Time (Seconds) = %.3e\tPacket Byte Count = %.0f”);

// Specify the probe type, trace source path (in configuration namespace), and
// probe output trace source (“OutputBytes”) to write.
fileHelper.WriteProbe (probeType,
tracePath,
“OutputBytes”);

Simulator::Stop (Seconds (20));


Simulator::Run ();
Simulator::Destroy ();

Return 0;
}

OUTPUT
Result
We havesimulate and analyze the changes in the ns-3 TCP congestion window, monitor packet drops, and
create graphs of packet byte counts over time in a network with a point-to-point connection and custom
applications.
Experiment-13
Aim
Wireless router configuration using cisco packet

Apparatus Required
Computer with Cisco Packet Tracer installed

Wireless router configuration is a fundamental aspect of network management and plays a crucial role in
providing wireless connectivity to devices. In this experiment, you will configure a wireless router using Cisco
Packet Tracer. Here’s a theoretical background to help you understand the key concepts involved:

Router
A router is a networking device that connects different networks together. It acts as a gateway, routing data
packets between devices on a local network and external networks such as the internet. Routers use routing
tables to determine where to forward data packets.

Wireless Networking
Wireless networking, also known as Wi-Fi, enables devices to connect to a network without physical cables.
Wireless routers provide this functionality. They broadcast wireless signals using radio waves, allowing devices
like laptops and smartphones to connect to the network.

SSID (Service Set Identifier)


SSID is the name of the wireless network. It allows devices to identify and connect to the correct network. You
can think of it as the “name” of your wireless network.

Wireless Security
Ensuring the security of your wireless network is crucial. Cisco routers offer various security protocols like
WPA (Wi-Fi Protected Access) and WPA2 to encrypt data and protect your network from unauthorized access.

DHCP (Dynamic Host Configuration Protocol)


DHCP is a network protocol used to assign IP addresses and other network configuration information to
devices in a network. In the context of a wireless router, DHCP simplifies the process of connecting devices by
automatically assigning IP addresses.
Configuration
Configuring a router involves setting up parameters such as the router’s hostname, IP addresses, subnet masks,
and more. It also includes enabling and configuring the wireless interface, setting up DHCP, and defining
security settings.

Testing and Troubleshooting


After configuring the router, it’s essential to test the network to ensure that devices can connect and access the
internet. Troubleshooting is often required to address any issues that may arise during the configuration process

Procedure
1. Open Cisco Packet Tracer and create a new topology.
2. Add a wireless router and a switch to the topology.
3. Connect the wireless router to the switch using a straight-through Ethernet cable.
4. Connect a laptop to the switch using a straight-through Ethernet cable.
5. Configure the wireless router with a basic SSID and security.
6. Double-click on the wireless router icon to open the configuration window.
7. Click on the Wireless tab.
8. Enter a name for your wireless network in the SSID field.
9. Select a security mode from the Security drop-down list.
10. Enter a password for your wireless network in the Password field.
11. Click OK to save the configuration.
12. Connect the laptop to the wireless network.
13. On the laptop, open the Wi-Fi settings.
14. Select the name of your wireless network from the list of available networks.
15. Enter the password for your wireless network.
16. Click Connect.
17. Verify that the laptop is connected to the wireless network and can access the internet.
18. Open a web browser and navigate to a website, such as https://
OUTPUT
Result: We have simulate wireless router configuration using cisco packet

Experiment-14
Aim
Connection of two different network using cisco packet
Material required
Computer with Cisco Packet Tracer installed

Network Planning
Define the IP address ranges for each network. Let’s say Network A uses 192.168.1.0/24, and Network B uses
192.168.2.0/24.

Device Selection
Select the appropriate Cisco devices, such as routers and switches, to connect the two networks.
IP Configuration: Assign IP addresses to the router interfaces. For example, Router A’s interface connecting to
Network A can be set to 192.168.1.1, and Router B’s interface connecting to Network B can be 192.168.2.1.

Subnetting Calculation
Each network may have multiple subnets. Calculate the subnet masks, subnet IDs, and broadcast addresses
using subnetting rules.
Routing Configuration:
Configure routing protocols (e.g., OSPF, EIGRP) on the routers to enable communication between the two
networks.

ACL Configuration
Implement Access Control Lists (ACLs) to control traffic between the networks. Calculate the wildcard masks
for ACLs.

Physical Connections
Physically connect devices using appropriate cables (e.g., Ethernet cables). Ensure you’ve calculated the cable
lengths needed.
Testing and Troubleshooting:
Use Packet Tracer’s simulation tools to test the connectivity. Calculate expected round-trip times (RTT) for
ping tests.

Documentation
Create detailed documentation of the network setup, including IP address assignments, subnetting details, and
routing configurations.

Security Considerations
Implement security measures like setting passwords and using encryption protocols. Calculate encryption key
lengths if applicable

Procedure
1. Launch Cisco Packet Tracer: Start by launching the Cisco Packet Tracer software on your computer.

2. Create Network Topology:

3. In the workspace, add the devices you want to connect (e.g., routers, switches, PCs) from the device
palette.
4. Arrange the devices as needed to represent your two separate networks.
5. Connect Devices:

6. Use the appropriate cables to connect the devices. For example, use Ethernet cables to connect PCs to
switches and serial cables to connect routers.
7. Ensure that the connections are made correctly. You can click on a device’s interface and select a cable
to connect to another device.
8. Configure IP Addresses:

9. Access the command-line interface (CLI) of each router by clicking on it and selecting “Command
Line.”
10. Configure IP addresses on the router interfaces connected to the different networks. Use commands like
interface FastEthernet0/0 and ip address x.x.x.x y.y.y.y to set the IP addresses.
11. Set Routing:

12. Configure routing protocols (e.g., OSPF, EIGRP, or static routes) on the routers to enable
communication between the two networks.
13. Ensure that the routers can reach each other through these routing configurations.
14. Test Connectivity:

15. Open the PCs’ command-line interface and try to ping devices on the other network by using their IP
addresses.
16. Verify that the pings are successful, indicating that the networks are connected.
17. Save Your Project:

18. Save your configuration in Cisco Packet Tracer to ensure you can reopen and continue your work.
19. Document Your Setup:

20. It’s important to document your configuration, including IP addresses, routing protocols, and
connections, in a lab report or documentation
OUTPUT

Result :- Connection of two different network using cisco packet


Experimen-15
Aim
Running and using services/commands like ping, trace, route, nslookup, arp, ftp etc.

Material Required:- cisco packet tracer


Theory
Ping
Ping is a network utility that is used to test the reachability of a host on a network. It works by sending a series
of ICMP (Internet Control Message Protocol) echo request packets to the destination host and waiting for a
response. If the destination host is reachable, it will respond with an ICMP echo reply packet. Ping can be used
to troubleshoot network connectivity issues and to measure the round-trip time (RTT) between two hosts.

To run ping, open a command prompt window and type the following command:
Ping <host>

Where `<host>` is the IP address or hostname of the destination host.


For example, to ping Google’s DNS server, you would type the following command:
Ping 8.8.8.8

Trace
Trace, also known as traceroute, is a network utility that is used to trace the path that a packet takes when
traveling from one host to another. It works by sending a series of UDP (User Datagram Protocol) packets to
the destination host with increasing TTL (time to live) values. Each router that the packet passes through will
decrement the TTL value. When the TTL value reaches zero, the router will discard the packet and send an
ICMP time exceeded packet back to the source host. Trace can be used to troubleshoot network connectivity
issues and to identify the source of network latency.

To run trace, open a command prompt window and type the following command.
Tracert <host>

Where `<host>` is the IP address or hostname of the destination host.


For example, to trace the path to Google’s DNS server, you would type the following command:
Tracert 8.8.8.8

Nslookup
Nslookup is a network utility that is used to query DNS servers. It can be used to resolve hostnames to IP
addresses, and vice versa. Nslookup can also be used to troubleshoot DNS issues.
To run nslookup, open a command prompt window and type the following command:
Nslookup

This will start the interactive nslookup mode. To resolve a hostname to an IP address, type the following
command:
<hostname>
For example, to resolve the hostname `google.com` to an IP address, you would type the following command:
Google.com

To resolve an IP address to a hostname, type the following command:


<ip address>
For example, to resolve the IP address `8.8.8.8` to a hostname, you would type the following command:
8.8.8.8

Arp
Arp is a network utility that is used to resolve IP addresses to MAC addresses. It works by sending an ARP
request broadcast to all hosts on the local network. The host with the specified IP address will respond with its
MAC address. Arp can be used to troubleshoot network connectivity issues and to identify MAC addresses of
devices on the local network.
To run arp, open a command prompt window and type the following command:
Arp -a
This will display a list of all IP addresses and MAC addresses that have been cached in the ARP cache.

Ftp
Ftp is a network protocol that is used to transfer files between two hosts. It is a client-server protocol, where
the client connects to the server and requests to transfer files. Ftp is often used to transfer files between web
servers and personal computers.
To run ftp, open a command prompt window and type the following command:
ftp <host>

Where `<host>` is the IP address or hostname of the FTP server.


For example, to connect to the FTP server `ftp.example.com`, you would type the following command:
ftp ftp.example.com

Once you are connected to the FTP server, you can use the following commands to transfer files:
* `get <file>`: Download the specified file from the FTP server.
* `put <file>`: Upload the specified file to the FTP server.
To disconnect from the FTP server, type the following command:
Bye

These are just a few of the many network utilities that are available. For more information on specific utilities,
please consult their documentation.
Procedure
1. Ping
- Open a command prompt or terminal on your computer.
- Type `ping` followed by the IP address or domain name you want to test (e.g., `ping www.example.com`).
- Press Enter.
- You’ll see the ping results, including response times and packet loss.

2. Traceroute
- Open a command prompt or terminal.
- Type `tracert` followed by the IP address or domain name (e.g., `tracert www.example.com`).
- Press Enter.
- Traceroute will display the route taken by packets and response times at each hop.

3. Route
- To view your computer’s routing table, open a command prompt or terminal.
- Type `route print`.
- Press Enter. This will display the routing table with destination networks and gateways.

4. Nslookup
- Open a command prompt or terminal.
- Type `nslookup` followed by the domain name (e.g., `nslookup www.example.com`).
- Press Enter.
- Nslookup will provide you with DNS-related information for the given domain.

5. ARP
- To view the ARP table, open a command prompt or terminal.
- Type `arp -a`.
- Press Enter. This will show the mapping between IP addresses and MAC addresses on your local network.

6. FTP (File Transfer Protocol)


- To use FTP, open a command prompt or terminal.
- Type `ftp` followed by the FTP server’s IP address or domain (e.g., `ftp ftp.example.com`).
- Press Enter.
- You’ll be prompted to enter a username and password to log in.
- Once logged in, you can use FTP commands like `get` to download files and `put` to upload files.
OUTPUT
Result :- we have running and using services/commands like ping, trace, route, nslookup, arp,
ftp etc.
Experiment 16
Aim
Connect two networks using router in cisco packet tracer

Material required :- Cisco packet tracer

Theory
A router is a network device that connects two or more networks and forwards traffic between them. Routers
work by routing packets based on their destination IP addresses. When a packet arrives at a router, the router
looks up the destination IP address in its routing table. The routing table tells the router which interface to send
the packet out on.

In the example above, the router has two interfaces, one for each network. The routing table tells the router to
send packets destined for the 192.168.1.0/24 network out on the fastEthernet 0/0 interface, and to send packets
destined for the 192.168.2.0/24 network out on the fastEthernet 0/1 interface.

When a computer on the 192.168.1.0/24 network sends a packet to a computer on the 192.168.2.0/24 network,
the packet will first be sent to the router. The router will then look up the destination IP address in its routing
table and forward the packet out on the fastEthernet 0/1 interface. The packet will then be sent to the computer
on the 192.168.2.0/24 network.

Routers play an important role in networks by connecting different types of networks together and allowing
traffic to flow between them. Routers also help to improve network performance by routing traffic around
congested areas.

Procedure
Connecting two networks using a router in Cisco Packet Tracer involves several steps. Here’s a procedure in
steps:

1. Launch Cisco Packet Tracer


- Open Cisco Packet Tracer on your computer.

2. Add Devices
- In Packet Tracer, drag and drop two network devices, typically two routers, onto the workspace. Place them
where you want the networks to connect.

3. Connect Routers
- Use the “copper crossover” cable to connect the FastEthernet interfaces of the two routers. This simulates a
direct connection between them.

4. Configure Router Interfaces


- Double-click on one of the routers to open its configuration window.
- Go to the Command Line Interface (CLI) by clicking on the CLI tab.

5. Assign IP Addresses
- Configure IP addresses on the interfaces connecting to the networks. For instance
Router1> enable
Router1# configure terminal
Router1(config)# interface FastEthernet0/0
Router1(config-if)# ip address 192.168.1.1 255.255.255.0
Router1(config-if)# no shutdown
Router1(config-if)# exit
Router1(config)# exit
Router1# copy running-config startup-config
```

- Repeat this process on the other router, ensuring it has an IP address on a different subnet,
like 192.168.2.1

6. Routing Configuration
- On each router, configure routing protocols (e.g., OSPF, EIGRP) or static routes to enable communication
between the networks.

7. Test the Connection


- Connect computers or devices to each network.
- Configure their IP settings to be in the respective subnets (e.g., 192.168.1.x and 192.168.2.x).
- Test connectivity between devices on the different networks. You should be able to ping or communicate
between them.

8. Save Your Project


- Save your project in Cisco Packet Tracer so you can revisit it or share it with others.

Remember that the specific configurations may vary depending on your requirements and the router models
you’re using. Always refer to the documentation for your router and networking standards.
OUTPUT

Result :- We have connected two networks using router in cisco packet tracer
Experiment 17
Aim
Connection two networks using switch in cisco packet tracer

Material Required :- Cisco packet tracer

Theory
Connecting two networks using a switch in Cisco Packet Tracer involves creating a network infrastructure that
facilitates communication between devices on different subnets or VLANs. A switch, typically a layer 2 device,
serves as the central point for interconnecting these networks.
To establish this connection, you would configure each network on separate VLANs, with associated IP
addresses and subnets. Then, the switch is configured with VLAN information, assigning each network to a
specific VLAN. Ports on the switch are assigned to these VLANs accordingly. By segmenting the networks
into VLANs, you prevent broadcast traffic from one network affecting the other, promoting efficient network
traffic management.
This setup allows devices within the same VLAN to communicate seamlessly while routing or inter-VLAN
routing can be achieved through a router or layer 3 switch. The result is a well-structured and efficient network
that can accommodate various network segments, enhancing security and traffic control between them. Proper
configuration of the switch, VLANs, and routing is essential to ensure the successful connection of these two
distinct networks.

Production
1. Launch Cisco Packet Tracer
- Open Cisco Packet Tracer on your computer.

2. Add Devices
- Drag and drop two network devices, such as routers or PCs, onto the workspace. These devices will
represent the two networks you want to connect.

3. Add a Switch
- Drag and drop a switch onto the workspace. This switch will serve as the central hub connecting the two
networks.

4. Connect Devices to the Switch


- Use straight-through Ethernet cables to connect the devices (routers or PCs) to the switch. Simply click on a
device’s interface and then click on the switch’s interface to make the connection.

5. Configure Devices
- For the routers, configure their interfaces with IP addresses in separate subnets. For example, Router1’s
interface could be configured with IP address 192.168.1.1, and Router2’s interface could be 192.168.2.1.
- If you’re using PCs, configure their IP addresses accordingly.
6. Test Connectivity
- Test the connectivity by pinging from one device to another across the switch. For example, try to ping from
a PC on Network 1 to a PC on Network 2.

OUTPUT
Result :- We have connected two networks using switch in cisco packet tracer

Experiment 18
Aim
To stimulate hybrid model network in cisco packet tracer

Material Required :- cisco packet tracer

Theory
Stimulating a hybrid model network in Cisco Packet Tracer involves a combination of physical and virtual
network components. This approach integrates both traditional hardware devices and virtualized elements to
optimize network performance and flexibility. In the physical realm, you would set up routers, switches, and
various networking peripherals, adhering to the specific design requirements. These devices form the core of
your network infrastructure, providing the necessary connectivity and routing functions.

In parallel, the virtual network components play a crucial role in enhancing the network’s capabilities. Virtual
machines and containers can be used to simulate hosts, servers, and various services within the network. Cisco
Packet Tracer allows for the creation of these virtual entities, enabling you to mimic real-world scenarios
efficiently. By combining physical and virtual components, you can fine-tune your network model, test various
configurations, and assess performance under different conditions. This hybrid approach provides a
comprehensive environment for experimentation, fostering a deeper understanding of network dynamics, all
while being cost-effective and adaptable to various networking scenarios.

Procedure
Stimulating a hybrid model network using Cisco Packet Tracer involves multiple steps. Here’s a high-level
procedure broken down into steps:

1. Planning and Setup


- Define the network’s purpose and objectives.
- Identify the components that will be part of the hybrid model network.
- Install and configure Cisco Packet Tracer on your computer.

2. Design the Network


- Create a network topology that includes both physical and virtual components.
- Determine the network’s IP addressing scheme and sub netting.

3. Add Physical Devices


- In Packet Tracer, drag and drop physical devices such as routers, switches, and PCs onto the workspace.
- Connect these devices using appropriate cables and interfaces.

4. Add Virtual Devices


- Integrate virtual devices like routers, servers, and virtual PCs as needed.
- Configure their settings, including operating systems, IP addresses, and services.

5. Configure Routing and Switching


- Set up routing protocols (e.g., OSPF, EIGRP) on routers.
- Configure VLANs and switchports on switches.
- Establish interconnectivity between physical and virtual devices.

6. Security Configurations
- Implement security measures, such as access control lists (ACLs) and firewall rules.
- Ensure secure communication within the network.

7. Services and Applications


- Install and configure necessary services and applications, such as web servers, DNS, and DHCP.
- Test their functionality within the network.

8. Testing and Troubleshooting


- Verify that all devices can communicate effectively.
- Use Cisco Packet Tracer’s built-in tools to troubleshoot any connectivity or configuration issues.

9. Performance Evaluation
- Monitor network performance and identify any bottlenecks.
- Optimize configurations for better performance if necessary.

10. Documentation
- Create documentation that includes network diagrams, configurations, and any additional notes.

11. Simulation and Analysis


- Utilize Packet Tracer’s simulation feature to observe how the network behaves.
- Analyze the performance of the hybrid model network under different scenarios.

12. Finalization
- Ensure that the network meets the desired objectives.
- Save your project in Cisco Packet Tracer.
OUTPUT
Result :- We have stimulated hybrid model network using cisco packet ttrace
Practicals Beyond The Syllabus

Experiment 19(A)
Aim
Stimulate routing information protocol using cisco packet tracer

Material Required :- cisco packet tracer

Theory

Routing Information Protocol (RIP)


Routing Information Protocol (RIP) is one of the oldest distance-vector routing protocols used to exchange
routing information within a network. It operates based on the hop count metric, where routers send routing
tables to their neighboring routers, and these tables are updated periodically. Here are the key concepts
associated with RIP:

1. Hop Count: RIP uses the number of hops (routers) as a metric to determine the best route to a
destination. It prefers routes with fewer hops.
2. Routing Tables: Routers in a RIP network maintain routing tables that list the available networks and
their associated hop counts.

3. Routing Updates: RIP routers periodically send routing updates to their neighboring routers to share
routing information. These updates contain the list of networks and their hop counts.

4. Routing Loops: RIP has limitations, such as its slow convergence and susceptibility to routing loops.
To mitigate loops, it uses various techniques like split horizon and route poisoning.

Procedure

Simulation in Cisco Packet Tracer

1. Network Topology: Create a network topology in Cisco Packet Tracer that includes routers. Place
routers on the workspace and interconnect them using appropriate cables.

2. Router Configuration: Access the command-line interface (CLI) of each router and configure RIP. Use
the following commands:

- `enable`: Enter privileged exec mode.


- `configure terminal`: Enter global configuration mode.
- `router rip`: Enter RIP configuration mode.
- `version 2`: Set the version to RIP version 2 (recommended over version 1).
- `network [network_address]`: Specify the network addresses that RIP should advertise.
- `no auto-summary`: Disable automatic summarization.
- `end`: Exit configuration mode.

3. Routing Tables: View the routing tables of the routers using the `show ip route` command. You should
see the RIP-learned routes with their hop counts.

4. Packet Tracer Simulation: Utilize Packet Tracer’s simulation feature to test the network. Send packets
between devices and observe how RIP updates the routing tables.

5. Troubleshooting: If there are issues, use Packet Tracer’s tools to troubleshoot and diagnose any
problems in the RIP configuration.

6. Analysis: Analyze the behavior of RIP in the simulated network. Observe how it converges and updates
routing tables based on changes in the network.
OUTPUT
Result :- Stimulated routing information protocol using cisco packet tracer

Experiment 19 (B)
Aim
Stimulate dynamic routing from routing protocol information using cisco packet tracer
Material Required :- cisco packet tracer

Theory
Simulating dynamic routing from routing protocol information using Cisco Packet Tracer involves replicating
the operation of dynamic routing protocols within a network. Dynamic routing protocols enable routers to
exchange and update routing information automatically, adapting to network changes.

In this experiment, you would typically configure a routing protocol like OSPF (Open Shortest Path First) or
EIGRP (Enhanced Interior Gateway Routing Protocol) to illustrate dynamic routing principles.

When you configure such protocols in Packet Tracer, routers exchange routing updates, building a routing table
that contains information about reachable networks and the best paths to reach them. These tables are
dynamically updated as the network topology changes.
By altering the network topology or making changes in the routing configurations, you can observe how
dynamic routing protocols react. Routers will recompute routes, adapting to new information, and rerouting
traffic as needed.

The primary theoretical concepts include:


- Routing Protocols: Understanding the specific routing protocol you're simulating, such as OSPF (which uses
a link-state algorithm) or EIGRP (which uses a complex metric).

- Routing Tables: Each router maintains a routing table with entries for destination networks and their
associated metrics.

- Routing Updates: Dynamic routing protocols send periodic updates to neighboring routers, containing
information about network changes.

- Metric Calculation: Routing protocols use metrics (e.g., cost, bandwidth) to determine the best path to a
network.

- Convergence: The time it takes for the network to stabilize after a change is made.

By configuring and simulating dynamic routing in Cisco Packet Tracer, you can gain practical insight into how
these protocols function and adapt to network modifications, ensuring efficient and up-to-date routing within
your network. Detailed calculations or numericals are typically not involved in this experiment but rather
configuration, observation, and analysis of dynamic routing behaviors.

Procedure

Step 1: Create the Network Topology


- Open Cisco Packet Tracer and create a network topology. Add routers to the workspace.
- Connect the routers using appropriate cables. Ensure that each router has at least one connection to another
router.

Step 2: Router Configuration


- Access the command-line interface (CLI) of each router.
- Configure the router’s interfaces with IP addresses using the `interface [interface_name]` and `ip address
[IP_address] [subnet_mask]` commands.
- Enable routing on each router using the `router [routing_protocol]` command. Replace `[routing_protocol]`
with OSPF or EIGRP, depending on your choice.

Step 3: Configure Routing Protocol


- If you’re using OSPF, configure OSPF parameters. For example:
- `router ospf [process_id]`: Enter OSPF configuration mode.
- `network [network_address] [wildcard_mask] area [area_id]`: Specify the networks and areas.
- If you’re using EIGRP, configure EIGRP parameters. For example:
- `router eigrp [AS_number]`: Enter EIGRP configuration mode.
- `network [network_address]`: Specify the networks.

Step 4: Advertise Networks


- Ensure that each router advertises the networks it’s connected to by using the appropriate
configuration commands.

Step 5: Verify Routing Information


- On each router, use the `show ip route` command to check the routing table. You should see
routes learned from the dynamic routing protocol.

Step 6: Test Network Communication


- Use Packet Tracer’s simulation tools to test network communication. Create and send
packets between devices to see how the routers use the dynamic routing protocol to
determine the best path.

Step 7: Introduce Network Changes


- Make changes in the network, such as adding or removing links or devices, and observe
how the dynamic routing protocol reacts and updates the routing tables.

Step 8: Monitor and Analyze


- Continuously monitor the routing tables and the behavior of the dynamic routing protocol as the network
changes.
- Analyze the convergence and stability of the routing protocol.

Step 9: Troubleshoot (if necessary)


- Use Packet Tracer’s tools to troubleshoot any routing issues that may arise during the

experiment.

Step 10: Document the RResult


- Document your observations, including changes in the routing tables and how the dynamic
routing protocol responds to network modifications.

OUTPUT
Result :- We have Stimulated dynamic routing from routing protocol information using cisco packet trace

Experiment 20
Aim
Stimulate college campus network design using cisco packet tracer
Material Required :- Cisco packet tracer
Theory
1. Network Segmentation
- Divide the network into segments, such as administrative, academic, and student areas.
- Use VLANs (Virtual Local Area Networks) to isolate and manage each segment separately.

2. Core, Distribution, and Access Layers


- Implement a hierarchical network design with core, distribution, and access layers.
- The core layer connects various distribution points, ensuring high-speed and redundant connections.
- The distribution layer connects to the access layer, providing services like routing and access control.
- The access layer connects end devices like computers, printers, and access points.

3. Redundancy and High Availability


- Implement redundancy to ensure network availability.
- Use technologies like HSRP (Hot Standby Router Protocol) or VRRP (Virtual Router Redundancy Protocol)
for router redundancy.
- Employ Spanning Tree Protocol (STP) to avoid network loops and provide redundancy at the access layer.

4. Security
- Implement security measures such as access control lists (ACLs) to restrict unauthorized access.
- Use firewall appliances or services to protect the network from external threats.
- Deploy network intrusion detection and prevention systems (NIDS/NIPS) for threat monitoring and
prevention.

5. Scalability
- Plan for future growth by designing a scalable network.
- Utilize technologies like OSPF or EIGRP for dynamic routing to adapt to network changes.

6. Quality of Service (QoS)


- Implement QoS to prioritize network traffic for services like VoIP, video streaming, and critical
applications.

7. Wireless Network
- Design and configure a secure wireless network with WPA2/WPA3 encryption and strong authentication.

8. Network Monitoring and Management


- Implement network management solutions for monitoring and configuring network devices.
- Use SNMP (Simple Network Management Protocol) for device monitoring and management.

9. Subnetting
- Apply proper IP addressing and subnetting to efficiently manage IP addresses and ensure proper
communication within the campus network.

Procedure

1. Build the Topology


- Create a network topology in Cisco Packet Tracer that reflects the campus network design. Add routers,
switches, and end devices as necessary.

2. Configuration
- Configure the routers, switches, and access points according to the design plan.
- Set up VLANs and inter-VLAN routing for network segmentation.

3. Security and Redundancy


- Configure security features like ACLs and implement redundancy where needed.

4. Routing
- Use dynamic routing protocols (e.g., OSPF) for efficient routing within the campus network.

5. QoS and Monitoring


- Implement Quality of Service (QoS) policies and set up network monitoring tools as required.

6. **Wireless Network**:
- Configure and secure the wireless network using WPA2/WPA3 and appropriate authentication.

7. Testing and Analysis


- Use Packet Tracer’s simulation features to test the network’s functionality, including failover and QoS
scenarios.

8. Documentation
- Create network documentation, including diagrams and configurations.

OUTPUT
Result :-We have Stimulate college campus network design using cisco packet tracer

Viva questions
1. What is fixed-size framing?
In fixed-size framing, the frame borders are not specified. A delimiter could be the size itself.

2. What is character stuffing?


The character stuffing or bite stuffing approach involves adding a special kind of byte to the frame's
data section along with a character or pattern that matches the flag. The data area is filled with the
aid of an additional byte. This bite is frequently referred to as the escape character, which has a
predetermined bit pattern. When the receiver comes across theescape character, it is deleted
from the data section and it sees the following character as data rather than a delimiting indicator.

3. What is bit stuffing?


It is a process in which one extra 0 is added when five consecutive 1 s follow a 0 in thedata,
get there will be no mistake when the receiver makes a pattern 0111110 for a flag.

4. How does flow control work?


Flow control refers to a collection of methods that is used to limit how much data a sender can send
before having to wait for an acknowledgment.

5. Define error control.


Error control is the combination of error detection and correction. It allows the receiver to inform
the sender of any frames lost or damaged and transmission, and it coordinates the transmission of
those frames by the sender. In the data link layer, error detection is referred to as "error control and
retransmission methods".

6. Define automatic repeat request.


Error control is the combination of error detection and correction. The data link layer frequently
implements error control. When an exchange error is discovered, the required programmes are sent
again. An automatic repeat request (ARQ) is the name given to the entire process.

7. Define stop-and-wait protocol.


In the stop-and-wait protocol, the sender sends the first frame and waits for the receiver to affirm,
"OK, go ahead", before sending the next frame.

8. What is an automatic stop-and-wait repeat request?


By keeping the copy of the sent frame, the error correction is done in a stop-and-wait automatic
repeat request, and when the timer expires, the transmission of the frame is done..

9. Could you explain the advantages and disadvantages of implementing a star network
topology in a real-world network scenario?
Advantages:
 Centralized Management: It’s easier to manage and troubleshoot the network as all
connections lead to a central hub.
 Fault Tolerance: If one device fails, it doesn’t affect the rest of the network.
 Scalability: Adding or removing devices is straightforward.
Disadvantages:
 Single Point of Failure: If the central hub fails, the entire network can be disrupted.
 Cost: Setting up a star network can be more expensive due to the central hub or switch.
 Limited Cable Length: Cable lengths are limited, so you may need repeaters for larger
networks.
10, Could you explain the steps involved in installing NS2?
To install NS2, you need to download the source code, configure, compile, and make the
installation. Detailed steps involve commands like ‘tar -xvzf ns-allinone-2.35.tar.gz,’ ‘./install’
within the extracted directory, and more, followed by setting environment variables.

11. What is the default IP address of a Cisco wireless router?


The default IP address of a Cisco wireless router is usually 192.168.1.1.

12. What is the purpose of NS2 in software experimentation?


NS2 is a discrete event simulator used to simulate computer networks and evaluate their
performance.

13. What is the purpose of using VLANs in network configuration within Cisco Packet
Tracer?
VLANs (Virtual Local Area Networks) are used to segment a network into smaller, isolated
groups, improving network security and efficiency by controlling broadcast domains and
logically grouping devices based on their functions or departments.

14. How can you verify network connectivity to a remote host using the ‘ping’ command?
You can use the ‘ping’ command to send ICMP echo requests to the remote host’s IP address
and check for replies to confirm network connectivity.

15. Explain the purpose of the EIGRP protocol in dynamic routing using Cisco Packet
Tracer?
EIGRP, or Enhanced Interior Gateway Routing Protocol, is used to dynamically discover and
maintain routing information, enabling routers to make efficient path decisions based on
bandwidth and delay metrics.

16. What is the impact of increasing the network delay in an ns-3 simulation on TCP
congestion window behavior?
Increasing network delay in ns-3 simulation results in a slower convergence of the TCP
congestion window, causing longer time to reach maximum throughput due to increased Round-
Trip Time (RTT).

17.Calculate the bandwidth-delay product (BDP) for this network.


BDP is 40,000 bits or 5,000 bytes.

18. What is the primary objective of simulating a network topology with point-to-point,
CSMA, and Wi-Fi connections for UDP echo communication?
The primary objective is to evaluate and measure the performance of UDP echo communication
in a mixed network environment.

19. What is the significance of measuring round-trip time in network simulations?


Measuring round-trip time helps evaluate network performance, detect delays, and assess the
quality of communication in various applications. It’s crucial for optimizing network designs and
configurations.

20. Explain one advantage of using Cisco Packet Tracer for simulating a hybrid model
network.
One advantage is that it allows for real-time, accurate calculations of network performance and
interactions between physical and virtual devices.
21. What is the purpose of connecting a trace function to an integer value within a custom
NS-3 object?
Connecting a trace function allows you to monitor changes in the integer value over time. It’s
useful for debugging and performance analysis, as it provides insights into how that value evolves
during simulations, helping in identifying and addressing issues.

22. What is the primary function of a switch in network connectivity?


A switch operates at the data link layer and forwards data frames based on MAC addresses,
effectively connecting devices within the same network.

23. Explain the role of the “arp” command in networking.


The “arp” command is used to display or manipulate the Address Resolution Protocol (ARP)
cache, which maps IP addresses to physical MAC addresses in a local network.

24. Can you calculate the required bandwidth for a college campus network with 500
simultaneous users, each requiring 5 Mbps?
Bandwidth = 500 users * 5 Mbps/user = 2500 Mbps.

25. What is the main purpose of designing a college campus network using Cisco Packet
Tracer?
The primary purpose is to create a scalable and efficient network infrastructure to support the
college’s communication and data needs.

You might also like