CN Final Lab Manual - APL
CN Final Lab Manual - APL
EXPERIMENT: 1
AIM: To study basic computer networks devices.
THEORY:
1. Hub:
A hub is a piece of hardware which provides the connectivity of a segment of a network by
directing traffic through the network. It simply copies the data to all of the Nodes connected to
the hub. Hubs are commonly used to connect segments of a LAN. A hub contains multiple
ports. When a packet arrives at one port, it is copied to the other ports so that all segments of
the LAN can see all packets.
Hubs work at the physical layer (layer 1) of the OSI model. The device is thus a form of
multiport repeater
1. Passive hubs do not amplify the electrical signal of incoming packets before broadcasting
them out to the network. Often the term concentrator is used for passive hub.
2. Active hubs do perform this amplification, as does a different type of dedicated network
device called a repeater. Some people use the term multiport repeater when referring to an
active hub.
3. Intelligent hubs add extra features to an active hub that are of particular importance to
businesses. An intelligent hub typically is stackable.
2. Repeaters:
Definition: A repeater is an electronic device that receives a signal and retransmits it at a higher
level or higher power, so that the signal can cover longer distances without degradation.
Repeaters operate within the physical layer of the OSI reference model. Repeaters are used in
LANs MAN and WANs. One example of a repeater is an Ethernet Hub. Repeaters do not have
any capability of directing network traffic or deciding what particular route that certain data
should take
3. Bridges:
As networks grow larger, they are often divided into smaller LANs to reduce traffic drain on
the network. A bridge is a Data Link Layer 2 device that provides a connection between
separate LAN segments. The bridge monitors packets as they move between segments, keeping
track of the MAC addresses that are associated with various ports. As they gain more
knowledge of the nodes connected to each network, they are better able to manage traffic flow.
4. Switches:
Definition: A network switch is a small hardware device that joins multiple computers together
within one local area network (LAN). Technically, network switches operate at layer two (Data
Link Layer) of the OSI model.
Network switches appear nearly identical to network hubs, but a switch generally contains
more "intelligence" A switch does the same as a hub, in that it connects devices to allow them
to act as a single segment. However, it does not automatically send traffic to every other port.
5. Routers:
A router allows connectivity to one or more computers, helping create a network. Routers are
physical devices that join multiple wired or wireless networks together and the router operates
at the network layer of the OSI model. Routers are the networking device that forwards data
packets along networks by using headers and forwarding tables to determine the best path to
forward the packets.
Routers forward data packets from one place to another. It forward data depending on the
Network address, not the Hardware (MAC) address. For TCP/IP networks, this means the IP
address of the network interface.
Routers, provide bandwidth control by keeping data out of subnets where it doesn't belong.
6. Gateways:
Definition: A network gateway is an internetworking system, a system that joins two networks
together. A network gateway can be implemented completely in software, completely in
hardware, or as a combination of the two. Depending on their implementation, network
gateways can operate at any level of the OSI model from application protocols to low-level
signaling.
Gateways are most commonly used to transfer data between private networks and the Internet.
A gateway may consist of devices such as protocol translators, rate converters, impedance
matching devices, fault isolators, or signal translators.
7. Modem:
A modem (from modulate and demodulate) is a device that modulates an analog carrier signal
to encode digital information, and also demodulates such a carrier signal to decode the
transmitted information. The goal is to produce a signal that can be transmitted easily and
decoded to reproduce the original digital data.
A modem is a device or program that enables a computer to transmit data over, for example,
telephone or cable lines. Computer information is stored digitally, whereas information
transmitted over telephone lines is transmitted in the form of analog waves. A modem converts
between these two forms.
Any external modem can be attached to any computer that has an RS-232 port, which almost
all personal computers have.
8. NIC Card:
NETWORK INTERFACE CARD often abbreviated as NIC, an expansion board you insert
into a computer so the computer can be connected to a network. Most NICs are designed for a
particular type of network, protocol, and media, although some can serve multiple networks.
A NIC, or Network Interface Card, is a circuit board or chip, which allows the computer to
communicate to other computers on a Network. This board, when connected to a cable or other
method of transferring data such as infrared, can share resources, information and computer
hardware.
9. RJ-45 JACK:
RJ stands for Registered Jacks and the 45 designation scheme. The jack is the device that the
connector plugs into, whether it is in the wall, the network interface card in the computer, or
the hub.
CONCLUSION:
EXPERIMENT: 2
AIM: To understand and use basic networking commands in packet tracer.
(1) IPCONFIG:
When System is in network at that time it is necessary to know the IP address of that system,
subnet mask and gateway address. IPCONFIG command is used to know about IP
configuration details.
Procedure:
Example:
C:\>ipconfig
IP Address. . . . . . . . . . : 192.168.11.7
(2) IPCONFIG/ALL:
This command is used to know the MAC (physical) address of the computer.
Procedure:
Example:
C:\>ipconfig/all
(3) NSLOOKUP:
Procedure:
PING command is useful for checking the reach ability of the system.
If any system (host or router) want to communicate with the other system (host or route)
then it is necessary to check the communication is possible or not? For this, First of all we have
to check for destination system is reachable or not. Due to hardware failure or any other reason
it is possible the system may on network but not reachable.
Procedure:
Example:
(5) TRACERT:
When one system (host or router) send the packet of data to another system then there be two
possibilities, Packet directly reach to destination system or it pass through one or more routers.
TRACERT command is useful to trace the route through which packet passes.
Procedure:
Example:
C:\>tracert 192.168.11.41
Trace complete.
CONCLUSION:
EXPERIMENT: 3
AIM: Create star topology and understand Network Components Hub and Switch
using Cisco Packet Tracer.
(1) Use of Hub:
To create the star topology shown in fig-1 follow the following steps:
1. Take a hub and six computers from the devices given at the bottom left of the screen.
2. Connect them with the Ethernet straight through cable.
3. Give a different IP address to each computer by clicking on it and select Desktop -> IP
Configuration.
4. Also select the static option button.
5. Select the packet and click on Source and Destination PC.
6. Switch to Simulation Mode
7. Packet will be sent to all devices as hub broadcasts incoming packet only desire device accept it
other will discard.
We can see the transfer of packet by selecting Simulation and can see the path traced.
Figure-1
Acknowledge packet is also broadcasted by hub only desire device accept it other will discard.
Figure-2
To create the star topology shown in fig-3 follow the following steps:
1. Take a switch and five computers from the devices given at the bottom left of the screen.
2. Connect them with the Ethernet straight through cable.
3. Give a different IP address to each computer by clicking on it and select Desktop -> IP
Configuration.
4. Also select the static option button.
5. Select the packet and click on Source and Destination PC.
6. Switch to Simulation Mode
7. Packet will be sent to only desire destination
Figure-3
Figure-4
Select the packet envelope on the workspace to show the PDU Information window like the one
shown in the screenshot below. This window contains the OSI Model tab, which shows how the
packet is processed at each layer of the OSI model by the current device.
Figure-5
Switch has memory and can store MAC addresses that can be seen in fig-6
Figure-6
CONCLUSION:
EXPERIMENT: 4
AIM: Write a C program to implement bit stuffing in data stream.
THEORY:
▸ Bit stuffing:
▸ Each frame begins and ends with a special bit pattern, 01111110 . This
pattern is a flag byte.
▸ The sender’s data link layer encounters five consecutive 1s in the data, it
automatically stuffs a 0 bit into the outgoing bit stream. This process is
called bit stuffing.
CODE:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i, j,count=0,nl;
char str[100];
printf("enter the bit string: ");
gets(str);
for (i=0;i<strlen(str);i++)
{
count=0;
//the following code search the six ones in given string
for (j=i;j<=(i+5);j++)
{
if(str[j]=='1')
{
count++;
}
}
//if there is six ones then following code execute to bit stuffing after five
ones
if(count==6)
{
SSASIT,SURAT E&C DEPT.
Computer Networks (6th sem)
nl=strlen(str)+2;
for (;nl>=(i+5);nl--)
{
str[nl]=str[nl-1];
}
str[i+5]='0';
i=i+5;
}
}
puts(str);
getch();
}
Output: 01110111100111110100
CONCLUSION:
EXPERIMENT: 5
AIM: Write a C program to implement parity checker.
▸ Parity checker:
▸ Even parity: Even Number of 1s in a code
▸ Odd parity: Odd Number of 1s in a code
CODE:
#include<stdio.h>
int main()
{
int parity=0,num,count=0;
printf("enter the number");
scanf("%d",&num); // Enter decimal number in input..//
while(num)
{
if(num&1) // bit wise AND operation with RSB of number..//
{
parity=!parity; // parity inverted if result of AND operation is 1..//
count++;
}
num=num>>1; // bit wise right shifting.. //
}
if(parity == 1) //1 is representing that parity is odd..//
printf("parity is odd");
else
printf("parity is even"); //0 is representing that parity is even..//
printf(“\n number of 1s in a number= %d”, count);
return 0;
}
Number of 1s in a number is = 2
CONCLUSION:
EXPERIMENT: 6
AIM: Write a C program to implement checksum.
CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[4], b[4], s_check, r_check, s_sum=0, r_sum=0;
int i;
printf("\n----SENDER----");
for(i=0;i<4;i++)
{
scanf("%x", &a[i]);
}
s_sum=s_sum+s_check;
printf("\nThe sum is %x", s_sum);
s_sum=s_sum+1;
s_sum=~s_sum;
printf("\nThe checksum generated is %x", s_sum);
printf("\n----RECEIVER----");
for(i=0;i<4;i++)
{
scanf("%x", &b[i]);
}
printf("\nEnter checksum: ");
scanf("%x", &r_check);
r_sum=r_sum+r_check;
printf("\nThe sum is %x", r_sum);
r_sum=r_sum+1;
r_sum=~r_sum;
printf("\nThe checksum generated is %x", r_sum);
if(r_sum==0000)
else
printf("\nError!");
getch();
Sample input:
nEnter checksum: 0
Sample output:
CONCLUSION:
EXPERIMENT: 7
AIM: Write a program to implement hamming code.
CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int data[7],rec[7],i,c1,c2,c3,c;
printf("\n enter message (4 bit) one by one bit: ");
scanf("%d%d%d%d",&data[0],&data[1],&data[2],&data[4]);
data[6]=data[0]^data[2]^data[4];
data[5]=data[0]^data[1]^data[4];
data[3]=data[0]^data[1]^data[2];
printf("\n the encoded bits are given below: \n");
for (i=0;i<7;i++) {
printf("%d ",data[i]);
}
printf("\n enter the received data bits one by one: ");
for (i=0;i<7;i++) {
scanf("%d",&rec[i]);
}
c1=rec[6]^rec[4]^rec[2]^rec[0];
c2=rec[5]^rec[4]^rec[1]^rec[0];
c3=rec[3]^rec[2]^rec[1]^rec[0];
c=c3*4+c2*2+c1 ;
if(c==0) {
printf("\ncongratulations there is no error: ");
SSASIT,SURAT E&C DEPT.
Computer Networks (6th sem)
} else {
printf("\nerron on the postion: %d\nthe correct message is \n",c);
if(rec[7-c]==0)
rec[7-c]=1; else
rec[7-c]=0;
for (i=0;i<7;i++) {
printf("%d ",rec[i]);
}
}
getch();
}
Sample input:
Sample output:
1010010
CONCLUSION:
EXPERIMENT: 8
AIM: Write a program to convert the given IP address from decimal to
binary and also decide the class.
CODE:
clc;
clear all;
IP(1) = input(“Give the first number of IP address:”)
IP(2) = input(“Give the second number of IP address:”)
IP(3) = input(“Give the third number of IP address:”)
IP(4) = input(“Give the fourth number of IP address:”)
IP = [IP(1) IP(2) IP(3) IP(4)];
IPB1 = de2bi(IP(1));
IPB2 = de2bi(IP(2));
IPB3 = de2bi(IP(3));
IPB4 = de2bi(IP(4));
IPB = [IPB1 IPB2 IPB3 IPB4];
disp(IPB);
if(IP(1)<127)
disp(‘This IP address is belong to class A’)
elseif(IP(1)<192)
disp(‘This IP address is belong to class B’)
elseif(IP(1)<224)
disp(‘This IP address is belong to class c’)
elseif(IP(1)<255)
disp(‘This IP address is belong to reserved range’)
else
disp(‘invalid IP address’)
end
Sample input:
Sample output:
CONCLUSION:
EXPERIMENT: 9
AIM: Write a program to implement encryption and decryption algorithm.
CODE:
#include <stdio.h>
int main()
{
int i, x, key;
char str[100];
case 2:
for(i = 0; (i < 100 && str[i] != '\0'); i++)
str[i] = str[i] - key;
default:
printf("\nError\n");
}
return 0;
}
Sample input:
Enter key: 3
Sample output:
CONCLUSION:
EXPERIMENT:10
AIM: Understand and implement static routing configuration using Cisco Packet
Tracer.
Theory:
Routing is simply a process of choosing route for delivering data to its destination.
Static Routing:
Procedure:
Figure-1
Figure-2
Figure-3
SSASIT,SURAT E&C DEPT.
Computer Networks (6th sem)
4. Select the packet and click on Source and Destination PC. Switch to Simulation
Mode and observe the routing path of the simple PDU as shown in figure-4.
Figure-4
CONCLUSION: