0% found this document useful (0 votes)
52 views29 pages

CN Final Lab Manual - APL

Uploaded by

Sneha Golakiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views29 pages

CN Final Lab Manual - APL

Uploaded by

Sneha Golakiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Computer Networks (6th sem)

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

Technically three different types of hubs exist:

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.

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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.

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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.

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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.

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

CONCLUSION:

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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:

1. First go to command prompt (go to start menu and type cmd)


2. Type ipconfig

Example:

C:\>ipconfig

Windows 2000 IP Configuration

Ethernet adapter LAN:

Connection-specific DNS Suffix . :

IP Address. . . . . . . . . . : 192.168.11.7

Subnet Mask . . . . . . . . : 255.255.255.224 (it determines our neighbors in n/w)

Default Gateway . . . . . : 192.168.11.2 (1st router IP address)

(2) IPCONFIG/ALL:

This command is used to know the MAC (physical) address of the computer.

Procedure:

1. First go to command prompt (go to start menu and type cmd)


2. Type ipconfig/all

Example:

C:\>ipconfig/all

Ethernet adapter Local Area Connection:

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

Connection-specific DNS Suffix . :

Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller

Physical Address. . . . . . . . . : F8-0F-41-66-E9-94

(3) NSLOOKUP:

This command is used to know IP address of another server through DNS.

Procedure:

1. First go to command prompt (go to start menu and type cmd)


2. Type nslookup and hit enter key
3. Type name of the server (Ex: www.google.com)

(4) PING (Packet Internet Groper Command)

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:

1. First go to command prompt


2. For help and information about this command type ping
3. Type ping IP address of system

Example:

C:\ >ping 192.168.11.42

Pinging 192.168.11.42 with 32 bytes of data:

Reply from 192.168.11.42: bytes=32 time<10ms TTL=127

Reply from 192.168.11.42: bytes=32 time<10ms TTL=127

Reply from 192.168.11.42: bytes=32 time<10ms TTL=127

Reply from 192.168.11.42: bytes=32 time<10ms TTL=127

(5) TRACERT:

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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:

1. First go to command prompt


2. Type tracert followed by “IP address or name of the destination”.

Example:

C:\>tracert 192.168.11.41

Tracing route to EC9-41 [192.168.11.41]

over a maximum of 30 hops:

1 <10 ms <10 ms <10 ms VPN [192.168.11.2]

2 <10 ms <10 ms <10 ms EC9-41 [192.168.11.41]

Trace complete.

CONCLUSION:

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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.

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

Figure-2

(2) Use of switch:

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

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

Switch has memory and can store MAC addresses that can be seen in fig-6

Figure-6

CONCLUSION:

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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();
}

Sample input: 0111011110011111100

Output: 01110111100111110100

CONCLUSION:

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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;
}

Sample input: 10 (binary 1010)

Output: parity is even

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

Number of 1s in a number is = 2
CONCLUSION:

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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----");

printf("\nEnter the values in hex: ");

for(i=0;i<4;i++)
{
scanf("%x", &a[i]);
}

printf("\nEnter checksum: ");


scanf("%x", &s_check);

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


{
s_sum=s_sum+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----");

printf("\nEnter the values in hex: ");

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

for(i=0;i<4;i++)
{
scanf("%x", &b[i]);
}
printf("\nEnter checksum: ");
scanf("%x", &r_check);

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


{
r_sum=r_sum+b[i];
}

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)

printf("\nNo Error in Transmission");

else

printf("\nError!");
getch();

Sample input:

Enter the values in hex: 7e 12 1a 6b

nEnter checksum: 0

Sample output:

The sum is 115

The checksum generated is fffffee9

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

CONCLUSION:

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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:

enter message (4 bit) one by one bit: 1 0 1 0

enter the received data bits one by one: 1 0 1 0 1 1 0

Sample output:

the encoded bits are given below: 1 0 1 0 0 1 0

erron on the postion: 3

the correct message is

1010010

CONCLUSION:

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

Sample input:

Give the first number of IP address: 125

Give the second number of IP address:20

Give the third number of IP address: 100

Give the fourth number of IP address: 10

Sample output:

This IP address is belong to class A

CONCLUSION:

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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];

printf("\nPlease enter a string:\t");


gets(str);
printf("Enter key: ");
scanf("%d", &key);

printf("\nPlease choose following options:\n");


printf("1 = Encrypt the string.\n");
printf("2 = Decrypt the string.\n");
scanf("%d", &x);

//using switch case statements


switch(x)
{
case 1:
for(i = 0; (i < 100 && str[i] != '\0'); i++)
str[i] = str[i] + key; //the key for encryption is 3 that is added to ASCII value

printf("\nEncrypted string: %s\n", str);


break;

case 2:
for(i = 0; (i < 100 && str[i] != '\0'); i++)
str[i] = str[i] - key;

printf("\nDecrypted string: %s\n", str);


break;

default:
printf("\nError\n");

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

}
return 0;
}

Sample input:

Please enter a string: hello

Enter key: 3

Sample output:

Encrypted string: khoor

CONCLUSION:

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

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:

As the name suggest, static routing is configured by an administrator manually. Static


routing does not use any routing algorithm or mechanism to update the routing tables.

Procedure:

1. Create a network topology as shown in fig-1.

Figure-1

SSASIT,SURAT E&C DEPT.


Computer Networks (6th sem)

2. Configure the end devices (PCs) as shown in figure-2.

Figure-2

3. Configure the routers as shown in figure-3.

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:

SSASIT,SURAT E&C DEPT.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy