Networking Devices Overview
Networking Devices Overview
EXPERIMENT-1
Aim: To study of Network devices in detail and connect the computers in Local Area
Network.
Description:
Network Devices: Network devices, also known as networking hardware, are physical devices
that allow hardware on a computer network to communicate and interact with one another.
1. Repeater
2. Hub
3. Bridge
4. Switch
5. Routers
6. Gateway
7. B-router
8. NIC
1. Repeater : A repeater operates at the physical layer. Its job is to amplifies (i.e., regenerates)
the signal over the same network before the signal becomes too weak or corrupted to extend the
length to which the signal can be transmitted over the same network. 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.
2. Hub: 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. In other
words, the collision domain of all hosts connected through Hub remains one. 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
Active Hub:- These are the hubs that have their power supply and can clean, boost, and relay
the signal along with the network. It serves both as a repeater as well as a wiring center. These
are used to extend the maximum distance between nodes.
Passive Hub:- These are the hubs that collect wiring from nodes and power supply from the
active hub. These hubs relay signals onto the network without cleaning and boosting them and
can’t be used to extend the distance between nodes.
Intelligent Hub:- It works like an active hub and includes remote management capabilities.
They also provide flexible data rates to network devices. It also enables an administrator to
monitor the traffic passing through the hub and to configure each port in the hub.
3. Bridge: A bridge operates at the data link layer. A bridge is a repeater, with add 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.
Types of Bridges
Transparent Bridges:- These are the bridge 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.
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.
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.
Types of Switch;
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.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.
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.
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.
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.
7. B-router: It is also known as the bridging router is a device that combines features of both
bridge and router. It can work either at the data link layer or a network layer. Working as a
router, it is capable of routing packets across networks and working as the bridge, it is capable
of filtering local area network traffic.
8. NIC: NIC or network interface card is a network adapter that is used to connect the computer
to the network. It is installed in the computer to establish a LAN. It has a unique id that is
written on the chip, and it has a connector to connect the cable to it. The cable acts as an
interface between the computer and the router or modem. NIC card is a layer 2 device which
means that it works on both the physical and data link layers of the network model.
EXPERIMENT-2
Aim: To write a Program to implement the data link layer farming methods such as i)
Character stuffing ii) bit stuffing.
Description:
Character stuffing or byte stuffing is which an escape byte (ESC) is stuffed character stream
before a flag byte in the data. It gets around the problem of re synchronization after an error by
having each frame start and end with special bytes.
A new technique allows data frames to contain arbitrary number of bits and allows character
codes with arbitrary number of bits per character. Bit stuffing is which an zero bit is stuffed
after five consecutive ones in the input bit stream.Example:
011011111111111111110010
0101111011111011111010010
Program:
Character stuffing
#include<stdio.h>
#include<string.h>
int main(){
char a[30],fs[50]=" ",t[3],sd,ed,x[3],s[3],y[3],d[3];
int i;
printf("\n Enter a character to be stuffed: ");
scanf("%s",a);
printf("\n Enter a character that represents starting delimiter: ");
scanf(" %c",&sd);
printf("\n Enter a character that represents ending delimiter: ");
scanf(" %c",&ed);
x[0]=s[0]=s[1]=sd;
x[1]=s[2]='\0';
y[0]=d[0]=d[1]=ed;
d[2]=y[1]='\0';
strcat(fs,x);
for(i=0;i<strlen(a);i++)
{
t[0]=a[i];
t[1]='\0';
if(t[0]==sd)
strcat(fs,s);
else
if(t[0]==ed)
strcat(fs,d);
else
strcat(fs,t);
}
strcat(fs,y);
Output:
Bit stuffing
#include<stdio.h>
#include<string.h>
int main(){
char a[20],b[50]=" ",t[6],r[5];
int i,j,p=0,q=0;
printf("Enter the bit to be stuffed:");
scanf("%s",a);
strcpy(b,"01111110");
if(strlen(a)<5)
strcat(b,a); else{
for(i=0;i<strlen(a)-4;i++){
for(j=i;j<i+5;j++)
t[p++]=a[j];
t[p]='\0';
if(strcmp(t,"11111")==0){ }
else{} p=0;}
strcat(b,"111110");
i=j-1; r[0]=a[i]; r[1]='\0';
strcat(b,r);
for(q=i;q<strlen(a);q++)
t[p++]=a[q];
t[p]='\0';
strcat(b,t);}
strcat(b,"01111110");
printf("\nStuffed bits are %s",b);
strcpy(a," ");
for(i=8;i<strlen(b)-8;i++){ p=0;
for(j=i;j<=i+5;j++)
t[p++]=b[j];
t[p]='\0';
if(strcmp(t,"111110")==0){}
else{}}
strcat(a,"11111");
i=j-1; r[0]=b[i]; r[1]='\0';
strcat(a,r);
printf("\nDestuffed bits are:%s",a);
return 0;
}
Output:
EXPERIMENT-3
Aim: To write a Program to implement data link layer farming method checksum.
Description:
The Checksum is an error detection method that detected errors in data/message while it is
transmitted from sender to receiver. This method is used by the higher layer protocols and
makes use of the Checksum Generator on the Sender side and Checksum Checker on the
Receiver side.
Program:
#include<stdio.h>
#include<math.h>
int main()
{
int a,b,c,d,i,j,k,sum,csum[4],binary[8],wsum[4],cs=0,fsum,wsum1[4],binary1[8];
printf("\nEnter the 4 inputs: \n");
scanf("%d%d%d%d",&a,&b,&c,&d);
sum=a+b+c+d;
for(i=7;i>=0;i--)
{
binary[i]=sum%2;
sum=sum/2;
printf("%d",binary[i]);
}
wsum[0]=binary[0]+binary[4];
wsum[1]=binary[1]+binary[5];
wsum[2]=binary[2]+binary[6];
wsum[3]=binary[3]+binary[7];
printf("ws\n"); for(j=0;j<4;j++)
{
if(wsum[j]==0)
wsum[j]=1;
else
wsum[j]=0;
printf("%d",wsum[j]);
csum[j]=wsum[j];
}
for(k=3;k>=0;k--){
cs=cs+csum[k]*pow(2,k);}
printf("\n%d\n",cs);
fsum=a+b+c+d+cs;
for(i=7;i>=0;i--){
binary1[i]=fsum%2;
fsum=fsum/2;
printf("%d",binary1[i]);
}
wsum1[0]=binary1[0]+binary1[4];
wsum1[1]=binary1[1]+binary1[5];
wsum1[2]=binary1[2]+binary1[6];
wsum1[3]=binary1[3]+binary1[7];
printf("\nreceiver side: \n");
for(j=0;j<4;j++)
{
if(wsum1[j]==0)
wsum1[j]=1;
wsum1[j]=0;
printf("%d",wsum1[j]);
}
Output:
EXPERIMENT-4
Aim: To write a program for Hamming Code generation for error detection and
correction.
Description:
Hamming code is an error-correcting code used to ensure data accuracy during transmission or
storage. Hamming code detects and corrects the errors that can occur when the data is moved or
stored from the sender to the receiver. This simple and effective method helps improve the
reliability of communication systems and digital storage.
Program:
#include<stdio.h>
int main()
{
int a[10],b[10],c1,c2,c3,i,p;
c2=b[2]^b[3]^b[6]^b[7];
c3=b[4]^b[5]^b[6]^b[7];
p=c1*1+c2*2+c3*4; if(p==0)
else
b[p]=0;
printf("\n");
for(i=1;i<8;i++)
printf("\t%d",b[i]);
}
return 0;
}
Output:
EXPERIMENT-5
Aim: To write a Program to implement on a data set of characters the three CRC
polynomials – CRC 12, CRC 16 and CRC CCIP.
Description:
The Cyclic Redundancy Check algorithm checks for errors and verifies the accuracy of the data
delivered by the sender. CRC requires a generator polynomial in order to compute the check
value using binary division in addition to the data that has to be transferred. To ensure that the
data is genuine, the check value or CRC is sent with it to the recipient.
Program:
#include <stdio.h>
#include <string.h>
char t[28], cs[28], g[28];
int a, e, c, b, N;
void xorOperation() {
int flag = 0; do {
printf("\n1. CRC12\n2. CRC16\n3. CRC CCIP\n4. Exit\n\nEnter your option: ");
scanf("%d", &b);
switch (b) {
case 1: strcpy(g, "1100000001111");
break;
case 2: strcpy(g, "11000000000000101");
break;
case 3: strcpy(g, "10001000000100001");
break;
case 4: return 0;
default:
crc();
printf("CRC code is: %s\n", cs);
for (e = a; e < a + N - 1; e++) {
t[e] = cs[e - a];}
printf("Final codeword is: %s\n", t);
printf("Receiver side\n");
printf("Test error detection 0 (yes) 1 (no)?: ");
scanf("%d", &e);
if (e == 0)
{do {
printf("Enter the position where error is to be inserted: ");
scanf("%d", &e);
if (e < 1 || e > a + N - 1) {
printf("Invalid position. Please try again.\n");
continue;}
t[e - 1] = (t[e - 1] == '0') ? '1' : '0';
printf("Erroneous data: %s\n", t);
crc();
if (cs[0] == '1') {
printf("Error detected\n");
} else {
printf("No error detected\n"); }
printf("Test another error? 0 (yes) 1 (no): ");
scanf("%d", &e);
} while (e == 0);
}}
while (flag != 1);
return 0;
}
Output:
EXPERIMENT- 6
Aim: To write a Program to implement Sliding window protocol for Goback N.
Description:
The Go Back-N or Go Back Automatic Repeat Request is a way to implement sliding window
protocol. This protocol is used for flow control in networking and is a part of the data-link layer.
The sender’s window is of size N and the receiver’s window size is always one.
Program:
#include<stdio.h>
int main()
{
int windowsize,sent=0,ack,i;
printf("enter window size\n");
scanf("%d",&windowsize);
while(1)
{
for( i = 0; i < windowsize; i++)
{
printf("Frame %d has been transmitted.\n",sent);
sent++;
if(sent == windowsize)
break;
}
printf("\nPlease enter the last Acknowledgement received.\n");
scanf("%d",&ack);
if(ack == windowsize)
break;
else
sent = ack;
}
return 0;
}
Output:
EXPERIMENT- 7
Aim: To write a Program to implement Sliding window protocol for Selective repeat.
Description:
The selective repeat automatic repeat request (ARQ) protocol uses the sliding window protocol
to deliver data frames reliably. The sliding window protocol allows the sender and receiver to
change their window sizes during communication, as long as the sum of the two remains within
a limit.
Program:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int f,n;
scanf("%d",&n);
f=pow(2,n-1);
for(int j=0;j<f;j++){
for(int i=0;i<f;i++){
printf("\n");
return 0;
Output:
(acknowledgement 1lost)
(acknowledgement 6lost)
(acknowledgement 7lost)
Want to continue
EXPERIMENT-8
It is a data-link layer protocol which is used for transmitting the data over the noiseless
channels. It provides unidirectional data transmission which means that either sending or
receiving of data will take place at a time.
Program:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
int i, j, noframes, x, x2;
noframes = 10;
i = 1;
j = 1;
printf("Number of frames is %d\n", noframes);
while (noframes > 0) {
sleep(x2); }
printf("\nSending frame %d\n", i);
x = rand() % 10;
printf("\nACK for frame %d\n", j);
noframes = noframes - 1;
i++;
j++;
}
printf("\nEnd of stop and wait control\n");
}
return 0;
}
Output:
EXPERIMENT-9
Aim: To write a program for congestion control using leaky bucket algorithm.
Description:
The leaky bucket algorithm can be implemented using a FIFO (First In First Out) queue.
Packets that arrive first in the bucket should be transmitted first. A queue acts as a bucket or a
buffer to hold the packets. This is implemented in the host operating system. Packets from the
host are pushed into the queue as they arrive.
Program:
#include<stdio.h>
#include<stdlib.h>
struct packet
{
scanf("%d",&n);
printf("enter packets in the order of there arrival time\n");
for(i=0;i<n;i++){
printf("enter time and size:");
scanf("%d%d",&p[i].time,&p[i].size);}
bfilled=0;
while(i<=m||bfilled!=0){
printf("\n\n at time %d",i);
if(p[k].time>=1){
if(bsize>=bfilled+p[k].size){}
else{
bfilled=bfilled+p[k].size;
printf("\n %d byte packet is inserted",p[k].size);
k=k+1;
printf("\n %d byte packet is discarded",p[k].size);
k=k+1;}}
if(bfilled==0){
bfilled=0;
printf("\n packets in the bucket %d byte",bfilled);
i++;
}
return 0;
}
Output:
EXPERIMENT- 10
Aim: To write a Program to implement Dijkstra‘s algorithm to compute the Shortest path
through a graph.
Description:
Dijkstra’s algorithm is very similar to Prim’s algorithm for minimum spanning tree. Like Prim’s
MST, we generate an SPT (shortest path tree) with a given source as the root. We maintain two
sets, one set contains vertices included in the shortest path tree, other set includes vertices not
yet included in the shortest path tree. At every step of the algorithm, we find a vertex that is in
the other set (set of not yet included) and has a minimum distance from the source.
Program:
#include <stdio.h>
#include <limits.h>
min = dist[v];
minIndex = v;
}}
return minIndex;}
}}
int dist[MAX_VERTICES];
int sptSet[MAX_VERTICES];
dist[i] = INT_MAX;
sptSet[i] = 0;
dist[src] = 0;
sptSet[u] = 1;
if (!sptSet[v] && graph[u][v] && dist[u] != INT_MAX && dist[u] + graph[u][v] < dist[v]) {
} }}
printSolution(dist, vertices);
int main() {
int vertices;
scanf("%d", &vertices);
return 1;}
int graph[MAX_VERTICES][MAX_VERTICES];
printf("Input the adjacency matrix for the graph (use INT_MAX for infinity):\n");
scanf("%d", &graph[i][j]); }
int source;
scanf("%d", &source);
return 1;
return 0;
Output:
Input the adjacency matrix for the graph (use INT_MAX for infinity):
3003
2345
1234
5678
0 2
1 0
2 4
3 5
EXPERIMENT: 11
Aim: To write a Program to implement Distance vector routing algorithm by obtaining
routing table at each node (Take an example subnet graph with weights indicating delay
between nodes).
Description:
The Distance vector algorithm is iterative, asynchronous and distributed.
The Distance vector algorithm is a dynamic algorithm.
It is mainly used in ARPANET, and RIP.
Each router maintains a distance table known as Vector.
Let dx(y) be the cost of the least-cost path from node x to node y. The least costs are related by
Bellman-Ford equation,
Program:
#include<stdio.h>
#include<conio.h>
struct node {
int dist[20]; int from[20];
}rt[10];
void main(){
int dmat[20][20];
int i,j,k,n,count=0;
printf("enter the no of nodes:");
scanf("%d",&n);
printf("enter the cost matrix,if no direct connection enter 99 :");
for(i=0;i<n;i++)
for(j=0;j<n;j++){
scanf("%d",&dmat[i][j]);
dmat[i][i]=0;
rt[i].dist[j]=dmat[i][j];
rt[i].from[j]=j; }do{
count=0; for(i=0;i<n;i++) for(j=0;j<n;j++)
for(k=0;k<n;k++)
if(rt[i].dist[j]>rt[i].dist[k]+rt[k].dist[j]) {
rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j];
rt[i].from[j]=k;
count++;}
}while(count!=0);
for(i=0;i<n;i++){
printf("\n\nstate value for router %d is \n",i+1);
for(j=0;j<n;j++){
printf("\t\n node %d via %d distance%d",j+1,rt[i].from[j]+1,rt[i].dist[j]); }}
printf("\n\n");
getch();
}
Output:
EXPERIMENT- 12
Aim: To write a Program to implement Broadcast tree by taking subnet of hosts.
Description:
In computer network, there are various ways in which we can transmit data from one node to
another node, one node to multiple node, and many node to many nodes. For each type of
transmission, there’s a term associated with it.
For node to node: ‘Unicast’ also known as POINT-TO-POINT communication. Example: cell
phone conversation.
When multiple POINT-TO-POINT communications are made its called – ‘Multicast‘. The
message is received by only those hosts who choose to be a part of a multicast group. Example:
Video
Program:
#include <stdio.h>
#define MAX_NODES 15
int minnode();
int main() {
scanf("%d", &n);
scanf("%d", &cost[i][j]);
} }
scanf("%d", &min_i);
mincost = cost[min_i][i];
min_j = i;
}}
t[1][1] = min_i;
t[1][2] = min_j;
nearnodes[i] = min_j;
else
nearnodes[i] = min_i;}
nearnodes[min_i] = nearnodes[min_j] = 0;
j = minnode();
t[i][2] = j;
t[i][1] = nearnodes[j];
mincost += cost[j][nearnodes[j]];
nearnodes[j] = 0;
nearnodes[k] = j;
}}
return 0;}
int minnode() {
min = cost[m][nearnodes[m]];
temp = m;
}}
return temp;
Output:
1 sends message to 2
1 sends message to 3