Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
31 views

Computer Networking

The document discusses different network devices including repeaters, hubs, bridges, switches, and routers. It provides details on what each device is, its types, advantages and disadvantages. Repeaters regenerate signals and extend network distance but cannot reduce traffic. Hubs connect ports but don't filter or choose best paths. Bridges segment networks and filter by MAC address. Switches improve efficiency by forwarding to correct ports only. Routers route between networks based on IP and divide broadcast domains.

Uploaded by

muskanbandaria
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Computer Networking

The document discusses different network devices including repeaters, hubs, bridges, switches, and routers. It provides details on what each device is, its types, advantages and disadvantages. Repeaters regenerate signals and extend network distance but cannot reduce traffic. Hubs connect ports but don't filter or choose best paths. Bridges segment networks and filter by MAC address. Switches improve efficiency by forwarding to correct ports only. Routers route between networks based on IP and divide broadcast domains.

Uploaded by

muskanbandaria
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

COMPUTER NETWORKS (3150710) 210090107052

Practical 1

AIM: Study of different Network Devices in detail.

1. Repeater
The physical layer could be used to operate a repeater. This device’s primary purpose is to
duplicate the signal on a similar network before it becomes weak or broken. The critical thing to
remember about these gadgets is that they don’t boost the signal. They recreate the signal at its
actual power whenever it becomes weak. A repeater is a gadget with two ports. When the signal
becomes weak, they copy it bit by bit and regenerate it at its star topology connectors connecting
following the original strength. It is a 2-port device.

Figure 1: Repeater[1]
[1]https://media.geeksforgeeks.org/wp-content/uploads/20230828190552/IMG-20230828
-WA0013.jpg
● Advantages:
➔ Repeaters can extend a network's total distance.
➔ A repeater is simple to connect.
➔ Repeaters do not seriously affect network performance.
➔ It is cost-effective.
➔ Certain repeaters can connect networks using different physical media.
➔ It has the ability to boost or strengthen the digital to retransmit.
➔ Some reporters can connect networks using various physical media.
● Disadvantages:
➔ Repeaters are unable to reduce network traffic.
➔ Limitation in the number of repeaters.
➔ It cannot connect different network architectures.
➔ It does not segment the network.
➔ Repeaters do not separate the device in the collision domain.

1
COMPUTER NETWORKS (3150710) 210090107052

2. Hub
A hub is a physical-layer device that acts on individual bits rather than frames. A hub is a
basically multi-port repeater. A hub connects multiple wires coming from different branches, for
example, the connector in star topology which connects different stations. Hubs cannot filter
data, so data packets are sent to all connected devices. Also, they do not have the intelligence to
find out the best path for data packets which leads to inefficiencies and wastage.

● Types of Hub:
1. Active Hub: It repeats and strengthens incoming transmissions. They are also sometimes
referred to as repeaters.
2. Passive Hub: It simply serves as a point of connectivity, without any additional
capabilities.

Figure 2: Hub[2]
[2]https://masrik1990.files.wordpress.com/2014/11/computer-network-component
s-2.gif

● Advantages:
➔ It provides support for different types of Network Media.
➔ It can be used by anyone as it is very cheap.
➔ It can easily connect many different media types.
➔ The use of a hub does not impact on the network performance.
➔ It can expand the total distance of the network.
● Disadvantages:
➔ It has no ability to choose the best path of the network.
➔ It does not include mechanisms such as collision detection.
➔ It does not operate in full-duplex mode and cannot be divided into the Segment.
➔ It cannot reduce the network traffic as it has no mechanism.
➔ It is not able to filter the information.

2
COMPUTER NETWORKS (3150710) 210090107052

3. Bridge
A bridge operates at the data link layer. A bridge is a repeater, which adds on the functionality of
filtering content by reading the MAC addresses of the source and destination. It is also used for
interconnecting two LANs working on the same protocol. It is a 2 port device.

Figure 3: Bridge[3]
[3]https://prepbytes-misc-images.s3.ap-south-1.amazonaws.com/assets/1678697085974-Group%
2011.png

● Types of Bridges:
1. Transparent Bridges: These are the bridges in which the stations are completely unaware
of the bridge’s existence i.e. whether or not a bridge is added or deleted from the
network, reconfiguration of the stations is unnecessary. These bridges make use of two
processes i.e. bridge forwarding and bridge learning.
2. Source Routing Bridges: In these bridges, routing operation is performed by the source
station and the frame specifies which route to follow. The host can discover the frame by
sending a special frame called the discovery frame, which spreads through the entire
network using all possible paths to the destination.
● Advantages:
➔ Improve the performance of bridges by segmenting large busy networks into
multiple smaller and interconnected networks.
➔ Cost-effective.
➔ Increases available bandwidth to individual nodes.
➔ Reduces network congestion by dividing LAN into multiple smaller segments.

3
COMPUTER NETWORKS (3150710) 210090107052

● Disadvantages:
➔ Cannot read specific IP addresses.
➔ Unable to provide communication networks among networks of different
protocols.
➔ Cannot limit the capacity of broadcast messages as they transfer all the messages.
➔ Unable to handle complicated variable data load.

4. Switch

A switch is a multiport bridge with a buffer and a design that can boost its efficiency(a large
number of ports imply less traffic) and performance. A switch is a data link layer device. The
switch can perform error checking before forwarding data, which makes it very efficient as it
does not forward packets that have errors and forward good packets selectively to the correct
port only. In other words, the switch divides the collision domain of hosts, but the broadcast
domain remains the same.

Figure 4: Switch[4]
[4]https://cdn1.byjus.com/wp-content/uploads/2022/09/diagram-1-1.png

4
COMPUTER NETWORKS (3150710) 210090107052

● Types of Switch:
1. Unmanaged switches: These switches have a simple plug-and-play design and do not
offer advanced configuration options. They are suitable for small networks or for use
as an expansion to a larger network.
2. Managed switches: These switches offer advanced configuration options such as
VLANs, QoS, and link aggregation. They are suitable for larger, more complex
networks and allow for centralized management.
3. Smart switches: These switches have features similar to managed switches but are
typically easier to set up and manage. They are suitable for small- to medium-sized
networks.
4. Layer 2 switches: These switches operate at the Data Link layer of the OSI model and
are responsible for forwarding data between devices on the same network segment.
5. Layer 3 switches: These switches operate at the Network layer of the OSI model and
can route data between different network segments. They are more advanced than
Layer 2 switches and are often used in larger, more complex networks.
6. PoE switches: These switches have Power over Ethernet capabilities, which allows
them to supply power to network devices over the same cable that carries data.
7. Gigabit switches: These switches support Gigabit Ethernet speeds, which are faster
than traditional Ethernet speeds.
8. Rack-mounted switches: These switches are designed to be mounted in a server rack
and are suitable for use in data centers or other large networks.
9. Desktop switches: These switches are designed for use on a desktop or in a small
office environment and are typically smaller in size than rack-mounted switches.
10. Modular switches: These switches have modular design, which allows for easy
expansion or customization. They are suitable for large networks and data centers.
● Advantages:
➔ They increase the available bandwidth of the network.
➔ They help in reducing workload on individual host PCs.
➔ They increase the performance of the network.
➔ Networks which use switches will have less frame collisions.
➔ Switches can be connected directly to workstations.

5
COMPUTER NETWORKS (3150710) 210090107052

● Disadvantages:
➔ They are more expensive compared to network bridges.
➔ Network connectivity issues are difficult to be traced through the network switch.
➔ Broadcast traffic may be troublesome.
➔ If switches are in promiscuous mode, they are vulnerable to security attacks e.g.
spoofing IP addresses or capturing of ethernet frames.
➔ Proper design and configuration is needed in order to handle multicast packets.
➔ While limiting broadcasts, they are not as good as routers.

5. Routers

A router is a device like a switch that routes data packets based on their IP addresses. The router
is mainly a Network Layer device. Routers normally connect LANs and WANs and have a
dynamically updating routing table based on which they make decisions on routing the data
packets. The router divides the broadcast domains of hosts connected through it.

Figure 5: Router[5].
[5]https://www.tutorialspoint.com/assets/questions/media/40446/networks.jpg
● Advantages:
➔ Network Segmentation
➔ Efficient Data Forwarding
➔ Connectivity
➔ Traffic Control
➔ Network Security
➔ Load Balancing

6
COMPUTER NETWORKS (3150710) 210090107052

● Disadvantages:
➔ Performance Bottlenecks
➔ Single Points of Failure
➔ Limited Broadcast Domain
➔ Cost
➔ Latency

6. Gateway

A gateway, as the name suggests, is a passage to connect two networks that may work upon
different networking models. They work as messenger agents that take data from one system,
interpret it, and transfer it to another system. Gateways are also called protocol converters and
can operate at any network layer. Gateways are generally more complex than switches or routers.
A gateway is also called a protocol converter.

Figure 6: Gateway[6]
[6]https://www.tutorialspoint.com/assets/questions/media/40447/internet.jpg

7
COMPUTER NETWORKS (3150710) 210090107052

Practical 2
AIM: Study of different types of network cables and practically implement
the cross-wired cable and straight through cable using clamping tool.
Some common types of network cables are:
● Twisted Pair Cable:

Figure 7: twisted pair cable[7]


[7]https://media.geeksforgeeks.org/wp-content/uploads/20210817095055/cables-660x387
.jpg
The twisted-pair cable was primarily developed for computer networks. This cable is also
known as an Ethernet cable. Almost all modern LAN computer networks use this cable.
This cable consists of color-coded pairs of insulated copper wires. Every two wires are
twisted around each other to form a pair. Usually, there are four pairs. Each pair has one
solid color and one striped color wire. Solid colors are blue, brown, green, and orange. In
striped color, the solid color is mixed with the white color.
There are two types of twisted pair cable:
1. Unshielded twisted pair cable:

Figure 8: UTP cables[8]


[8]https://static.javatpoint.com/tutorial/computer-network/images/utp-vs-stp2.png

8
COMPUTER NETWORKS (3150710) 210090107052

In this type of cable, all the pairs are wrapped in a single plastic sheath. It has
weak immunity against noise and interference. It is easy to install. It is used for
telephone lines that have low speed data.
2. Shielded twisted pair cable:

Figure 9: STP cables[9]


[9]https://static.javatpoint.com/tutorial/computer-network/images/utp-vs-stp3.png
In this type of cable, each pair is wrapped with an additional metal shield, then all
pairs are wrapped in a single outer plastic sheath. It has high attenuation. It
provides a high data transmission rate. . They were developed for computer
networks and are an excellent choice for areas with high interference.
➢ Advantages:
➔ Best performance in short distances.
➔ High-cost performance
➔ The twisted-pair cable is low in weight.
➔ Twisted pair cable is flexible to use
➔ Twisted Pair cable is easy to connect.
➔ These cables are suitable for Data and voice infrastructure.
➢ Disadvantages:
➔ It results in signal distortion in a very effective manner.
➔ Attenuation is very high.
➔ It supports 10 mbps upto a distance of 100 meters on a 10BASE-T which are
considered to be low bandwidth.
➔ It provides poor security and is relatively easy to tap.
➔ Easily breakable.
➔ Low durability (must be maintained regularly).
➔ Susceptible to electromagnetic interference (EMI).

9
COMPUTER NETWORKS (3150710) 210090107052

● Coaxial Cable:

Figure 10: Coaxial cable[10]


[10]https://media.geeksforgeeks.org/wp-content/uploads/20211025154256/CoaxialCable-
660x330.jpg
This cable contains a conductor, insulator, braided conductor and plastic covering. The
plastic covering covers the braided conductor, the braided conductor covers the
insulation, and the insulation covers the conductor. The metal shield in coaxial cables
blocks any elements or interferences from the outside. The sheath(plastic covering)
protects the cable from physical damage. The braided shield protects signals from
external interference and noise. The insulator protects the core and the conductor carries
electromagnetic signals.

➢ Advantages:
➔ Coaxial cables support high bandwidth.
➔ It is easy to install coaxial cables.
➔ They have better cut-through resistance so they are more reliable and durable.
➔ Less affected by noise or crosstalk or electromagnetic interference.
➔ Coaxial cables support multiple channels.
➢ Disadvantages:
➔ Coaxial cables are expensive.
➔ The coaxial cable must be grounded in order to prevent any crosstalk.
➔ As a Coaxial cable has multiple layers it is very bulky.
➔ There is a chance of breaking the coaxial cable and attaching a “t-joint” by
hackers, this compromises the security of the data.

10
COMPUTER NETWORKS (3150710) 210090107052

● Fiber Optic Cable:

Figure 11: Fiber Optic Cable[11]


[11]https://www.tutorialspoint.com/assets/questions/media/51905/fibre_optic_cable.jpg
It is made of glass and transmits signals in the form of light.The glass core is surrounded
by the cladding of less dense glass. The difference in the density of the 2 materials must
be such that a beam of light moving through a core is reflected off the cladding instead of
being refracted into it.
Fiber optic cables can be single-mode fiber or multi-mode fiber. SMF cables support
longer distances, while MMF cables carry more data.
➢ Advantages:
➔ Bandwidth is above copper cables.
➔ Less power loss and allows data transmission for extended distances.
➔ Optical cable is resistance for electromagnetic interference.
➔ As cables are lighter, thinner, in order that they use less area as compared to
copper wires.
➔ Installation is extremely easy thanks to less weight.
➢ Disadvantages:
➔ These cable are highly vulnerable while fitting
➔ These cables are more delicate than copper wires.
➔ Special devices are needed to ascertain transmission of fiber cable.
➔ Fiber optic cable is dear to put in. It needs costly splicing machines and trained
specialists to place in fiber optic cables.

11
COMPUTER NETWORKS (3150710) 210090107052

Practical 3

AIM: Study of basic network commands and network configuration


commands

1. ipconfig:

This is a command-line application which displays all the current TCP/IP (Transmission Control
Protocol/Internet Protocol) network configuration, refreshes the DHCP (Dynamic Host
Configuration Protocol) and DNS (Domain Name Server). It also displays IP address, subnet
mask, and default gateway for all adapters.

12
COMPUTER NETWORKS (3150710) 210090107052

2. tracert :

It is a utility designed for displaying the time it takes for a packet of information to travel
between a local computer and a destination IP address or domain. After running a traceroute
command, the results displayed are a list of the 'hops' that data packets take along their path to
the designated IP address or domain. It is commonly associated with the troubleshooting of
connection issues.

3. ping :

PING (Packet Internet Groper) command is used to check the network connectivity between host
and server/host. This command takes as input the IP address or the URL and sends a data packet
to the specified address with the message “PING” and gets a response from the server/host this
time is recorded which is called latency. Fast ping low latency means faster connection.

13
COMPUTER NETWORKS (3150710) 210090107052

4. arp :

The arp command is used to display or modify the ARP cache on a computer. The ARP cache is
a table that stores the mapping of IP addresses to their corresponding MAC addresses. The arp
command can be used to display the ARP cache, add entries to the cache, and delete entries from
the cache.

14
COMPUTER NETWORKS (3150710) 210090107052

5. netstat :

Netstat command displays various network related information such as network connections,
routing tables, interface statistics, masquerade connections, multicast memberships etc. It is a
networking tool used for troubleshooting and configuration that can also serve as a monitoring
tool for connections over the network. Both incoming and outgoing connections, routing tables,
port listening, and usage statistics are common uses for this command.

6. nslookup:

It lets an Internet server administrator or any computer user enter a hostname and find out the
corresponding IP address or domain name system(DNS) record. The user can also enter a
command for it to do a reverse DNS lookup and find the hostname for an IP address that is
specified. Based on the system used, the default could be the local DNS server at the service
provider, some intermediate name server or the root server system for the entire DNS hierarchy.

7. systeminfo:

It is a command-line utility available in operating systems that provides detailed information


about the computer's hardware, software, and network configuration. It's a useful tool for
gathering comprehensive information about a computer's setup and can be particularly helpful
for troubleshooting and system administration tasks.

15
COMPUTER NETWORKS (3150710) 210090107052

8. hostname:

This command allows us to set and view the hostname of the system. A hostname is the name of
any computer that is connected to a network that is uniquely identified over a network. It can be
accessed without using a particular IP address. By default, the hostname of a system is set during
the installation of the OS.

16
COMPUTER NETWORKS (3150710) 210090107052

PRACTICAL – 4

AIM: Implement different LAN topologies using Packet Tracer

1. BUS topology:

A BUS topology is a type of network configuration where all devices are connected to a
central cable called a "bus." Data is transmitted along the bus, and all devices receive the
data, but only the intended recipient processes it. It is a simple and cost-effective network
design but can suffer from data collisions as multiple devices share the same
communication medium. BUS topologies are commonly used in small-scale networks or
as a backbone in larger networks.

● Advantages:
➔ Simple and cost-effective to set up and expand.
➔ Ease of adding new devices without disruption
➔ Easy to detect faults and isolate them.
➔ Minimal cabling required, reducing costs.
● Disadvantages:
➔ Limited scalability for larger networks.
➔ Performance can degrade as more devices are added.
➔ Security concerns due to the ease of eavesdropping.

17
COMPUTER NETWORKS (3150710) 210090107052

2. STAR topology:

Star topology is a network topology in which all devices (such as computers, printers, or
other networked devices) are connected to a central hub or switch. Each device has its cable
that connects directly to the central hub. In this arrangement, data traffic between devices
must pass through the central hub, which acts as a data distribution point. Star topology is a
popular choice for modern Ethernet networks, as it provides a balance between reliability,
scalability, and ease of management.

● Advantages:
➔ Easy to troubleshoot and isolate issues.
➔ Better performance than bus topology, especially in larger networks.
➔ Enhanced security as data transmission is more isolated.
➔ It is cost-effective.
● Disadvantages:
➔ The cost of installation is high.
➔ Performance is based on the single concentrator i.e. hub.
➔ Limited expandability.

18
COMPUTER NETWORKS (3150710) 210090107052

3. RING topology:

A ring topology in computer networks is a configuration where each device is connected to


exactly two other devices, forming a circular communication path. Data travels in a
unidirectional or bidirectional manner along the ring, passing through each device until it
reaches its intended destination. While it offers uniform access and fault tolerance, a single
break in the ring can disrupt the entire network. To overcome this limitation, some ring
networks employ features like token passing or dual-ring designs to enhance reliability.

● Advantages:
➔ Efficient and predictable data transmission.
➔ Redundant pathways enhance network reliability.
➔ Suitable for smaller networks with relatively few devices.
● Disadvantages:
➔ Difficult to install and expand
➔ More complex and costly to implement

19
COMPUTER NETWORKS (3150710) 210090107052

➔ Data collisions can occur if multiple devices attempt to transmit simultaneously.

4. MESH topology:

In mesh topology, every device in the network is connected to every other device,
creating a dense web of connections. This means that data can take multiple paths to
reach its destination, offering exceptional fault tolerance and redundancy. If one
connection or device fails, data can still navigate an alternate route, ensuring network
reliability. Mesh topology is commonly employed in critical applications, such as military
communications, data centres, and industrial control systems, where network uptime and
fault tolerance are crucial.
● Advantages:
➔ Excellent network performance and minimal data congestion.
➔ Enhanced security.
➔ High reliability and fault tolerance due to redundant connections.

20
COMPUTER NETWORKS (3150710) 210090107052

● Disadvantages:
➔ Network management and troubleshooting can be challenging.
➔ High cost and complexity.
➔ Not cost-effective for small networks with few devices.

5. HYBRID topology:

A hybrid topology in computer networks combines two or more traditional network


topologies, such as star, bus, ring, or mesh, to create a more flexible and resilient network
structure. This approach allows for redundancy and fault tolerance while maintaining
centralized control in certain segments of the network. Hybrid topologies are often used
in large-scale networks where different parts of the infrastructure have varying
connectivity requirements, offering a balance between performance and reliability.

21
COMPUTER NETWORKS (3150710) 210090107052

● Advantages:
➔ Combines the strengths of different topologies to create a more flexible and robust
network.
➔ Offers high reliability and fault tolerance by combining redundant connections
and isolation of network segments.
➔ Provides scalability and the ability to customize the network to suit specific
needs.
➔ Suitable for complex networks with diverse requirements, optimizing
performance, and cost-effectiveness.
➔ Enhanced security and data management options
● Disadvantages:
➔ Can be expensive and complex to design and implement.
➔ Requires careful planning and maintenance to ensure optimal performance and
reliability.
➔ Network management may be more challenging due to the various topology
components.
➔ May not be necessary for smaller or less demanding networks, making it overkill
in some cases.

22
COMPUTER NETWORKS (3150710) 210090107052

PRACTICAL 5
AIM : Implement error detection methods using simple parity check and 2D
parity check.

1. Simple Parity Check

In this technique One extra bit called a parity bit is sent along with the original data bits.
Parity bit helps to check if any error occurred in the data during the Transmission.

CODE:
#include <stdio.h>
// Function to check parity
int checkParity(int num) {
int count = 0;
// Counting set bits
while (num) {
count += num & 1;
num >>= 1;
}
// Determining parity (even or odd)
return (count % 2 == 0) ? 0 : 1; // 0 for even parity, 1 for odd parity
}
int main() {
int number = 23; // Change this number to test different cases
int parity = checkParity(number);
if (parity == 0) {
printf("Even parity\n");
} else {
printf("Odd parity\n");
}
return 0;
}
OUTPUT :

● Advantages:
➔ This technique is guaranteed to detect an odd number of bit errors (one,
three, five, and so on).
➔ If an odd number of bits flip during transmission, then the receiver can

23
COMPUTER NETWORKS (3150710) 210090107052

detect it by counting the number of 1s.


● Disadvantages:
➔ This technique can not detect an even number of bit errors (two, four,
six, and so on).
➔ If an even number of bits flips during transmission, then the receiver
can not catch the error.

1. 2-D Parity Check


Performance can be improved by using two-dimensional parity check, which organises
the block of bits in the form of a table. Parity check bits are calculated for each row,
which is equivalent to a simple parity check bit. Parity check bits are also calculated for
all columns then both are sent along with the data. At the receiving end, these are
compared with the parity bits calculated on the received data.

CODE:
#include <stdio.h>
// Function to generate parity bits
void generateParity(int matrix[4][4]) {
for (int i = 0; i < 3; i++) {
int row_parity = 0;
int col_parity = 0;
for (int j = 0; j < 3; j++) {
row_parity ^= matrix[i][j];
col_parity ^= matrix[j][i];
}
matrix[i][3] = row_parity;
matrix[3][i] = col_parity;
}
// Calculate the parity for the bottom-right corner
int total_parity = 0;
for (int i = 0; i < 3; i++) {
total_parity ^= matrix[3][i];
}
matrix[3][3] = total_parity;
}
// Function to check parity
int checkParity(int matrix[4][4]) {
int error_row = -1, error_col = -1;
int row_parity, col_parity, total_parity;
for (int i = 0; i < 4; i++) {

24
COMPUTER NETWORKS (3150710) 210090107052

row_parity = 0;
col_parity = 0;
for (int j = 0; j < 4; j++) {
row_parity ^= matrix[i][j];
col_parity ^= matrix[j][i];
}
if (row_parity != matrix[i][3]) {
error_row = i;
}
if (col_parity != matrix[3][i]) {
error_col = i;
}
}
total_parity = 0;
for (int i = 0; i < 3; i++) {
total_parity ^= matrix[3][i];
}
if (total_parity != matrix[3][3]) {
if (error_row == -1) {
error_row = 3;
}
if (error_col == -1) {
error_col = 3;
}
}
if (error_row == -1 && error_col == -1) {
printf("No errors found.\n");
} else if (error_row == -1) {
printf("Error in column %d.\n", error_col + 1);
} else if (error_col == -1) {
printf("Error in row %d.\n", error_row + 1);
} else {
printf("Error in data at row %d, column %d.\n", error_row + 1, error_col + 1);
}
return (error_row != -1 || error_col != -1) ? 1 : 0;
}

int main() {
int matrix[4][4] = {
{1, 0, 1, 0},

25
COMPUTER NETWORKS (3150710) 210090107052

{0, 1, 0, 1},
{1, 1, 1, 0},
{0, 0, 0, 1}
};
generateParity(matrix);
printf("Matrix with parity bits:\n");
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
printf("%d ", matrix[i][j]);
}
printf("\n");
}
checkParity(matrix);
return 0;
}

OUTPUT :

● Advantages:
➔ Increases the likelihood of detecting burst errors.
➔ A burst error of more than n bits is also detected with high probability.
● Disadvantages:
➔ If two bits in one data unit are damaged and two bits in exactly the same position
in another data unit are also damaged, the 2-D Parity checker will not detect an
error.

26
COMPUTER NETWORKS (3150710) 210090107052

PRACTICAL 6
AIM : Implement error detection using CRC

CRC generator is an algebraic polynomial represented as a bit pattern. Bit pattern is obtained
from the CRC generator using the rule - “The power of each term gives the position of the bit
and the coefficient gives the value of the bit.”
The algebraic polynomial chosen as a CRC generator should have at least the following
properties:

Rule-01:
● It should not be divisible by x.
● This condition guarantees that all the burst errors of length equal to the
length of the polynomial is detected.

Rule-02:
● It should be divisible by x+1.
● This condition guarantees that all the burst errors affecting an odd
number of bits are detected.

If the CRC generator is chosen according to the above rules, then-


● CRC can detect all single-bit errors
● CRC can detect all double-bit errors provided the divisor contains at least three logic 1’s.
● CRC can detect any odd number of errors provided the divisor is a factor of x+1.
● CRC can detect all burst errors of length less than the degree of the polynomial.
● CRC can detect most of the larger burst errors with a high probability.

CODE:

#include<stdio.h>

#include<string.h>

#define N strlen(gen_poly)

char data[28];

char check_value[28];

char gen_poly[10];

int data_length,i,j;

27
COMPUTER NETWORKS (3150710) 210090107052

void XOR(){

for(j = 1;j < N; j++)

check_value[j] = (( check_value[j] == gen_poly[j])?'0':'1');

void receiver(){

printf("Enter the received data: ");

scanf("%s", data);

printf("\n-----------------------------\n");

printf("Data received: %s", data);

crc();

for(i=0;(i<N-1) && (check_value[i]!='1');i++);

if(i<N-1)

printf("\nError detected\n\n");

else

printf("\nNo error detected\n\n");

void crc(){

for(i=0;i<N;i++)

check_value[i]=data[i];

do{

if(check_value[0]=='1')

XOR();

for(j=0;j<N-1;j++)

28
COMPUTER NETWORKS (3150710) 210090107052

check_value[j]=check_value[j+1];

check_value[j]=data[i++];

}while(i<=data_length+N-1);

int main()

printf("\nEnter data to be transmitted: ");

scanf("%s",data);

printf("\n Enter the Generating polynomial: ");

scanf("%s",gen_poly);

data_length=strlen(data);

for(i=data_length;i<data_length+N-1;i++)

data[i]='0';

printf("\n----------------------------------------");

printf("\n Data padded with n-1 zeros : %s",data);

printf("\n----------------------------------------");

crc();

printf("\nCRC or Check value is : %s",check_value);

for(i=data_length;i<data_length+N-1;i++)

data[i]=check_value[i-data_length];

printf("\n----------------------------------------");

printf("\n Final data to be sent : %s",data);

printf("\n----------------------------------------\n");

29
COMPUTER NETWORKS (3150710) 210090107052

receiver();

return 0;

OUTPUT:

● Advantages:
➔ CRC is simple to implement in binary hardware.
➔ It is good at detecting common errors caused by noise in transmission.
➔ Mathematical analysis of CRC is very simple.
● Disadvantages:
➔ CRC is not suitable for protecting against intentional alteration of data.
➔ Overflow of data is possible in CRC.

30
COMPUTER NETWORKS (3150710) 210090107052

PRACTICAL 7
AIM : Implement error correction method using HAMMING CODE

In this coding method, the source encodes the message by inserting redundant bits within the
message. These redundant bits are extra bits that are generated and inserted at specific positions
in the message itself to enable error detection and correction. When the destination receives this
message, it performs recalculations to detect errors and find the bit position that has an error.

CODE:
#include <math.h>
#include <stdio.h>
int input[32];
Int code[32];
int ham_calc(int, int);
void solve(int input[], int);
int ham_calc(int position, int c_l)
{
int count = 0, i, j;
i = position - 1;
while (i < c_l) {
for (j = i; j < i + position; j++) {
if (code[j] == 1)
count++;
}
i = i + 2 * position;
}
if (count % 2 == 0)
return 0;
else
return 1;
}
void solve(int input[], int n)
{
int i, p_n = 0, c_l, j, k;
i = 0;
while (n > (int)pow(2, i) - (i + 1)) {
p_n++;
i++;
}
c_l = p_n + n;

31
COMPUTER NETWORKS (3150710) 210090107052

j = k = 0;
for (i = 0; i < c_l; i++) {
if (i == ((int)pow(2, k) - 1)) {
code[i] = 0;
k++;
}
else {
code[i] = input[j];
j++;
}
}
for (i = 0; i < p_n; i++) {
int position = (int)pow(2, i);
int value = ham_calc(position, c_l);
code[position - 1] = value;
}
printf("\nThe generated Code Word is: ");
for (i = 0; i < c_l; i++) {
printf("%d", code[i]);
}
}
void main()
{
input[0] = 0;
input[1] = 1;
input[2] = 1;
input[3] = 1;
int N = 4;
solve(input, N);
}
OUTPUT:

● Advantages:
➔ Hamming code not only detects bit errors but also aids in the identification of bits
containing errors so that they can be repaired.
● Disadvantages:
➔ Can only address single-bit problems.

32
COMPUTER NETWORKS (3150710) 210090107052

PRACTICAL 8
AIM : Implement Bit Stuffing

CODE:

#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
int x[50], y[50], n;
int i, j, k, count = 1;
printf("Enter size of a bit string:");
scanf("%d", &n);
printf("Enter the bit string(0's &1's):");
for (i = 0; i < n; i++)
{
scanf("%d", &x[i]);
}
i = 0;
j = 0;
while (i < n)
{
if (x[i] == 1)
{
y[j] = x[i];
//count is less than 5 as 0 is inserted after every
//5 consecutive 1's
for (k = i + 1; x[k] == 1 && k < n && count < 5; k++)
{
j++;
y[j] = x[k];
count++;
if (count == 5)
{
j++;
y[j] = 0;
}
i = k;
}

33
COMPUTER NETWORKS (3150710) 210090107052

}
else
{
y[j] = x[i];
}
i++;
j++;
}
//Displaying final result
printf("Result of Bit Stuffing:");
for (i = 0; i < j; i++)
{
printf("%d", y[i]);
}
getch();
}

OUTPUT:

34
COMPUTER NETWORKS (3150710) 210090107052

PRACTICAL 9
AIM : Implement concept of VLAN using Packet Tracer.

VLAN (Virtual Local Area Network) allows administrators to limit the access of the user by
dividing isolated LAN segments. In other words, Vlan is the process of dividing a group of
devices to give limited access to a Network. This is a custom network we create from one or
more existing LANs. It can be administered like a physical area network.
● Advantages:
➔ It solves a broadcast problem.
➔ VLAN reduces the size of broadcast domains.
➔ VLAN allows you to add an additional layer of security.
➔ It can make device management simple and easier.
➔ You can make a logical grouping of devices by function rather than location.
● Disadvantages:
➔ A packet can leak from one VLAN to another.
➔ An injected packet may lead to a cyber-attack.
➔ Threat in a single system may spread a virus through a whole logical network.

35
COMPUTER NETWORKS (3150710) 210090107052

PRACTICAL 10
AIM : Implement concept of static routing

Static routing is a form of routing that occurs when a router uses a manually-configured routing
entry, rather than information from dynamic routing traffic. In many cases, static routes are
manually configured by a network administrator by adding entries into a routing table, though
this may not always be the case. Unlike dynamic routing, static routes are fixed and do not
change if the network is changed or reconfigured. Static routing and dynamic routing are not
mutually exclusive. Both dynamic routing and static routing are usually used on a router to
maximize routing efficiency and to provide backups in case dynamic routing information fails to
be exchanged.

● Advantages:
➔ It is easy to implement.
➔ It is the most secure way of routing.
● Disadvantages:
➔ Administrator must update all routers.
➔ It does not handle multiple paths to a destination.

36
COMPUTER NETWORKS (3150710) 210090107052

PRACTICAL 11
AIM : Implement the concept of dynamic routing (RIP, OSPF).

Dynamic routing occurs when routers talk to adjacent routers, informing each other of what
networks each router is currently connected to. It allows routers to share information about the
network with other routers to allow them to select the best path to reach a destination. It uses
multiple protocols and algorithms. The most popular are Routing Information Protocol(RIP) and
Open Shortest Path First(OSPF).

RIP:

Routing Information Protocol (RIP) is an active routing protocol that operates hop count as a
routing metric to find the most suitable route between the source and the destination network. It
is a distance-vector routing protocol that has an AD value of 120 and works on the Network
layer of the OSI model.

37
COMPUTER NETWORKS (3150710) 210090107052

❖ Advantages:
➢ Feasible configuration.
➢ Easy to understand.
➢ Predominantly loop-free.
❖ Disadvantages:
➢ Unable to scale to large or very large networks.
➢ Does not support discontinuous networks.

OSPF:

The OSPF protocol is a link-state routing protocol, which means that the routers exchange
topology information with their nearest neighbors. It is used to find the best and the optimal
pathway between the starting point and the destination target router using its own shortest path
first algorithm. It automatically generates or decides the optimal path and it is used to send router
packets with the auto path decision method.

38
COMPUTER NETWORKS (3150710) 210090107052

❖ Advantages:
➢ Load balancing with equal-cost routes for the same destination.
➢ VLSM and route summarization.
➢ Unlimited hop counts.
❖ Disadvantages:
➢ It needs lots of information to calculate the best route for each destination.
➢ It can be complex to install.

39
COMPUTER NETWORKS (3150710) 210090107052

PRACTICAL 12
AIM : Packet capture and header analysis by wire-shark (TCP,UDP,IP)

Wireshark:

Wireshark is an open-source packet analyzer,which is used for education, analysis, software


development,communication protocol development, and network troubleshooting. It is used to
track the packets so that each one is filtered to meet your specific needs. It is commonly called as
a sniffer, network protocol analyzer, and network analyzer.

TCP and UDP Headers:

To analyze TCP or UDP headers, select a packet and expand the "Transmission Control
Protocol" or "User Datagram Protocol" section in the packet details pane. Here, you can see
source and destination ports, sequence numbers, and other TCP or UDP-specific information.

40
COMPUTER NETWORKS (3150710) 210090107052

IP Headers:

You can click on any packet in the packet list, and the lower pane will display detailed
information about the selected packet. Expand the "Internet Protocol Version 4" section to view
the IP header, including source and destination IP addresses.

● Advantages:
➔ Can see detailed information about packets within a network.
➔ Captures network traffic.
● Disadvantages:
➔ Doesn’t capture how long packets have taken to reach their destination, or even
the capture point.

41

You might also like