Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 25

What Is a Network Device?

Network device is the physical device that is used to connect computer hardware such as workstation,
printers, faxes, scanners and other electronic devices to a computer network.

It is also referred to as an intermediary device that helps to transfer information from source to
destination in a faster, secure and reliable way on the same network or different networks.

Types of Network Devices :-

1. Network Interface Card (NIC)


NIC stands on the top of the list of network devices. Networking cannot be done without this device.
It is also known as a network adapter card, Ethernet card, or LAN card. A NIC allows a networking
device to communicate with other networking devices.

Types of NICs
There are two types of NICs: media-specific and network design specific.

 Media Specific: - A media-specific NIC supports a particular type of media. For example, to
connect a coaxial cable, you need a NIC that has the BNC port whereas to connect an Ethernet
cable, you need a NIC that has the RJ-45 port.

 Network Design Specific: - A network design-specific NIC supports a specific network


topology. For example, FDDI, Token Ring, and Ethernet have their distinctive type of NIC cards.
They cannot use other types of NIC cards.

2. Hub
A hub is a centralized device that connects multiple devices in a single LAN network. When a hub
receivea data signal from a connected device on one of its ports, except for that port, it forwards

1
those signals from the remaining ports to all other connected devices. Typically, a hub has one or
more uplink ports that are used to connect it to another hub.

Types of Hub :-

 Passive Hub: -

A passive hub forwards data signals as it receives them. It does not change data signals in any
manner.

 Active Hub: -

An active hub also forwards data signals. But, before forwarding them, it amplifies them. Due to this
added feature, an active Hub is also called a repeater.

3. Bridge
A bridge is used to divide a large network into smaller segments. The basic functions of a bridge are
the following: -

 Breaking a large network into smaller segments.


 Connecting different media types such as UTP and fiber optic.
 Connecting different network architectures such as Ethernet and the Token ring.

2
4. Switch
It is an intelligent network device that can be conceived as a multiport network bridge.Switches can perform
some error checking before forwarding data to the destined port.

 It uses MAC addresses (addresses of medium access control sublayer) to send data packets to selected
destination ports.
 It uses packet switching technique to receive and forward data packets from the source to the
destination device.

5. Modem
A modem is a hardware networking device that is used to connect the computer to the internet where it
converts data signals into digital and analog forms. It works as a signal translator because it translates one
signal to another signal so the computers and telephone lines can interact with each other.

Types of Modems: -

 Optical Modem: -
OpticalModem uses optical cables instead of other metallic media. It converts the digital data signals into the
pulse of light transmitted on the optical fiber used by it.

 Digital Modem: -
A digital modem converts digital data into digital signals. It modulates the digital data on the digital carrier
signals for transmission on digital transmission lines.

 Acoustic Modem: -
The acoustic modem is a particular type of modem that can couple the telephone handset with a device used
by traveling salespeople to connect the hotel phones.

 Smart Modem: -
The smart modem allows auto-dial/redial and auto-answer capabilities.

 Short Haul Modem: -


The short-haul modem is those who are present in your PC at home. They can transmit data over 20 miles or
less.

3
6. Gateway
Gateway is used to forward packets that originate from a local host or a local network and are intended for
remote networks.The gateway device knows the path to the remote destination address. If necessary, it also
encapsulates the packet so that it can travel through other networks to reach its destination address.

7. Router
A router connects different network segments. It switches data packets between networks that are either
located in different logical segments or constructed with different network-layer protocols.

To forward data packets to their destination, the router keeps a record of the connected network. These
records are maintained in a database table known as the routing table. Routing tables can be created statically
or dynamically.

4
8. Access Point

An access point is a hub which allows multiple devices to connect with each other. The network may be
intranet or internet. An access point can be used as extender to increase the network connectivity beyond the
wired connection.

9. Repeater

A repeater is a dynamic network device used to reproduce the signals when they transmit over a greater
distance so that the signal’s strength remains equal. It can be used to create an Ethernet network. A repeater
that occurs as the first layer of the OSI layer is the physical layer.

3. Click Network and Internet


Connections.
4. Click Network Connections.
5. Right-click Local Area Connection
and then click Properties.
5
6. Click the General tab, click
Internet Protocol (TCP/IP) in the
connection uses the
following items list, and then click
Properties.
7. In the Internet Protocol (TCP/IP)
Properties dialog box, click Obtain
an IP address
automatically (if it is not already
selected), and then click OK.
Note: You can also assign a unique
static IP address in the range of
192.168.0.2 to

6
192.168.0.254. For example, you can
assign the following static IP
address, subnet mask, and
default gateway:
8. IP Address 192.168.31.202
9. Subnet mask 255.255.255.0
10. Default gateway 192.168.31.1

11. In the Local Area Connection


Properties dialog box, click OK.
12. Quit Control Panel.

7
Data Link Framing Method – Character Count

Character Count

This method is rarely used and is generally required to count total number of characters that are
present in frame. This is be done by using field in header. Character count method ensures data link
layer at the receiver or destination about total number of characters that follow, and about where the
frame ends.

Implementation :

#include<stdio.h>
#include<string.h>
void main()
{
int x[20],y[30],i,j,k,count,n;
printf("Enter the frame length: ");
scanf("%d",&n);
printf("Enter the input frame (0's & 1's only): ");
for(i=0;i<n;i++)
scanf("%d",&x[i]);
i=0; count=1; j=0;
while(i<n)
{
if(x[i]==1)
{
y[j]=x[i];
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;
8
}}
else
{
y[j]=x[i];
}
i++;
j++;
}
printf("After stuffing the frame is: ");
for(i=0;i<j;i++)
printf("%d",x[i]);
}

OUTPUT:

9
Data Link Framing Method – Bit Stuffing and De- Stuffing

Bit Stuffing

In a data link frame, the delimiting flag sequence generally contains six or more consecutive 1’s. In
order to differentiate the message from the flag in case of the same sequence, a single bit is stuffed
in the message. Whenever a 0 bit is followed by five consecutive 1 bits in the message, an extra 0 bit
is stuffed at the end of the five 1’s. When the receiver receives the message, it removes the stuffed 0’s
after each sequence of five 1’s.

Implementation :

#include<stdio.h>
#include<string.h>
void main()
{
int i=0,count=0;
char databits[80];
printf("Enter Data Bits: ");
scanf("%s",databits);
printf("\nData Bits After Bit stuffing: ");
for(i=0; i<strlen(databits); i++)
{
if(databits[i]=='1')
count++;
else
count=0;
printf("%c",databits[i]);
if(count==5)
{
printf("0");
count=0;
}
}
}

OUTPUT:

10
Bit De-Stuffing

Bit Destuffing or Bit Unstuffing is a process of undoing the changes in the array made during the bit
stuffing process i.e, removing the extra 0 bit after encountering 5 consecutive 1’s.

Implementation:

#include <stdio.h>
#include <string.h>
void bitDestuffing(int N, int arr[])
{
int brr[30];
int i, j, k;
i = 0;
j = 0;
int count = 1;
while (i < N)
{
if (arr[i] == 1)
{
brr[j] = arr[i];
for (k = i + 1;
arr[k] == 1 && k < N && count < 5;
k++)
{
j++;
brr[j] = arr[k];
count++;
if (count == 5)
11
{
k++;
}
i = k;
}
}
else
{
brr[j] = arr[i];
}
i++;
j++;
}
for (i = 0; i < j; i++)
printf("%d", brr[i]);
}
int main()
{
int N = 7;
int arr[] = {1, 1, 1, 1, 1, 0, 1};
bitDestuffing(N, arr);
return 0;
}

OUTPUT :

12
Error Detection method – Even & Odd parity

The parity check is done by adding an extra bit, called parity bit, to the data to make the number of
1s either even or odd depending upon the type of parity. The parity check is suitable for single bit
error detection only.
The two types of parity checking are

 Even Parity  − Here the total number of bits in the message is made even.
 Odd Parity − Here the total number of bits in the message is made odd.

Implementation:

# include <stdio.h>
# define bool int
bool getParity(unsigned int n)
{
bool parity = 0;
while (n)
{
parity = !parity;
n = n & (n - 1);
}
return parity;
}
int main()
{
unsigned int n = 7;
printf("Parity of no %d = %s", n,(getParity(n)? "odd": "even"));
getchar();
return 0;
}

OUTPUT :

13
Error Detection method – CRC Polynomial

CRC or Cyclic Redundancy Check is a method of detecting accidental changes/errors in the


communication channel.

CRC uses Generator Polynomial which is available on both sender and receiver sides. An example
generator polynomial is of the form of x^3 + 1. This generator polynomial represents key 1001.
Another example is x^2 + x. that represents key 110.

Implementation:

#include <stdio.h>
#include <conio.h>
#include <string.h>
void main() {
int i,j,keylen,msglen;
char input[100], key[30],temp[30],quot[100],rem[30],key1[30];
printf("Enter Data: ");
gets(input);
printf("Enter Key: ");
gets(key);
keylen=strlen(key);
msglen=strlen(input);
strcpy(key1,key);
for (i=0;i<keylen-1;i++) {
input[msglen+i]='0';
}
for (i=0;i<keylen;i++)
temp[i]=input[i];
for (i=0;i<msglen;i++) {
quot[i]=temp[0];
if(quot[i]=='0')
for (j=0;j<keylen;j++)
key[j]='0'; else
for (j=0;j<keylen;j++)
key[j]=key1[j];
for (j=keylen-1;j>0;j--) {
14
if(temp[j]==key[j])
rem[j-1]='0'; else
rem[j-1]='1';
}
rem[keylen-1]=input[i+keylen];
strcpy(temp,rem);
}
strcpy(rem,temp);
printf("\nQuotient is ");
for (i=0;i<msglen;i++)
printf("%c",quot[i]);
printf("\nRemainder is ");
for (i=0;i<keylen-1;i++)
printf("%c",rem[i]);
printf("\nFinal data is: ");
for (i=0;i<msglen;i++)
printf("%c",input[i]);
for (i=0;i<keylen-1;i++)
printf("%c",rem[i]);
getch();
}

OUTPUT :

15
Data Link protocols - Unrestricted simplex protocol

Data transmitting is carried out in one direction only. The transmission (Tx) and receiving (Rx) are always ready
and the processing time can be ignored. In this protocol, infinite buffer space is available, and no errors are
occurring that is no damage frames and no lost frames.

In order to appreciate the step by step development of efficient and complex protocols such as SDLC,
HDLC etc., we will begin with a simple but unrealistic protocol.
In this protocol:
 Data are transmitted in one direction only the transmitting (Tx) and receiving (Rx) hosts are
always ready.
 Processing time can be ignored.
 Infinite buffer space is available.
 No errors occur; i.e. no damaged frames and no lost frames (perfect channel).

Implementation :

HEADER.H

#include<stdio.h>
#include<fcntl.h>
#include<string.h>
typedef struct
{
int seqno;
int ackno;
char data[50];
}frame;
void from_network_layer(char buffer[])
{
printf("Enter Data : ");
scanf("%s",buffer);
}
void to_physical_layer(int pid1,frame *f)
{
write(pid1,f,sizeof(frame));
}
void from_physical_layer(int pid1,frame *f)
{
read(pid1,f,sizeof(frame));
}
void to_network_layer(char buffer[])
{
printf("\n%s",buffer);

16
}

SENDER SIDE

#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include "header.h"
void main()
{
int pid1, i, no;
char buffersize[50];
frame f;
System(">pipe1");
pid1 = open("pipe1", O_WRONLY);
printf("Enter NUMBER OF DATA :");
scanf("%d", &no);
write(pid1, &no, sizeof(no));
for (i = 0; i < no; i++)
{
from_network_layer(buffer);
strcpy(f.data, buffer);
to_physical_layer(pid1, &f);
}
close(pid1);
}

RECEIVER SIDE

#include<stdio.h>
#include<fcntl.h>
#include<string.h>
#include "header.h"
void main()
{
int pid1,no,iI;
char buffer[50];
frame f;
pid1=open("pipe1",O_RDONLY);
read(pid1,&no,sizeof(no));

17
printf("DATA RECEIVED : %d",no);
printf("\nDATA");
for(i=0;i<no;i++)
{
from_physical_layer(pid1,&f);
strcpy(buffer,f.data);
to_network_layer(buffer);
}
close(pid1);
unlink("pipe1");
}

18
Data Link protocols – Stop and Wait protocol
Here stop and wait means, whatever the data that sender wants to send, he sends the data to the
receiver. After sending the data, he stops and waits until he receives the acknowledgment from the
receiver. The stop and wait protocol is a flow control protocol where flow control is one of the
services of the data link layer.

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. It provides flow-control mechanism but does not provide any error control
mechanism.

Implementation:

#include <conio.h>
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#define TIMEOUT 5
#define MAX_SEQ 1
#define TOT_PACKETS 8
#define inc(k) if (k < MAX_SEQ) k++;else k = 0;
typedef struct
{
int data;
} packet;
typedef struct
{
int kind;
int seq;
int ack;
packet info;
int err;
} frame;
frame DATA;
typedef enum
{
frame_arrival,
err,
timeout,

19
no_event
} event_type;

void from_network_layer(packet *);


void to_network_layer(packet *);
void to_physical_layer(frame *);
void from_physical_layer(frame *);
void wait_for_event_sender(event_type *);
void wait_for_event_reciever(event_type *);
void reciever();
void sender();
int i = 1;
char turn;
int DISCONNECT = 0;
void main()
{
clrscr();
randomize();
while (!DISCONNECT)
{
sender();
delay(400);
reciever();
}
getch();
}
void sender()
{
static int frame_to_send = 0;
static frame s;
packet buffer;
event_type event;
static int flag = 0;

if (flag == 0)
{
from_network_layer(&buffer);
s.info = buffer;

20
s.seq = frame_to_send;
printf("SENDER : Info = %d Seq No = %d ", s.info, s.seq);
turn = 'r';
to_physical_layer(&s);
flag = 1;
}
wait_for_event_sender(&event);
if (turn == 's')
{
if (event == frame_arrival)
{
from_network_layer(&buffer);
inc(frame_to_send);
s.info = buffer;
s.seq = frame_to_send;
printf("SENDER : Info = %d Seq No = %d ", s.info, s.seq);
turn = 'r';
to_physical_layer(&s);
}
if (event == timeout)
{
printf("SENDER : Resending Frame :");
turn = 'r';
to_physical_layer(&s);
}
}
}
void reciever()
{
static int frame_expected = 0;
frame r, s;
event_type event;

wait_for_event_reciever(&event);
if (turn == 'r')
{
if (event == frame_arrival)
{
from_physical_layer(&r);
21
if (r.seq == frame_expected)
{
to_network_layer(&r.info);
inc(frame_expected);
}
else
printf("RECIEVER : Acknowledgement Resent\n");

turn = 's';
to_physical_layer(&s);
}
if (event == err)
{
printf("RECIEVER : Garbled Frame\n");
turn = 's';
}
}
}
void from_network_layer(packet *buffer)
{
(*buffer).data = i;
i++;
}
void to_physical_layer(frame *s)
{
s->err = random(4);
DATA = *s;
}
void to_network_layer(packet *buffer)
{
printf("RECIEVER :Packet %d recieved , Ack Sent\n", (*buffer).data);
if (i > TOT_PACKETS)
{
DISCONNECT = 1;
printf("\nDISCONNECTED");
}
}
void from_physical_layer(frame *buffer)
{
22
*buffer = DATA;
}
void wait_for_event_sender(event_type *e)
{
static int timer = 0;

if (turn == 's')
{
timer++;
if (timer == TIMEOUT)
{
*e = timeout;
printf("SENDER : Ack not recieved=> TIMEOUT\n");
timer = 0;
return;
}
if (DATA.err == 0)
*e = err;
else
{
timer = 0;
*e = frame_arrival;
}
}
}
void wait_for_event_reciever(event_type *e)
{
if (turn == 'r')
{
if (DATA.err == 0)
*e = err;
else
*e = frame_arrival;
}
}

23
Routing Algorithms - Dijkstra’s Algorithm
Dijkstra's algorithm allows us to find the shortest path between any two vertices of a graph.

It differs from the minimum spanning tree because the shortest distance between two vertices might
not include all the vertices of the graph.

Implementation:

#include <limits.h>
#include <stdio.h>
#define V 9
int minDistance(int dist[], bool sptSet[])
{
int min = INT_MAX, min_index;
for (int v = 0; v < V; v++)
if (sptSet[v] == false && dist[v] <= min)
min = dist[v], min_index = v;
return min_index;
}
int printSolution(int dist[], int n)
{
printf("Vertex Distance from Source\n");
for (int i = 0; i < V; i++)
printf("%d \t\t %d\n", i, dist[i]);
}
void dijkstra(int graph[V][V], int src)
{
int dist[V];
bool sptSet[V];
for (int i = 0; i < V; i++)
dist[i] = INT_MAX, sptSet[i] = false;
dist[src] = 0;
for (int count = 0; count < V - 1; count++)
{
int u = minDistance(dist, sptSet);
sptSet[u] = true;
for (int v = 0; v < V; v++)
if (!sptSet[v] && graph[u][v] && dist[u] != INT_MAX && dist[u] + graph[u][v] < dist[v])

24
dist[v] = dist[u] + graph[u][v];
}

printSolution(dist, V);
}
int main()
{
int graph[V][V] = {{0, 4, 0, 0, 0, 0, 0, 8, 0},
{4, 0, 8, 0, 0, 0, 0, 11, 0},
{0, 8, 0, 7, 0, 4, 0, 0, 2},
{0, 0, 7, 0, 9, 14, 0, 0, 0},
{0, 0, 0, 9, 0, 10, 0, 0, 0},
{0, 0, 4, 14, 10, 0, 2, 0, 0},
{0, 0, 0, 0, 0, 2, 0, 1, 6},
{8, 11, 0, 0, 0, 0, 1, 0, 7},
{0, 0, 2, 0, 0, 0, 6, 7, 0}};
dijkstra(graph, 0);
return 0;
}

OUTPUT:

25

You might also like