Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 72

Department Of Computer Science and Engineering

Department Of Computer Science and Engineering


University Institute of Technology
Rajiv Gandhi Proudyogiki Vishwavidyalaya Bhopal

LAB MANUAL
Computer Networking
1
Page
Department Of Computer Science and Engineering

List of Experiments
1. Study of Different Type of LAN& Network Equipment.

2. Study and Verification of standard Network topologies i.e., Star, Bus, Ring etc.

3. LAN installations and Configurations.

4. Write a program to implement various types of error correcting techniques.

5. Write a program to Implement various types of framing methods.

6. Study of Tool Command Language (TCL).

7. Study and Installation of Standard Network Simulator: N. S-2, N. S-3. OpNet, QualNet etc.

8. Study & Installation of ONE (Opportunistic Network Environment) Simulator for High Mobility
Networks.

9. Configure 802.11WLAN.

10. Implement & Simulate various types of routing algorithm.

11. Study & Simulation of MAC Protocols like Aloha, CSMA, CSMA/CD and CSMA/CA using Standard
Network Simulators.

12. Study of Application layer protocols- DNS, HTTP, HTTPS, FTP and Telnet.

2
Page
Department Of Computer Science and Engineering

Experiment no.-1

AIM: To study of different types of Network & Network equipment’s.

Description:

There are so many different types of computer networks in existence, it can be hard to understand the
differences between them, particularly the ones with very similar-sounding names. This lesson explains the
structures and functions of some of the most popular computer networks.

Types of Networks

There are several different types of computer networks. Computer networks can be characterized by their
size as well as their purpose.

The size of a network can be expressed by the geographic area they occupy and the number of computers
that are part of the network. Networks can cover anything from a handful of devices within a single room to
millions of devices spread across the entire globe.

Some of the different networks based on size are:

 Personal area network, or PAN

 Local area network, or LAN

 Metropolitan area network, or MAN

 Wide area network, or WAN

In terms of purpose, many networks can be considered general purpose, which means they are used for
everything from sending files to a printer to accessing the Internet. Some types of networks, however, serve
a very particular purpose. Some of the different networks based on their main purpose are:

 Storage area network, or SAN

 Enterprise private network, or EPN

 Virtual private network, or VPN

Let's look at each of these in a bit more detail.

Personal Area Network

A personal area network, or PAN, is a computer network organized around an individual person within a
single building. This could be inside a small office or residence. A typical PAN would include one or more
computers, telephones, peripheral devices, video game consoles and other personal entertainment devices.
3

If multiple individuals use the same network within a residence, the network is sometimes referred to as a
Page

home area network, or HAN. In a very typical setup, a residence will have a single wired Internet connection
Department Of Computer Science and Engineering
connected to a modem. This modem then provides both wired and wireless connections for multiple devices.
The network is typically managed from a single computer but can be accessed from any device.

This type of network provides great flexibility. For example, it allows you to:

 Send a document to the printer in the office upstairs while you are sitting on the couch with your
laptop.

 Upload a photo from your cell phone to your desktop computer.

 Watch movies from an online streaming service to your TV.

If this sounds familiar to you, you likely have a PAN in your house without having called it by its name.

Local Area Network

A local area network, or LAN, consists of a computer network at a single site, typically an individual
office building. A LAN is very useful for sharing resources, such as data storage and printers. LANs can be
built with relatively inexpensive hardware, such as hubs, network adapters and Ethernet cables.

The smallest LAN may only use two computers, while larger LANs can accommodate thousands of
computers. A LAN typically relies mostly on wired connections for increased speed and security, but
wireless connections can also be part of a LAN. High speed and relatively low cost are the defining
characteristics of LANs.

LANs are typically used for single sites where people need to share resources among themselves but not
with the rest of the outside world. Think of an office building where everybody should be able to access files
on a central server or be able to print a document to one or more central printers. Those tasks should be easy
for everybody working in the same office, but you would not want somebody just walking outside to be able
to send a document to the printer from their cell phone! If a local area network, or LAN, is entirely wireless,
it is referred to as a wireless local area network, or WLAN.

Metropolitan Area Network

A metropolitan area network, or MAN, consists of a computer network across an entire city, college
campus or small region. A MAN is larger than a LAN, which is typically limited to a single building or site.
Depending on the configuration, this type of network can cover an area from several miles to tens of miles.
A MAN is often used to connect several LANs together to form a bigger network. When this type of
network is specifically designed for a college campus, it is sometimes referred to as a campus area network,
or CAN.

Wide Area Network

A wide area network, or WAN, occupies a very large area, such as an entire country or the entire world. A
WAN can contain multiple smaller networks, such as LANs or MANs. The Internet is the best-known
example of a public WAN.
4

Network equipment’s:-
Page
Department Of Computer Science and Engineering
The different type of hardware found in a LAN environment. The following discussion addresses the
suitability for different environments of various types of hardware.

Hubs, Bridges, and Switches. How each piece of hardware functions specifically in an Ethernet
environment.

ROUTER

A router is a device for connecting computer networks to one another, used for handling the routing of
packets between two networks, or to determine the path that a data packet shall take. When a user enters a
URL, the Web client (the browser) queries the domain name server, which shows it the IP address of the
desired machine.

The workstation sends the request to the nearest router, i.e. to the default gateway on the network it is
located on. This router determines the next machine to which the data will be forwarded, in such a way as to
choose the best pathway possible. To do so, the routers keep up-to-date routing

tables, which are like maps showing the paths that can be taken to get to the destination address. There are
numerous protocols designed to handle this process.

In addition to their routing function, routers are also used to manipulate data travelling in the form of
datagram so that they can go from one kind of network to another. As not all networks are able to handle the
same size of data packets, routers are tasked with fragmenting packets so they can travel freely.

HUBS
A hub is often used to connect small LAN segments in which the number of devices is generally 24 or
fewer, and hubs are multiport repeaters. Hubs are used to create collision domains, in which all devices on
5

the network can see each other. In larger designs, signal quality begins to deteriorate as segments exceed
Page

their maximum length, often a couple hundred feet. Hubs provide the signal amplification required to allow
Department Of Computer Science and Engineering
a segment to be extended a greater distance. A hub takes an incoming signal on any one port and repeats it
out all ports to enable users to share the Ethernet network resources.

Ethernet hubs create star topologies in 10-Mbps or 100-Mbps half-duplex Ethernet LANs. It is the hub that
enables several point-to-point segments to be joined together into one single network, and it is this network
of hubs that makes up a shared Ethernet, just as several point-to-point roads join together into the single
large network of roads you use to get around town.

A shared Ethernet LAN means that all members of the network are contending for transmission of data onto
a single network (collision domain); individual members of a shared network get only a percentage of the
available network bandwidth.
Shared Ethernet (Total Bandwidth Shared Among Attached Hosts)

One end of the point-to-point link is attached to the hub, and the other is attached to the network device,
such as a computer or printer. Connecting multiple hubs together expands the shared Ethernet segment but
puts more stress on the line's bandwidth because now more users are trying to use the same bandwidth. This
is similar to building a new neighborhood without adding roads and thus putting stress on existing roads. As
you and your car sit stuck in traffic, so might your data suffer in network congestion.
Network bridges are one way to prevent this congestion. Network bridges function like hubs in that bridges
provide a network connection; however, bridges preserve the separation of these network segments by
keeping network traffic local to its respective segment instead of repeating it all to the world. Bridge
operation is discussed in detail in the following section.

BRIDGES
Repeaters and hubs have no intelligence; they just repeat whatever signal is received from one port out
all ports without looking at what is being sent or received. Bridges add a level of intelligence to the
network by using the MAC address to build a table of hosts, mapping these hosts to a network segment
and containing traffic within these network segments. For example, below Figure illustrates a bridged
network with two network segments.

Bridge Connecting Two Ethernet Segments


6
Page
Department Of Computer Science and Engineering

Segments 1 and 2 contain two workstations each, a file server (for file sharing) and a network printer.

A hub in this scenario is not the preferred method because of the contention for the network bandwidth. In
this scenario, a bridge is a better choice than a hub because the bridge segments the network into two
smaller parts an engineering team segment and a financial team segment keeping traffic local to its
respective segment.

Ethernet bridges map the MAC addresses of the network devices, or nodes, residing on each network
segment. Bridges allow only necessary traffic to pass through the bridge, such as traffic destined for a
segment other than the source. When a frame is received by the bridge, the bridge looks at the frame
header and reads the source and destination MAC addresses, determining the frame sender and
destination. If the frame's source and destination segments are the same, the frame is dropped, or filtered
by the bridge; if the segments differ, the bridge forwards the frame to the correct segment.
Figure illustrates a small bridged network with three network segments.
Bridge Connecting Three LAN Segments
7
Page
Department Of Computer Science and Engineering
If the bridge sees a frame arrive on port 1 from Host 9, the bridge concludes that Host 9 can be reached
through the segment connected to port 1. If the same bridge sees a frame arrive on port 2 from Host 12, the
bridge concludes that Host 12 can be reached through the network segment

connected to port 2, as illustrated in below Figure Through this learning process, bridges build a table, such
as shown in Table

Bridge Connecting Two LAN Segments (A and B)

Table - Bridge Table


Host Address Network Segment
15 1
17 1
12 2
13 2
18 1
9 1
14 3

SWITCHES
Hubs create a network environment in which each connected device shares the available network
bandwidth with other devices contending for the same network resources, as illustrated in below Figure .

Shared Network
8
Page
Department Of Computer Science and Engineering

The hub is connecting six workstations together, each sharing the network bandwidth. A finite amount of
network bandwidth is available. For example, 10BASE-T Ethernet provides 10 Mbps, and the more
workstations added to this network, the less bandwidth available for each. Switches address the shared
bandwidth issue and eliminate contention by dedicating a path between the source and the destination, as
illustrated in the below Figure .
Dedicated Network

9
Page
Department Of Computer Science and Engineering

Experiment no.-2
AIM : To study and verification of standard Network Topologies i.e Star, Bus,Ring etc.
Description:

The pattern of interconnection of nodes in a n/w is known as TOPOLOGY.The selection of the topology
for a network can’t be done in isolation as it affects choice of media and access net. There are no. of factors
to consider in making this choice:-

1. Cost.
2. Flexibility.
3. Reliability.

TYPE OF CONNECTIONS:-

A network is two or more device connected through links. A link is communication pathway that
transfer data from one device to another. There are two possible type of connections i.e point to point
and multipoint.
 Point to point: This connection provides a dedicated link b/w two devices.The entire capacity of
link is reserved for transmission between those two device. Most point to point connection use as
length of wire or cables to connect two ends, but other option, such as microwave or satellite
links are also possible.
 Multipoint: It is also k/n as multi drop connection. Here more than twospecific devices share
a single link.
In a multipoint environment capacity of channel is shared either spatially or temporally. If
several devices can use save link simultaneously, if is a spatially shared connection.If user must
take turns, if is a connection.

STAR TOPOLOGY

In star topology each device for a dedicated to point-to-point link only to a central controller, called a tab.
The device are not directly linked to one another : if one device wants to send data to another, it sends data
to controller, which then relays data to other connected device.
It is less expensive than mesh topology. In star topology each device needs only one link and one i/o part to
connect it to any no. of other.It is robust. If one only that link is affected. All other links remain.
10
Page
Department Of Computer Science and Engineering
BUS TOPOLOGY

It is a multipoint connection. One long cable acts as a backbone to link all devices in a n/w. nodes are
connected to bus cable by drop links and taps. A drop link is a connected running b/w device and main
cable. A tap is a connector that either special into main cable and punctures of a cable to create a contact
with metallic core. As a signal travels along back bone some of its energy is transferred into heat. Here it
becomes weaker and weaker as it travels further and further for this reason there is a limit or no. of taps a
bus can support and on distance between those taps. It is easy to install. It uses less cabling than mesh and
star topologies.

RING TOPOLOGY

In RT , each device has a dedicated point- to- point connection with only one two devices on either side of
it. A signal is passed only ring in one direction, from device to device until it reaches its destination. Each
device in ring in corporate a repeaters. When a device receives a signal intended for another device , its
repeater regenerates bits and passes them along.

 In RT is relatively easy to install and .each one device is linked to only its immediate neighbour.
 In RT fault isolation is simplified.
 In RT a signal is circulating at all ties. If one device does not receive a signal with in a specified
period it can issue on alarm. The alarm alerts n/w operator to problem and its location.

MESH TOPOLOGY

In MT, every device has a dedicated point-to-point link to every other device. The term dedicated means
that link carries traffic only b/w two device it connects. To no. of physical links is a fully connected mesh
n/w with n nodes, we first consider that each node must be connected to every other node. In a mesh
topology we need n(n-1)/2 duplex –node links. To accommodate that many links, every device on n/w must
have (n-1) i/o ports to be connected to other (n-1) stations.

 It offers several advantages over other n/w topologies.


 It eliminates traffic problem.
 It is Robust.
 It is more private or secure.
 Fault identification and fault isolation are easy in MT.

HYBRID TOPOLOGY
A network can be hybrid for eg. We can have main star topology with each branch connecting several
station in a bus topology.
11
Page
Department Of Computer Science and Engineering

Experiment No.-3

AIM: - To study communication guided media system and various types of connectors.
Description:
By communication system, it is meant that connecting cable or connecting media are being talked about.
The cables that correct two or more workstations are communication channels.

Now we can group communication media in two categories:

a) Guided Media

b) Unguided Media

a) Guided Media: These include cables.

b) Unguided Media: It includes waves through air, water or vaccum.

GUIDED MEDIA

The various types of cables are:

1. Twisted pair cable

2. Coaxial cable

3. Optical fibers

1. TWISTED PAIR CABLE: It is the most common form of wiring in data communication
applications. As a voice grade medium (VGM), it is the basis for most internal office telephone
wiring. It consists of two identical wires wrapped in a double coated cover.

Different types of twisted pair cable exist, but they all have two things in common: -

o The wires are in pairs.

o The pairs of wires are twisted around each other.

Twisting of wires returns crosstalk, which is bleeding of a signed from one wire to another & which can
corrupt signal & cause network errors.

ADVANTAGES OF TWISTED PAIR CABLE:

1. Simple
2. Easy to install & maintain.
3. Physically flexible.
12

4. Less weight.
5. Inexpensive.
Page

6. Can be easily connected.


Department Of Computer Science and Engineering
TYPES OF TWISTED PAIR CABLES:

1. Unshielded Twisted Pair Cable (UTP): It is used for variety of electronic communication. It is
available in five categories.

2. Shielded Twisted Pair Cable (STP): It has shielding of individual pair of wires, which further protect
it from external interference. It also has maximum segment length of 100 meters.

TYPE DESCRIPTION

CAT1 VGM communication only, No


data transmission
CAT2 Data grade transmission up to 4
Mbps.
CAT3 Data grade transmission up to 10
Mbps.
CAT4 Data grade transmission up to 16
Mbps.
CAT5 Data grade transmission up to
100Mbps.

2.COAXIAL CABLE: It consist of a solid wire core surrounded by one or more foil or wire shields each
separated by some kind of plastic insulator. It is better than twisted pair cable.

ADVANTAGES OF COAXIAL CABLE:

1. Its data transmission characteristics is considerably better than those of twisted pair cable.
2. It can be used as basis for a shared cable.
3. It can be used for broadband transmission.
4. Offer higher bandwidth up to 400 Mbps.

TYPES OF COAXIAL CABLE:

a) Thick Net: It is thicker. It can be up to 500 meters long.

b) Thin Net: It is thinner & it can have max segment length of 185 meters.

3.OPTICAL FIBRES: It consist of glass or glass like material which are so constructed that they carry light
from a source at one end of fiber to a detector at other end.

The fiber cable consist of three pieces:

a) Core
b) Cladding
c) Protective coating

ADVANTAGES OF OPTICAL FIBRES:


13

1. Highly suitable for harsh industrial environment.


Page
Department Of Computer Science and Engineering

2. It guarantees secure transmission & has a very high capacity.

3. It can be used for broadband transmission where several channels are handled in parallel & where it
is possible to data from channels with channels for telescope, graphics, TV & sound.

UNGUIDED MEDIA

1. MICRO WAVE: microwave signals are used to transmit data without use of cables. These are
similar to radio & TV signals are used for long distance communication. Its transmission consist of a
transmitter, receiver & atmosphere.

ADVANTAGES OF MICROWAVE

i) Cheaper
ii) Gives freedom from land acquisition that are required for laying, repairing, cables.
iii) It offers ease of communication over different training.
iv) It has the ability to communication over oceans.

2.RADIO WAVE: If transmission use of radio frequency there it is known as radio wave transmission. Any
radio setup has two parts:

a) Transmitter

b) Receiver

a) TRANSMITTER: Transmitter takes some sort of message encodes it onto a sine wave & transmits
it with radio waves.

b) RECEIVER: It receives radio waves & decodes message from sine wave it receives.

ADVANTAGES OF RADIO WAVES:

It gives mobility.

3.SATELLITE: It is special core of microwave relay system. It uses synchronous satellite to relay radio
signal transmitted from ground station.

ADVANTAGES OF SATELLITE:

1. It covers a large area.

2. The heavy usage of intercontinental traffic.

VARIOUS TYPES OF CONNECTORS.


i) UTP RJ45 CONNECTORS: The most common UTP connector is RJ45 (REGISTERED JACK).
The RJ45 is a keyed correctors, meaning connectors can be inserted in only one way.

ii) COAXIAL CABLE CONNECTORS: To connect coaxial cable to devices, we need coaxial
connectors. Its most common type is BNC connectors. Its most popular types are:

a) BNC connectors

b) BNC T connectors

c) BNC terminator
14

1.BNC CONNECTORS: It is used to connect end of cable to a devices, such as a TV set.


Page
Department Of Computer Science and Engineering

2.BNC T CONNECTORS: It is used in Ethernet network to branch out to a connection to a computer or


other devices.

3. BNC TERMINATOR: It is used at end of cable to prevent reflection of signal.

iii) FIBER OPTIC CABLE CONNECTORS: There are 3 types of connectors for fabric cable.

1. SC (SUBSCRIBER CHANNEL CONNECTORS):

It is used for cable TV. It uses a push pull locking system.

2. ST (STRAIGHT TIP CONNECTORS) :

It is used for connecting cable to network devices. It uses a payment locking system and is more reliable
than SC.

3. MT-RJ CONNECTORS:

It is of same size as RJ45.

15
Page
Department Of Computer Science and Engineering

Experiment No.-4

AIM: To study LAN installation & their configuration.

Description:
Some connecting devices can be used to connect LANS in a backbone network. A backbone network
allows several LANS to be connected. In a backbone network, so station is directly connected to
backbone, connects LANS. The backbone is itself a LAN that uses a LAN protocol such as Etternet, each
connection to the backbone is itself another LAN.
Different architectures can be used for a backbone, the two most common are : The Bus & The Star.

BUS BACKBONE:
In a bus backbone, topology is a bus. The backbone itself can use one of the protocols that support a
BUS topology such as10Base5 or 10Base2.
These are normally used as a distribution backbone to connect different buildings in an organization. Each
building can comprise there a SINGLE LAN or another backbone. e.g. A good example of a bus backbone
is one that connects single or multiple floor buildings on a campus. Each single floor building usually has a
single LAN. Each multiple floor building has a backbone that connects each LAN on a floor. A bus
backbone can interconnect these LANS & backbones.

STAR BACKBONE:
It is sometimes also known as COLLAPSED or SWITCHED backbone. Here topology of backbone is a
star. Here backbone is just one switch (that is why it is called, erroneously, a collapsed backbone) that
connects LANS. In this configuration, the switch does the job of the backbone & at the same time connects
the LANS.
These are mostly used as a distribution backbone inside a building. In a multifloor building, we find one
LAN that serves each particular floor. A star backbone connects these LANS. The backbone network, which
is just a switch, can be installation in basement or the first floor & separate cables can run from the switch to
each LAN.

CONNECTING REMOTE LANS: -

Another common application for a backbone network is to connect remote LANS. This type of backbone
network is useful when a company has several offices with LANS & needs to connect them. The connection
can be done through bridge, sometimes called REMOTE bridges. The bridge act as connecting devices
connecting LAN & point-to-point network such as leased telephone lines or ADSL lines. The point-to-point
network in this case is considered a LAN without stations. The point-to-point lines can use a protocol such
as PPP.

VIRTUAL LANS: -
It is defined as a local area network configured by s/w, not by physical wiring. The whole idea of
VLAN technology is to divide a LAN into logical, instead of physical, segments. A LAN can be
divided into several logical LANS called VLANS. Each VLAN is a work group in the organization.
16

If a person from one group to another, there is no need to change physical configuration. The group
membership in VLANS is defined by S/W not L/W. Any station can be logically moved to another
Page

VLAN. All members belonging to a VLAN can receive broadcast messages sent to that particular
VLAN. This means that if a station
Department Of Computer Science and Engineering

from VLAN1 to VLAN2, it receives broadcast messages sent to VLAN2 but no longer receives
broadcast messages sent to VLAN1. It even allows grouping of stations connected to different switches
in a VLAN.

VLAN group stations belonging to one or more physical LANS into broadcast domains. Stations in a VLAN
communicate with one another

17
Page
Department Of Computer Science and Engineering

Experiment No.-5

AIM : To implement various type of error correcting techniques.

Description:

IN error correction we need to know the exact number of bits that are corrupted & more importantly ,their
location in message. The no. errors & size of msg are important factors.

TYPES OF ERROR CORRECTING TECHNIQUES:


(i) Forward error correction.
(ii) Correction by Retransmission.
(i) Forward error correction:- It is process in which receiver tries to guess msgby sign redundant bits.
This is possible is no of errors is small.
(ii) Correction by Retransmission:here receiver detects occurrence of an error &asks sender to resend
message . Resending is reported until amsg arrives that receiver believes is error or tree.

CODING : Redundancy is achieved through various coding schemes. Sender addsredundant bits through a
process that creates a relationship between redundant bit & actual data bits. Receiver checks relationship
between two sets of bits to detect or correct errors. Ratio of redundant bits to data bits & robustness of
process are important factors in any coding scheme.

MODULAR ARITHMETIC: In modular arithmetic we use only a limited rangeof integers. We define an
upper limit, called a modules-N. We then use only integers 0 to N-1 inclusive. This is modulo-N
arithmetic.

BLOCK CODING: In block coding, we derived on msg in to blocks each of K-bits, called data words. We
add r redundant bits to each block to make length [r=k+r]. The resulting r-bit blocks are called code words.
We have a set of data words each of size K & a set of code words, each of size n. With K bits we can create
a combination of 2k data words we can create a combination of 2 k code words. Since n>k, the no of possible
code words is longer then no. of possible data words. Block coding process is always encoded as the save
codeword. This means that we have 2 n-2k codeword are not used. These codeword are known as INVALED
or ILLEGAL.
HAMMING DISTANCE: It is one of central concept in coding for error control.It is the no. of differences
between corresponding bits (between two words). We show Hamming distance between two words x & y as
d(x,y). It can easily be found if we apply XOR operation or the two words & count the no. of 1’s in the reset.
Its value is grater then zero.

MINIMUM HAMMING DISTANCE: It is the smallest hamming distancebetween all possible pairs
in set of words. We use dmin to define the minimum hamming distance in a coding scheme.

HAMMING DISTANCE ERROR: When a codeword is corrupted duringtransmission, hamming


distance between sort &received code word is to of bits affected by error. e.g. if codeword 00000 is sent
& 01101 is received 3 bits are in error & hamming distance between two is d(00000,01101)=3.
18
Page

MINIMUM DISTANCE FOR ERROE CORRECTION: When a receiverreceived an invalid


codeword, the receiver needs to decide which valid codeword was a actually sent. The decision is based or
Department Of Computer Science and Engineering
concept of territory or exclusive area surrounding codeword. To guarantee correction of up to t error in all
cases minimum hamming distance in a block code must be [for in = 2t+1].

LINEAR BLOCK CODES:In a linear code XOR of any two valid code wordscreates another valid code
words.

MINIMUM DISTANCE LINEAR BLOCK CODES: The minimum hamming distance is no. of 1’s in
nonzero valid code words with the smallest number of 1’s.

CYCLIC CODE: These are special linear block codes with are extra property. Ina cyclic code, if a code
word is cyclically shifted (rotated) the result is another code word e.g., if 1011000 is a code word &
cyclically left-shift, then 0110001 is also a code word if we call bits is the first word a0 to a6 & bits is
second word bo to b6 can shift the bits by using following.

b1 = Q0 , b2= Q1 , b3 = Q2 , b4 = Q3 , b5 = Q4 , b6 = Q5 , b0 = Q6

CYCLIC REDUNDENCY CHECK: We can create codes to correct error. CRC is used is network
services LANS & WANS.
PROGRAM FOR CALCULATION OF CRC (CYCLIC RECIDENCY CHECK).

#include<stdlib.h>

#unclude<conio.h>

#include<stdio.h> void main ()


{

inti, j, n, g, a, arr [20], gen [20], b [20], q [20], s; clrscr ();

printf (“Transmitter side:”); printf (“\n enter 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\t the generator matrix”); for (j=0; j<g; j++);

printf (“%d”, gen *j+); a= r+(j-1);


19
Page

printf (“\n\t The oppended matrix is “); arr [n+i] =0;


Department Of Computer Science and Engineering
for (i=0; i<a; ++i) printf (“%d”, arr*i+); for (i=0; i<n; ++i) g[i] = arr[i]

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

{
if (arr [i]==o)

for (j=i; j<g+i; ++j) arr [i] =arr [i] 0;

}
else
arr [i] = arr [i] gen [0];

arr [i+1] = arr [i+1] gen [1]; arr [i+2] = arr [i+2] gen [2]; arr [i+3] = arr [i+3] gen [3];

}
}
printf (“\n\t The CRC is:”);

for (i=n; i<a; ++i) printf (“%d”, arr*i+); s = n+a;

for (i=n; i<s; i++) g [i] = arr[i] printf(“\n”);

for (i=0; i<a; i++) printf (“%d”, g*i+); getch ();

OUTPUT

Transmitter site: Enter no of data bits: 8 Enter data: 10100001

Enter size of generator: 4 Enter generator: 1001

The generator matrix: 1001

The oppendedmatrix: 101000010000 The CRC is :111

10100001111
20
Page
Department Of Computer Science and Engineering

Experiment No.-6

AIM: To implement various type of framing method.


Description:
Framing in data link large separate a message from one source to a destination or from other message to
other destinations, by adding a sender address & a destination address. The destination address defines
where the packet is to go. The sender address helps the recipient acknowledge the receipt. Although the
whole message could be packed in one frame, that is not normally done. When a message is carried out in
one very large frame even a single bit error would require the retransmission of whole message. When a
Message is divided into smaller frames single bit error affects only that small frame.

FIXED SIZE FRAMING:


There is no need for defining the boundaries of the frame, the size itself can be used as a delimiter. An
example of this type of framing is ATM wide area network, which use frames of fixed size called cells.

VARIABLE SIZE FRAMING:


It is prevalent in local area network. Here defines the end of the frame & beginning of the next. Historically
two approaches were used for this purpose: A character oriented approach & A bit oriented approach.

CHARACTER ORINTED PROTOCOLS:


Here data to be carried on 8 bit characters from a coding system such as ASCII.The header, which
normally carries the source & destination addresses & other control information & the trailer which
carries error detection on error correction redundant bits are also multiples of 8 bits. To separate one
frame from the next 8-bit flag is added at the beginning 8 the end of the frame. The flag composed of
protocol dependent special characters, signals start or end of the frame. The following figure shows the
format of a frame in a character-oriented protocol.

Character-oriented framing was popular when only text was exchanged by the data link layers. The flag
could be selected to be any character not used for text communication. However, if we send other types of
information such as graphs, audio, and video. Any pattern used for the flag.

could also be part of the information. If this happens, the receiver, when it encounters this pattern in the
middle of the data, thinks it has reached the end of the frame.

To fix this problem, a byte-stuffing strategy was added to character-oriented framing. 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
21

same pattern as the flag. The data section is stuffed with an extra byte. This byte is usually called the escape
Page
Department Of Computer Science and Engineering
character (ESC), which has a predefined bit pattern. Whenever the receiver encounters the ESC character, it
removes it from the data section and treats the next character as data, not a delimiting flag.

Byte stuffing by the escape character allows the presence of the flag in the data section of the frame, but it
creates another problem. What happens if the text contains one or more escape characters followed by a
flag? The receiver removes the escape character, but keeps the flag, which is incorrectly interpreted as the
end of the frame. To solve this problem, the escape characters that are part of the text must also be marked
by another escape character. In other words, if the escape character is part of the text, an extra one is added
to show that the second one is part of the text. The following figure shows the situation.

Character-oriented protocols present another problem in data communications. The universal coding systems
in use today, such as Unicode, have 16-bit and 32-bit characters that conflict with 8-bit characters. We can
say that in general, the tendency is moving toward the bit-oriented protocols.

BIT ORINTED PROTOCOLS:


In this data section of a frame is a sequence of bits to be interpreted by upper layer as text, graphics, audio,
video & so on. However in addition to letters (& possible trailers), we still need a delimiters to separate one
frame from the other. Most protocol used a special 8 bit pattern flag 0111110 or the delimiter to define
beginning & end of the frame.

This flag can create the same type of problem we saw in the byte-oriented protocols. That is, if the flag
pattern appears in the data, we need to somehow inform the receiver that this is not the end of the frame. We
22

do this by stuffing 1 single bit (instead of 1 byte) to prevent the pattern from looking like a flag. The strategy
Page
Department Of Computer Science and Engineering
is called bit stuffing. In bit stuffing, if 0 and five consecutive 1 bits are encountered, an extra 0 is added.
This extra stuffed bit is eventually removed from the data by the receiver. Note that the extra bit is added
after one 0 followed by five 1s regardless of the value of the next bit. This guarantees that the flag field
sequence does not inadvertently appear in the frame.

The following figure shows bit stuffing at the sender and bit removal at the receiver. Note that even if we
have a 0 after five 1s, we still stuff a 0. The 0 will be removed by the receiver.

This means that if the flag like pattern 01111110 appears in the data, it will change to 011111010
(stuffed) and is not mistaken as a flag by the receiver. The real flag 01111110 is not stuffed by the sender
and is recognized by the receiver.

23
Page
Department Of Computer Science and Engineering
Experiment No.-7

AIM: To study tool command language (TCL).

Description:

TCL has become a popular choice of programming language for a diverse range of applications. This is a
platform used in UNIX, MICROSOFT, WINDOWS AND APPLE MAC OS.

Now we see how to write TCL program:

Here is a “GOOD MORNING” Program

Good.tcl

Set s “good morning”

Put $s

TCL is an interpreted language & TCL program are referred to as scripts.TCL scripts have to be
executed by a TCL shell, known as a tcls1
The following will run a good.tcl script

$tclsc1 good.tcl

Good morning

The source command can be used to make tcls1 take command from a file let us make TCL read our
program again.

$ source. Good.tcl

Good Morning

% ext

Ext command causes TCL shell to end & returns us to TCL Unix Shell. We can turn out script into a Unix
program by specifying interpreter to use an the first line.
Save following in a file, say good1.tcl
# /usr/bin/tclsh

Set s “good Morning Dear”

Put $s

After making script executable .we can run it in usual way


24

$ chmod +x good1.tcl
Page

$ good1.tcl
Department Of Computer Science and Engineering

Good Morning Dear

It is important to note that location of TCL shell tclsh, may vary from system to system. In our case, it has
been installed in /usr/bin.

TCL COMMANDS
Generally all TCL commands take same form. They always begin with a keyword followed by zero or more
arguments. TCL is easy to learn & simple to extend. One can place multiple TCL commands on the same
line by separating them with semicolon. TCL deals with strings & groups of strings.

VARIOUS TCL COMMANDS

1. To assign to a variable, we can use set command.


$ tclsh

% set a 999 999

% set my_name Nameless Nameless

%
Variable names are case sensitive & they can be of any length.

2. To use value of a variable in another command, we prefix its name with

a$

% put s $ a

999

3. To use result of one command in another, we place command in square brackets


% puts [expr $a+ expr $a]

4. We can remove a variable from TCL interpreter by using a set.

5. A variable is replaced with its value whenever its name appears preceded by a dollar sign.

6. TCL provides a command expr to perform arithmetic calculations.


25
Page
Department Of Computer Science and Engineering
Experiment No.- 8

AIM:- Study and Installation of Standard Network Simulator: N.S-2.

Description:

Network Simulator 2 Installation Procedure

Network Simulator 2 (NS2) is a program designed to enable the simulation of networking scenarios without
having the actual hardware. It can be used to test many aspects of a networking environment including the
development of new protocols.

The program it self is notoriously difficult to install and runs on either windows (using Cygwin or the native
windows version) or Linux. For the purpose and functionality of NS2, Cygwin is the preferred method of
running NS2 within windows.

Cygwin Install
1. Go to http://www.cygwin.com/ and download the latest version (Latest Cygwin DLL release version is
1.5.22-1)
2. Run setup.exe

3. Select “Install from Internet” then click next

4. Leave the all the default entries including the install directory as this makes things a little easier when
browsing the computer via XWindows.
26
Page
Department Of Computer Science and Engineering

5. Install local package (This is the default install directory where files are stored and extracted for later
use… This is not essential as all programs can be retrieved from the internet so this folder can be deleted to
save space but is good to keep)

6. Select the connection method


27
Page
Department Of Computer Science and Engineering

7. Select a mirror (a UK mirror is best for the UK)

7. Select packages
28
Page
Department Of Computer Science and Engineering

Accept all the defaults but you need to add all 9 of these extra packages

Automake

Make

Patch

Perl

X86 libraries

Window Maker

All GCC components

Nano Text editor (Optional… If you are not used to VI or other UNIX editors)

Xgraph (optional, but needed for test suites)

8. Click next and accept any dependencies and next again…


Cygwin will now download
29
Page
Department Of Computer Science and Engineering

This may take a while depending on the speed of your Internet connection and the speed of your system as
this stage will extract and finalize the install.

NS2 Install

Firstly run up Cygwin and make sure that all is ok. Run XWindows and some application that works within,
try xclock.
30

Try running a windows manager, I selected Windows Maker during the install selection as this I my
preferred method.
Page
Department Of Computer Science and Engineering

Now go to http://www.isi.edu/nsnam/dist/ns-allinone-2.29.2.tar.gz and download the file (Direct link to the


file)

Copy this to C:\cygwin\home\%USERNAME%

Then go to Cygwin and go to the directory where you just downloaded the file and type the command
between the parenthesis including the space and hyphen at the end.

( gzip -d -c ns-allinone-2.29.2.tar.gz | tar xvf - )

Once this has finished (can take a long time depending on system speed)
cd in to the directory just created “/home/%USERNAME%/ns-allinone-2.29”
Now type the command (./install) dot slash install.
Let NS2 run the course, this can also take a while.

Environmental Variables

The next step is to add the Environmental Variables

To do this you have to go to your home directory and locate the file .bashrc
The .bashrc in this directory is your login script. You can change shells, set bash scripts and add
environmental variables.

I use the UNIX file editor VI if you are not familiar with VI I advises you to use the NANO editor as this is
an easier interface to use.

You can also use a windows editor if you browse to the path c:\cygwin\home\%USERNAME% and edit
the .bashrc files

31

The add these lines but be sure to change the directories to the same as your systems set up and be sure to
change any version numbers.
Page

export NS_HOME=/home/%USERNAME%/ns-allinone-2.29
Department Of Computer Science and Engineering

export PATH=$NS_HOME/tcl8.4.11/unix:$NS_HOME/tk8.4.11/unix:$NS_HOME/bin:$PATH
export LD_LIBRARY_PATH=$NS_HOME/tcl8.4.11/unix:$NS_HOME/tk8.4.11/unix:\$NS_HOME/otcl-
1.11:$NS_HOME/lib:$LD_LIBRARY_PATH
export TCL_LIBRARY=$NS_HOME/tcl8.4.11/library

Reload Cygwin, and then type “which NS” and “which NAM”. If you get a path shown then you are ok if
not you will have to check your paths again.

32
Page
Department Of Computer Science and Engineering

Experiment No.- 10
AIM:- Configure 802.11 WLAN.

Description:

Introduction
This document provides information on how 802.11n technology works and how to configure 802.11n on
the Wireless LAN Controller (WLC).
Prerequisites
Requirements
Cisco recommends that you have knowledge of these topics:
 How to configure a WLC for basic operations
 Lightweight Access Point Protocol (LWAPP)
Components Used
The information in this document is based on these software and hardware versions:
 WLC 4404 that runs software version 5.1.151.0
 Cisco Aironet 1250 series Access Point (AP)
 Intel Wireless client card adapter
The information in this document was created from the devices in a specific lab environment. All of the
devices used in this document started with a cleared (default) configuration. If your network is live, make
sure that you understand the potential impact of any command.
Related Products
This document can also be used with these hardware and software versions:
 Cisco 2100 series WLC
 Cisco Catalyst 6500 Series/7600 Series Wireless Services Module (WiSM)
 Cisco Catalyst 3750 Series Integrated WLCs
 Cisco WLC Module
Conventions
Refer to Cisco Technical Tips Conventions for more information on document conventions.

802.11n - An Overview
33

Wireless networks are widely deployed in industrial and domestic environments. New applications are
Page

emerging to meet customer needs. Many of these applications are bandwidth intensive. Multimedia
Department Of Computer Science and Engineering
applications require more bandwidth for improved performance. 802.11n addresses these challanges by
providing throughput as high as 600 Mbps. It also provides better reliability and coverage when compared to

existing 802.11 a/b/g technology. This document provides an overview of how 802.11n works and how to
configure 802.11n on a WLC.
802.11n can operate either in 2.4 or 5 GHz. They are interoperable with existing 802.11a or 802.11 b/g
technologies. This section provides an overview of how 802.11n works. Currently, 802.11n is supported in
Cisco 1250 series APs and Cisco 1140 series APs.
How Does 802.11n Provide Greater Throughput
Various techniques are employed in 802.11n to provide higher data rates and better coverage. This section
details the techniques used.
MIMO: In the existing 802.11 a or 802.11 b/g technologies, transmission and reception of data streams
usually happen using only one of the antennas. However, in 802.11n data streams can be transmitted and
received over both the antennas. This results in a greater number of bits transmitted and received at a given
point of time, effective usage of multipath signals which is usually a problem in indoor coverage. This leads
to increased throughput and wider coverage. Table 1 shows the data rates of 802.11n currently supported by
Cisco1. MCS 0-7 are the data rates achieved using single spatial stream (data bits). MCS 8-15 are the data
rates achieved using 2 spatial streams, one over each antenna. Note that the data rates are doubled from 8-
15. These data rates (0-15) are described as MCS rates throughout this document.
Note: 1Further higher data rates are planned for future deployments.
Channel Bonding: The amount of data that can be transmitted also depends on the width of the channel
used in data transmission. By bonding or combining two or more channels together, more bandwidth is
available for data transmission. In 2.4 and 5 GHz frequency band, each channel is approximately 20 MHz
wide. In 802.11n, two adjacent channels, each of 20 MHz are bonded to get a total bandwidth of 40 MHz.
This provides increased channel width to transmit more data. Cisco does not support channel bonding in 2.4
GHz frequency (802.11 b/g), because only three nonoverlapping channels 1, 6 and 11 are available.
However, the channel bonding has more relevance in 5 GHz frequency range where you have as many as 23
adjacent non-overlapping channels currently available. Channel bonding is supported only in 5 GHz, for
example 802.11a. Table 2 shows the data rates achieved through channel bonding.
Frame Aggregation with A-MPDU: In 802.11, after transmission of every frame, an idle time called
Interframe Spacing (IFS) is observed before transmitting the subsequent frame
In 802.11n, multiple packets of application data are aggregated into a single packet. This is called A-MPDU
(Aggregated - MAC Protocol Data Unit). This reduces the number of IFS, which in turn provides more
time for data transmission. In addition, clients operating in 802.11n send acknowledgement for block of
packets instead of individual packet acknowledgement. This reduces the overhead involved in frame
acknowledgements and increases the overall throughput.
Decreased Timers: In 802.11n, few timers have been reduced to decrease the idle time between individual
frame transmissions.
1. Guard Interval (GI): In 802.11, data is transmitted as individual bits. A certain amount of time interval
is observed before the next bit is transmitted. This is called Guard Interval. GI ensures that bit transmissions
do not interfere with one another. As long as the echoes fall within this interval, they will not affect the
receiver's ability to safely decode the actual data, as data is only interpreted outside the guard interval. By
34

reducing this interval, data bits are transmitted in shorter intervals and provide for increased throughput.
Page

Table 1 shows how data rates differ based on the Guard Interval for a channel width of 20 MHz.
Department Of Computer Science and Engineering

Table 2 shows how data rates differ based on the Guard Interval for a channel width of 40 MHz.
Note: You can see that data rates are doubled from MCS 8 - MCS 15.

35
Page

2. IFS: IFS is less in 802.11n when compared to 802.11.


Department Of Computer Science and Engineering
Guidelines for 802.11n Deployment
Keep these guidelines in mind when you deploy 802.11n:

1. Use QoS for LWAPP packets to ensure APs do not lose heartbeats with the controller due to a heavy load
added by 802.11n.
2. LAPs can be powered using a local power supply, power injector or an 802.3 af capable switch. 1140
series APs are easy to deploy as these APs can be fully powered using the existing 802.3 af standard.
However, in 1250 series APs, dual-band products (APs with both 802.11b/g/n and 802.11a/n radios) cannot
be fully powered by 802.3af and require 802.3at or a power injector to operate both transmitters in each
band.
802.3af can either support both transmitters on an AP with a single radio (either 802.11b/g/n or 802.11a/n),
or 802.11n with a single transmitter in each band (802.11b/g/n and 802.11a/n).

Note: M8 to M15 data rates are disabled because they require both transmitters in the band to be
operational.
3. 1250 series APscan support 802.11n with reduced power (11 dBm) for both transmitters in each band
(802.11b/g/n and 802.11a/n).
a. Requires Cisco switches with Enhanced POE (16.8W) and CDP.
b. M0 to M15 data rates are reduced due to reduced power but are still enabled.
4. Use only 20 MHz 802.11n mode in 2.4 GHz. Cisco supports both 20 MHz and 40 MHz (Channel
bonding) 802.11n mode only in 5GHz..
5. Use 20 MHz (Non-Channel Bonding) in 5 GHz (802.11 a/n) when:
a. Voice traffic is using 802.11a
b. 20 MHz is better in mixed .11a and .11n environments
6. Use 40 MHz (Channel Bonding) in 5 GHz (802.11a/n) when:
a. Traffic uses heavy bandwidth (video)
b. 40 MHz is better when most clients are 802.11n
Configuring 802.11n
Configure the WLC for 802.11n
This section shows how to configure the 5 GHz frequency band on the WLC for 802.11n support. Complete
these steps:
Note: These steps are similar for 2.4 GHz frequency band except that occurrences of 802.11a should be
replaced with 802.11 b/g.
1. Enable the 802.11n support on the 802.11a network.
36

(Cisco Controller)>config 802.11a 11nsupport enable


Page

Note: Before you enable 802.11n support, the 802.11a network needs to be disabled.
Department Of Computer Science and Engineering
3. 802.11n operates on the same channel as 802.11a. For better compatibility with 802.11n clients, it is
recommended to stay on lower channels (UNII-1 band). Check the list of channels used in channel
allocation for APs from the DCA Channel List menu under Wireless > 802.11a/n >DCA on the
WLC GUI. In order to include or delete a channel from the list, use the Select Channel list.

3. You can also manually configure the channel for an individual lightweight access point (LAP). This helps
to control the channel in an environment where only 802.11n clients connect. This makes troubleshooting
easier. Use this command:
(Cisco Controller) >config 802.11a channel AP001b.d4e3.a81b 36
!--- Sets 802.11a channel to 36 on AP AP001b.d4e3.a81b.
4. Channel bonding in 802.11a provides twice the normal throughput. You bind a channel with the next
adjacent channel in the frequency domain.
This is an example of channel bonding. Here the channel 36 is bonded with the adjacent channel to provide a
channel width of 40 MHz.
(Cisco Controller)> config ap <AP Name>
(Cisco Controller)> config 802.11a disable <Ap name>
(Cisco Controller)> config 802.11a channel <Ap name> 36
Set 802.11a channel to 36 on the specified AP.
(Cisco Controller)> config 802.11a txpower <Ap name> 1
37

Sets power on the AP.


Page

(Cisco Controller)> config 802.11a chan_width <Ap name>


Department Of Computer Science and Engineering
40
Here you have an option of configuring channel width
(Cisco Controller)> config 802.11a enable <Ap name>

(Cisco Controller)> config ap enable <Ap name>


In order to check if this has worked, use the show ap config 802.11a <ap name> command. This command
shows the list of parameters that
are specific to 802.11a. The Extension channel field under the PHY OFDM parameters displays the
channel bonded to the Current operating
channel of the AP.
5. Use these commands to configure the features that are specific to 802.11n:
(Cisco Controller) >config 802.11a 11nSupport a-mpdu tx priority <0-7/all> enable/disable
(This enables the aggregation of frames(A-MPDU) for the traffic of priority levels 0-7)
(Cisco Controller) >config 802.11a 11nSupport mcs tx <0-15>
(This configures the 802.11n rates at which data is transmitted between the access point and the cl
Configure the Client for 802.11n
Many of the client cards operate in 2.4 GHz. Make sure you use the client card that supports 5 GHz to make
use of channel bonding.
These steps show how to configure an Intel Card for 802.11n on an XP machine:
1. Click the Start menu. Go to Settings and choose Control Panel.
2. Double-click the Network Connections icon.
3. Right-click the Intel Wireless Card and click Properties.
4. Click the Advanced tab.
5. Choose the Use the default value option for the Wireless Mode property so the client can operate either in
802.11a mode or in 802.11 b/g mode, whichever is available.
38
Page
Department Of Computer Science and Engineering

6. Unless the network is comprised only of 802.11n clients, use Mixed mode protection so the 802.11n
clients coexist with existing 802.11a or 802.11 b/g clients.

7. Set the Channel Width either in Auto mode so the client negotiates the channel width with the WLC,
or in 20 MHz if it is 2.4 GHz frequency band.
39
Page
Department Of Computer Science and Engineering

Note: Cisco supports 40 MHz only in 5 GHz band. Set the channel width option to Auto to make use of 40
MHz channel width. However, make sure 40 MHz channel width is enabled on the WLC.
8. Disable the Fat Channel Intolerant property to allow 40 MHz Channel Bonding.

Factors that Affect 802.11n Throughput


There are circumstances where 802.11n devices cannot operate at their maximum capable data rates. There
are various reasons why this occurs. This is the list of factors that affect 802.11n throughput:
1. When 802.11n clients operate in a mixed environment with 802.11a or 802.11 b/g clients, 802.11n
provides a protection mechanism to interoperate with 802.11a or 802.11 b/g clients. This introduces an
overhead and reduces the throughput of 802.11n devices. Maximum throughput is achieved in Greenfield
40

mode where only 802.11n clients exist.


Page
Department Of Computer Science and Engineering

2. Factors such as Channel width, Guard Interval and Reduced IFS (RIFS) play a major role in the
bandwidth. Table 1 and Table 2 show how these factors affect the bandwidth.
3. Clients ability to send a Block Ack instead of individual frame acknowledgements.
4. MCS Index configured on the WLC.
5. Proximity to AP—Clients closer to the AP experience higher data rates. As clients move farther away
from the AP, signal strength reduces. As a result, data rate decreases steadily.
6. RF environment—Amount of noise and interference in the environment. The less the noise and
interference, the greater the bandwidth.

7. Encryption/ Decryption—Encryption in general reduces the throughput due to the overhead involved in
the data encryption/decryption process. However, advanced encryption standards, such as AES, can provide
better throughput when compared to other encryption standards, such as TKIP and WEP.
8. Wired Network Infrastructure—Bandwidth of the wired infrastructure determines the speed of the traffic
to and from the wired network to the wireless clients.
9. If using an AP1250, change the AP to H-REAP mode for a 5-10% boost.
10. If using an AP1140, keep the AP in local mode and enable TCP MSS on the controller. Use the config
ap tcp-adjust-mss enable all 1363 command in order to enable it.
11. Disable RRM scanning to prevent any throughput drops when going off channel. This can yield a 1-3%
improvement.
12. Disable RLDP to ensure the AP does not attempt to connect to rogue devices during testing.
13. Use a Wireless Controller 5508 as the data plane is superior to the 4404-series.
Verify
You can check the connection status, speed, mode and signal strength of a client both from the WLC and the
client.
1. If you use an Intel client, right-click the Wireless icon in the System Tray (bottom right corner of the
desktop) in order to view the wireless mode. Then, click Status and check the band. In order to check the
speed of client operation, right-click the Wireless icon and click View Available Wireless Networks. Click
the SSID and check the speed as shown here:
41
Page
Department Of Computer Science and Engineering

2. On the WLC GUI, click Monitor. Then, click Clients in the left side. This displays the list of clients
currently associated to the WLC. Next, click on a client to check the mode, speed and other details of its
connectivity.

Troubleshoot
Unable to Achieve 802.11n Data Rates
One of the most common issues is that you cannot achieve the maximum throughput in 802.11n. Perform
these checks:
1. 802.11n requires AES encryption to be enabled on WLANs used by 802.11n clients. You can use a
WLAN with NONE as Layer 2 Security. However, if you configure any Layer 2 security, 802.11n requires
WPA2 AES enabled to operate at 11n rates.
42
Page
Department Of Computer Science and Engineering

Note: If you have legacy clients, you can enable WPA TKIP to provide interoperability.
2. Make sure the AP has enough power. Lower power on the AP results in lower signal strength, which
decreases the throughput.
3. Make sure the 802.11n rates are enabled. MCS rates should be enabled (this is recommended to keep all
of the MCS rates enabled).

43
Page
Department Of Computer Science and Engineering

4. Make sure that the AP has 2 external antennas to avail the data rates MCS 8-15 as shown in the previous
figure.
5. Ensure that WMM is set to Allowed on the WLAN profile in order to achieve 802.11n rates.
Clients Cannot Connect to the WLC
Issues in 802.11n networks are similar to that of the 802.11 network as far as the connectivity is concerned.
Perform these checks:
1. Make sure that the LAP has joined the controller and all radios are up. Check this under Wireless > All
APs.
2. Make sure that the WLAN is enabled and configured to All under Radio Policy in order to operate in both
2.4 GHz and 5 GHz band.

44
Page
Department Of Computer Science and Engineering

Experiment no.-10

AIM:- Implement &simulate various types of routing algorithm.

Description:
Routing is the process of getting information packets where they need to go. Routing is a surprisingly
complicated task, and there are a number of different algorithms used to find the shortest route between
two points.IP addressing is based on the concept of hosts and networks. A host is essentially anything on
the network that is capable of receiving and transmitting IP packets on the network, such as a workstation
or a router. Routing is a process of moving data from one host computer to another. The difference
between routing and bridging is that bridging occurs at Layer 2 (the link layer) of the OSI reference
model, whereas routing occurs at Layer 3 (the network layer). Routing determines the optimal routing
paths through a network.

Routing Algorithms
The routing algorithm is stored in the router's memory. The routing algorithm is a major factor in the
performance of your routing environment. The purpose of the routing algorithm is to make decisions for the
router concerning the best paths for data. The router uses the routing algorithm to compute the path that
would best serve to transport the data from the source to the destination. Note that you do not directly
choose the algorithm that your router uses. Rather, the routing protocol you choose for your network
determines which algorithm you will use. For example, whereas the routing protocol Routing Information
Protocol (RIP) may use one type of routing algorithm to help the router move data, the routing protocol
Open Shortest Path First (OSPF) uses another. The routing algorithm cannot be changed. The only way to
change it is to change routing protocols. The overall performance of your network depends mainly on the
routing algorithm, so you should research the algorithms each protocol uses before deciding which to
implement on your network. There are two major categories of routing algorithms - distance vector or link-
state. Every routing protocol named "distance vector" uses the distance vector algorithm, and every link-
state protocol uses the link-state algorithm.

DISTANCE VECTOR ALGORITHMS

45
Page
Department Of Computer Science and Engineering

Distance vector algorithm uses metrics known as costs in order to help determine the best path to a
destination. The path with the lowest total cost is chosen as the best path.When a router utilizes a distance
vector algorithm, different costs are gathered by each router. These costs can be completely arbitrary
numbers. Costs can also be dynamically gathered values, such as the amount of delay experienced by routers
when sending packets over one link as opposed to another. All the costs are compiled and placed within the
router's routing table and then they are used by the algorithm to calculate a best path for any given network
scenario.Although there are many resources that will offer complex mathematical representations of what
distance vector algorithms are and how they compute their decisions, the core concept remains the same - by
adding the metrics for every optional path on a network, you will come up with at least one best path. The
formula for this is as follows:

M(i,k) = min [M(i,t) + M(t,k)]

This formula states that the best path between two networks (M(i,k)) can be found by finding the lowest
(min) value of paths between all network points. Let's look again at the routing information in the table
above. Plugging this information into the formula, we see that the route from A to B to C is still the best
path:

5(A,C) = min[2(A,B) + 3(B,C)]

Whereas the formula for the direct route A to C looks like this:

6(A,C) = min[6(A,C)]

LINK-STATE ALGORITHMS

Link-state protocols work in more localized manner. Whereas a router running a distance vector algorithm
will compute the end-to-end path for any given packet, a link-state protocol will compute that path as it
relates to the most immediate link. That is, where a distance vector algorithm will compute the lowest metric
between Network A and Network C, a link-state protocol will compute it as two distinct paths, A to B and B
46

to C. This process is very efficient for larger environments. Link-state algorithms enable routers to focus on
their own links and interfaces. Any one router on a network will only have direct knowledge of the routers
Page

and networks that are directly connected to it (or, the state of its own links). In larger environments, this
Department Of Computer Science and Engineering
means that the router will use less processing power to compute complicated paths. The router simply needs
to know which one of its direct interfaces will get the information where it needs to go the quickest. The
next router in line

will repeat the process until the information reaches its destination. Another advantage to such localized
routing processes is that protocols can maintain smaller routing tables.

In Link-State Algorithms, every router has to follow these steps:

1. Identify the routers that are physically connected to them and get their IP addresses When a router starts
working, it first sends a "HELLO" packet over network. Each router that receives this packet replies with a
message that contains its IP address.
2. Routers measure the delay time (or any other important parameters of the network, such as average
traffic) for neighbor routers. In order to do that, routers send echo packets over the network. Every router
that receives these packets replies with an echo reply packet. By dividing round trip time by 2, routers can
count the delay time. The delay time includes both transmission and processing times - the time it takes the
packets to reach the destination and the time it takes the receiver to process it and reply.

3. Broadcast its information over the network for other routers and receive the other routers' information.
In this step, all routers share their knowledge and broadcast their information to each other. In this way,
every router can know the structure and status of the network.

4. Routers use an appropriate algorithm to identify the best route between two nodes of the network. In this
step, routers choose the best route to every node. They do this using an algorithm, such as the Dijkstra
shortest path algorithm. In this algorithm, a router, based on information that has been collected from other
routers, builds a graph of the network. This graph shows the location of routers in the network and their
links to each other. Every link is labeled with a number called the weight or cost. This number is a function
of delay time, average traffic, and sometimes simply the number of hops between nodes. For example, if
there are two links between a node and a destination, the router chooses the link with the lowest weight.

The Dijkstra algorithm goes through the following steps:

1. The router builds a graph of the network. Then it identifies source and destination nodes, for example
R1 and R2. The router builds then a matrix, called the "adjacency matrix." In the adjacent matrix, a
coordinate indicates weight. [i, j], for example, is the weight of a link between nodes Ri and Rj. If
there is no direct link between Ri and Rj, this weight is identified as "infinity."
2. The router then builds a status record for each node on the network. The record contains the
following fields fields:
o Predecessor field - shows the previous node.
o Length field - shows the sum of the weights from the source to that
node.
o Label field - shows the status of node; each node have one status mode: "permanent"
or "tentative."
3. In the next step, the router initializes the parameters of the status record (for all nodes) and sets their
label to "tentative" and their length to "infinity".
4. During this step, the router sets a T-node. If R1 is to be the source T-node, for example, the router
changes R1's label to "permanent." Once a label is changed to "permanent," it never changes again.
5. The router updates the status record for all tentative nodes that are directly linked to the source T-
node.
47

6. The router goes over all of the tentative nodes and chooses the one whose weight to R1 is lowest.
That node is then the destination T-node.
Page

7. If the new T-node is not R2 (the intended destination), the router goes back to step 5.
Department Of Computer Science and Engineering
8. If this node is R2, the router extracts its previous node from the status record and does this until it arrives
at R1. This list of nodes shows the best route from R1 to R2.

48
Page
Department Of Computer Science and Engineering

Experiment No.-11
AIM:- Study & Simulation of MAC Protocols like Aloha, CSMA, CSMA/CD and CSMA/CA using
Standard Network Simulators

Description:

1 Introduction
The paper is organized as follows. In section 1, we discuss the various network layers. In section 2, we look
at the common Medium Access Control (MAC) protocols used. The next three sections discuss some of the
analytical, simulation, and experimentation techniques used for performance evaluation of MAC protocols.
1.1 Open Systems Interconnection Model
The OSI model [11] is generally referred to as the OSI reference model (Figure 1). It presents an abstract
model of network protocol layers and is helpful in the design of network protocols. Every layer provides
some functions (interfaces) which are used by the layer above it. This structure is often referred to as a
protocol stack.

Fig. 1 - OSI protocol stack


The OSI standard consists of 7 layers:
7. Application Layer - This is where the user applications are run. Some common applications are FTP,
HTTP, etc.
6. Presentation Layer - Data in the network can be represented in many different formats. It can differ in the
encryption used, MIME encoding, etc. This layer this presents the application layer a uniform interface by
hiding these differences.
5. Sessions Layer - It is responsible for creating, maintaining and terminating connections between the local
49

host and a remote host. It supports half-duplex or full duplex operation.


Page
Department Of Computer Science and Engineering
4. Transport Layer - This layer is responsible for providing the transportation of data between the source and
the destination. The service can be connection oriented or connectionless. It also performs fragmentation and
error control.
3. Network Layer - It is responsible for transferring packets between various networks. It provides for
various routing decisions, as well as addressing and internetworking.
2. Data Link Layer - This layer is responsible for delivery of frames to the next hop destination. It also tries
to correct any errors introduced by the physical layer. This layer is often divided into two layers: Medium
Access Control (MAC) and Logical Link Control (LLC). LLC is responsible for frame synchronization,
flow control and error checking. The MAC decides which node gets access to the channel and who transmits
when.
1. Physical Layer - It deals with the actual transmission of bits over the medium in the form of electrical
signals.
TCP/IP reference model - This is also referred to as the Internet reference model. Compared to the OSI
model, it has fewer
layers, but it provides an easy fit for real World products. The model defines 4 layers: Application layer,
Transport Layer, Internetworking Layer, and the Network Access Layer.

2 Medium Access Control


As discussed previously it is responsible for controlling access to the channel amongst various entities. Its
role is important in networks where multiple users can transmit at the same time over the same channel
(Ethernet segment, same radio channel, etc.), such as IEEE 802.11, Bluetooth, etc.
Various MAC protocols have been defined in literature that employ different techniques to regulate access.
They can be grouped into two categories: distributed and centralized. In the former, each node decides on its
own when is the best time for it to transmit such that it is the only one which transmits to avoid collision.
These are also referred to as random access protocols. If multiple nodes transmit, then these protocols
provide mechanisms to resolve the collision.
In the centralized version, a node is responsible for deciding who can access the channel, and the duration
for which that node has control over the channel. The centralized node is generally referred to as a base
station (BS). There are two ways to provide access to other nodes. One is in a round-robin fashion. Here the
BS would poll every node periodically to find if it has data to transmit or not. The other can be a Request-
Grant mechanism wherein the nodes contend to send channel access requests to the base station. The BS
then allocates a time slot for every node from which it would have received the request. The next section
details out some of the commonly used MAC protocols.
2.1 Aloha
Aloha is based on the principle that if you have data to send, send it. If there is a collision then the protocol
resends the data at a latter time. This leads to degraded channel utilization since multiple nodes may transmit
at the same time. An improvement of this protocol is the slotted Aloha, as discussed in the next section. The
finite state machine for this protocol is given in figure 2.
50
Page
Department Of Computer Science and Engineering

Fig. 2 - State Transition Diagram of Aloha


Slotted Aloha is an extension of basic Aloha in which time is divided into discrete time slots. A node can
only transmit at the beginning of these time slots. This helps in reducing collisions.
2.2 CSMA
This stands for Carrier Sense Multiple Access with Collision Detection. In CSMA, before transmitting,
nodes listen for other traffic on the same shared medium. If they sense another node is transmitting, they
withhold their transmission. Once the other node's transmission has finished, the waiting node may proceed
to transmit. However, this still leaves a probability that multiple nodes may sense the channel idle and start
transmitting simultaneously.
2.3 CSMA/CD
CSMA with Collision Detection (CD) refers to the ability of the node to detect if and when a collision
occurs. When this happens, the transmitting node immediately stops its transmission. It then calculates a
random backoff time t, after which it tries to re-transmit its frame. Since multiple nodes each choose a
different t, this technique helps sort the problem of collisions. This protocol is used in 802.3 networks.
2.4 CSMA/CA Wireless networks do not employ CSMA/CD
but employ CSMA/CA (Collision Avoidance). The reason is that in the former the collision is detected at the
transmitter. However in wireless networks, it is important to detect collisions at the receiver side due to the
hidden node problem

2.4.1 Hidden Node Problem


Assume node A in figure 3 wants to transmit to B. Also, node C wants to transmit to B. Node A does carrier
sensing and decides the medium is free and starts its transmission to B. The transmission from node A can
reach node C but it can not reach node C. Hence when C does carrier sensing, it also assumes the channel to
be idle and starts transmitting for B. This causes a collision to occur at B. Authors in propose solving this
problem by the use of a two-way handshake. It requires the exchange of Request to Transmit (RTS) and
Clear to Transmit (CTS) packets between the sender and the receiver. The sender first transmits a RTS and
awaits a CTS packet before continuing with the transmission of data packets. RTS and CTS packets alert all
other nodes in the range of A and B that a transmission is going to occur. Furthermore, they also contain the
duration of the transmission hence no other nodes which have heard these RTS/CTS packets should attempt
51

to transmit in this duration.


Page
Department Of Computer Science and Engineering

Fig. 3 - The circles show the communication ranges of the nodes at the centers.
2.5 IEEE 802.11
This standard specifies the Distributed Coordination Function (DCF) which is based on CSMA/CA. A
transmitter must wait for a channel to be idle for Distributed InterFrame Space (DIFS) amount of time
before it can start to transmit. If the channel is sensed busy, either immediately or during the DIFS, it backs
off its transmission by a random amount of time to avoid collisions. The time after the DIFS period is slotted
and a node is allowed to transmit only at the start of a time slot. The backoff scheme is exponential. The
backoff time is uniformly chosen in the range (0, W), where W is the contention window (CW). W is
variable in nature and its initial
value (the first time a node has to backoff) is CWmin. Each time a node has to backoff for the same frame
after the first backoff, it doubles the contention window. There is a CWmax, beyond which the window is
not incremented.

Fig. 4 - Distributed Coordination Function (DCF) with 4 stations


52

DCF (Figure 4) uses ACKs sent by the destination to judge whether a frame was successfully received or
not. A maximum of 8 retries are allowed after which the frame is dropped from the interface queue.
Page
Department Of Computer Science and Engineering
Point Coordination Function (PCF) - This is a centralized MAC protocol which works over DCF. The BS
polls mobile nodes (MN) periodically. To ensure PCF traffic has priority over the DCF traffic, the BS waits
for Point InterFrame Space (PIFS) amount of time for the channel to be idle before transmitting, where PIFS
< DIFS.
2.6 MAC for sensor networks
Sensor-MAC (S-MAC) It has been designed for sensor networks where energy consumption is a major
criteria. In S-MAC, a node sleeps for a certain period of time and is awake for a certain period of time.
These periods repeat in cycles and the total time is the time taken to complete one cycle. Otherwise the
protocol is very similar to the DCF protocol as described above as it uses RTS/CTS for hidden terminals,
RTS/CTS/DATA/ACK cycle, randomized backoff time and carrier sensing. The basis of this protocol is not
to overhear frames which are not destined for it. It does this by going to sleep. A node co-operates with its
neighbors so as it knows when it can sleep and when it should be in the listening mode. Similar variants of
these protocols exist: Timeout (T-MAC), and Berkeley (B-MAC).
2.7 IEEE 802.16
This is a standard for Metropolitan Area Networks (MAN). The network consists of a Base Station (BS) and
several Subscriber Stations (SS). A BS and multiple SS form a cell with a point to multipoint structure. The
BS controls access to the air interface in its cell. Time is divided into frames and each frame consists of a
downlink frame and an uplink frame. Access in the uplink frame is controlled by the BS and assigned
according to a scheduling algorithm.

3 Analytical Modeling Techniques for MAC Protocols


In authors analyze Time Division Multiple Access (TDMA) channels for transmitting data messages.
Stations are assumed to have a fixed TDMA channel and the data messages arrive at the station with a
Poisson distribution. The buffer capacity for queuing is considered unlimited. A packet is assumed to be the
amount of data that can be transmitted in a TDMA slot. A message is thus broken down into packets. Firstly,
the steady state probability generating function for the queue size is found. From this, a model for the delay
is obtained. Assume there are M slots, each with a duration of T. Every station is idle for (M-1)T/M time
before it can send another packet. The analysis follows a single server queue example with the arrivals at the
rate of λ messages per second. The service time is a random variable having its value between T/M and (T +
T/M). The
expected message delay is found to be

L is the number of packets in a message which is a random variable given by a probability density function
with L1 and L2 being the first and the second moments.
Bianchi analyses the DCF of IEEE 802.l1. It is assumed that there are no hidden terminals in the network
and is operating under a saturation condition (every node has a packet to transmit at all times). The paper
first proposes a Markov model to find the probability that a station transmits in a randomly chosen slot.
Markov chain model for the backoff window size is show in the Figure 5. The probability found is
53
Page

where,
Department Of Computer Science and Engineering
p = conditional collision probability
W = Contention window

Fig. 5 - Markovian Model for backoff window. p is the probability with which each packet collides and is a
constant and independent. The next part of the analysis deals with
finding an expression for the throughput. S is the normalized system throughput which is the fraction of the
time the channel is used to transmit payload bits. S is expressed as,

the authors analyze


54
Page

the authors analyze the 802.11 protocol using an approach based on system approximation. Here, the
protocol's statistical characteristics are analyzed and then approximated by an appropriate distribution. Then
Department Of Computer Science and Engineering
a queuing model is constructed. Firstly, a general model which assumes there are k stations wanting to
transmit on a shared medium is assumed that uses a MAC protocol s to access the medium. Out of k, i
stations are saturated (always have traffic to send). The authors use a M/M/1/k model to analyze the protocol
and measure some performance metrics. The state of the queue represents the number of active stations. The
authors assume that the service time under any number of saturated nodes is exponential. This however may
not be appropriate in all cases for which the authors propose using a pH distribution like Erlang. To find the
delay performance, the authors use the saturation throughput developed by Bianchi. The service rate can be
calculated by S(i)/td where td is the mean duration of the payload transmission. Simulations are used to find
the service time distribution and a Cumalative Distribution Function (CDF) is obtained. The protocol
parameters used are given in table. Using the same parameters and k=50, and the balance equations, the
authors plot numerical results.

4 Simulation Studies
Simulation studies on MAC protocols generally involve more time but are generally preferred over
experimental studies especially in the wireless world. This is because experimental studies in wireless
networks involve a lot of cost. Furthemore, it is not always feasible to have a large scale testbed required for
full experimentation.
In authors simulate the performance of 802.16 protocol. Each Subscriber Station (SS) uses a Poisson traffic
source and the packet size is varied. The throughput and channel utilization has been plotted with varying
offered load. The simulation parameters used are as in the table. However, the simulation particulars are
missing in the paper. Particularly, the authors do not mention anything on the simulator used, or how long
the simulations are run.

In authors provide an analytical model for the delay performance of multi-channel MAC in point to
multipoint wireless networks under Poisson traffic. For the model, M orthogonal channels are assumed, with
each node having a single transceiver. However the base station can communicate on multiple channels
simultaneously. Let TA = length of contention interval; TD = length of data transmission interval in a frame;
TF = Frame size. Hence, TF = TD+TA. During the contention period all nodes send contention requests on
the same channel. Once the contention is over, nodes can shift to the channels which they were assigned
during contention. Let SA = number of contention slots. The authors then derive the probability of
successful contention for a channel m and find an expression for the average delay. This is given by
55
Page
Department Of Computer Science and Engineering

The model is also validated using simulations. The simulator used is ns-2. Three orthogonal channels having
a capacity of 10Mbps, contention slot 0.2 ms, and data slot time 0.5ms is simulated. Average service time
with TF=5ms and arrival rate = 20 packets/s is compared with the analytical model. The two graphs are
found to be highly close.

56
Page
Department Of Computer Science and Engineering

Experiment no.-12
AIM: - Study of Application layer protocols- DNS, HTTP, HTTPS, FTP and TelNet.

Description:
An application layer protocol defines how an application processes (clients and servers) , running on
different end systems, pass messages to each other. In particular, an application layer protocol defines:
 The types of messages, e.g., request messages and response messages.
 The syntax of the various message types, i.e., the fields in the message and how the fields are
delineated.
 The semantics of the fields, i.e., the meaning of the information that the field is supposed to contain;
 Rules for determining when and how a process sends messages and responds to messages.

SMTP (Simple Mail Transfer Protocol):


 One of the most popular network service is electronic mail (e-mail).
 The TCP/IP protocol that supports electronic mail on the Internet is called Simple Mail Transfer
Protocol (SMTP).
 SMTP transfers messages from senders' mail servers to the recipients' mail servers using TCP
connections.
 Users based on e-mail addresses.
 SMTP provides services for mail exchange between users on the same or different computers.
57

 Following the client/server model:


Page
Department Of Computer Science and Engineering
o SMTP has two sides: a client side which executes on a sender's mail server, and server side
which executes on recipient's mail server.
o Both the client and server sides of SMTP run on every mail server.
o When a mail server sends mail (to other mail servers), it acts as an SMTP client.
o When a mail server receives mail (from other mail servers) it acts as an SMTP server.
TELNET (Terminal Network):
 TELNET is client-server application that allows a user to log onto remote machine and lets the user
to access any application program on a remote computer.
 TELNET uses the NVT (Network Virtual Terminal) system to encode characters on the local system.
 On the server (remote) machine, NVT decodes the characters to a form acceptable to the remote
machine.
 TELNET is a protocol that provides a general, bi-directional, eight-bit byte oriented communications
facility.
 Many application protocols are built upon the TELNET protocol

FTP (File Transfer Protocol):


 FTP is the standard mechanism provided by TCP/IP for copying a file from one host to another.
 FTP differs form other client-server applications because it establishes 2 connections between hosts.
 FTP is built on a client-server architecture and uses separate control and data connections between
the client and the server.
 One connection is used for data transfer, the other for control information (commands and
responses).
 It transfer data reliably and efficiently.
Multipurpose Internet Mail Extensions (MIME):
 It is an extension of SMTP that allows the transfer of multimedia messages.
 If binary data is included in a message MIME headers are used to inform the receiving mail agent:
o Content-Transfer-Encoding: Header alerts the receiving user agent that the message body has
been ASCII encoded and the type of encoding used.
o Content-Type: Header informs the receiving mail agent about the type of data included in the
message.
POP (Post Office Protocol):
 POP is also called as POP3 protocol.
 This is a protocol used by a mail server in conjunction with SMTP to receive and holds mail for
hosts.
58

 POP3 mail server receives e-mails and filters them into the appropriate user folders. When a user
connects to the mail server to retrieve his mail, the messages are downloaded from mail server to the
Page

user's hard disk.


Department Of Computer Science and Engineering
HTTP (Hypertext Transfer Protocol):
 This is a protocol used mainly to access data on the World Wide Web (www).
 The Hypertext Transfer Protocol (HTTP) the Web's main application-layer protocol although current
browsers can access other types of servers
 A respository of information spread all over the world and linked together.
 The HTIP protocol transfer data in the form of plain text, hyper text, audio, video and so on.
 HTTP utilizes TCP connections to send client requests and server replies.
Domain Name System (DNS):
 To identify an entity, TCP/IP protocol uses the IP address which uniquely identifies the connection
of a host to the Internet.
 DNS is a hierarchical system, based on a distributed database, that uses a hierarchy of Name Servers
to resolve Internet host names into the corresponding IP addresses required for packet routing by
issuing a DNS query to a name server.
 However, people refer to use names instead of address. Therefore, we need a system that can map a
name to an address and conversely an address to name.
 In TCP/IP, this is the domain name system.
 DNS in the Internet: DNS is protocol that can be used in different platforms.
 Domain name space is divided into three categories.
 Generic Domain: The generic domain defines registered hosts according, to their generic behaviour.
Each node in the tree defines a domain which is an index to the domain name space database.

 Country Domain: The country domain section follows the same format as the generic domain but
uses 2 characters country abbreviations (e.g., US for United States) in place of 3 characters.
59

 Inverse Domain: The inverse domain is used to map an address to a name.


Page
Department Of Computer Science and Engineering

Experiment no.-13

AIM - Study & Installation of Wireshar


1. Run the exe installer that was downloaded.
2. Click Next on the Welcome to Wireshark screen.

3. Read the license agreement and click I Agree.

60
Page
Department Of Computer Science and Engineering
4. At the Choose Components screen leave the defaults checked and click Next. You can read
more about the different components here.

5. At the Select Additional Tasks screen choose your preferred shortcuts and leave the radio
button for “associate trace file extensions to Wireshark” selected. Click Next.

61
Page
Department Of Computer Science and Engineering
6. Choose the install location you prefer and click Next.

7. At the Packet Capture page make sure Install WinPcap 4.1.3 is selected. You need this to
capture traffic with Wireshark. Without it you can still view Wireshark capture files. Click
Next.

8. At the USB Capture page you can choose to Install USBPcap. Check the box next to Install
62

USBPcap 1.2.0.3 if you desire to capture raw usb traffic as well (such as from a USB to RJ45
Ethernet adapter). Click Install.
Page
Department Of Computer Science and Engineering

9. The software will begin installing.

10. Eventually the installer will pause at “Execute: “C:\Program Files\Wiresharek\


WinPcap_4_1_3.exe” and lunch a new installer window for WinPcap. Click Next in this
63
Page
Department Of Computer Science and Engineering
window.

11. Read the license agreement and click I Agree.

64
Page
Department Of Computer Science and Engineering
12. Make sure the check box is checked next to “Automatically start the WinPcap driver at boot
time” unless you have a good reason for disabling this and click Install.

The install will begin and eventually complete. Click Finish.

13. Next the installer for USBPcap will launch. Read the USBPcap Driver license agreement,
check the “I accept” box, and click Next.

65
Page
Department Of Computer Science and Engineering
14. Read the USBPcapCMD license, check the “I accept” box, and click Next.

15. Leave the Installation Options set to Full and click Next.

16. Choose your Installation Folder and click Install. The install will begin.

66

17. When the USBpcap install finishes click close and the Wireshark install will continue.
Page
Department Of Computer Science and Engineering
At the Installation Complete screen click Next.

18. Wireshark will now ask to reboot your machine to complete installation. You can either
choose to reboot now or manually reboot later. You will not be able to run packet captures
until you reboot your machine. I suggest rebooting right away.

Once your machine has rebooted you should find the Wireshark shortcuts in the locations you specified
in the install. For this example the shortcut was found in the Start Menu.
67
Page
Department Of Computer Science and Engineering

Experiment no.-14
AIM: - Socket Programing
Socket programming is a way of connecting two nodes on a network to communicate with each other. One
socket(node) listens on a particular port at an IP, while the other socket reaches out to the other to form a
connection. The server forms the listener socket while the client reaches out to the server.

State diagram for server and client model

68
Page

State diagram for server and client model of Socket


Department Of Computer Science and Engineering

1. Socket creation:
int sockfd = socket(domain, type, protocol)

sockfd: socket descriptor, an integer (like a file-handle)


domain: integer, specifies communication domain. We use AF_ LOCAL as defined in the POSIX standard
for communication between processes on the same host. For communicating between processes on different
hosts connected by IPV4, we use AF_INET and AF_I NET 6 for processes connected by IPV6.
type: communication type
SOCK_STREAM: TCP(reliable, connection oriented)
SOCK_DGRAM: UDP(unreliable, connectionless)
protocol: Protocol value for Internet Protocol(IP), which is 0. This is the same number which appears on
protocol field in the IP header of a packet.(man protocols for more details)
2. Setsockopt:
This helps in manipulating options for the socket referred by the file descriptor sockfd. This is completely
optional, but it helps in reuse of address and port. Prevents error such as: “address already in use”.

int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen);

3. Bind:
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);

After the creation of the socket, the bind function binds the socket to the address and port number specified
in addr(custom data structure). In the example code, we bind the server to the localhost, hence we use
INADDR_ANY to specify the IP address.

4. Listen:
int listen(int sockfd, int backlog);

It puts the server socket in a passive mode, where it waits for the client to approach the server to make a
connection. The backlog, defines the maximum length to which the queue of pending connections for sockfd
may grow. If a connection request arrives when the queue is full, the client may receive an error with an
indication of ECONNREFUSED.

5. Accept:
int new_socket= accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);

It extracts the first connection request on the queue of pending connections for the listening socket, sockfd,
creates a new connected socket, and returns a new file descriptor referring to that socket. At this point, the
connection is established between client and server, and they are ready to transfer data.

Stages for Client


Socket connection: Exactly same as that of server’s socket creation
Connect: The connect() system call connects the socket referred to by the file descriptor sockfd to the
address specified by addr. Server’s address and port is specified in addr.
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);

Implementation
Here we are exchanging one hello message between server and client to demonstrate the client/server model.
69
Page
Department Of Computer Science and Engineering

Server.c

// Server side C/C++ program to demonstrate Socket


// programming
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#define PORT 8080
int main(int argc, char const* argv[])
{
int server_fd, new_socket, valread;
struct sockaddr_in address;
int opt = 1;
int addrlen = sizeof(address);
char buffer[1024] = { 0 };
char* hello = "Hello from server";

// Creating socket file descriptor


if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
perror("socket failed");
exit(EXIT_FAILURE);
}

// Forcefully attaching socket to the port 8080


if (setsockopt(server_fd, SOL_SOCKET,
SO_REUSEADDR | SO_REUSEPORT, &opt,
sizeof(opt))) {
perror("setsockopt");
exit(EXIT_FAILURE);
}
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons(PORT);

// Forcefully attaching socket to the port 8080


if (bind(server_fd, (struct sockaddr*)&address,
sizeof(address))
< 0) {
perror("bind failed");
exit(EXIT_FAILURE);
}
if (listen(server_fd, 3) < 0) {
perror("listen");
exit(EXIT_FAILURE);
}
if ((new_socket
70

= accept(server_fd, (struct sockaddr*)&address,


(socklen_t*)&addrlen))
Page

< 0) {
Department Of Computer Science and Engineering
perror("accept");
exit(EXIT_FAILURE);
}
valread = read(new_socket, buffer, 1024);
printf("%s\n", buffer);
send(new_socket, hello, strlen(hello), 0);
printf("Hello message sent\n");

// closing the connected socket


close(new_socket);
// closing the listening socket
shutdown(server_fd, SHUT_RDWR);
return 0;
}

client.c

// Client side C/C++ program to demonstrate Socket


// programming
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#define PORT 8080

int main(int argc, char const* argv[])


{
int status, valread, client_fd;
struct sockaddr_in serv_addr;
char* hello = "Hello from client";
char buffer[1024] = { 0 };
if ((client_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
printf("\n Socket creation error \n");
return -1;
}

serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(PORT);

// Convert IPv4 and IPv6 addresses from text to binary


// form
if (inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr)
<= 0) {
printf(
"\nInvalid address/ Address not supported \n");
return -1;
}

if ((status
71

= connect(client_fd, (struct sockaddr*)&serv_addr,


sizeof(serv_addr)))
Page

< 0) {
Department Of Computer Science and Engineering
printf("\nConnection Failed \n");
return -1;
}

send(client_fd, hello, strlen(hello), 0);


printf("Hello message sent\n");
valread = read(client_fd, buffer, 1024);
printf("%s\n", buffer);

// closing the connected socket


close(client_fd);
return 0;
}

Compiling:

gcc client.c -o client


gcc server.c -o server
Output:

Client:Hello message sent


Hello from server
Server:Hello from client
Hello message sent

72
Page

You might also like