[go: up one dir, main page]

0% found this document useful (0 votes)
2 views42 pages

Computer Networks Lab File

The document provides an overview of various tools used in computer networking, including cable strippers, cable testers, wire crimpers, tone generators, and more. Each tool is described with its advantages and disadvantages, highlighting their importance in ensuring efficient and secure connections in networking and electrical systems. The document serves as a guide for technicians and electricians in selecting and using these essential tools.

Uploaded by

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

Computer Networks Lab File

The document provides an overview of various tools used in computer networking, including cable strippers, cable testers, wire crimpers, tone generators, and more. Each tool is described with its advantages and disadvantages, highlighting their importance in ensuring efficient and secure connections in networking and electrical systems. The document serves as a guide for technicians and electricians in selecting and using these essential tools.

Uploaded by

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

COMPUTER NETWORKS

&
SECURITY

SUBMITTED TO: PREPARED BY:

SUKHVINDER SINGH ANSH KUSHWAHA


BABBER SIR
Roll No.: SG20312

BE CSE 6th Sem (Group-1)


TABLE OF CONTENTS

S. NO. TITLE PAGE NO.

01 Know how many various tools are used in LAN network 03

02 Get familiar with the devices used in computer networks 13

03 Explain any 5 networking commands 23

04 Hamming Distance between two given Code Words

05 Write a program to implement any one sliding window protocol

06 Link State Routing ( LSR ) Protocol Implementation

07 Path Vector Routing ( PVR ) Protocol Implementation

08 Hamming Distance between two given Code Words

09 Rivest Shamir Adleman ( RSA ) Algorithm Implementation

10 Diffie Hellman Algorithm Implementation

2|Pa ge
NETWORKING EQUIPMENTS

CABLE STRIPPER

Fig.: Cable Stripper

A cable stripper is a tool used for removing the outer insulation of a cable, such as electrical
wire. Cable strippers typically feature a blade that is used to cut through the insulation, as well
as a grip or handle to hold the cable in place during the stripping process. Some cable strippers
also feature adjustable blades, allowing you to select the appropriate cutting depth for the cable
being stripped. Cable strippers are an essential tool for any electrician or technician working
with electrical wiring, as they allow for efficient and precise removal of the insulation, allowing
for the safe and efficient installation of electrical wiring.

Advantages:

The main advantage of using a cable stripper is that it is fast and accurate. It quickly and
precisely strips the outer insulation of wires and cables, allowing for a clean connection and
reducing the risk of shorting. Additionally, it can save time and effort, as it eliminates the need
to cut the insulation with scissors or a knife. It can also be used to remove connectors and other
components from wires and cables. Cable strippers are particularly useful when working with
small gauge wires, as they can accurately strip the insulation without damaging the wires.

Disadvantages:
The main disadvantage of using a cable stripper is that it can damage the wires if it is not used
properly. If the stripper is not set to the correct size, it can cut too deeply into the insulation,
leading to damaged wires. Additionally, cable strippers can be difficult to use on smaller gauge
wires, as they may not be able to accurately strip the insulation without damaging the wires.
Finally, cable strippers can be relatively expensive, so it may not be feasible for some users.

3|Pa ge
CABLE TESTER

Fig.: Cable Tester

A cable tester is an electronic device used to verify the electrical connections in a signal cable
or other wired assembly. Basic cable testers are used to check for continuity, meaning that
they can tell whether a cable is connected and not broken. Advanced cable testers can also be
used to test for shorts, crossed wires, and other issues that could cause problems in the signal
being transmitted over the cable. Cable testers are a must-have tool for any electrician or
technician working with electrical wiring, as they allow for efficient and precise testing of
cables, ensuring that they are connected correctly and will not cause any issues.

Advantages:

The main advantage of using a cable tester is that it can quickly and accurately diagnose any
problems in a wired network. Cable testers can identify a wide range of issues, including
incorrect wiring, short circuits, open circuits, continuity issues, and more. Additionally, cable
testers can be used to verify the performance of a network and ensure that it is working
correctly. Cable testers also provide detailed information about the cable itself, including
length, impedance, attenuation, and signal-to-noise ratio. This can help to identify any
potential issues before they become problems.

Disadvantages:

The main disadvantage of using a cable tester is that it can be relatively expensive.
Additionally, cable testers may not be able to detect certain problems with the cable, such as
intermittent connections or signal interference. In some cases, the cable tester may not be able
to detect a problem until it has already become an issue. It is also possible for the cable tester
to provide false positives which can lead to unnecessary troubleshooting and wasted time.
Finally, cable testers are not always easy to use, as they require a certain level of technical
knowledge to operate properly.

4|Pa ge
WIRE CRIMPER

Fig.: Wire Crimper

A wire crimper is a tool used to connect two separate terminals on electrical wires, creating
an electrical connection. The crimper is designed to squeeze the metal collar of a connector
around the wire conductor, allowing the two wires to be securely connected. Wire crimpers
are essential tools for any electrician or technician working with electrical wiring, as they
allow for efficient and secure connections of the wires.

Advantages:

The main advantage of using a wire crimper is that it provides a secure, reliable connection. It
quickly and accurately compresses the insulation and terminals of wires and cables, ensuring
that the connection is properly made and is unlikely to come loose. Additionally, using a wire
crimper can save time and effort, as it eliminates the need to twist or solder wires together.
Finally, wire crimpers are relatively inexpensive and can be used with a variety of wires and
cables.

Disadvantages:

The main disadvantage of using a wire crimper is that it can be difficult to make precise
connections, as it can be difficult to get the crimping terminal to make a secure, consistent
connection with the wire. Additionally, wire crimpers can be expensive and require
specialized tools and expertise to use properly. Furthermore, crimped connections are not
always as reliable as soldered connections and can be prone to coming apart over time.

5|Pa ge
TONE GENERATOR

Fig.: Tone Generator

A tone generator is an electronic device used to generate sound waves of a specific frequency.
Tone generators are commonly used in audio production and engineering, as well as in
scientific and medical applications. Tone generators can generate simple tones, as well as
more complex waveforms such as sine, square, triangle and sawtooth waves. Tone generators
are also commonly used for testing the frequency response of audio equipment, and for
hearing tests.

Advantages:

Tone generators have a number of advantages, including their ability to produce low phase
noise signals and accurate power levels, as well as their extended dynamic range and energy-
saving capabilities. Tone generators are also capable of producing a wide range of
frequencies and voltages and can be used in applications such as embedded systems
engineering and RF testing. Tone generators are also capable of synchronous output,
providing a square wave signal which can be useful in various applications.

Disadvantages:

The main disadvantage of tone generators is that they are limited to producing sine waves,
which may not be suitable for certain applications. Additionally, they can be expensive and
require specific expertise to operate and calibrate. There can also be issues with accuracy and
stability when using a tone generator, as it can be difficult to maintain the desired frequency
and amplitude over time. Furthermore, tone generators typically require a significant amount
of power, making them less energy efficient than other signal generator options.

6|Pa ge
OPTICAL TIME DOMAIN REFLECTOMETER

Fig.: Optical Time Domain Reflectometer

An Optical Time Domain Reflectometer (OTDR) is an optoelectronic instrument used to


characterize an optical fiber. It is the optical equivalent of an electrical time-domain
reflectometer (TDR) and can be used to detect events such as breaks, splices, or
misconnections in the fiber, as well as measure the length of the fiber. OTDRs work by
sending a pulse of light down the fiber, and then measuring the reflected light that is returned.
The OTDR can detect characteristics such as the location, type, and size of any events or
defects in the fiber, as well as overall optical loss. OTDRs are essential tools for any
electrician or technician working with optical fiber, as they allow for precise and accurate
testing and characterization of the fiber.

Advantages:

Optical Time Domain Reflectometers (OTDRs) have a number of advantages. They are able
to measure the length and reflectance of a fiber optic line in a single measurement, and can
detect breaks, splices, and other faults along the line. OTDRs are also capable of measuring
the optical power of a signal, which can be used to identify poor connections, or to locate a
fault. OTDRs are also relatively low-cost and easy to use, making them a popular choice for
fiber optic testing.

Disadvantages:

The main disadvantage of Optical Time Domain Reflectometers (OTDRs) is their limited
dynamic range and sensitivity, which can make it difficult to measure small changes in the
optical signal. Additionally, OTDRs are typically expensive and require a considerable
amount of expertise to operate and calibrate. Additionally, they are limited to measuring
changes in a single direction and cannot measure changes in multiple directions, which can
be an issue when dealing with complex fiber optic networks. Furthermore, OTDRs are
limited to measuring the optical power of a signal, and cannot measure other parameters such
as the amplitude or phase of the signal.

7|Pa ge
TIME DOMAIN REFLECTOMETER

Fig.: Time Domain Reflectometer

A Time Domain Reflectometer (TDR) is an electronic instrument used to determine the


characteristics of electrical lines by observing reflected waveforms. TDRs work by sending a
pulse of electricity down the line, and then measuring the reflected signal that is returned. The
TDR can detect characteristics such as the location, type, and size of any faults or defects in
the line, as well as overall electrical loss. TDRs are essential tools for any electrician or
technician working with electrical lines, as they allow for precise and accurate testing and
characterization of the line.

Advantages:

The main advantages of time domain reflectometers (TDRs) are their ability to quickly and
accurately measure the length and reflectance of a transmission line, their ability to detect
breaks, splices, and other faults along the line, their ability to measure the optical power of a
signal, and their low cost and ease of use. Additionally, TDRs are capable of producing a
square wave signal for synchronous output, which can be useful in various applications.

Disadvantages:

The main disadvantages of time domain reflectometers (TDRs) are their limited dynamic
range and resolution, which can make it difficult to measure small changes in the electrical
signal. Additionally, TDRs are typically expensive and require a considerable amount of
expertise to operate and calibrate. Additionally, they are limited to measuring changes in a
single direction and cannot measure changes in multiple directions, which can be an issue
when dealing with complex networks. Furthermore, TDRs are limited to measuring the
electrical power of a signal, and cannot measure other parameters such as the amplitude or
phase of the signal.

8|Pa ge
LIGHTER METER

Fig.: Lighter Meter

A lighter meter is a device used to measure the amount of light produced by a lighter or other
similar device. Lighter meters are used by manufacturers and customers alike to ensure the
lighters are producing the correct amount of light, as well as to ensure that the lighters are
safe to use. Lighter meters measure the intensity of the light produced by the lighter, typically
in lux or lumens, and can also measure other parameters such as temperature and power
consumption.

Advantages:

The main advantages of light meters are their accuracy and repeatability in measuring light
levels. They are also relatively low-cost and easy to use, making them suitable for a wide
range of applications. Additionally, light meters are able to measure light levels over a wide
range of wavelengths, allowing them to be used for both color and black-and-white
photography. Furthermore, light meters are able to measure both incident and reflected light,
making them suitable for both indoor and outdoor photography.

Disadvantages:

Some of the drawbacks of using a light meter include the cost of the device, the potential for
error in the readings, and the need for regular calibration. Additionally, a light meter cannot
provide a full range of lighting information, such as color temperature and spectral
distribution, which can be important for some applications. Light meters may also be affected
by surrounding light sources, which can make readings less accurate.

9|Pa ge
PUNCH DOWN TOOL

Fig.: Punch Down Tool

A punch down tool, also known as a IDC tool, or Krone tool, is a small hand tool used by
telecommunication and network technicians. This tool is used to insert and cut terminations
in one operation, allowing for efficient and secure connections of the wires. The tool is
spring-loaded, and can be used to terminate twisted pair cable into 110-style patch panels,
connecting blocks and keystone jacks. Some punch down tools also comes with
interchangeable blades for 110 and Krone connections. Punch down tools are essential tools
for any electrician or technician working with telecommunications, as they allow for precise
and secure connections of the wires.

Advantages:

Some of the advantages of using a punch down tool include increased accuracy and
efficiency when connecting wires to a block or panel, a secure connection that is difficult to
damage, and a low cost of ownership. Punch down tools are also easy to use, require minimal
training, and are suitable for a wide range of applications. Additionally, they are more reliable
than other connection methods and provide a consistent connection every time.

Disadvantages:

Some of the disadvantages of using a punch down tool include the potential for incorrect
connections if the tool is not used properly, the need for proper training to use the tool, and
the cost of purchasing the tool. Additionally, some punch down tools are not suitable for use
with all types of cables, and the tool may be difficult to use in tight spaces.

10 | P a g e
MULTIMETER

Fig.: Multimeter

A multimeter is a hand-held electronic device used to measure electrical current, voltage, and
resistance. It is an essential tool for any electrician or technician working with electrical
systems, as it allows for precise and accurate testing and characterization of the electrical
parameters. Multimeters can measure a variety of things, such as current, continuity,
resistance, and voltage. They can also measure other parameters such as temperature and
power consumption. Multimeters are available in both analog and digital versions, with
digital multimeters generally offering more accurate measurements and a wider range of
features.

Advantages:

Some of the advantages of using a multimeter include the ability to measure a wide variety of
electrical signals, the ability to diagnose electrical problems quickly and accurately, and the
ability to measure current, voltage, and resistance with a single device. Additionally,
multimeters are relatively inexpensive and easy to use. They can also be used to test for
continuity, which can help identify broken or poorly soldered connections.

Disadvantages:

Some of the disadvantages of using a multimeter include the need for proper training to use
the device correctly, the potential for inaccurate readings if the device is not used properly,
and the need for periodic calibration to ensure accuracy. Additionally, multimeters can be
expensive, and their size and weight can make them difficult to use in tight spaces.
Additionally, multimeters are not suitable for measuring all types of electrical signals, and
they may not be able to measure very low or very high voltages.

11 | P a g e
COAXIAL COMPRESSION TOOL

Fig.: Coaxial Compression Tool

A coaxial compression tool is a hand tool used to install coaxial cable connectors onto coaxial
cables. The tool is designed to compress the connector onto the cable, ensuring a secure
connection. Coaxial compression tools come in a variety of designs, with some being
adjustable to fit different sizes of cable and connectors. Coaxial compression tools are
essential tools for any electrician or technician working with coaxial cables, as they allow for
precise and secure connections of the cables.

Advantages:

The main advantage of using a coaxial compression tool is that it creates a more reliable
connection than other methods, such as soldering or using a f-type screw head. Compression
tools use a 360-degree crimping action to secure the connector and wire together, providing
superior electrical contact and a more secure connection that is less prone to corrosion and
damage. Additionally, using a coaxial compression tool is a relatively quick and easy process,
requiring only a few simple steps to complete.

Disadvantages:

The main disadvantage of using a coaxial compression tool is that it can be difficult to tell if
the connection is secure or not. When the handles of the tool are squeezed together, it is
impossible to tell if the contact and wire are properly secured. Additionally, compression
tools require specialised tools that may not be readily available, and if the connectors are not
properly aligned when the tool is used, it can cause damage to the cable or connector. Finally,
some coaxial cables require specialised compression tools for installation, which can lead to
additional costs.

12 | P a g e
NETWORKING DEVICES

REPEATER

Fig.: Repeater

A Repeater is a networking device that amplifies and extends the range of a network. It operates
at the Physical Layer (OSI Layer 1) and regenerates the incoming electrical or optical signals
to overcome signal degradation caused by distance or other factors.

Working:

A repeater receives incoming signals from the network and amplifies them to restore their
strength. It then retransmits the amplified signals back into the network, extending the overall
range of the network.

Advantages:

Repeaters are simple and inexpensive devices that can significantly extend the range of a
network. They can also improve network performance by reducing the number of collisions
and retransmissions on the network.

Disadvantages:

Repeaters can increase network latency and reduce network performance if used improperly.
They can also introduce security vulnerabilities if not properly secured, as they repeat all
network traffic, including malicious traffic. Additionally, repeaters are limited in the amount of
signal degradation they can overcome, and may not be suitable for networks with large signal
losses.

13 | P a g e
HUB

Fig.: Hub

A Hub is a basic networking device that provides a connection between multiple devices on a
single network. It operates at the Physical Layer (OSI Layer 1) and provides a central point for
data to flow between connected devices.

Working:

A hub receives incoming data from one connected device and broadcasts it to all other
connected devices. All devices on the network receive the broadcasted data, but only the
intended recipient device processes it. Hubs are simple and do not provide any advanced
features, such as data filtering or network segmentation.

Advantages:

Hubs provide improved network accessibility by allowing multiple devices to connect to a


single network. They are also relatively inexpensive compared to other networking devices.

Disadvantages:

Hubs are not very secure, as they broadcast all data to all connected devices. They also do not
provide any advanced networking features, such as network segmentation or data filtering,
which can result in increased network congestion. Additionally, hubs have limited performance
and may not be able to support high data transfer rates.

14 | P a g e
BRIDGE

Fig.: Bridge

A Bridge is a networking device that connects two separate networks and controls the flow of
data between them. It operates at the Data Link Layer (OSI Layer 2) and uses media access
control (MAC) addresses to forward data to the correct destination network.

Working:

A bridge receives incoming data packets and examines the destination MAC address to
determine the intended recipient network. It then forwards the data to the correct network based
on its MAC address table, which maps MAC addresses to network segments. Bridges can help
to improve network performance by reducing network congestion and separating network
traffic.

Advantages:

Bridges provide improved network performance by reducing network congestion and


improving network segmentation. They also provide improved network security by isolating
network segments and preventing unauthorized access.

Disadvantages:

Bridges can be complex to set up and configure, and can become a bottleneck for network
traffic if not properly configured. They can also be vulnerable to hacking and other security
threats if not properly secured.

15 | P a g e
SWITCH

Fig.: Switch

A Switch is a networking device that connects multiple devices to a single network. It operates
at the Data Link Layer (OSI Layer 2) and uses media access control (MAC) addresses to
forward data to the correct destination device.

Working:

A switch receives incoming data packets and examines the destination MAC address to
determine the intended recipient device. It then forwards the data to the correct device based
on its MAC address table, which maps MAC addresses to network ports. Switches can help to
improve network performance by reducing network congestion and separating network traffic.

Advantages:

Switches provide improved network performance by reducing network congestion and


allowing for faster data transfer speeds. They also provide improved network security by
isolating network segments and preventing unauthorized access.

Disadvantages:

Switches can be complex to set up and configure, and can become a bottleneck for network
traffic if not properly configured. They can also be vulnerable to hacking and other security
threats if not properly secured.

16 | P a g e
ROUTER

Fig.: Router

A Router is a networking device that provides a connection between multiple networks. It


operates at the Network Layer (OSI Layer 3) and provides a bridge between multiple networks,
allowing data to travel between them.

Working:

A router receives incoming data packets and determines the intended recipient network. It then
forwards the data to the correct network based on its routing tables and network configuration.
Routers can also provide additional security features, such as firewalling and network address
translation (NAT).

Advantages:

Routers provide improved network performance by reducing network congestion and allowing
for faster data transfer speeds. They also provide improved network security by isolating
network segments and preventing unauthorized access, as well as by providing network address
translation (NAT) and firewalling capabilities.

Disadvantages:

Routers can be complex to set up and configure, and can be vulnerable to hacking and other
security threats if not properly secured. They can also introduce network latency if not properly
configured, as data must pass through the router for all network traffic.

17 | P a g e
GATEWAY

Fig.: Gateway

Gateway is a networking device that provides a connection between two separate networks. It
operates at the Network Layer (OSI Layer 3) and provides a bridge between two networks,
allowing data to travel between them.

Working:

A gateway receives incoming data packets and determines the intended recipient network. It
then forwards the data to the correct network based on its routing tables and network
configuration. Gateways can also provide additional security features, such as firewalling,
network address translation (NAT), and virtual private network (VPN) support.

Advantages:

Gateways provide improved network performance by reducing network congestion and


allowing for faster data transfer speeds. They also provide improved network security by
isolating network segments and preventing unauthorized access, as well as by providing
network address translation (NAT) and firewalling capabilities.

Disadvantages:

Gateways can be complex to set up and configure, and can be vulnerable to hacking and other
security threats if not properly secured. They can also introduce network latency if not properly
configured, as data must pass through the gateway for all network traffic.

18 | P a g e
MODEM

Fig.: Modem

A Modem is a networking device that provides a connection between a computer and a


telecommunications network. It operates at the Physical Layer (OSI Layer 1) and provides a
bridge between the computer and the network, allowing data to travel between them.

Working:

A modem receives incoming data from the computer and modulates it into a form that can be
transmitted over the telecommunications network. It then demodulates incoming data from the
network and sends it to the computer. Modems can provide features such as data compression
and error correction to improve the reliability of data transmission.

Advantages:

Modems provide improved network accessibility by allowing computers to connect to


telecommunications networks. They also provide improved network reliability by providing
data compression and error correction capabilities.

Disadvantages:

Modems can be slow and may have limited capabilities, such as limited data transfer speeds
and limited support for advanced networking features. Additionally, modems may not provide
enough security, as they do not provide built-in security features such as encryption or
firewalling.

19 | P a g e
FIREWALL

Fig.: Firewall

A Firewall is a networking device that provides a barrier between a private internal network
and the public internet. It operates at the Network Layer (OSI Layer 3) and provides security
by filtering incoming and outgoing network traffic based on predefined security rules.

Working:

A firewall examines incoming and outgoing network traffic and blocks traffic that does not
meet its security rules. The security rules can be based on various criteria, such as source and
destination IP address, port number, and type of data. Firewalls can provide additional security
features, such as virtual private network (VPN) support, intrusion detection and prevention,
and anti-malware protection.

Advantages:

Firewalls provide improved network security by filtering incoming and outgoing network
traffic and blocking traffic that does not meet its security rules. They also provide additional
security features, such as VPN support and intrusion detection and prevention.

Disadvantages:

Firewalls can be complex to set up and configure, and may cause network congestion if not
properly configured. They can also be vulnerable to hacking and other security threats if not
properly secured.

20 | P a g e
ACCESS POINT

Fig.: Access Point

An Access Point (AP) is a networking device that allows wireless devices to connect to a wired
network. It operates at the Data Link Layer (OSI Layer 2) and provides a wireless access point
for wireless devices to connect to a wired network.

Working:

An access point receives incoming wireless signals from wireless devices and forwards the
data to the wired network. It also transmits outgoing data from the wired network to the
connected wireless devices. Access points typically provide features such as wireless security,
network segmentation, and quality of service (QoS) for wireless traffic.

Advantages:

Access points provide improved network accessibility by allowing wireless devices to connect
to a wired network. They also provide improved network security by providing wireless
security features, such as encryption and authentication.

Disadvantages:

Access points can introduce security vulnerabilities if not properly secured, as they provide a
bridge between the wired and wireless network. They can also cause network congestion if not
properly configured, as all wireless traffic must pass through the access point. Additionally,
access points may have limited range and may require additional infrastructure, such as
antennas and cabling, to properly function.

21 | P a g e
NETWORK INTERFACE CARD (NIC)

Fig.: Network Interface Card (NIC)

A Network Interface Card (NIC) is a hardware component that connects a computer to a


network. It acts as a communication interface between the computer and the network, allowing
the computer to transmit and receive data over the network.

Working:

A NIC typically has a physical connector, such as an Ethernet port, that connects to a network
cable. When a computer is connected to a network, the NIC uses the cable to transmit data to
and from the network. The NIC uses a unique Media Access Control (MAC) address to identify
the computer on the network. When data is sent to the computer, the NIC receives the data,
checks the MAC address to ensure it's meant for the computer, and then passes the data to the
computer's operating system.

Advantages:

NICs are typically easy to install and use, and provide a reliable connection between a computer
and a network. They also allow for faster network speeds and improved network performance.

Disadvantages:

NICs can be expensive, and can become a bottleneck for network traffic if not properly
configured. They can also be vulnerable to interference and signal degradation.

22 | P a g e
NETWORKING COMMANDS

PING

The ping command is a diagnostic tool used to verify the connectivity between two network
devices. It works by sending an Internet Control Message Protocol (ICMP) Echo Request
Packet to a target device and waiting for an ICMP Echo Reply. The response time, or "round-
trip time," is measured and displayed, along with the number of packets sent and received, and
any errors that may occur.

Syntax:

ping [options] destination_address

Options:
-c count: Specifies the number of echo requests to send.
-t: Continuously sends echo requests until interrupted.
-W timeout: Specifies the timeout value, in seconds, for the ping command to wait for a
response.

Example:

23 | P a g e
TRACEROUTE

The traceroute command is used to display the path that a packet of data takes from the
source device to the destination device. It works by sending a series of Internet Control
Message Protocol (ICMP) Echo Request packets with incrementally increasing Time-To-Live
(TTL) values. Each hop along the way returns an ICMP Time Exceeded message, revealing
the IP address of the device at that hop.

Syntax:

traceroute [options] destination_address

Options:
-I: Specifies that the traceroute command should use ICMP Echo Requests instead of UDP
packets.
-m max_ttl: Specifies the maximum number of hops to search for the target.
-w wait_time: Specifies the wait time, in seconds, for the traceroute command to wait for a
response from each hop.

Example:

24 | P a g e
NSLOOKUP

The nslookup command is used to query the Domain Name System (DNS) to obtain
information about a domain name or IP address. It can be used to determine the IP address
associated with a domain name, the name server responsible for a domain, and other
information related to a domain's DNS records.

Syntax:

nslookup [options] [hostname/IP_address]

Options:
-a: Displays the authoritative name server and IP address for a domain.
-r: Disables recursion, causing the nslookup command to only query the local DNS server.
-t type: Specifies the type of record to query, such as "A" for an IP address or "MX" for a
mail exchange record.

Example:

25 | P a g e
NETSTAT

The netstat command is used to display various network-related statistics, such as the current
state of network connections, the number of packets sent and received, and information about
routing and network interfaces.

Syntax:

netstat [options]

Options:
-a: Displays all active connections and listening sockets.
-r: Displays the IP routing table.
-t: Displays only TCP connections.
-u: Displays only UDP connections.
-n: Displays numerical addresses instead of resolving hostnames.
-p: Shows the process ID (PID) and name of the program that owns each network connection.

Example:

26 | P a g e
IFCONFIG

The ifconfig command is used to configure and display information about network interfaces
on a Unix-like system. It can be used to view the status of a network interface, such as its IP
address, netmask, and broadcast address, as well as to configure network interfaces, such as
setting an IP address or enabling or disabling a network interface.

Syntax:

ifconfig [options] [interface]

Options:
-a: Displays information about all network interfaces, even those that are down.
-s: Displays a summary of network interface statistics, such as the number of packets
received and sent.
interface: Specifies the name of the network interface to display or configure.

Example:

27 | P a g e
LINK STATE ROUTING ( LSR )

Definition:

Link state routing is a method in which each router shares its neighbourhood’s knowledge
with every other router in the internetwork. In this algorithm, each router in the network
understands the network topology then makes a routing table depend on this topology.

Flowchart:

Start the program

Create an empty directed graph using NetworkX

Take input from the user for the number of nodes in the graph

Add nodes to the graph using a for loop

Take input from the user for the edges in the graph (in the format <node1> <node2> <cost>)

Add edges to the graph using a while loop that continues until the user enters -1

Calculate the shortest paths using the OSPF algorithm and NetworkX's shortest_path()
function

Print the shortest paths for all node pairs using a nested loop that iterates over the spf
dictionary returned by shortest_path()

End the program

28 | P a g e
Algorithm:

1. Create an empty directed graph using nx.DiGraph().


2. Add nodes to the graph using the add_node() method.
3. Add edges to the graph by taking input from the user in the format <node1> <node2>
<cost> and use the add_edge() method to add the edge to the graph.
4. Calculate the shortest paths using the shortest_path() method of NetworkX with the graph
object G and the keyword argument weight='weight'.
5. Print the shortest paths for all node pairs using a nested loop that iterates over the spf
dictionary returned by shortest_path().
6. Use the join() method to concatenate the node IDs in the shortest path and print them.

Program:

import networkx as nx
# Create an empty directed graph
G = nx.DiGraph()
# Add nodes to the graph
n = int(input("Enter the number of nodes: "))
for i in range(n):
G.add_node(i+1)
# Add edges to the graph
print("Enter the edges in the format <node1> <node2> <cost>")
print("Enter 0 to stop")
while True:
edge = input().split()
if edge[0] == '0':
break
G.add_edge(int(edge[0]), int(edge[1]), weight=int(edge[2]))
# Calculate shortest paths using OSPF
spf = nx.shortest_path(G, weight='weight')
# Print the shortest paths
print("Shortest paths:")
for node1 in spf:
for node2 in spf[node1]:
path = spf[node1][node2]
print(f"{node1} to {node2}: {' to '.join(map(str, path))}")

29 | P a g e
Output:

30 | P a g e
PATH VECTOR ROUTING ( PVR )

Definition:

A path-vector routing protocol is a network routing protocol which maintains the path
information that gets updated dynamically. Updates that have looped through the network and
returned to the same node are easily detected and discarded. This algorithm is sometimes
used in Bellman–Ford routing algorithms to avoid "Count to Infinity" problems.

Algorithm:

1. Input the number of nodes (n) in the graph.

2. Create an n x n matrix a to represent the adjacency matrix of the graph, where a[i][j]
represents the weight of the edge from node i to node j. Initialize the matrix with
appropriate values.

3. Initialize another n x n matrix b as a copy of a.

4. For each node k in the graph:

 For each pair of nodes i and j in the graph:

 If the distance from i to j through node k is less than the current distance
from i to j, update the distance from i to j to the new shorter distance.

5. The resulting matrix b contains the shortest distance between every pair of nodes in the
graph.

31 | P a g e
Flowchart:

Start

Read n

Read distance matrix a

Display a

for k,i,j in range of n

a[i][j] > a[i][k] + a[k][j] shortest path:


a[i][j]

shortest path a[i][j] = a[i][k] + a[k][j]

i==j no b[i][j] = a[i][j]

yes

b[i][j] = 0

Display b

End

32 | P a g e
Program:

n = int(input("Number of nodes: "))


a = [[0 for i in range(n)] for j in range(n)]
b = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
for j in range(n):
a[i][j] = int(input(f"Enter distance between nodes {i+1},{j+1}: "))
print("Given inputs")
for i in range(n):
for j in range(n):
print(a[i][j], end="\t")
print()
for k in range(n):
for i in range(n):
for j in range(n):
if a[i][j] > a[i][k] + a[k][j]:
a[i][j] = a[i][k] + a[k][j]
for i in range(n):
for j in range(n):
b[i][j] = a[i][j]
if i == j:
b[i][j] = 0
print("output: ")
for i in range(n):
for j in range(n):
print(b[i][j], end="\t")
print()

33 | P a g e
HAMMING DISTANCE

Definition:

The Hamming distance between two strings of equal length is the number of positions at
which the corresponding symbols are different. In other words, it measures the minimum
number of substitutions required to change one string into the other, or the minimum number
of errors that could have transformed one string into the other. In a more general context, the
Hamming distance is one of several string metrics for measuring the edit distance between
two sequences. It is named after the American mathematician Richard Hamming.

Flowchart:

START

i=0
count = 0

input word1,word2

while i<length of word1

if(word[i]!=word[j])
NO
YES
count++

i++

return count
(hamming distance)

END

34 | P a g e
Algorithm:

1. Input two strings: string1 and string2.


2. Check that the length of string1 is equal to the length of string2. If they are not equal,
return an error message.
3. Initialize hamming_distance to zero.
4. For each character position i in string1 and string2:
5. If the character in string1 at position i is different from the character in string2 at position
i, increment hamming_distance by 1.
6. Return hamming_distance.

Program:

print("Enter first string: ")


str1 = input()
print("Enter second string: ")
str2 = input()
dist = 0
if(len(str1) == len(str2)):
for i in range(len(str1)):
if(str1[i] != str2[i]):
dist += 1
print("Hamming Distance: ", dist)
else:
print("Strings are of unequal length")

35 | P a g e
RIVEST SHAMIR ADELMAN ( RSA ) ALGORITHM

Flowchart:

START

Choose Prime numbers p and q

Compute n=p*q

Compute phi= (p-1)*(q-1)

Choose an integer e such that 1<e<phi(n) and gcd(e, phi(n))=1; i.e., e and phi(n) are coprime.

Calculate d as d*e=1 (mod phi(n))

For encryption, c = m mod n, here m = original message.

For decryption, m = c mod n.

END

36 | P a g e
Algorithm:
Begin
1. Choose two prime numbers p and q.
2. Compute n = p*q.
3. Calculate phi = (p-1) * (q-1).
4. Choose an integer e such that 1 < e < phi(n) and gcd(e, phi(n)) = 1; i.e., e and phi(n) are
coprime.
5. Calculate d as d ≡ e−1 (mod phi(n)); here, d is the modular multiplicative inverse of e
modulo phi(n).
6. For encryption, c = me mod n, where m = original message.
7. For decryption, m = c d mod n.
End

Program:
#include <iostream>
#include <math.h>
using namespace std;
int gcd(int a, int b)
{
int t;
while (1)
{
t = a % b;
if (t == 0)
return b;
a = b;
b = t;
}}
int main()
{
//2 random prime numbers
double p ;
double q ;
double trk;
double phi = (p - 1) * (q - 1);
double message;
cout << "Original Message = ";
cin>>message;
cout << "p = " ;
cin>>p;
cout << "q = ";

37 | P a g e
cin>>q;
double n =p*q;
cout << "n = pq = " << n <<"\n";
double e;
cout << "e = ";
cin>> e;
while (e < phi)
{
trk = gcd(e, phi);
if (trk == 1)
break;
else
e++;
}
double d1 = 1 / e;
double d = fmod(d1, phi);
double c = pow(message, e);
double m = pow(c, d);
c = fmod(c, n);
m = fmod(m, n);
cout << "\n"
<< "phi = " << phi;
cout << "\n"
<< "d = " << d;
cout << "\n"
<< "Encrypted message = " << c;
cout << "\n"
<< "Decrypted message = " << m;
return 0;
}

Result:

38 | P a g e
DIFFIE - HELLMAN ALGORITHM

Flowchart:

USER1 and USER2 agree on a public generator g and prime number p

USER1 USER2

Generate a secret Compute Compute Generate a secret

Random no. a y=g mod p y=g mod p random no. b

Receive Receive

V=g mod p U=g mod p

Compute S =V mod p Compute S =U modp

Shared Secret Key

S= S =S = g mod p

39 | P a g e
Algorithm:
1. Define prime_checker(p) function that takes an integer p as input
2. If p < 1, return -1
3. Else if p > 1:
- If p == 2, return 1
- For i in range(2, p):
- If p % i == 0:
- Return -1
- Return 1
4. Define primitive_check(g, p, L) function that takes an integer g, an integer p and an empty
list L as input
5. For i in range(1, p):
- Append pow(g, i) % p to L
6. For i in range(1, p):
- If L.count(i) > 1:
- Clear L & Return -1
- Return 1
7. Create an empty list l
8. While True:
- Prompt user to enter P as an integer
- If prime_checker(P) == -1:
- Print "Number Is Not Prime, Please Enter Again!"
- Continue
- Break out of loop
9. While True:
- Prompt user to enter G as an integer and format string with P
- If primitive_check(G, P, l) == -1:
- Print f"Number Is Not A Primitive Root Of {P}, Please Try Again!"
- Continue
- Break out of loop
10. Prompt user to enter x1 and x2 as integers
11. While True:
- If x1 >= P or x2 >= P:
- Print f"Private Key Of Both The Users Should Be Less Than {P}!"
- Continue
- Break out of loop
12. Calculate y1 and y2 using pow(G, x1) % P and pow(G, x2) % P respectively
13. Calculate k1 and k2 using pow(y2, x1) % P and pow(y1, x2) % P respectively
14. Print f"\nSecret Key For User 1 Is {k1}\nSecret Key For User 2 Is {k2}\n"
15. If k1 == k2:
- Print "Keys Have Been Exchanged Successfully"
16. Else:
- Print "Keys Have Not Been Exchanged Successfully"

40 | P a g e
Program:

def prime_checker(p):
if p < 1:
return -1
elif p > 1:
if p == 2:
return 1
for i in range(2, p):
if p % i == 0:
return -1
return 1
def primitive_check(g, p, L):
for i in range(1, p):
L.append(pow(g, i) % p)
for i in range(1, p):
if L.count(i) > 1:
L.clear()
return -1
return 1
l = []
while 1:
P = int(input("Enter P : "))
if prime_checker(P) == -1:
print("Number Is Not Prime, Please Enter Again!")
continue
break
while 1:
G = int(input(f"Enter The Primitive Root Of {P} : "))
if primitive_check(G, P, l) == -1:
print(f"Number Is Not A Primitive Root Of {P}, Please Try Again!")
continue
break
x1, x2 = int(input("Enter The Private Key Of User 1 : ")),
int( input("Enter The Private Key Of User 2 : "))
while 1:
if x1 >= P or x2 >= P:
print(f"Private Key Of Both The Users Should Be Less Than {P}!")
continue
break
y1, y2 = pow(G, x1) % P, pow(G, x2) % P
k1, k2 = pow(y2, x1) % P, pow(y1, x2) % P
print(f"\nSecret Key For User 1 Is {k1}\nSecret Key For User 2 Is {k2}\n")
if k1 == k2:
print("Keys Have Been Exchanged Successfully")
else:
print("Keys Have Not Been Exchanged Successfully")

Output:

41 | P a g e
42 | P a g e

You might also like