List of Lab Exercises: SL - No Name of The Program
List of Lab Exercises: SL - No Name of The Program
Experiment 1:-
Transmission Media:-
A transmission medium can be broadly defined as anything that can carry information from a source to
a destination.
In data communication the definition of the information and the transmission medium is more specific.
The transmission medium is usually free space, metallic cable or fiber-optic cable.
In telecommunication, transmission media can be divided into two broad categories: guided and
unguided.
Transmission Media
Free space
Twisted-Pair Coaxial Fiber-optic
Cable Cable Cable
Guided media
Guided media are those that provide a conduct form one device to another, include twisted pair cable,
coaxial cable and fiber-optic cable. A signal travelling along any of these media is directed and contained by
the physical limits of the medium.
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 1|Page
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 2|Page
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Coaxial Cable
Coaxial Cable carries signals of higher frequency ranges than those in twisted pair cable,
in part because the two media are constructed quite differently. Instead of having 2 wires coaxial has a central
conductor of solid or stranded wire(usually copper) enclosed in an insulating sheath, which is in turn encased in
an outer conductor of metal foil, braid or a combination of the two. The outer metal wrapping serves both as a
shield against noise and as the second conductor, which completes the circuit. The outer conductor is also
enclosed in an insulating sheath, and the whole cable is protected by a plastic cover.
Application
Coaxial Cable was widely used in analog telephone networks cable TV networks also use
coaxial cables. Another common application of coaxial cable is in traditional ethernet LANs.
Coaxial cable connectors
There are number of connectors available for coax some of them are
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 3|Page
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Unguided Media
Unguided media transports electromagnetic waves without using a physical conductor. This type of
communication is often referred to as wireless communication. Signals are normally broadcast through free
space and thus are available to anyone who has a device capable of receiving them.
Electromagnetic spectrum for wireless communication
Unguided signals can travel from the source to destination in several ways: ground propagation, sky
propagation and line-of-sight propagation.
In ground propagating, radio waves travel through the lowest portion of the atmosphere, hugging the
earth. These low-frequency signals emanate in all directions from the transmitting antenna and follow the
curvature of the planet. Distance depends on the amount of power in the signal, the greater the power, the
greater the distance.
In sky propagation, higher frequency radio waves radiate upward into the ionosphere, where they are
reflected back to the earth.
In live-of-sight propagation, very high frequency signals are transmitted in straight lines directly from
antenna to antenna.
Radio waves:
Electromagnetic waves ranging in frequencies between 3KHz and 1 GHz are normally called radio
waves.
Radio wave for the most part is omni-directional. The transmitting and receiving antenna‟s do nt need to
be aligned.
Radio waves particularly those of low and medium frequencies can penetrate walls.
Omnidirectional Antennas used in AM and FM radio, television, maritime radio etc.
Microwaves:
Electromagnetic waves having frequencies between 1 and 300 GHz are called microwaves.
Electromagnetic waves (Microwaves) are unidirectional.
Microwave propagation is line-of-light.
Very high-frequency microwaves cannot penetrate walls.
Unidirectional antennas are used.
Infrared:
Infrared with frequencies from 300GHz to 400THz can be used for short range communication. Infrared
waves, having high frequencies, cannot penetrate walls. This advantageous characteristic prevents interference
between one system and another, a short range communication system is one room cannot be affected by
another system in the next room.
Infrared signals can be used for short range communication in a closed area using line-of-sight
propagation.
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 4|Page
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Connector A Connector B
Pin 1 Pin 1
Pin 2 Pin 2
Pin 3 Pin 3
Pin 4 Pin 4
Pin 5 Pin 5
Pin 6 Pin 6
Pin 7 Pin 7
Pin 8 Pin 8
Connector A Connector B
Pin 1 Pin 3
Pin 2 Pin 6
Pin 3 Pin 1
Pin 4 Pin 7
Pin 5 Pin 8
Pin 6 Pin 2
Pin 7 Pin 4
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 5|Page
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Pin 8 Pin 5
Different Type of CAT Cables
Ethernet cables have been evolving since the beginning of the Ethernet standard in 1985. Many different
categories of Ethernet cable have been developed, and each category has different specifications as far as
shielding from electromagnetic interference, data transmission speed, and the possible bandwidth frequency
range required to achieve that speed.
Category 1
Category 1 typically telephone communication cable CAT-1 cable is used as level-1 or vice
grade copper is a grade of unshielded twisted pair cabling designed for telephonic communication, at
one-time the most for telephonic communication for data transmission.
Category 2
Category 2 cable also known as CAT-2 or level 2 is grade of unshielded and twisted pair cabling
designed for telephone and data communication. Maximum speed is 2 Mbps.
Category 3
Category 3 Ethernet cable, also known as Cat 3 or station wire, is one of the oldest forms of
Ethernet cable still in use today. It is an unshielded twisted pair (UTP) cable that is capable of carrying
10 megabits per second (Mbps) of data or voice transmissions. Its maximum possible bandwidth is 16
MHz. Cat 3 cable reached the peak of its popularity in the early 1990s, as it was then the industry
standard for computer networks. With the debut of the faster Category 5 cable, however, Cat 3 fell out
of favor. It still can be seen in use in two-line telephone systems and older 10BASE-T Ethernet
installations.
Category 4
Category 4 is that cable which contains 4 unshielded twisted pair UTP copper wire with a data
rate of 20Mbps. It is used generally jacketed with an outside sheath used in token Ring.
Category 5
Category 5 (Cat 5) Ethernet cable is the successor to the earlier Category 3. Like Cat 3, it is a
UTP cable, but it is able to carry data at a higher transfer rate. Cat 5 cables introduced the 10/100Mbps
speed to the Ethernet, which means that the cables can support either 10 Mbps or 100 Mbps speeds. A
100 Mbps speed is also known as Fast Ethernet, and Cat 5 cables were the first Fast Ethernet-capable
cables to be introduced. They also can be used for telephone signals and video, in addition to Ethernet
data. This category has been superseded by the newer Category 5e cables.
Category 5e
The Category 5e standard is an enhanced version of Cat 5 cable, which is optimized to reduce
crosstalk, or the unwanted transmission of signals between data channels. This category works for
10/100 Mbps and 1000 Mbps (Gigabit) Ethernet, and it has become the most widely used category of
Ethernet cable available on the market. While Cat 5 is common in existing installations, Cat 5e has
completely replaced it in new installations. While both Cat 5 and Cat 5e cables contain four twisted
pairs of wires, Cat 5 only utilizes two of these pairs for Fast Ethernet, while Cat 5e uses all four,
enabling Gigabit Ethernet speeds. Bandwidth is also increased with Cat 5e cables, which can support a
maximum bandwidth of 100 MHz. Cat 5e cables are backward compatible with Cat 5 cables, and can be
used in any modern network installation.
Category 6
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 6|Page
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
One of the major differences between Category 5e and the newer Category 6 is in transmission
performance. While Cat 5e cables can handle Gigabit Ethernet speeds, Cat 6 cables are certified to
handle Gigabit Ethernet with a bandwidth of up to 250 MHz. Cat 6 cables have several improvements,
including better insulation and thinner wires, that provide a higher signal-to-noise ratio, and are better
suited for environments in which there may be higher electromagnetic interference. Some Cat 6 cables
are available in shielded twisted pair (STP) forms or UTP forms. However, for most applications, Cat 5e
cable is adequate for gigabit Ethernet, and it is much less expensive than Cat 6 cable. Cat 6 cable is also
backwards compatible with Cat 5 and 5e cables.
Category 6a
Category 6 a cable, or augmented Category 6 cable, improves upon the basic Cat 6 cable by
allowing 10,000 Mbps data transmission rates and effectively doubling the maximum bandwidth to 500
MHz. Category 6a cables are usually available in STP form, and, as a result, must have specialized
connectors that ground the cable.
Category 7
Category 7 cable, also known as Class F, is a fully shielded cable that supports speeds of up to
10 Gbps (10,000 Mbps) and bandwidths of up to 600 Mhz. Cat 7 cables consist of a screened, shielded
twisted pair (SSTP) of wires, and the layers of insulation and shielding contained within them are even
more extensive than that of Cat 6 cables. Because of this shielding, they are thicker, more bulky, and
more difficult to bend. Additionally, each of the shielding layers must be grounded, or else performance
may be reduced to the point that there will be no improvement over Cat 6, and performance may be
worse than Cat 5. For this reason, it‟s very important to understand the type of connectors at the ends of
a Cat 7 cable.
The following table summarizes the most common types of Ethernet cables, including their maximum
data transmission speeds and maximum bandwidths.
With each successive category, there has been an increase in data transmission speed and bandwidth. To
fully future-proof a network installation, the highest categories are recommended, but only if all of the other
equipment on the network is capable of similar speeds. Otherwise, expensive cables will be only as fast as the
slowest piece of hardware on the network.
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 7|Page
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Experiment 2:
Various Interconnecting Devices
Repeaters
A physical layer device the acts on bits not on frames or packets
Can have two or more interfaces
When a bit (0,1) arrives, the repeater receives it and regenerates it, the transmits it onto all other
interfaces
Used in LAN to connect cable segments and extend the maximum cable length extending the
geographical LAN range
o Ethernet 10base5 – Max. segment length 500m – 4 repeaters (5 segments) are used to extend the
cable to 2500m)
o Ethernet 10Base2- Max. segment length 185m - 4 repeaters (5 segments) are used to extend the
cable to 925m
Repeaters do not implement any access method
o If any two nodes on any two connected segments transmit at the same time collision will happen
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 8|Page
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
A repeater is a device that operates only in the physical layer. Signals that carry information within a
network can travel a fixed distance before attenuation endangers the integrity of the data. A repeater receives a
signal and, before it becomes too weak or corrupted, regenerates the original bit pattern. The repeater then
sends the refreshed signal. A repeater can extend the physical length of a LAN
A repeater does not actually connect two LANs; it connects two segments of the same LAN. The
segments connected are still part of one single LAN. A repeater is not a device that can connect two LANs of
different protocols.
A repeater can overcome the 10Base5 Ethernet length restriction. In this standard, the length of the
cable is limited to 500 m. To extend this length, we divide the cable into segments and install repeaters between
segments. Note that the whole network is still considered one LAN, but the portions of the network separated
by repeaters are called segments. The repeater acts as a two-port node, but operates only in the physical layer.
When it receives a frame from any of the ports, it regenerates and forwards it to the other port.
The location of a repeater on a link is vital. A repeater must be placed so that a signal reaches it before
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 9|Page
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
any noise changes the meaning of any of its bits. A little noise can alter the precision of a bit's voltage without
destroying its identity. If the corrupted bit travels much farther, however, accumulated noise can change its
meaning completely. At that point, the original voltage is not recoverable, and the error needs to be corrected. A
repeater placed on the line before the legibility of the signal becomes lost can still read the signal well enough
to determine the intended voltages and replicate them in their original form.
Hubs
Acts on the physical layer
Operate on bits rather than frames
Also called multiport repeater
Used to connect stations adapters in a physical star topology but logically bus
Connection to the hub consists of two pairs of twisted pair wire one for transmission and the other for
receiving.
Hub receives a bit from an adapter and sends it to all the other adapters without implementing any
access method.
does not do filtering (forward a frame into a specific destination or drop it) just it copy the received
frame onto all other links
The entire hub forms a single collision domain, and a single Broadcast domain
o Collision domain: is that part of the network (set of NICs) when two or more nodes transmit at
the same time collision will happen.
o Broadcast domain: is that part of the network (set of NIC) where each NIC can 'see' other
NICs' traffic broadcast messages.
Multiple Hubs can be used to extend the network length
For 10BaseT and 100BaseT the maximum length of the connection between an adapter and the hub is
100 meters the maximum length between any two nodes is 200 m = maximum network length
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 10 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Bridge
A bridge operates in both the physical and the data link layer. As a physical layer device, it
regenerates the signal it receives. As a data link layer device, the bridge can check the physical (MAC)
addresses (source and destination) contained in the frame.
In telecommunication networks, a bridge is a product that connects a local area network (LAN) to
another local area network that uses the same protocol (for example, Ethernet or token ring). You can envision
a bridge as being a device that decides whether a message from you to someone else is going to the local area
network in your building or to someone on the local area network in the building across the street. A bridge
examines each message on a LAN, "passing" those known to be within the same LAN, and forwarding those
known to be on the other interconnected LAN (or LANs).
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 11 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
In bridging networks, computer or node addresses have no specific relationship to location. For this reason,
messages are sent out to every address on the network and accepted only by the intended destination node.
Bridges learn which addresses are on which network and develop a learning table so that subsequent messages
can be forwarded to the right network.
Bridging networks are generally always interconnected local area networks since broadcasting every message
to all possible destinations would flood a larger network with unnecessary traffic. For this reason, router
networks such as the Internet use a scheme that assigns addresses to nodes so that a message or packet can be
forwarded only in one general direction rather than forwarded in all directions.
A bridge works at the data-link (physical network) level of a network, copying a data frame from one network
to the next network along the communications path.
Switches
A network switch (also called switching hub, bridging hub, officially MAC Bridge) is a computer
networking device that connects devices together on a computer network, by using packet switching to receive,
process and forward data to the destination device. Unlike less advanced network hubs, a network switch
forwards data only to one or multiple devices that need to receive it, rather than broadcasting the same data out
of each of its ports.
A network switch is a multiport network bridge that uses hardware addresses to process and forward
data at the data link layer (layer 2) of the OSI model. Switches can also process data at the network layer (layer
3) by additionally incorporating routing functionality that most commonly uses IP addresses to perform packet
forwarding; such switches are commonly known as layer-3 switches or multilayer switches. Beside most
commonly used Ethernet switches, they exist for various types of networks, including Fibre Channel,
Asynchronous Transfer Mode, and InfiniBand.
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 12 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 13 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Full-Duplex operation
Routers
A router is a three-layer device that routes packets based on their logical addresses (host-to-host
addressing). A router normally connects LANs and WANs in the Internet and has a routing table that is used for
making decisions about the route. The routing tables are normally dynamic and are updated using routing
protocols.
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 14 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Deals with global address ( network layer address (IP)) not local address (MAC address)
Routers Communicate with each other and exchange routing information
Determine best route using routing algorithm by special software installed on them
Forward traffic if information on destination is available otherwise discard it (not like a
switch or bridge)
Gateway
A gateway is a network point that acts as an entrance to another network. On the Internet, a node or
stopping point can be either a gateway node or a host (end-point) node.
A gateway is often associated with both a router, which knows where to direct a given packet of data
that arrives at the gateway, and a switch, which furnishes the actual path in and out of the gateway for a given
packet.
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 15 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Experiment 3:
Bit Stuffing Using C Program
Introduction:
Bit stuffing is the insertion of a one or more bits into a transmission unit as a way to
provide signaling information to the receiver. The receiver knows how to detect, remove and discarded
the stuffed bits.
Bit stuffing is required by many networks and communication protocol for the following
reasons
To prevent data being interrupted as contro information
For protocols that require a fixed size frame. Bits are sometimes inserted to make the
frame size equal to the set size.
Program:
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
int pattern[] ={1,1,1,1,1};
int data[100], output[100];
int n,i,l,count=0,j,flag;
printf("\n Enter the length of the data string");
scanf("%d",&n);
printf("\n Enter the bits now");
for(i=0;i<n;i++)
{
printf("\n Enter the %d bit",(i+1));
scanf("%d",&data[i]);
}
i=0;
while(i<n-4)
{
flag=0;
for(j=0;j<5;j++)
{
if(data[i+j]==pattern[j])
flag++;
else
flag=0;
}
if(flag==0)
{
for(j=0;j<5;j++)
{
output[count]=data[i+j];
count++;
}
i=i+4;
output[count]=0;
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 16 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
count++;
}
else
{
output[count] = data[i];
count++;
i++;
}
}
l=count;
j=0;
printf("\n Output ");
while(j<l)
{
printf("%d",output[j]);
j++;
}
getch();
}
Output:
Enter the length of the data string: 5
Enter the bits now
Enter the 1 bit : 1
Enter the 2 bit : 1
Enter the 3 bit : 1
Enter the 4 bit : 1
Enter the 5 bit : 1
Output : 111110
Program:
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
int pattern[] ={1,1,1,1,1};
int data[100], output[100];
int n,i,l,count=0,j,flag,len;
printf("\n Enter the length of the data string Unstuffed");
scanf("%d",&n);
printf("\n Enter the bits now");
for(i=0;i<n;i++)
{
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 17 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 18 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Experiment 4:
Byte Stuffing Using C Program
Introduction:
In byte stuffing or character stuffing a special byte is added to the data section of the
frame when there is a character with the same pattern as the flag. The data section is stuffed with an
extra byte.
This byte usually called the escape character, which has a predefined bit pattern.
Program:
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
char c[100], b[100];
int i=0,k=0,j;
printf(“\n Enter a string ”);
fflush(stdin);
gets(c);
while(c[k]!=‟\0‟)
{
if(c[k]==‟e‟&& c[k+1]==‟n‟&&c[k+2]==‟d‟)
{
for(j=0;j<3;j++)
{
b[i++] = c[k++];
b[i++] = „&‟;
b[i++] = „\0‟;
}
}
}
printf(“\n Output: \n”);
puts(b);
getch();
}
Output:
Enter a String: abcdendabcendabc
Output : abcdend&abcend&abc
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 19 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Introduction:
In byte stuffing or character stuffing a special byte is added to the data section of the
frame when there is a character with the same pattern as the flag.
For implementing character in order to obtain to obtain original data within the data
section of the frame.
Program:
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
char input[100], output[100];
int i=0,k=0,j;
printf(“\n Enter a string to be Unstuff ”);
fflush(stdin);
gets(input);
while(input[k]!=‟\0‟)
{
if(input[k]==‟e‟&& inut[k+1]==‟n‟&&input[k+2]==‟d‟&&input[k+3]==‟&‟)
{
for(j=0;j<3;j++)
{
output[i++] = input[k++];
output[i] = „\0‟;
k++;
}
}
}
printf(“\n Output: \n”);
puts(output);
getch();
}
Output:
Enter a String: abcdend&abcend&abc
Output : abcdendabcendabc
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 20 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Experiment 5.
Error detection and correction using CRC(Cyclic Redundancy Check)
Introduction:
An cyclic redundancy check is an error detecting code, commonly used in digital
network and storage devices, to detect accidental change in raw data. It consists of the following:
b(x) -> transmitted code word
q(x) -> Quotient
i(x) -> Information polynomial.
r(x) -> Remainder polynomial
g(x) -> Generated Polynomial
Program:
#include< stdlib.h>
#include< conio.h>
#include< stdio.h>
void main()
{
int i,j,n,g,a,arr[20],gen[20],b[20],q[20],s;
clrscr();
printf("Transmitter side:");
printf("\nEnter no. of data bits:");
scanf("%d",&n);
printf("Enter data:");
for(i=0;i< n;i++)
scanf("%d",&arr[i]);
printf("Enter size of generator:");
scanf("%d",&g);
do{
printf("Enter generator:");
for(j=0;j< g;j++)
scanf("%d",&gen[j]);
}
while(gen[0]!=1);
printf("\n\tThe generator matrix:");
for(j=0;j< g;j++)
printf("%d",gen[j]);
a=n+(g-1);
printf("\n\tThe appended matrix is:");
for(i=0;i< j;++i)
arr[n+i]=0;
for(i=0;i< a;++i)
printf("%d",arr[i]);
for(i=0;i< n;++i)
q[i]= arr[i];
for(i=0;i< n;++i)
{
if(arr[i]==0) {
for(j=i;j< g+i;++j)
arr[j] = arr[j]^0;
} else {
arr[i] = arr[i]^gen[0];
arr[i+1]=arr[i+1]^gen[1];
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 21 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
arr[i+2]=arr[i+2]^gen[2];
arr[i+3]=arr[i+3]^gen[3];
}
}
printf("\n\tThe CRC is :");
for(i=n;i < a;++i)
printf("%d",arr[i]);
s=n+a;
for(i=n;i< s;i++)
q[i]=arr[i];
printf("\n");
for(i=0;i< a;i++)
printf("%d",q[i]);
getch();
}
Output:
Transmitter side:
Enter no. of data bits:8
Enter data:1 0 1 0 0 0 0 1
Enter size of generator:4
Enter generator:1 0 0 1
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 22 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Experiment 6:
Error detection and correction using Hamming Codes
Introduction
When a code-word is corrupted during transmission the hamming distance between
the sent and received code-word is the no od bits affected by the errors to guarantee the detection of up to s
errors in all cases, the minimum hamming distance in a block code must be d(min) = s+1
To guarantee correction up to t errors in all cases the minimum hamming distance
in a block code must be d(min) = 2t+1
Program
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int m,r,i,j,k,err,l;
int a[20]={0},p[20]={0},b1[20],b2[20][20]={0},q[20][20]={0},s[20],
n[20]={0},c[20]={0},flag=0;
clrscr();
printf("\nEnter the no of bits in the data string:");
scanf("%d",&m);
for(i=1;i<=m;i++)
{
if(pow(2,i)>=(m+i+1))
{
r=i;
break;
}
}
printf("\nNo of redundant bits:");
printf("%d",r);
printf("\nEnter the data string:");
for(i=m+r;i>r;i--)
scanf("%d",&a[i]);
for(i=r;i>0;i--)
a[i]=-1;
for(i=0;i<r;i++)
{
p[i]=pow(2,i);
if(p[i]>r)
{
a[i]=a[p[i]];
for(l=0;l<abs(p[i]-r-1);l++)
s[l]=a[p[i]-l];
l=0;
for(j=p[i];j>r;j--)
{
a[j-1]=s[l];
l++;
}
a[p[i]]=-1;
}
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 23 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
}
for(i=m+r;i>0;i--)
{
k=i;
for(j=0; ;j++)
{
if(k!=0)
{
b2[i][j]=k%2;
b1[j]=k/2;
k=b1[j];
}
else
break;
}
}
for(j=0;j<r;j++)
{
for(i=m+r;i>0;i--)
{
if(b2[i][j]==1)
q[j][m+r-i]=i;
n[j]++;
}
}
for(j=0;j<r;j++)
{
for(i=0;i<n[j];i++)
{
if(a[q[j][i]]==1)
c[j]++;
}
if(c[j]%2==0)
a[p[j]]=0;
else
a[p[j]]=1;
}
printf("\nThe data string sent by the sender:");
for(i=m+r;i>0;i--)
{
c[i]=a[i];
printf("%d",a[i]);
}
printf("\nDo you want to create any error(Y-1/N-0)\n");
scanf("%d",&err);
if(err==1)
{
printf("\nEnter the position for error\n");
scanf("%d",&err);
c[err]=!c[err];
}
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 24 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Output
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 25 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Experiment 7:
Socket Programming Using TCP
Introduction
Program
File: MyServer.java
import java.io.*;
import java.net.*;
public class MyServer {
public static void main(String[] args){
try{
ServerSocket ss=new ServerSocket(6666);
Socket s=ss.accept();//establishes connection
DataInputStream dis=new DataInputStream(s.getInputStream());
String str=(String)dis.readUTF();
System.out.println("message= "+str);
ss.close();
}catch(Exception e){System.out.println(e);}
}
}
File: MyClient.java
import java.io.*;
import java.net.*;
public class MyClient {
public static void main(String[] args) {
try{
Socket s=new Socket("localhost",6666);
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
dout.writeUTF("Hello Server");
dout.flush();
dout.close();
s.close();
}catch(Exception e){System.out.println(e);}
}
}
Output
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 26 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 27 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Experiment 8.
Socket Programming using UDP
Introduction
Program
DSender.java
import java.net.*;
public class DSender{
public static void main(String[] args) throws Exception {
DatagramSocket ds = new DatagramSocket();
String str = "Welcome java";
InetAddress ip = InetAddress.getByName("127.0.0.1");
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 28 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
import java.io.*;
class UDPSENDERBIDIRECT
{
public static void main(String args[]) throws Exception
{
InetAddress rechost=InetAddress.getByName("localhost");
int recport=3333;
DatagramSocket ds=new DatagramSocket(2222);
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String msg1="",msg2="";
byte buf[]=new byte[400];
while(!msg1.equals("bye"))
{
msg1=(String)br.readLine();
byte arr[]=msg1.getBytes();
DatagramPacket dp1=new DatagramPacket(arr,arr.length,rechost,recport);
ds.send(dp1);
DatagramPacket dp2=new DatagramPacket(buf,400);
ds.receive(dp2);
msg2=new String(dp2.getData(),0,dp2.getLength());
System.out.println("reciver says::"+msg2);
}
ds.close();
}
}
RECEIVER
import java.net.*;
import java.io.*;
class UDPRECIEVERBIDIRECT
{
public static void main(String args[])throws Exception
{
InetAddress rechost=InetAddress.getByName("localhost");
int recport=2222;
DatagramSocket ds=new DatagramSocket(3333);
byte buf[]=new byte[400];
String msg1="",msg2="";
while(!msg2.equals("bye"))
{
DatagramPacket dp2=new DatagramPacket(buf,400);
ds.receive(dp2);
msg2=new String(dp2.getData(),0,dp2.getLength());
System.out.println("sender says::"+msg2);
msg1=(String)br.readLine();
byte arr[]=msg1.getBytes();
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 29 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Experiment 9.
Write down the steps to configure ip address in a windows and Linux system.
Use the following steps to setup your LAN connection in Windows XP, when your computer is the
device plugged in to your wireless radio or POE.
Note: - You will need your static IP settings and DNS settings before you continue. If you don't have your
settings, call into support so we can provide them to you.
2. Once in Control Panel, if you are in Category view, click on "Switch to Classic View" in the top left.
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 30 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
3. Now that you are in classic view, find and double click on Network Connections.
4. Now that you are in Network Connections, right click on your Local Area Connection, and left click
on properties.
5. In the Local Area Connections properties window, highlight Internet Protocol, and click on the
properties button.
6. In the Internet Protocol (TCP/IP) Properties window, you will need to select "Use the following IP
address" and "Use the following DNS server addresses:"Enter in the corresponding settings per their
section. If you don't have the settings, or need help with them, call into tech support so we can
provide them to you.
7. Once the settings have been entered in, click ok on the Internet Protocol (TCP/IP) Properties
window, then click on close on the Local Area Connections properties window.
At this point the Local Area Connection should say connected. See if you can browse to a web site at
this time. If you are able to, your setup is complete. If you are not able to browse, call us here at tech
support, so we can verify your settings are correct.
Objectives
Learn to create a simple LAN with two PCs using an Ethernet hub and two straight-
through cables to connect the workstations
Learn to configure and verify the network connectivity.
Learn about various network related commands
Exercise:
The two PCs will be connected with a hub between them [Refer Figure 1]. Using a hub allows
for more than just two workstations to be connected depending on the number of ports on the hub. Hubs
can have from 4 to 32 ports.
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 31 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
1. Two Pentium-based workstations with a NIC in each (NIC drivers should be available)
2. An Ethernet hub (4 or 8 port) and two CAT5 straight-wired cables.
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 32 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 33 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 34 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
Experiment 10
Using rsa algorithm encrypt a text data and decrypt the same
Introduction
Program
#include <stdio.h>
#include <conio.h>
char *r,en[10],de[10],b[10],g;
char
a[26]={„a‟,‟b‟,‟c‟,‟d‟,‟e‟,‟f‟,‟g‟,‟h‟,‟I‟,‟j‟,‟k‟,‟l‟,‟m‟,‟n‟,‟o‟,‟p‟,‟q‟,‟r‟,‟s‟,‟t‟,‟u‟,‟v‟,‟w‟,‟x
‟,‟y‟,‟z‟};
main()
{
int q,l=0,j,cop[50],flag=0,f;
int temp[10],p,e,d,I,n,z,m,g;
unsigned long c;
clrscr();
printf(“\n Enter the plaintext at the end type”);
while((b[i]=getchar())!=‟@‟)
i++;
r=b;
printf(“\n Enter two prime numbers”);
scanf(“%d%d”,&p&q);
n=p*q;
z=(p-1)*(q-1);
i=0;j=0;
for(f=3;f
{
if(f%2==0)
flag=0;
else
{
cop[i]=f;
i++;j++;
}}
printf(“\n The coprimes for %d are”,z);
for(i=0;i
printf(“%d\t”,cop[i]);
printf(“\n enter one coprime”);
scanf(“%d”,&e);
j=0;
while(*r!=‟@‟)
{
for(i=0;i!=25&&flag==0;i++)
{
if(*r==a[i])
{
c=pow(I,e)
g=c%n;
temp[j]=g;
flag=1;
en[j]=toupper(a[g]);
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 35 | P a g e
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering
j++;
} }
r++;
flag=0; }
printf(“\n The cipher text is:”);
for(i=0;i
printf(“%c”,en[i]);
for(d=1;;d++)
{
if((e*d)%z==1)
break;}
printf(“\n The decryption key is %d”,d);
printf(“\n Enter decryption key”);
scanf(“%d”,&d);
printf(“\n the decrypted text is:”);
for(i=0;i
{
c=pow(temp[i],d);
m=c%n;
printf(“%c”,a[m]);
}getch();
}
Output
14. REFERENCES:
B. A. Forouzan – “Data Communications and Networking (3rd Ed.) “ – TMH
A. S. Tanenbaum – “Computer Networks (4th Ed.)” – Pearson Education/PHI
W. Stallings – “Data and Computer Communications (5th Ed.)” – PHI/ Pearson Education
Black, Data & Computer Communication, PHI
Miller, Digital & Data Communication, Jaico
Kurose and Rose – “ Computer Networking -A top down approach featuring the internet” – Pearson Education
Leon, Garica, Widjaja – “Communication Networks” – TMH
Walrand – “Communication Networks” – TMH.
Comer – “Internetworking with TCP/IP, vol. 1, 2, 3(4th Ed.)” – Pearson Education/PHI
________________________________________________________________________________________________________________________________
RCC INSTITUTE OF INFORMATION TECHNOLOGY (Dept. Of CSE) 36 | P a g e