0% found this document useful (0 votes)
112 views37 pages

List of Lab Exercises: SL - No Name of The Program

The document contains a list of lab exercises for a computer networks course. It includes 10 experiments related to topics like transmission media, networking devices, coding techniques for error detection/correction, socket programming, and network configuration. It also provides sample solutions and introductions for additional experiments involving network simulation and Qualnet. The exercises aim to help students learn practical skills in areas key to computer networks.

Uploaded by

bigger
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)
112 views37 pages

List of Lab Exercises: SL - No Name of The Program

The document contains a list of lab exercises for a computer networks course. It includes 10 experiments related to topics like transmission media, networking devices, coding techniques for error detection/correction, socket programming, and network configuration. It also provides sample solutions and introductions for additional experiments involving network simulation and Qualnet. The exercises aim to help students learn practical skills in areas key to computer networks.

Uploaded by

bigger
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/ 37

LIST OF LAB EXERCISES

SL.No Name of the program

1 Experiment 1 Describe different guided and unguided transmission media.


Discuss straight cabling and Crossover cabling technique.
Describe different types of CAT cables.
2 Experiment 2 Describe various interconnecting devices (Hub, Repeater, Bridge,
Switch, Router, and Gateway).
Describe the network connection of your department including type of
the network, type of connection and its topology and interconnecting
device used.
3 Experiment 3 Write a C program to implement bit stuffing in UNIX.
Write a C program in UNIX to show bit unstuffing. Take output of the
previous experiment as input.
4 Experiment 4 Write a C program to implement byte stuffing.
Write a C program to implement byte unstuffing. Take output of the
previous experiment as input.
5 Experiment 5 Error detection and correction using CRC(Cyclic Redundancy Check)
6 Experiment 6 Error detection and correction using Hamming Codes
7 Experiment 7 Write a java program to implement simple socket program using TCP
socket.
Write a java program to implement bi directional chat program using
TCP socket.
8 Experiment 8 Write a java program to implement a simple socket program using
UDP socket.
Write a java program to implement a bi directional chat program using
UDP socket.
9 Experiment 9 Write down the steps to configure ip address in a windows and Linux
system.
Write down the syntax, description and output of the following Linux
commands…
Ifconfig, ping, netstat –a, netstat -at, netstat -r,netstat -x, netstat -s,
netstat -ic
10 Experiment 10 Using RSA algorithm encrypt a text data and decrypt the same

6. List of Additional Lab Exercise

1 Experiment 1 Introduction to simulation, Introduction to Qualnet GUI, Setting up


basic of Qualnet.
2 Experiment 2 Simulation of Wired scenarious, Implenting VOIP in wired network,
intro to Qualnet analyzer.
3 Experiment 3 Introduction to the simulation of wireless scenarios, Setting Basic ad-hoc
networks, changing routing protocols.
Computer Networks Lab Manual(Prepared By Dr. Anup Kumar Kolya Asst.Prof, Dept of CSE) Department of Computer Science and Engineering

7. Sample Solutions for Lab Exercises

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

Guided (Wired) Unguided (Wireless)

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.

Twisted Pair Cable


A twisted pair consists of two conductors (normally copper) each with its own plastic
insulation, twisted together.
One of the wires is used to carry signals to the receiver, and the other is used only as ground
reference. The receiver uses the difference between the two. In addition to the signal sent by the sender on one
of the wires, interference (noise) and crosstalk may affect both wires and create unwanted signals.
If the two wires are parallel, the effect of these unwanted signals is not the same in both wires
because they are at different location relative to the noise. This results in a difference at the receiver. By
twisting the pairs a balance is maintained. Frequency range of Twisted Pair Cable is 100 Hz to 5 MHz.

Twisted pair cable comes in two forms:


1. Unshielded Twisted Pair (UTP),

________________________________________________________________________________________________________________________________
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

2. Shielded Twisted Pair (STP).

1. Unshielded Twisted Pair (UTP)


UTP is the most common type of telecomm. Medium and is use in telephone system, which consists
of two conductor (Cu), each with of different plastic color insulation to identify specific conductor.
Advantage of UTP
UTP is cheap, flexible and easy to install, higher grade of UTP are used in many LAN
technologies.
UTP connector
UTP is most commonly connected to n/w devices via a snap-in plug like RJ45 connector with 8
conductors.

2. Shielded Twisted Pair (STP)


STP has a metal foil or braided-mesh covering that encases each pair of insulated conductors. The
metal casing prevents the penetration of electromagnetic noise.
 Through the use of STP we can eliminate the phenomenon called cross talk.
 STP has the same quality consideration as UTP.
 STP is more expensive than that of UTP but less susceptible to noise.
STP connector
STP Uses same connectors as UTP but shield must be connected to ground

________________________________________________________________________________________________________________________________
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

1. BNC (bayonet n/w connector)


2. T-connectors which allow secondary cable to branch off from main line
3. Terminators used in Bus topologies.

Fiber Optic Cable


A fiber optic cable is made of glass or plastic and transmits signal in the form of light.
Optical fibers use reflection to guide light through a channel. A glass or plastic core is
surrounded by a cladding of less dense glass or plastic. The difference in density of the two materials must be
such that a beam of light moving through the core is reflected off the cladding instead of being refracted into it.

Advantages of optical fiber:


 Higher Bandwidth
 Less Signal Attention
 Immunity to electromagnetic interference
 Resistance to corrosive materials
 Light Weight
 Greater immunity to tapping.

________________________________________________________________________________________________________________________________
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

Disadvantages of optical Fiber


 Installation and maintainance
 Unidirectional light propagation
 Cost (High Cost)

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

Straight Cabling Technique


Straight-Through refers to cables that have the pin assignments on each end of the cable. In other words
Pin 1 connector A goes to Pin 1 on connector B, Pin 2 to Pin 2 etc. Straight-Through wired cables are most
commonly used to connect a host to client. For cat5e patch cables, the Straight-Through wired cat5e patch cable
is used to connect computers, printers and other network client devices to the router switch or hub (the host
device in this instance).

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

Crossover Cabling Technique


Crossover wired cables (commonly called crossover cables) are very much like Straight-Through cables
with the exception that TX and RX lines are crossed (they are at opposite positions on either end of the cable.
Using the 568-B standard as an example below you will see that Pin 1 on connector A goes to Pin 3 on
connector B. Pin 2 on connector A goes to Pin 6 on connector B etc. Crossover cables are most commonly used
to connect two hosts directly. Examples would be connecting a computer directly to another computer,
connecting a switch directly to another switch, or connecting a router to a router. Note: While in the past when
connecting two host devices directly a crossover cable was required. Now days most devices have auto sensing
technology that detects the cable and device and crosses pairs when needed.

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.

Cable Type Maximum Data Transmission Speed Maximum


Bandwidth
Category 3 UTP 10 Mbps 16 MHz
Category 5 UTP 10/100 Mbps 100 MHz
Category 5e UTP 1000 Mbps 100 MHz
Category 6 UTP OR STP 1000 Mbps 250 MHz
Category 6a STP 10,000 Mbps 500 MHz
Category 7 SSTP 10,000 Mbps 600 MHz

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.

It is tempting to compare a repeater to an amplifier, but the comparison is inaccurate. An amplifier


cannot discriminate between the intended signal and noise; it amplifies equally everything fed into it. A
repeater does not amplify the signal; it regenerates the signal. When it receives a weakened or corrupted signal,
it creates a copy, bit for bit, at the original strength.

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

Interconnecting with hubs

________________________________________________________________________________________________________________________________
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

 Backbone hub interconnects LAN segments


 Advantage:
o Extends max distance between nodes
 Disadvantages
o Individual segment collision domains become one large collision domain  (reduce the
performance)
o Can‟t interconnect different Ethernet technologies(like 10BaseT & 100BaseT) because no
buffering at the hub

Here we have a single collision domain and a single broadcast domain

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

 N-Port bridge where N is equal to number of stations


 Usually used to connect individual computers not LANs like bridge
 Allows more than one device connected to the switch directly to transmit simultaneously
 Can operates in Full-duplex mode (can send and receive frames at the same time over the same
interface)
 Performs MAC address recognition and frame forwarding in hardware (bridge in software)
 Two types :
o Store-and-forward: switch receives the whole a frame on the input line, buffers it briefly ,
performs error checking, then routes it to the appropriate output line (similar to bridge).
Buffering will cause some delay.
o Cut-through: based on the fact that the destination address appears at the beginning of the MAC
frame, so once the address is recognized the frame is directly sent to the appropriate output line
if the output buffer is empty (no need to buffer it).  no buffering delay  NO ERROR
CHECKING

Isolated collision domains

________________________________________________________________________________________________________________________________
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.

 Operates at network layer = deals with packets not frames


 Connect LANs and WANs with similar or different protocols together
 Switches and bridges isolate collision domains but forward broadcast messages to all LANs
connected to them. Routers isolate both collision domains and broadcast domains
 Acts like normal stations on a network, but have more than one network address (an address to
each connected network)

________________________________________________________________________________________________________________________________
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.

• Connect two networks with different communication protocols


– e.g. connect Ethernet to Unix
• Handle larger range of protocols than a router
• Translate information between systems.

________________________________________________________________________________________________________________________________
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

Bit UnStuffing Using C Program


 Introduction:
For implementing bit unstuffing we need an enable signal. Except for stuffed zero the
enable bit is high. Thus the receiver block should not accept the data if enable is low.

 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

printf("\n Enter the %d bit",(i+1));


scanf("%d",&data[i]);
}
i=0; j=0; count =0;
while(i<n-5)
{
flag=0;
for(j=0;j<6;j++)
{
if(data[i+j]==pattern[j])
flag++;
else
flag=0;
}
if(flag==6)
{
for(j=0;j<5;j++)
{
output[count]=data[i+j];
count++;
}
i=i+6;
}
else
{
output[count] = data[i];
count++;
i++;
}
}
l=count;
j=0;
printf("\n Output Unstuffed ");
while(j<l)
{
printf("%d",output[j]);
j++;
}
getch();
}
 Output:
Enter the length of the data string: 6
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
Enter the 6 bit : 0
Output : 11111

________________________________________________________________________________________________________________________________
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

Byte Unstuffing 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.
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

The generator matrix:1001


The appended matrix is:10100001000
The CRC is :111

________________________________________________________________________________________________________________________________
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

printf("\nThe data string received by the receiver:");


for(i=m+r;i>0;i--)
printf("%d",c[i]);
for(i=m+r;i>0;i--)
{
c[i]=(c[i]^a[i]);
if(c[i]==1)
{
flag=1;
break;
}
}
if(flag==1)
printf("\nThe data string has error at position %d and is
rejected.",i);
else
printf("\nThe data string has no error and is accepted.");
getch();
}

 Output

Enter the no of bits in the data string: 7


No of redundant bits: 4
Enter the data string: 1
0
0
1
1
0
1
The data string send by the sender: 10011100101
Do you want to create any error(Y-1/N-0)
1
Enter the position for error
2
The data string received by the receiver: 10011100111
The data string has error at position 2 and is rejected.

________________________________________________________________________________________________________________________________
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

Bi directional chat program using TCP socket.


 Introduction
 Program
File: MyServer.java
import java.net.*;
import java.io.*;
class MyServer{
public static void main(String args[])throws Exception{
ServerSocket ss=new ServerSocket(3333);
Socket s=ss.accept();
DataInputStream din=new DataInputStream(s.getInputStream());
DataOutputStream dout=new DataOutputStream(s.getOutputStream());

________________________________________________________________________________________________________________________________
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

BufferedReader br=new BufferedReader(new


InputStreamReader(System.in));
String str="",str2="";
while(!str.equals("stop")){
str=din.readUTF();
System.out.println("client says: "+str);
str2=br.readLine();
dout.writeUTF(str2);
dout.flush();
}
din.close();
s.close();
ss.close();
}
}
File: MyClient.java
import java.net.*;
import java.io.*;
class MyClient{
public static void main(String args[])throws Exception{
Socket s=new Socket("localhost",3333);
DataInputStream din=new DataInputStream(s.getInputStream());
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
String str="",str2="";
while(!str.equals("stop")){
str=br.readLine();
dout.writeUTF(str);
dout.flush();
str2=din.readUTF();
System.out.println("Server says: "+str2);
}
dout.close();
s.close();
}
}
 Output

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

DatagramPacket dp = new DatagramPacket(str.getBytes(), str.length(), ip,


3000);
ds.send(dp);
ds.close();
}
}
//DReceiver.java
import java.net.*;
public class DReceiver{
public static void main(String[] args) throws Exception {
DatagramSocket ds = new DatagramSocket(3000);
byte[] buf = new byte[1024];
DatagramPacket dp = new DatagramPacket(buf, 1024);
ds.receive(dp);
String str = new String(dp.getData(), 0, dp.getLength());
System.out.println(str);
ds.close();
}
}
 Output

Bi Directional Socket Programming using UDP


 Introduction
 Program
SENDER
import java.net.*;

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

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

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

DatagramPacket dp1=new DatagramPacket(arr,arr.length,rechost,recport);


ds.send(dp1);
}
ds.close();
}
}
 Output

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.

1. First, go to the start menu and into Control Panel.

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

Setting up a simple network


In this experiment, we will learn how to connect two PCs to create a simple Peer-to-Peer
network. The instructions for this Lab focus on the Windows 2003 operating system. You will share a
folder on one workstation and connect to that folder from the other workstation. This Lab is divided into
two exercises as follows:

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

Network Connection via Hub


Tools / Preparation: The workstations should have Network Interface Cards (NIC) installed with the
proper drivers. The following resources will be required:

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.

Check Local Area Network Connections


Task: Verify the cables.
Explanation: You should check the cables to verify that you have good layer 1 physical connections.
Exercise: Check each of the two CAT 5 cables from each workstation to the hub. Verify that the pins
are wired straight through by holding the two RJ-45 connectors for each cable side by side with the clip down
and inspect them. All pins should have the same color wire on the same pin at both ends of the cable. (Pin 1
should match pin 1 and pin 8 should match pin 8 etc.)

Plug in and connect the equipment


Task: Check the workstations and hub for exercise.
Exercise: Check to make sure that the NICs are installed correctly in each workstation. Plug in the
workstations and turn them on. Plug the straight through cable from workstation 1 into port 1 of the hub and the
cable from workstation 2 into port 2 of the hub. After the workstations have booted, check the green link light
on the back of each NIC and the green lights on ports 1 and 2 of the hub to verify that the are communicating.
This also verifies a good physical connection between the Hub and the NICs in the workstations (OSI Layers 1
and 2). If the link light is not on it usually indicates a bad cable connection, an incorrectly wired cable or the
NIC or hub may not be functioning correctly.

Network Adapters and Protocols


Task: Check the Network Adapter (NIC): Use the Control Panel�System�Device Manager utility to
verify that the Network Adapter (NIC) is functioning properly for both workstations. Double click on Network
Adapters and then right click the NIC adapter in use. Click Properties to see if the device is working properly.
Explanation: If there is a problem with the NIC or driver, the icon will show a yellow circle with an
exclamation mark in it with (possible resource conflict) or a red X indicating a serious problem (device could
cause Windows to lock up).

________________________________________________________________________________________________________________________________
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

Check the TCP/IP Protocol Settings


Task: Use the Control Panel/Network Connections (or Properties in Context Menu of My Network
Places) to display Network Connections Window. Then use Properties in Context Menu of Local Area
Connection to display Local Area Connection Properties Window. Select the TCP/IP protocol from the
Configuration Tab and click on properties. Check the IP Address and Subnet mask for both workstations on the
IP Address Tab.

Network Connections Window

________________________________________________________________________________________________________________________________
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

TCP/IP Properties Window


Explanation: The IP addresses can be set to anything as long as they are compatible and on the same
network. Record the existing settings before making any changes in case they need to be set back (for instance,
they may be DHCP clients now). For this lab, use the Class C IP network address of 192.168.230.0 and set
workstation 1 to static IP address 192.168.230.1 and set workstation 2 to 192.168.230.2. Set the default subnet
mask on each workstation to 255.255.0.0. For the purpose of this lab, you can leave the Gateway and DNS
Server entries blank.

Network Status commands


o ifconfig –a
Show all interfaces
o ifconfig <interface name>
setup for a particular interface, e.g. ln0
o ifconfig <interface name> <params>
Set params of the interface. Root only. Typically IP address, subnet,
are set upon bootup in /etc/rc*
o ping <host>
Send an ICMP echo message (one packet) to a host. This may go continually until
you hit Control-C. Ping means a packet was sent from your machine via ICMP, and echoed
at the IP level. ping tells you if the OS is up; but doesn't tell you if inetd or other daemons
are running.
o netstat <seconds>
running error stats + counts on config interface every N seconds
o netstat –a
socket ports and state
o netstat -s
protocol (tcp etc.) counts and errors
o netstat -r
routing table dump
o netstat –i
list of interfaces and gives 3 letter interface names If you use the –n flag, host
addressed will be numeric and avoid a DNS lookup, which might be faster in some cases.
Combine with the other switches.
o netstat –r
Print routing tables. The routing tables are stored in the kernel and used by ip to
route packets to non-local networks.
o netstat –at
listening only TCP(Transmission Control Protocol) port connections using
netstat-at. Active Internet connections (Services established)

________________________________________________________________________________________________________________________________
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

You might also like