0% found this document useful (0 votes)
25 views18 pages

Unit 2

Uploaded by

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

Unit 2

Uploaded by

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

Data Link Layer Design Issues

The data link layer has a number of functions to carry out. The functions include providing a well defined
service interface to the network layer, determining how the bits of the physical layer are grouped to frames.

The design issues of the data link layer are given below

1. Services provided to the Network Layer: The function of the data link layer is to provide services to
the network layer. The principle service is transferring data from the network layer on the source
machine to the network layer in the destination machine.
The actual service offered can vary from system to system. Three reasonable possibilities that
commonly provide are :
1. Unacknowledged Connectionless Service: Source machine send independent frames to the
destination machine without expecting any reply from the destination machine.
2. Acknowledged Connectionless Service: Source machine send independent frames to the
destination machine expecting reply from the destination machine. Frames are individually
acknowledged. Here reliability is high.
3. Acknowledged Connection Oriented Services: Here Connection is first established between
source and receiver. Source machine send independent frames to the destination machine
expecting reply from the destination machine. Frames are individually acknowledged.
2. Framing
Data link layer groups bits to frames so that each frame is distinguishable from one another. Format
is as follows.
Flag Header Data Trailer Flag
Fig: Frame Format

Here sender address and destination address is also attached. The source address helps the
recipient acknowledge the receipt; the destination address defines where the packet is to go.
i) Fixed size framing: boundaries of the frame is already defined here. For eg., the size of the
frame is set as delimiter.
ii) Variable size framing:boundaries of the frame is not defined here. Two approaches used here
are
a) Character oriented protocol
variable number of data

Flag Header ………….. Trailer Flag


Fig: Frame Format in character oriented protocol

Character oriented protocol carries data as 8-bit ASCII characters. Flags, header,trailer are also carried as 8
bits or its multiples.

b) Bit oriented protocols


variable number of data

Flag Header ………….. Trailer Flag


Fig: Frame Format in bit oriented protocol

Bit oriented protocols carries data as a sequence of bits. Flags, header, trailer are also carried as 8 bits or
its multiples. Flags use a special pattern like 01111110 which is used as a delimiter to define the beginning
and end of frame.

3. Flow Control: flow control is a set of procedures that tells the sender how much data it can transmit
before it must wait for an acknowledgment from the receiver. Any receiving device has a limited
speed at which it can process incoming data and a limited amount of memory in which it can store
incoming data. The receiving device must be able to inform the sending device before those limits
are reached and to request that the transmitting device send fewer frames or stop temporarily.

Two approaches used are

i) Feedback based flow control: Receiver send back the sender information regarding
permission to send more data.
ii) Rate based flow control: There is a built in mechanism that limits the rate at which the
sender may transmit data without any feedback from the receiver.
Two categories of flow control are:
a. Stop and wait
b. Sliding window

4. Error control: Error control provides error correction and detection. Some algorithms are
implemented such as checksum in error detection and correction.

PROTOCOLS

Different types of protocols are as follows:


Module 2
PROTOCOLS
NOISELESS CHANNEL NOISY CHANNEL
CHANNEL
a) Simplest protocol
i) Stop and wait ARQ
b) Stop and wait protocol ii) Go-Back-N ARQ
iii) Selective Repeat ARQ
Simplest Protocol
In simplest protocol sender sends frames and it is received by the
receiver. Stop and wait Protocol
In stop and wait protocol the source sends a frame received by the receiver, which sends an
acknowledgment which is received by the sender and then sends the next frame. Sender repeats this
process until sender sendsan end of transmission frame (EOT). The process is illustrated below

sender receiver

Packet1

ACK1

Packet2

ACK2

Fig: Stop and Wait Protocol

Advantages of stop and wait protocol

1. Simple
2. Error detection is easy due to its small size

of framesDisadvantages of stop and wait protocol

1. Only single frame is transmitted which wastes the sender time


2. Throughput is very poor and the and the channel is not utilized efficiently.
Stop and Wait ARQ

 Automatic Repeat Request(ARQ) is an error control method for data transmission that uses
acknowledgements and timeouts(specified period of time allowed to resend the frame
before an acknowledgment is received).
 ARQ maintains reliable data transmission over an unreliable service.
 Stop and wait ARQ is a form of stop and wait protocol which includes retransmission of
data in caseof lost or damaged frames.
 The sending device keeps a copy of the last frame transmitted until it receives an
acknowledgement for that frame. Keeping a copy allows the sender to retransmit lost or
damaged frames until they arereceived correctly.
 If an error is discovered in a data frame indicating that it has been corrupted then NAK
frame is returned which tells the sender to retransmit the last frame sent.
receiver
sender
Data1

ACK1

Data2

NAK

Data2

ACK1
Fig: Stop and wait ARQ, damaged frame

 The sending device is equipped with a timer. If an expected acknowledgement is not


received within an allotted time period, the sender assumes that the last data frame was lost
in transit and sends it again.
receiver
sender
data
timeout ACK1

data

ACK1

Fig: stop and wait ARQ, lost ACK Frame

Advantages of stop and wait ARQ

1. It can be used for noisy channels


2. It has both flow control and error control
3. It has timer implementation
4. Easy to implement
5. Low processor burden
6. Low buffer requirement

Disadvantages of stop and

wait ARQ
1. Efficiency is very less.
2. Timer set for each frame.
3. Sender window size is 1.
4. Receiver window size is 1.

Go back N ARQ

 Sliding window method used here where the sender continues to send a number of frames
specified by a window size even without receiving an acknowledgement frame from the
receiver.
 The sender maintains information about:
o Size of the sender window
o Last acknowledgement received
o Last frame sent
 The receiver holds information about
o Receiver window size
 The frames are numbered modulo-n which means they are numbered from 0 to n-1. When the
receiver sends an ACK, it includes the number of next frame it expects to receive.
 Sender Sliding window can be seen as below

Frames
already send
Sender window Frames that are to be send
& ack

6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

Fig: sender sliding window

 Receiver Sliding window can be seen as follows

6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

Fig: Receiver sliding window(window size =1)


 When the receiver finds an error in frame, it tells the transmitter to go back , resend
that frame and all succeeding frames. This feature guarantees that the frame are
received in order, but it also means that some good frames may have to be resent.
sender receiver

Data 0

Data 1

Data 2

ACK

Fig: frames sent and acknowledgement received

Here the frames 0,1,2 sent as a group and the acknowledgment received for the group

Sender receiver

Ack
Data 0
lost
and Data 1
time
out Data 2

ACK2

Data 0

Data 1

Data 2

Fig: Go back N, lost ACK


Here the frames are sent as group and the acknowledgement lost and the group is resent.
Here the frames are sent as group and the frame 1 is damaged, so acknowledgement sent to resend the
frame1. Here the frame1 and frame 2 are resend as per the name of Go Back N.

Advantages of Go back N

 The sender can send as many frames at a time


 One ACK can acknowledge one or more frame
 Efficiency is more
 Waiting time is low
 We can alter the size of the sender

windowDisadvantages of Go Back N ARQ

 Buffer is required
 Sender needs to duplicate the last send N frames.
 Retransmission of many error free packet because of resending the nth error packet

Selective Repeat ARQ

 With selective repeat ARQ (also known as selective reject ARQ) the receiver sends ACK
for eachframe individually which is not cumulative ACK as used with Go Back N.
 Here the sender and the receiver has window size N.

Fig: Send window for Selective repeat request


Fig: Receive window for Selective repeat
request

 The receiver accepts frames out of order and buffers them. The sender individually
retransmits framesthat have time out.
 In selective repeat ARQ only the specific damaged or lost frame is retransmitted. If a
frame iscorrupted in transit an NAK is returned and the frame is resent.
 The receiving device must be able to sort the frames.

Here the data1 is damaged and the acknowledgement for the damaged frame is received and
only that data1 is resend.
 Advantages of selective repeat ARQ
o Similar to Go back N ARQ. Sender only retransmits frames for which a NAK is received.
o Fewer retransmissions
 Disadvantages of selective repeat ARQ
o More complex at sender and receiver side
o Each frame must be individually acknowledged
o Receiver receives frames out of sequence

HDLC (High Level Data Link Control)


 HDLC is a bit oriented protocol. It works for point to point and multipoint link.
 HDLC defines three types of stations.
o Primary station: frames are issued by the primary station
o Secondary station: it operates under the control of primary station. Frames
issued by thesecondary station are called responses.
o Combined station: combines the features of both primary and secondary stations.
 HDLC provides two configuration modes
o Normal Response Mode(NRM): This mode is used in unbalanced
configuration(only single primary station). The primary node will initiate the data
transfer, but the secondary node can send data only on command from the primary
node. NRM is used for communication between a host computer and the terminal
connected to it.

o Asynchronous Balanced Mode(ABM): This mode is used with balanced


configuration(morethan one primary station where each station can act as both
primary and secondary station). Here the combined node can initiate the
transmission.ABM is used extensively for point-point full-duplex communication.

Fig: Asynchronous Balanced Mode

o Aynschronous Response Mode(ARM):this mode is used with unbalanced


configuration. The primary node will intiate link,do error recovery and logical
disconnection, but the secondary node may intiate data transmission without
permission from the primary. ARM is rarely used.
 HDLC support various frame formats for the different modes of operation.
o Unnumbered Frames(U-Frames): These are used for functions like link set up
anddisconnection. They do not contain any acknowledgement information.
o Information Frames(I-Frames): These carry the actual information or data. They can
be usedto piggy back acknowledgement information along with information.
o Supervisory Frames(S-Frames): These are used for error control and flow control.

Fig: HDLC Frames


 Frame for the HDLC is as follows
Flag Address Control Information FCS Flag
Fig: HDLC Frame format
 The functions of each field are as follows:
o Flag field: 8-bit sequence with a bit pattern of 01111110. It identifies the beginning
and end of frame.
o Address Field: It contains the address of the secondary station. If frame is created by
the primary station the address of the secondary station is stored. If frame is created
by the secondary station the from address is stored in it.
o Control Field: Used for flow control and error control.
o Information Field: contains user data information

Errors

When bits are transmitted over the computer network, they are subject to get corrupted due to interference
and network problems.

Types of Errors.

Single bit error − In the Multiple bits error − In the received Burst error − In the received frame,
received frame, only one bit frame, more than one bits are more than one consecutive bits are
has been corrupted, i.e. either corrupted. corrupted.
changed from 0 to 1 or from 1
to 0.

Error Control

Error control can be done in two ways.

 Error detection − Error detection involves checking whether any error has occurred or not. The number of
error bits and the type of error does not matter.
 Error correction − Error correction involves ascertaining the exact number of bits that has been corrupted and
the location of the corrupted bits.

Error Detection Techniques

There are three main techniques for detecting errors in frames: Parity Check, Checksum, and Cyclic
Redundancy Check (CRC).
Parity Check
 In case of even parity: If a number of 1s is even then parity bit value is 0. If the number of 1s is odd then parity
bit value is 1.
 In case of odd parity: If a number of 1s is odd then parity bit value is 0. If a number of 1s is even then parity bit
value is 1.

Checksum
 Data is divided into fixed sized frames or segments.
 The sender adds the segments using 1’s complement arithmetic to get the sum. It then complements the sum to
get the checksum and sends it along with the data frames.
 The receiver adds the incoming segments along with the checksum using 1’s complement arithmetic to get the
sum and then complements it.
 If the result is zero, the received frames are accepted; otherwise, they are discarded.

Cyclic Redundancy Check (CRC)


 Here, the sender performs binary division of the data segment by the divisor. It then appends the remainder
called CRC bits to the end of the data segment. This makes the resulting data unit exactly divisible by the
divisor.
 The receiver divides the incoming data unit by the divisor. If there is no remainder, the data unit is assumed to
be correct and is accepted. Otherwise, it is understood that the data is corrupted and is therefore rejected.

Error Correction Techniques


Error correction techniques find out the exact number of bits that have been corrupted and as well
as their locations. There are two principle ways

 Backward Error Correction (Retransmission) − If the receiver detects an error in the incoming frame, it
requests the sender to retransmit the frame. It is a relatively simple technique. But it can be efficiently used
only where retransmitting is not expensive as in fiber optics and the time for retransmission is low relative to
the requirements of the application.
 Forward Error Correction − If the receiver detects some error in the incoming frame, it executes error-
correcting code that generates the actual frame. This saves bandwidth required for retransmission. It is
inevitable in real-time systems. However, if there are too many errors, the frames need to be retransmitted .
The Media Access Control (MAC) data communication Networks protocol sub-layer, also known as the Medium
Access Control, is a sub-layer of the data link layer specified in the seven-layer OSI model.

Following Protocols are used by Medium Access Layer;

ALOHA : ALOHA is a system for coordinating and arbitrating access to a shared communication channel. In the
ALOHA system, a node transmits whenever data is available to send. If another node transmits at the same time, a
collision occurs, and the frames that were transmitted are lost. However, a node can listen to broadcasts on the
medium, even its own, and determine whether the frames were transmitted.

There are two different versions of ALOHA

Pure ALOHA

• In pure ALOHA, the stations transmit frames whenever they have data to send.
• When two or more stations transmit simultaneously, there is collision and the frames are destroyed.
In pure ALOHA, whenever any station transmits a frame, it expects the acknowledgement from the receiver.
• If acknowledgement is not received within specified time, the station assumes that the frame (or acknowledgement)
has been destroyed.
• If the frame is destroyed because of collision the station waits for a random amount of time and sends it again. This
waiting time must be random otherwise same frames will collide again and again.
• Therefore pure ALOHA dictates that when time-out period passes, each station must wait for a random amount of
time before re-sending its frame. This randomness will help avoid more collisions.
• Figure shows an example of frame collisions in pure ALOHA.
In fig there are four stations that .contended with one another for access to shared channel. All these stations are
transmitting frames. Some of these frames collide because multiple frames are in contention for the shared channel.
Only two frames, frame 1.1 and frame 2.2 survive. All other frames are destroyed.

• Whenever two frames try to occupy the channel at the same time, there will be a collision and both will be
damaged. If first bit of a new frame overlaps with just the last bit of a frame almost finished, both frames will be
totally destroyed and both will have to be retransmitted.

Slotted ALOHA
• Slotted ALOHA was invented to improve the efficiency of pure ALOHA as chances of collision in pure ALOHA
are very high.

• In slotted ALOHA, the time of the shared channel is divided into discrete intervals called slots.

• The stations can send a frame only at the beginning of the slot and only one frame is sent in each slot.

In slotted ALOHA, if any station is not able to place the frame onto the channel at the beginning of the slot i.e. it
misses the time slot then the station has to wait until the beginning of the next time slot.

• In slotted ALOHA, there is still a possibility of collision if two stations try to send at the beginning of the same time
slot as shown in fig.

• Slotted ALOHA still has an edge over pure ALOHA as chances of collision are reduced to one-half.

Carrier Sense Multiple Access (CSMA)

CSMA is a network access method used on shared network topologies such as Ethernet to control
access to the network. Devices attached to the network cable listen (carrier sense) before transmitting. CSMA
protocol was developed to overcome the problem found in ALOHA i.e. to minimize the chances of collision, so as to
improve the performance. CSMA protocol is based on the principle of ‘carrier sense’. The station senses the carrier
or channel before transmitting a frame. It means the station checks the state of channel, whether it is idle or busy.
There Are Three Different Type of CSMA Protocols

(I) I-persistent CSMA

(ii) Non- Persistent CSMA

(iii) p-persistent CSMA

I-persistent CSMA

• In this method, station that wants to transmit data continuously senses the channel to check whether the channel is
idle or busy.

• If the channel is busy, the station waits until it becomes idle.

• When the station detects an idle-channel, it immediately transmits the frame with probability 1. Hence it is called I-
persistent CSMA.

• This method has the highest chance of collision because two or more stations may find channel to be idle at the
same time and transmit their frames.

• When the collision occurs, the stations wait a random amount of time and start allover again.

Drawback of I-persistent

• The propagation delay time greatly affects this protocol. Let us suppose, just after the station I begins its
transmission, station 2 also became ready to send its data and senses the channel. If the station I signal has not yet
reached station 2, station 2 will sense the channel to be idle and will begin its transmission. This will result in
collision.

Non-persistent CSMA

• In this scheme, if a station wants to transmit a frame and it finds that the channel is busy (some other station is
transmitting) then it will wait for fixed interval oftime.
• After this time, it again checks the status of the channel and if the channel is.free it will transmit.
• A station that has a frame to send senses the channel.
• If the channel is idle, it sends immediately.
• If the channel is busy, it waits a random amount of time and then senses the channel again.
• In non-persistent CSMA the station does not continuously sense the channel for the purpose of capturing it when it
detects the end of previous transmission.
Advantage of non-persistent
• It reduces the chance of collision because the stations wait a random amount of time. It is unlikely that two or more
stations will wait for same amount of time and will retransmit at the same time.
Disadvantage of non-persistent
• It reduces the efficiency of network because the channel remains idle when there may be stations with frames to
send. This is due to the fact that the stations wait a random amount of time after the collision.
p-persistent CSMA
• This method is used when channel has time slots such that the time slot duration is equal to or greater than the
maximum propagation delay time.

• Whenever a station becomes ready to send, it senses the channel.

• If channel is busy, station waits until next slot.

• If channel is idle, it transmits with a probability p.

• With the probability q=l-p, the station then waits for the beginning of the next time slot.

• If the next slot is also idle, it either transmits or waits again with probabilities p and q.

• This process is repeated till either frame has been transmitted or another station has begun transmitting.

• In case of the transmission by another station, the station acts as though a collision has occurred and it waits a
random amount of time and starts again.

Advantage of p-persistent : • It reduces the chance of collision and improves the efficiency of the network.
Carrier Sense Multiple Access with Collision Detection (CSMA/CD)

The shared channel for communication is detected or heard, and transmissions are postponed until the
channel is clear. By detecting transmissions from other stations, the collision detection technique finds collisions.

Step 1: Check if the sender is ready for transmitting data packets.


Step 2: Check if the transmission link is idle.
Sender has to keep on checking if the transmission link/medium is idle. For this, it continuously senses transmissions
from other nodes. Sender sends dummy data on the link. If it does not receive any collision signal, this means the link
is idle at the moment. If it senses that the carrier is free and there are no collisions, it sends the data. Otherwise, it
refrains from sending data.
Step 3: Transmit the data & check for collisions.
Sender transmits its data on the link. CSMA/CD does not use an ‘acknowledgment’ system. It checks for successful
and unsuccessful transmissions through collision signals. During transmission, if a collision signal is received by the
node, transmission is stopped. The station then transmits a jam signal onto the link and waits for random time
intervals before it resends the frame. After some random time, it again attempts to transfer the data and repeats the
above process.
Step 4: If no collision was detected in propagation, the sender completes its frame transmission and resets the
counters.

Advantages of CSMA/CD:

 Simple and widely used: CSMA/CD is a widely used protocol for Ethernet networks, and its simplicity makes it
easy to implement and use.
Fairness: In a CSMA/CD network, all devices have equal access to the transmission medium, which ensures
fairness in data transmission.
Efficiency: CSMA/CD allows for efficient use of the transmission medium by preventing unnecessary collisions
and reducing network congestion.

Disadvantages of CSMA/CD:

 Limited scalability: CSMA/CD has limitations in terms of scalability, and it may not be suitable for large
networks with a high number of devices.
Vulnerability to collisions: While CSMA/CD can detect collisions, it cannot prevent them from occurring.
Collisions can lead to data corruption, retransmission delays, and reduced network performance.
Inefficient use of bandwidth: CSMA/CD uses a random backoff algorithm that can result in inefficient use of
network bandwidth if a device continually experiences collisions.
Susceptibility to security attacks: CSMA/CD does not provide any security features, and the protocol is
vulnerable to security attacks such as packet sniffing and spoofing.

CSMA with Collision Avoidance (CSMA/CA):


 CSMA/CA protocol is used in wireless networks because they cannot detect the collision so the
only solution is collision avoidance.
 CSMA/CA avoids the collisions using three basic techniques.
 Interframe space
 Contention window
 (iii) Acknowledgements

Interframe space (IFS)


Whenever the channel is found idle, the station does not transmit immediately. It waits for a period of time
called interframe space (IFS).
• When channel is sensed to be idle, it may be possible that same distant station may have already started
transmitting and the signal of that distant station has not yet reached other stations.
• Therefore the purpose of IFS time is to allow this transmitted signal to reach other stations.
• If after this IFS time, the channel is still idle, the station can send, but it still needs to wait a time equal to
contention time.
• IFS variable can also be used to define the priority of a station or a frame.

Contention Window

Contention window is an amount of time divided into slots.


• A station that is ready to send chooses a random number of slots as its wait time.
• The number of slots in the window changes according to the binary exponential back-off strategy. It
means that it is set of one slot the first time and then doubles each time the station cannot detect an idle
channel after the IFS time.
• This is very similar to the p-persistent method except that a random outcome defines the number of slots
taken by the waiting station.
• In contention window the station needs to sense the channel after each time slot.
• If the station finds the channel busy, it does not restart the process. It just stops the timer & restarts it
when the channel is sensed as idle.
Acknowledgement
• Despite all the precautions, collisions may occur and destroy the data.
• The positive acknowledgment and the time-out timer can help guarantee that receiver has received the
frame.

CSMA/CA Procedure:

You might also like