CN Lab Manual
CN Lab Manual
CERTIFICATE
has satisfactorily completed the Practical / Tutorial work for the subject
Place:
Date:
Sr. CO CO CO CO CO
Objective(s) of Experiment
No. 1 2 3 4 5
Study of different types of Network cables and
1. √ √
practically implement the cross-wired
cable and straight through cable using clamping tool.
Study of networking devices in detail.
2. √ √
To Connect the computers in Local Area Network
3. √
II. To train graduates with good scientific and engineering breadth so as to comprehend,
analyze, design, and create novel products and solutions for the real life problems.
III. To inculcate in graduates professional and ethical attitude, effective communication skills,
teamwork skills, multidisciplinary approach, and an ability to relate engineering issues to
broader social context.
PSO-II: Demonstrate soft skills, aptitude and technical skills & knowledge to work in the
industry and Research and Development organization.
NBA has defined the following twelve POs for an engineering graduate:
I. Problem Analysis: Identify, formulate, review research literature, and analyse complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences and engineering sciences.
Index
(Progressive Assessment Sheet)
Total
Computer Networks (3161007)
Experiment No: 1
Study of different types of Network cables and practically implement the cross-wired cableand
straight through cable using clamping tool.
Date:
Competency and Practical Skills:
➢ Understanding the types of network cables and practically implement this and test
it for network purpose in LAN and WAN.
Relevant CO:
CO-1: Enumerate the layers of the OSI model and TCP/IP functions of each layer
Objectives:
To categorize standard cable types and their properties
Theory:
1. Start by stripping off about 2 inches of the plastic jacket off the end of the cable. Be very careful
at this point, as to not nick or cut into the wires, which are inside. Doing so could alter the
characteristics of your cable, or even worse render is useless. Check the wires, one more time for
nicks or cuts. If there are any, just whack the whole end off, and start over.
2. Spread the wires apart, but be sure to hold onto the base of the jacket with your other hand. You
do not want the wires to become untwisted down inside the jacket. Category 5 cable must only have
1/2 of an inch of 'untwisted' wire at the end; otherwise, it will be 'out of spec'. At this point, you
obviously have ALOT more than 1/2 of an inch of un-twisted wire.
3. You have 2 end jacks, which must be installed on your cable. If you are using a pre-made cable,
with one of the ends whacked off, you only have one end to install - the crossed over end. Below are
two diagrams, which show how you need to arrange the cables for each type of cable end.
The codes are commonly depicted with RJ-45 jacks as follows (the view is from the front of the jacks)
Computer Networks (3161007)
Crossover cables are very similar to straight-through cables, except that they have pairs of wiresthat
crisscross. This allows for two devices to communicate at the same time. Unlike straight through
cables, we use crossover cables to connect like devices.
Conclusion: -
Computer Networks (3161007)
Quiz:
1. What type of connector do twisted pair cables on computer network use?
A. RJ11
B. RJ30
C. RJ45
D. None of the above
Ans-
Ans-
Ans-
Computer Networks (3161007)
Suggested Reference:
1. Computer Networks by Andrew S. Tanenbaum, 4th Edition, Prentice Hall Publication
2. Data Communication and Networking by Behrouz Forouzan, 4th Edition, Tata McGraw-Hill Publication
Rubrics 1 2 3 4 5 Total
Marks
Computer Networks (3161007)
Experiment No: 2
Date:
Competency and Practical Skills:
➢ To understand function of networking device.
➢ Able to do network configuration using network devices.
Relevant CO:
CO-1: Enumerate the layers of the OSI model and TCP/IP functions of each layer
Objectives:
The purpose of networking devices is to enable smooth communication between different hardware
connected to a network. Addition of a network device helps in hassle free sharing of network resources
between different systems.
Theory:
Repeater: Functioning at Physical layer. A repeater is electronics device that regenerate the signalover
the same network before the signal becomes too weak or corrupted so as to extend the length towhich
the signal can be transmitted over the same network. It does not amplify the signal. When thesignal
becomes weak, they copy the signal bit by bit and regenerate it at the original strength. It is a 2-port
device.
Gateway: In communication network, a network node equipped for interfacing with another
network that uses different protocol. A gateway operates at any network layer. It is a passage to
connect two networks together that may work upon different networking models. It works as the
messenger agents that take data from one system, interpret it, and transfer it to another system.
Gateways are also called protocol converters.
Bridge: A bridge operates at data link layer. A bridge is a repeater, with add on functionality of filtering
content by reading the MAC addresses of source and destination. It is also used for interconnecting two
Computer Networks (3161007)
LANs working on the same protocol. It has a single input and single output port, thus making it a 2-
port device.
Switch: A switch is a multi-port bridge with a buffer and a design that can boost its efficiency and
performance. Switch is data link layer device. Switch processes and routes data at the data link layer
(layer 2) of the OSI model. Switches that additionally processes data at network layer (layer 3) are
often referred to as Layer 3 switches or multilayer switches. Switch can perform error checking before
forwarding data.
Hub: A hub is a device for connecting multiple twisted pair and fiber optic. Hubs work at physical
layer (layer 1) of OSI the model. The device is form of multiport repeater. Hubs cannot filter data,
so data packets are sent to all connected devices. Also, they do not have intelligence tofind out best
path for data packets which leads to inefficiencies and wastage. Repeater Hubs alsoparticipate in
collision detection, forwarding a jam signal to all ports if it detects a collision.
Router: A router is a device like a switch that routes data packets based on their IP addresses. Router
is mainly a Network Layer device. Routers normally connect LANs and WANs together andhave a
dynamically updating routing table based on which they make decisions on routing the data packets.
Router divide broadcast domains of hosts connected through it.
Conclusion :
Quiz:
1. When microwave signals follow the curvature of the earth, this phenomenon is known as
A. Troposcatter
B. Ducting
C. Ionospheric reflection
D. Faraday effect
Ans-
Computer Networks (3161007)
2. Using the point to point propagation prediction model the path loss slope will have a
standard deviation of less than only.
A. 1 dB
B. 2-3 dB
C. 6-8 dB
D. 10-12 dB
Ans-
Suggested Reference:
1. Computer Networks by Andrew S. Tanenbaum, 4th Edition, Prentice Hall Publication
2. Data Communication and Networking by Behrouz Forouzan, 4th Edition, Tata McGraw-Hill Publication
Rubrics 1 2 3 4 5 Total
Marks
Computer Networks (3161007)
Experiment No: 3
Date:
Competency and Practical Skills:
➢ Understanding the development of LAN.
Relevant CO:
CO-1: Enumerate the layers of the OSI model and TCP/IP functions of each layer
Objectives:
To design the Local Area Network using various network top olog y.
Equipment/Instruments: No software or hardware is needed.
Theory:
On the host computer, follow these steps to share the Internet connection:
To connect to the Internet by using the shared connection, you must confirm the LAN adapter IP
configuration, and then configure the client computer. To confirm the LAN adapter IP configuration,
follow these steps:
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.
Conclusion:
Quiz:
1. Which of the following services use TCP?
A. DHCP
B. SMTP
C. HTTP
D. TFTP
E. FTP
Ans-
Computer Networks (3161007)
Ans-
Suggested Reference:
1. Computer Networks by Andrew S. Tanenbaum, 4th Edition, Prentice Hall Publication
2. Data Communication and Networking by Behrouz Forouzan, 4th Edition, Tata McGraw-Hill Publication
Rubrics 1 2 3 4 5 Total
Marks
Computer Networks (3161007)
Experiment No: 4
Date:
Competency and Practical Skills:
➢ To develop skills of design, implement, manage and monitor the wide area and local area
networks of businesses and organizations
➢ To develop skills for designing using hardware, software, protocols, and topologies for a
network, as well as ensuring its security, reliability, scalability, and performance.
Relevant CO:
CO-1: Enumerate the layers of the OSI model and TCP/IP functions of each layer
Objectives: To understand various network topologies and able to design network in LAN and WAN
Theory:
To implement this practical following network topology is required to be configure during the
commands. After configuring the given network, a packet should be ping from any one machine
to another.
Conclusion:
Quiz:
(1) The data in the network layer is in the form of
a. IP Packets
b. Frames
c. Cables
d. None of the above
Ans.
(2) If there are n devices in a mesh topology network then the total number of duplex links are
a. n (n-1)/2
b. n+2
c. n-1
d. n(n+1)
Ans.
Computer Networks (3161007)
Suggested Reference:
1. Computer Networks by Andrew S. Tanenbaum, 4th Edition, Prentice Hall Publication
2. Data Communication and Networking by Behrouz Forouzan, 4th Edition, Tata McGraw-Hill Publication
Rubrics 1 2 3 4 5 Total
Marks
Computer Networks (3161007)
Experiment No: 5
Study of Basic network command and Network configuration commands
Date:
Competency and Practical Skills:
➢ Understanding the various command of network design models
Relevant CO:
CO-3 Analyze MAC Layer Protocols
Objectives:
To design the Local Area Network using network con f igu ratio n command
Equipment/Instruments: Packet tracer software
Theory:
To understand basic commands e.g. ping and tracert etc. All commands related to Network
configuration which includes how to switch to privilege mode and normal mode and how to
configure router interface and how to save this configuration to flash memory or permanent
memory.
Ping: It sends an ICMP ECHO_REQUEST packet to the specified host. It the host responds, you getand
ICMP packet back. You can ping an IP address to if a machine is alive. If there is no response, you know
something is wrong.
Computer Networks (3161007)
Traceroute :
Traceroute is a command which can show you the path a packet of information taken from your
computer to one you specify. It will list all the routers it passes through until it reaches its
destination. Or fails to and is discarded. It will tell you how long each “hop” from router to router
takes.
Computer Networks (3161007)
This command queries DNS servers to find out the IP address or addresses associated with the domain
name cisco.com.
It gives you detailed information about the networks that are know to the router, either directly
connected to the router, statically configured using static routing or automatically added to the routing
table using dynamic routing protocols.
Conclusion:
Quiz:
1. Which of the following has stored the startup configuration of a Router
A. ROM
B. Flash
C. RAM
D. NVRAM
Ans-
3. Which of the following feature can be used to carry all the VLAN traffic on one link from a
Switch to a Router
A. PAGP
B. LACP
C. Trunking
D. ACL
Ans-
Suggested Reference:
1. Computer Networks by Andrew S. Tanenbaum, 4th Edition, Prentice Hall Publication
2. Data Communication and Networking by Behrouz Forouzan, 4th Edition, Tata McGraw-Hill Publication
Rubrics 1 2 3 4 5 Total
Marks
Computer Networks (3161007)
Experiment No: 6
Write a C program for IPV4, Implementation of decimal to binary,
Implementation ofbinary to decimal and study of network IP
• Classification of IP address
• Subnetting and Supernetting
Date:
Competency and Practical Skills:
➢ To understand IP address which is used to connect network devices that connect
to the internet.
➢ To understand how to access data and information available on the web when the
client device sends a request to the server and is passed through routers, hubs and
network nodes.
Relevant CO:
1) CO-3: Implement routing and congestion control algorithms
Objectives:
To understand IP address, subnetting and super netting and Classification of IP address.
Equipment/Instruments: Turbo C, C++
Theory:
Classification of IP address: As shown in figure we teach how the IP addresses are classified and
when they are used.
Subnetting and Super netting: A subnetting is a process of dividing a network into subnetworks. The
number of bits of network addresses is increased. A super netting is a process of combining small
networks into a larger network. The number of bits of host addresses is increased.
void main ()
{
int IP1,IP2,IP3,IP4;
printf("enter IP address:");
scanf("%d\n",&IP1);
scanf("%d\n",&IP2) ;
scanf("%d\n",&IP3) ;
scanf("%d",&IP4);
printf("%d . %d . %d . %d\n",IP1,IP2,IP3,IP4);
if(IP1>255 || IP2>255 || IP3>255 || IP4>255)
{
printf("INVALID ");
}
else if (IP1>=0 && IP1<128)
{
printf ("IP ADDRESS BELONGS TO CLASS A");
}
else if (IP1>=128 && IP1<192)
{
printf ("IP ADDRESS BELONGS TO CLASS B");
}
else if(IP1>=192 && IP1<224)
{
printf("IP ADDRESS BELONGS TO CLASS C");
}
else if(IP1>=224 && IP1<240)
{
printf("IP ADDRESS BELONGS TO CLASS D");
}
else if(IP1>=240 && IP1<=255)
{
printf("IP ADDRESS BELONGS TO CLASS E");
}
else
{printf("INVALID IP ADDRESS");
}
getch();
}
Computer Networks (3161007) Enrollment No.
Output:
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
void main()
{
clrscr();
int a, b, c, d, e, x [50], stop, count, code;
printf("\n enter the desimal bit of max. upto 80000 digit\n");
Scanf ("\n %d \n",&c) ;
Printf ("%d", c) ;
code=c; count=0;
printf("\n digit reminder /n");
for(a=1;a<50;a++)
{
Computer Networks (3161007) Enrollment No.
count++;
d=c;
if(d==1)
{
goto stop;
}
e=d/2;
b=d%2;
x[a]=b;
c=e;
}
stop:
printf("\n %d is converted in to binary code \n",code);
printf("1");
for(a=count-1;a>0;a--)
{
printf("%d",x[a]);
}
getch();
}
Output:
Computer Networks (3161007) Enrollment No.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr ();
int num, bnum,dec=0,base=0,rem; printf
(“Enter the binary number => ”);
scanf(“%d”,&num);
bnum=num;
while(num>0)
{
rem=num%10;
dec=dec+rem*base;
num=num/10;
base=base*2;
}
printf (“Decimal number => %d”,dec);
getch();
}
Output:
Computer Networks (3161007) Enrollment No.
Conclusion:
Quiz:
1. implies that all subnets obtained from the same subnet mask
A. Static subnetting
B. Dynamic subnetting
C. Variable length subnetting
D. Dynamic length subnetting
Ans-
Suggested Reference:
1. Computer Networks by Andrew S. Tanenbaum, 4th Edition, Prentice Hall Publication
2. Data Communication and Networking by Behrouz Forouzan, 4th Edition, Tata McGraw-Hill Publication
Rubrics 1 2 3 4 5 Total
Marks
Computer Networks (3161007) Enrollment No.
Experiment No: 7
Date:
Competency and Practical Skills:
➢ Understand framing methods of data link layer.
Relevant CO:
CO-2: Analyze MAC Layer Protocols
Objectives:
To implement bit stuffing and D e Stuffing framing methods in turbo C / C++
Equipment/Instruments: Turbo C / C++
Theory:
In a data link frame, the delimiting flag sequence generally contains six or more consecutive 1s. 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 1bits in the message, an extra 0 bit
is stuffed at the end of the five 1s.
Computer Networks (3161007) Enrollment No.
When the receiver receives the message, it removes the stuffed 0s after each sequence of five 1s. The
un-stuffed message is then sent to the upper layers.
Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main ()
{
int i, j=0;
char a [20], b [20];
char flag[8]="01111110",esc='0';
clrscr();
printf ("\n Enter any bit stream:");
fflush (stdin);
gets(a);
for (i=0; i<8; i++)
{
b[j]=flag[i];
j++;
}
for (i=0; a[i]! ='\0’; i++)
{
if(a[i-1] =='1'&&a[i-2] =='1'&&a[i-3] =='1'&&a[i-4] =='1'&&a[i-5] =='1')
{
b[j]=esc;
j++;
b[j]=a[i];
j++;
a[i-1] =0;
}
else
{
b[j]=a[i];
j++;
}
}
for (i=0; i<8; i++)
{
b[j]=flag[i];
j++;
}
Computer Networks (3161007) Enrollment No.
b[j]='\0';
printf ("\n Stuffed bit stream is:");
Date:
Page No.
puts(b);
printf ("\n Destuffed bit stream is:");
for (j=0, i=0;i<8;j++,i++)
{
if (b[j]==flag[i])
{
for (j=0; b[j]! ='\0’; j++)
{
if(b[j]=='0'&&b[j+1]=='1'&&b[j+2]=='1'&&b[j+3]=='1'&&b[j+4]=='1'&&b[j+5]=='1'&&b[j+6]
=='1'&&b[j+7] =='0')
}
goto end;
{
else if(b[j]=='0'&&b[j-1]=='1'&&b[j-2]=='1'&&b[j-3]=='1'&&b[j-4]=='1'&&b[j-5]=='1')
}
else
{
printf ("\%c”, b[j]);
}
end:
getch ();
}
Output:
Conclusion:
Computer Networks (3161007) Enrollment No.
Quiz:
1. A bit-stuffing based framing protocol uses an 8-bit delimiter pattern of 01111110. If the
output bit-string after stuffing is 01111100101, then the input bit-string is
A. 0111110100
B. 0111110101
C. 0111111101
D. 0111111111
Ans-
2. The range of the possible sequence numbers of Go-Back-N Protocol which is the
concern of the receiver is called the
A. Sender sliding window
B. Pipelining at the sender
C. Pipelining at the receiver
D. Receiver sliding window
Ans-
3. The term that is used to define the end of the frame and the beginning of the next frame is called
A. byte stuffing
B. byte unstuffing
C. fixed size framing
D. variable size framing
Ans-
Suggested Reference:
1. Computer Networks by Andrew S. Tanenbaum, 4th Edition, Prentice Hall Publication
2. Data Communication and Networking by Behrouz Forouzan, 4th Edition, Tata McGraw-Hill Publication
Rubrics 1 2 3 4 5 Total
Marks
Computer Networks (3161007) Enrollment No.
Experiment No: 8
Date:
Competency and Practical Skills:
➢ Understand error detection method
Relevant CO:
CO-2: Analyze MAC Layer Protocols
Objectives:
To understand the parity checker method in turbo c/c++ .
Equipment/Instruments: Turbo C/C++
Theory:
A parity bit is an extra bit included in binary message to make total number of 1’s either odd or even.
Parity word denotes number of 1’s in a binary string. There are two parity system – even and odd
parity checks
1. Even Parity Check: Total number of 1’s in the given data bit should be even. So, if the total
number of 1’s in the data bit is odd then a single 1 will be appended to make total number of
1’s even else 0 will be appended (if total number of 1’s is already even). Hence, if any error
occurs, the parity check circuit will detect it at the receiver’s end
2. Odd Parity Check: In odd parity system, if the total number of 1’s in the given binary string
(or data bits) are even then 1 is appended to make the total count of 1’s as odd else 0 is
appended. The receiver knows that whether sender is an odd parity generator or even parity
generator. Suppose if sender is an odd parity generator, then there must be an odd number of
1’s in received binary string. If an error occurs to a single bit that is either bit is changed to 1
to 0 or 0 to 1, received binary bit will have an even number of 1’s which will indicate an
error.
Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i=0,j=0;
char msg[]="110011100"; for(i=0;i<=strlen(msg);i++)
{ if(msg[i]==1
{
Computer Networks (3161007) Enrollment No.
j=j+1;
}
}
if (j%2==0)
printf ("Even Parity"); else
printf("Odd Parity")
}
Output:
Conclusion:
Quiz:
A. 1 bit error
B. 2-bit error
C. 8-bit error
D. Any bit error
Ans-
2. Which one of the following set of gates are best suited for parity checking and parity
Computer Networks (3161007) Enrollment No.
generation.
A. AND, OR, NOT gates
B. EX NOR or EX OR gates
C. NAND gates
D. NOR gates
Ans-
Suggested Reference:
1. Computer Networks by Andrew S. Tanenbaum, 4th Edition, Prentice Hall Publication
2. Data Communication and Networking by Behrouz Forouzan, 4th Edition, Tata McGraw-Hill Publication
Rubrics 1 2 3 4 5 Total
Marks
Computer Networks (3161007) Enrollment No.
Experiment No: 9
Write a program to implement CRC
Date:
Competency and Practical Skills:
➢ Understand and implement Cyclic Redundancy Check in Data link layer
Relevant CO:
CO-2: Analyze MAC Layer Protocols
Objectives:
Understand the error detection method such as CRC in computer networks
Equipment/Instruments: Turbo C/C++
Theory:
The cyclic redundancy check (CRC) is a technique for detecting errors in digital data. It is used in data
transmission. In the CRC method, a certain number of check bits, often called a checksum, are appended
to the message being transmitted. The receiver can determine whether or not the check bits agree with
the data, to ascertain with a certain degree of probability whether or not an error occurred in
transmission. If an error occurred, the receiver sends a "negative acknowledgement" (NAK) back to
the sender, requesting that the message be retransmitted.
Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main ()
{
char st1[10], st2[15], div [5], q[15],i_ans[5], i_op[5],cw[15];int
l,i,n,m;
printf ("\nEnter the string:");
scanf ("%s",st1);
strcpy(div,"10101");
strcpy(st2,st1);
strcat(st2,"000000");
printf("\nDivisor is : %s",div);
printf("\nDividendo is : %s\n",st2);
l=strlen(st2);
for(i=0;i<5;i++)
{i_op[i]=st2[i];}
l=l-5;
i_op[5]='\0';
for(n=0;n<l;n++)
{
if (i_op[0]=='0')
{
strcpy(i_ans, i_op);
q[n]='0';
}
Computer Networks (3161007) Enrollment No.
else
{
for(i=0;i<5;i++)
{
if (i_op[i]==div[i])
i_ans[i]='0'; else
i_ans[i]='1'; }
i_ans[5]='\0';
q[n]='1';
}
q[n+1]='\0';
for(i=0;i<4;i++)
{m=i+1;
i_op[i]=i_ans[m];}
i_op[4]=st2[n+5];
i_op[5]='\0';
} q[n+1]='\0';
strcpy(cw,st1);
strcat(cw,i_op);
printf("\ni_op=%s",i_op);
printf("\nq=%s\n",q);
printf("\ncodeword=%s",cw);
getch();
}
Output:
Conclusion:
Computer Networks (3161007) Enrollment No.
Quiz:
1. In CRC if the data unit is 100111001 and the divisor is 1011 then what is dividend at the receiver
?
A. 100111001101
B. 100111001011
C. 100111001
D. 100111001110
Ans-
2. Which of the following is/are the popular techniques for error detection?
A. Cyclic redundancy check
B. Checksum
C. Simple parity check
D. All of the options
Ans-
3. In data link control, which of the following is used for error correction?
A. Backward error correction
B. Simple parity check
C. Checksum
D. Cyclic Redundancy Checks (CRC)
Ans-
Suggested Reference:
1. Computer Networks by Andrew S. Tanenbaum, 4th Edition, Prentice Hall Publication
2. Data Communication and Networking by Behrouz Forouzan, 4th Edition, Tata McGraw-Hill Publication
Rubrics 1 2 3 4 5 Total
Marks
Computer Networks (3161007) Enrollment No.
Experiment No: 10
Write a program to implement Hamming code.
Date:
Objectives:
Hamming code is a block code that is capable of detecting up to two simultaneous bit errors and
correcting single-bit errors. It was developed by R.W. Hamming for error correction.
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 error.
The procedure used by the sender to encode the message encompasses the following steps −
Once the redundant bits are embedded within the message, this is sent to the user.
If the message contains m𝑚number of data bits, r𝑟number of redundant bits are added to it so that m𝑟
is able to indicate at least (m + r+ 1) different states. Here, (m + r) indicates location of an error in each
of (𝑚 + 𝑟) bit positions and one additional state indicates no error. Since, r𝑟 bits can indicate 2r𝑟 states,
2r𝑟 must be at least equal to (m + r + 1). Thus the following equation should hold 2r ≥ m+r+1
Computer Networks (3161007) Enrollment No.
The r redundant bits placed at bit positions of powers of 2, i.e. 1, 2, 4, 8, 16 etc. They are referred in
the rest of this text as r1 (at position 1), r2 (at position 2), r3 (at position 4), r4 (at position 8) and so on.
The redundant bits are parity bits. A parity bit is an extra bit that makes the number of 1s either even
or odd. The two types of parity 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.
Each redundant bit, ri, is calculated as the parity, generally even parity, based upon its bit position. It
covers all bit positions whose binary representation includes a 1 in the i th position except the position
of ri. Thus −
• r1 is the parity bit for all data bits in positions whose binary representation includes a 1 in the
least significant position excluding 1 (3, 5, 7, 9, 11 and so on)
• r2 is the parity bit for all data bits in positions whose binary representation includes a 1 in the
position 2 from right except 2 (3, 6, 7, 10, 11 and so on)
• r3 is the parity bit for all data bits in positions whose binary representation includes a 1 in the
position 3 from right except 4 (5-7, 12-15, 20-23 and so on)
The r redundant bits placed at bit positions of powers of 2, i.e. 1, 2, 4, 8, 16 etc. Once the receiver gets
an incoming message, it performs recalculations to detect errors and correct them. The steps for
recalculation are −
Using the same formula as in encoding, the number of redundant bits is ascertained.
2r ≥ m + r + 1 where m is the number of data bits and r is the number of redundant bits.
Computer Networks (3161007) Enrollment No.
Parity bits are calculated based upon the data bits and the redundant bits using the same rule as during
generation of c1,c2 ,c3 ,c4 etc. Thus
The decimal equivalent of the parity bits binary values is calculated. If it is 0, there is no error.
Otherwise, the decimal value gives the bit position which has error. For example, if c1c2c3c4 = 1001, it
implies that the data bit at position 9, decimal equivalent of 1001, has error. The bit is flipped to get
the correct message.
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a, b,c, d,f,g,i,x[5],y[8];
printf(“Enter 4 digit data => ”);
for(i=1;i<5;i++)
scanf(“%d”,&x[i]);
a=x[1];
b=x[2];
c=x[3];
d=x[4];
e=a+b+d;
f=a+c+d;
g=b+c+d;
y[1]=e%2;
y[2]=f%2;
y[3]=a;z
y[4]=g%2;
y[5]=b;
Computer Networks (3161007) Enrollment No.
y[6]=c;
y[7]=d;
printf(“Newly generated Hamming Code \n based on even parity => ”);
for(i=1;i<8;i++)
printf(“%d”,y[i]);
getch();
}
Output:
Conclusion:
Computer Networks (3161007) Enrollment No.
Quiz:
1. The representation of 4 bit code 1101 into 7 bit, even parity Hamming code is
A. 1010101
B. 1111001
C. 1011101
D. 1110000
Ans-
2. What is the hamming distance between the codes “11001011” and “10000111”
A. 2
B. 3
C. 4
D. 5
Ans-
3. The final code after encoding data bits 1101 into 7 bit even parity Hamming Code is
A. 1110101
B. 1011101
C. 1010101
D. 0110101
Ans-
Suggested Reference:
1. Computer Networks by Andrew S. Tanenbaum, 4th Edition, Prentice Hall Publication
2. Data Communication and Networking by Behrouz Forouzan, 4th Edition, Tata McGraw-Hill Publication
Rubrics 1 2 3 4 5 Total
Marks
Computer Networks (3161007) Enrollment No.
Experiment No: 11
Date:
Competency and Practical Skills:
➢ Able to understand the encryption and decryption algorithm
Relevant CO:
CO-4: Examine the functions of Transport and application layers
Objectives:
To understand encrypt and decrypt algorithm in network security.
Theory:
• The Caesar cipher is a simple encryption technique. It works by shifting the letters in the
plaintext message by a certain number of positions, known as the “shift” or “key”.
• The Caesar Cipher technique is one of the earliest and simplest methods of encryption
technique. It’s simply a type of substitution cipher, i.e., each letter of a given text is replaced
by a letter with a fixed number of positions down the alphabet. For example with a shift of 1,
A would be replaced by B, B would become C, and so on.
• The encryption can be represented using modular arithmetic by first transforming the letters
into numbers, according to the scheme, A = 0, B = 1,…, Z = 25.
• For example, if the shift is 3, then the letter A would be replaced by the letter D, B would
become E, C would become F, and so on. The alphabet is wrapped around so that after Z, it
starts back at A.
• Here is an example of how to use the Caesar cipher to encrypt the message “HELLO” with a
shift of 3:
1. Write down the plaintext message: HELLO
2. Choose a shift value. In this case, we will use a shift of 3.
3. Replace each letter in the plaintext message with the letter that is three positions to the right
in the alphabet.
H becomes K (shift 3 from H)
E becomes H (shift 3 from E)
L becomes O (shift 3 from L)
L becomes O (shift 3 from L)
O becomes R (shift 3 from O)
4.The encrypted message is now “KHOOR”.
• To decrypt the message, you simply need to shift each letter back by the same number of
positions. In this case, you would shift each letter in “KHOOR” back by 3 positions to get the
original message, “HELLO”.
Computer Networks (3161007) Enrollment No.
Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
int i;
char a[20];
for(i=0;i<20;i++)
a[20]='\0';
printf("enter the word with max 20 char=");
scanf("%s",&a);
i=0;
while(a[i]!='\0')
{
a[i]=a[i]+3;
i++;
}
printf("encoded data =%s",a);
i=0;
while (a[i]!='\0')
{
a[i]=a[i]-3;
i++;
}
printf("\n decoded data = %s",a);
getch();
}
Output:
Conclusion:
Computer Networks (3161007) Enrollment No.
Quiz:
1. We are provided the plain text “SUN”. You need to convert the given plain text into
ciphertext under the Ceasar cipher encryption technique. Which of the following options is the
correct ciphertext for the given text if the key is 2?
A. UWP
B. NUS
C. WUP
D. QSL
Ans-
Suggested Reference:
1. Computer Networks by Andrew S. Tanenbaum, 4th Edition, Prentice Hall Publication
2. Data Communication and Networking by Behrouz Forouzan, 4th Edition, Tata McGraw-Hill Publication
Rubrics 1 2 3 4 5 Total
Marks
Computer Networks (3161007) Enrollment No.
Experiment No: 12
Date:
Competency and Practical Skills:
➢ Understand distant vector routing algorithm RIP.
Relevant CO:
CO-4: Examine the functions of Transport and application layers
Objectives:
The main objective of Distance vector routing algorithm is used to find the shortest route from one
node to another node in the network. It is called as Bellman-Ford algorithm.
Equipment/Instruments: Packet tracer software
Theory:
It is used in computer networks to choose the optimal path for data to travel between nodes
It works by exchanging data with its nearby nodes that are directly linked in order to compile a table
of the most direct paths to every other node in the network.
Every node in the network keeps a routing table that details the distance to each target node as well as
the subsequent hop node on the way there.
Normally, the distance is expressed in terms of the number of hops or the travel duration to the
destination.
The Bellman-Ford algorithm is used by the Distance vector routing algorithm to update the routing
database. Each node sends its routing table to its neighbours on a regular basis, and they use the data
they receive to update their own tables. Until every node has access to the most recent routing
information, this procedure is repeated.
It is best suitable for small sized computer networks. As the number of nodes in the network increase,
the data transfer becomes slow due to the slow convergence rate of the DVR algorithm.
RIP is one of the most commonly used routing protocols in the networking industry. Here you can
build a multi-router network and use RIP to automatically propagate routes, so hosts on remote
networks can communicate.
Computer Networks (3161007) Enrollment No.
Required Resources
• Configure host H1 attached to R1 with an IP address, subnet mask, and default gateway thatis
compatible with the IP address of the R1 Fast Ethernet interface (172.16.0.1/24).
Host H1 IP configuration:
IP address: 172.16.0.2
Subnet mask: 255.255.0.0
Default gateway: 172.16.0.1
• Configure host H2 attached to R2 with an IP address, subnet mask, and default gateway thatis
compatible with the IP address of the R2 Fast Ethernet interface (172.18.0.1/24).
Host H2 IP configuration:
IP address: 172.18.0.2
Subnet mask: 255.255.0.0
Default gateway: 172.18.0.1
Computer Networks (3161007) Enrollment No.
R1#ping 172.18.0.1
C:\>ping 172.18.0.2
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#network 172.16.0.0
R1(config-router)#network 172.17.0.0
R1(config-router)#exit R1(config)#exit
R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#network 172.17.0.0
R2(config-router)#network 172.18.0.0
R2(config-router)#exit R2(config)#exit
R1#ping 172.18.0.1
b. From the host H1 command prompt, ping H2 (from network 172.16.0.2 to network 172.18.0.2).
C:\>ping 172.18.0.2
On router R1, enter the debug ip rip command from privileged EXEC mode.
On router R2, enter the undebug all to stop all debugging activity.
Conclusion:
Quiz:
1. The size of an updating packet in distance vector routing is normally the size of an
updating packet in a link state routing.
A. Smaller than
B. Larger than
C. The same as
D. None of the above
Ans-
2. In distance vector routing, the updating packet conveys the knowledge of the router about
.
A. The whole internetwork
B. The neighborhood
C. Either a or b
D. Neither a not b
Ans-
Suggested Reference:
1. Computer Networks by Andrew S. Tanenbaum, 4th Edition, Prentice Hall Publication
2. Data Communication and Networking by Behrouz Forouzan, 4th Edition, Tata McGraw-Hill Publication
Rubrics 1 2 3 4 5 Total
Marks