CNS Unit 02 RBN
CNS Unit 02 RBN
Nawale
Asst. Professor
Dept. of Computer Engineering
Sinhgad College of Engineering, Pune 1
Computer Network and Security
T.E. Computer Engineering Semester I
Unit II
Data Link Layer
2
Data Link Layer
The communication channel that connects the adjacent nodes is
known as links, and in order to move the datagram from source to the
destination, the datagram must be moved across an individual link.
The main responsibility of the Data Link Layer is to transfer the
datagram across an individual link.
The Data link layer protocol defines the format of the packet
exchanged across the nodes as well as the actions such as Error
detection, retransmission, flow control, and random access.
The Data Link Layer protocols are Ethernet, token ring, FDDI and
PPP.
An important characteristic of a Data Link Layer is that datagram
can be handled by different link layer protocols on different links in a
path. For example, the datagram is handled by Ethernet on the first
3
link, PPP on the second link.
Data Link Layer
Functions
Framing & Link access:
• Data Link Layer protocols encapsulate each network frame within a Link layer frame before the
transmission across the link.
• A frame consists of a data field in which network layer datagram is inserted and a number of
data fields.
• It specifies the structure of the frame as well as a channel access protocol by which frame is to
be transmitted over the link.
Functions
Reliable delivery: (hop to hop)
• Data Link Layer provides a reliable delivery service, i.e., transmits the network layer datagram
without any error.
• A data link layer mainly provides the reliable delivery service over the links as they have higher
error rates and they can be corrected locally, link at which an error occurs rather than forcing to
retransmit the data.
Functions
Flow control: (stop and wait)
• A receiving node can receive the frames at
a faster rate than it can process the frame.
• Without flow control, the receiver's buffer
can overflow, and frames can get lost.
• To overcome this problem, the data link
layer uses the flow control to prevent the
sending node on one side of the link from
overwhelming the receiving node on
another side of the link.
Functions
Error detection: (Parity Check, Checksum and Cyclic Redundancy Check (CRC))
• Errors can be introduced by signal attenuation and noise.
• Data Link Layer protocol provides a mechanism to detect one or more errors.
• This is achieved by adding error detection bits in the frame and then receiving node can
perform an error check.
• Service consists of having the source machine send independent frames to the destination
machine without having the destination machine acknowledge them.
• No logical connection is established beforehand or released afterward.
• If a frame is lost due to noise on the line, no attempt is made to detect the loss or recover
from it in the data link layer.
• This class of service is appropriate when the error rate is very low so that recovery is left
to higher layers.
Services Provided to the Network Layer
Methods of Framing :
1. Character Count
2. Flag Byte with Character Stuffing
3. Starting and Ending Flags, with Bit Stuffing
Character Count
This method is rarely used and is generally required to count total number of
characters that are present in frame.
This is be done by using field in header.
Character count method ensures data link layer at the receiver or destination about
total number of characters that follow, and about where the frame ends.
There is disadvantage also of using this method i.e., if anyhow character count is
disturbed or distorted by an error occurring during transmission, then destination or
receiver might lose synchronization.
Character Count
Flag Byte with Character Stuffing
Character stuffing is also known as byte stuffing
In byte stuffing, special byte that is basically known as ESC (Escape Character) that has predefined
pattern is generally added to data section of the data stream or frame when there is message or
character that has same pattern as that of flag byte.
But receiver removes this ESC and keeps data part that causes some problems or issues. In simple
words, we can say that character stuffing is addition of 1 additional byte if there is presence of ESC
or flag in text.
Flag Byte with Character Stuffing
Starting and Ending Flags, with Bit Stuffing
Bit stuffing is also known as bit-oriented framing or bit-oriented approach.
In bit stuffing, extra bits are being added by network protocol designers to data streams.
It is generally insertion or addition of extra bits into transmission unit or message to be transmitted
as simple way to provide and give signaling information and data to receiver and to avoid or ignore
appearance of unintended or unnecessary control sequences.
It is type of protocol management simply performed to break up bit pattern that results in
transmission to go out of synchronization.
Bit stuffing is very essential part of transmission process in network and communication protocol.
It is also required in USB.
Types of Errors
• Whenever bits flow from one point to another, they are subject to
unpredictable changes because of interference.
• This interference can change the shape of the signal.
• In a single-bit error, a 0 is changed to a 1 or a 1 to a O.
• In a burst error, multiple bits are changed. For example, a 11100 s burst of
impulse noise on a transmission with a data
Single-Bit Error
The term single-bit error means that only 1 bit of a given data unit (such as a byte,
character, or packet) is changed from 1 to 0 or from 0 to 1.
Figure shows the effect of a single-bit error on a data unit.
Single-bit errors are the least likely type of error in serial data transmission
Burst Error
The term burst error means that 2 or more bits in the data unit have changed from 1 to 0 or from 0 to 1.
Note that a burst error does not necessarily mean that the errors occur in consecutive bits.
The length of the burst is measured from the first corrupted bit to the last corrupted bit. Some bits in
between may not have been corrupted.
A burst error is more likely to occur than a single-bit error.
The duration of noise is normally longer than the duration of 1 bit, which means that when noise affects
data, it affects a set of bits.
The number of bits affected depends
on the data rate and duration of noise.
Figure shows the effect of a
burst error on a data unit.
In this case, 100010001000011 was
sent, but 0101110101100011 was
received.
Redundancy
The parity check is done by adding an extra bit, called parity bit to the data to
make a number of 1s either even in case of even parity or odd in case of odd
parity.
While creating a frame, the sender counts the number of 1s in it and adds the
parity bit in the following way
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.
Error Detection - Parity Check
On receiving a frame, the receiver counts the number of 1s in it.
In case of even parity check, if the count of 1s is even, the frame is accepted, otherwise, it is
rejected. A similar rule is adopted for odd parity check.
The parity check is suitable for single bit error detection only
Error Detection -Cyclic redundancy check (CRC)
CRC is based on binary division.
In CRC, a sequence of redundant bits, called
cyclic redundancy check bits, are appended to the
end of data unit so that the resulting data unit
becomes exactly divisible by a second,
predetermined binary number.
At the destination, the incoming data unit is
divided by the same number.
If at this step there is no remainder, the data unit is
assumed to be correct and is therefore accepted.
A remainder indicates that the data unit has been
damaged in transit and therefore must be rejected.
Error Detection -Cyclic redundancy check (CRC)
Hamming Code
Encoding a message by Hamming Code
Step 1 − Calculation of the number of redundant bits.
Step 2 − Positioning the redundant bits.
Step 3 − Calculating the values of each redundant bit.
Step 1 − Calculation of the number of redundant bits.
If the message contains m number of data bits, r number of redundant bits are added to it so
that is able to indicate at least (m + r + 1) different states.
Here, (m + r) indicates location of an error in each of bit positions and one additional state
indicates no error.
Since, r bits can indicate 2r states, 2r must be at least equal to (m + r + 1). Thus the following
equation should hold − 2r ≥ 𝑚 + 𝑟 + 1
If the data is of 7 bits, i.e. m = 7, the minimum value of r that will satisfy the above equation
is 4, (16 ≥ 7 + 4 + 1). The total number of bits in the encoded message, (m + r) = 11. This is
referred as (11,4) code 35
Hamming Code
If the data is of 7 bits, i.e. m = 7, the minimum value of r that will satisfy the above
equation is 4, (16 ≥ 7 + 4 + 1). The total number of bits in the encoded message, (m + r) =
11. This is referred as (11,4) code
To find the redundant bit R1, we check for even parity. Since the total number of 1’s in all the
bit positions corresponding to R1 is an even number the value of R1 (parity bit’s value) = 0
Hamming Code
R2 bit is calculated using parity check at all the bits positions whose binary representation
includes a 1 in the second position from the least significant bit. R2: bits 2,3,6,7,10,11
To find the redundant bit R2, we check for even parity. Since the total number of 1’s in all the
bit positions corresponding to R2 is odd the value of R2(parity bit’s value)=1
Hamming Code
R4 bit is calculated using parity check at all the bits positions whose binary representation
includes a 1 in the third position from the least significant bit. R4: bits 4, 5, 6, 7
To find the redundant bit R4, we check for even parity. Since the total number of 1’s in all the bi
positions corresponding to R4 is odd the value of R4(parity bit’s value) = 1
Hamming Code
R8 bit is calculated using parity check at all the bits positions whose binary representation
includes a 1 in the fourth position from the least significant bit. R8: bit 8,9,10,11
To find the redundant bit R8, we check for even parity. Since the total number of 1’s in all the bi
positions corresponding to R8 is an even number the value of R8(parity bit’s value)=0. Thus, the
data transferred is:
Hamming Code
Decoding Code Decoding a message in Hamming Code
Once and Once the receiver gets an incoming message, it performs recalculations to detect errors and
correct correct them. The steps for recalculation are −
Step 1 − Calculation of the number of redundant bits.
Step 2 − Positioning the redundant bits.
Step 3 − Parity checking.
Step 4 − Error detection and correction follows
Calculation of the number of redundant bits
Using the same formula as in encoding, the number of redundant bits are ascertained.
2r ≥ 𝑚 + 𝑟 + 1
Where m is the number of data bits and r is the number of redundant bits
43
Hamming Code
Parity checking
Parity bits are calculated based upon the data bits and the redundant bits using the same rule as
during generation of c1, c2, c3, c4 etc. Thus
c1 = parity(1, 3, 5, 7, 9, 11 and so on)
c2 = parity(2, 3, 6, 7, 10, 11 and so on)
c3 = parity(4, 5, 6, 7 and so on)
c4 = parity(8,9,10,11and so on)
44
Hamming Code
Error detection and correction
The decimal equivalent of the parity bits binary values is calculated. If it is 0, there is no error.
Otherwise, the decimal value gives the bit position which has error. For example, if c1c2c3c4 =
1001, it implies that the data bit at position 9, decimal equivalent of 1001, has error. The bit is
flipped (converted from 0 to 1 or vice versa) to get the correct message.
Hamming Code
46
Flow Control
Necessary when data is being sent faster than it can be processed by receiver
The simplest, most effective, least expensive, and most commonly used method
for transmission error control.
Using retransmission.
Computer to printer is typical setting
Can also be from computer to computer, when a processing program is limited in
capacity
Sliding window protocols are data link layer protocols for reliable and sequential
delivery of data frames.
The sliding window is also used in Transmission Control Protocol.
In this protocol, multiple frames can be sent by a sender at a time before receiving an
acknowledgment from the receiver.
The term sliding window refers to the imaginary boxes to hold frames.
Sliding window method is also known as windowing.
SLIDING WINDOW PROTOCOLS
SLIDING WINDOW PROTOCOLS
SLIDING WINDOW PROTOCOLS
SLIDING WINDOW PROTOCOLS
SLIDING WINDOW PROTOCOLS
SLIDING WINDOW PROTOCOLS
The sliding window provides several benefits:
• It controls the speed of transmission so that no fast sender can overwhelm the
slower receiver
1. Go-Back-N
2. Selective Repeat
Go-Back-N PROTOCOL
Go-Back-N ARQ protocol is also known as Go-Back-N Automatic Repeat Request.
It is a data link layer protocol that uses a sliding window method.
In this, if any frame is corrupted or lost, all subsequent frames have to be sent again.
The size of the sender window is N in this protocol. For example, Go-Back-8, the size
of the sender window, will be 8.
The receiver window size is always 1.
If the receiver receives a corrupted frame, it cancels it.
The receiver does not accept a corrupted frame.
When the timer expires, the sender sends the correct frame again.
Go-Back-N PROTOCOL
Go-Back-N PROTOCOL
Go-Back-N PROTOCOL
Go-Back-N PROTOCOL
Go-Back-N PROTOCOL
Go-Back-N PROTOCOL
Go-Back-N PROTOCOL
Negative Ack. Send by the receiver for frame no. 02 and after
receiving the negativeAck. Sender sends frame no. 02 again
Selective Repeat PROTOCOL
HDLC
HDLC defines three types of frames: information frames (I-frames), supervisory frames
(S-frames), and unnumbered frames (U-frames).
I-frames are used to transport user data and control information relating to user data
(piggybacking).
S-frames are used only to transport control information.
U-frames are reserved for system management.
Information carried by U-frames is intended for managing the link itself.
HDLC-Types of Frames
Each frame in HDLC may contain up to six fields, a beginning flag field, an address field, a
control field, an information field, a frame check sequence (FCS) field, and an ending flag
field. In multiple-frame transmissions, the ending flag of one frame can serve as the beginning
flag of the next frame.
HDLC-Types of Frames
Flag field.
• The flag field of an HDLC frame is an 8-bit sequence with the bit pattern01111110 that
identifies both the beginning and the end of a frame and serves as a synchronization pattern
for the receiver.
Address field.
• The second field of an HDLC frame contains the address of the secondary station.
• If a primary station created the frame, it contains a to address.
• If a secondary creates the frame, it contains a from address.
• An address field can be 1 byte or several bytes long, depending on the needs of the network.
One byte can identify up to 128 stations.
HDLC-Types of Frames
Control field.
• The control field is a 1- or 2-byte segment of the frame used for flow and error control.
• The interpretation of bits in this field depends on the frame type.
Information field.
• The information field contains the user's data from the network layer or management
information.
• Its length can vary from one network to another.
FCS field.
• The frame check sequence (FCS) is the HDLC error detection field.
• It can contain either a 2- or 4-byte ITU-T CRC.
HDLC-Types of Frames (Control Field)
Control Field for I-Frames
• I-frames are designed to carry user data from the network layer.
• The subfields in the control field are used to define these
functions.
• The first bit defines the type.
• If the first bit of the control field is 0, this means the frame is an
I-frame.
• The next 3 bits, called N(S), define the sequence number of the
frame.
Control Field for S-Frames
• Supervisory frames are used for flow and error control whenever piggybacking is either
impossible or inappropriate.
• S-frames do not have information fields. If the first 2 bits of the control field is 10, this means the
frame is an S-frame.
• The last 3 bits, called N(R), corresponds to the acknowledgment number (ACK) or negative
acknowledgment number (NAK) depending on the type of S-frame.
• The 2 bits called code is used to define the same itself. 88
HDLC-Types of Frames (Control Field)
• It is used to transmit the multiprotocol data between the two connected (point-to-point)
computers. It is mainly used in point-to-point devices, for example, routers are point-to-
point devices where PPP protocol is widely used as it is a WAN protocol not a simple
LAN ethernet protocol.
Frame format of PPP protocol
Flag: The flag field is used to indicate the start and end of the frame. The flag field is a 1-byte field
that appears at the beginning and the ending of the frame. The pattern of the flag is similar to the bit
pattern in HDLC, i.e., 01111110.
Address: It is a 1-byte field that contains the constant value which is 11111111. These 8 ones
represent a broadcast message.
Control: It is a 1-byte field which is set through the constant value, i.e., 11000000. It is not a
required field as PPP does not support the flow control and a very limited error control mechanism.
The control field is a mandatory field where protocol supports flow and error control mechanism.
Frame format of PPP protocol
Protocol: It is a 1 or 2 bytes field that defines what is to be carried in the data field. The
data can be a user data or other information.
Payload: The payload field carries either user data or other information. The maximum
length of the payload field is 1500 bytes.
It is responsible for encapsulating frames so that they are suitable for transmission via
the physical medium.
It performs multiple access resolutions when more than one data frame is to be
transmitted. It determines the channel access methods for transmission.
It generates the frame check sequences and thus contributes to protection against
transmission errors. 98
Taxonomy of Multiple-access protocols
99
Random Access Protocols
let's use the example of mobile phone communication. Whenever you call someone, a
connection between you and the desired person is established, also anyone can call anyone.
So here we have all the users (stations) at an equal priority, where any station can send data
depending on medium's state whether it is idle or busy, meaning that if you friend is talking to
someone else through the mobile phone, then its status is busy and you cannot establish a
connection and since all the users are assigned equal priority you can not disconnect your
friend's ongoing call and connect yours.
100
ALOHA
ALOHA is a system for coordinating and arbitrating access to a shared communication Networks
channel.
The original system used for ground based radio broadcasting, but the system has been
implemented in satellite communication systems.
A shared communication system like ALOHA requires a method of handling collisions that occur
when two or more systems attempt to transmit on the channel at the same time.
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.
Pure ALOHA
Pure ALOHA
If the acknowledgement is not received within this time, the station assumes that the frame
has been destroyed due to collision and resends the frame.
A collision occurs if more than one frame tries to occupy the channel at the same time
Pure ALOHA
Pure ALOHA
Slotted ALOHA
P-Persistent
• It is the combination of 1-Persistent and Non-persistent modes. The P-Persistent mode defines
that each node senses the channel, and if the channel is inactive, it sends a frame with a P
probability. If the data is not transmitted, it waits for a (q = 1-p probability) random time and
resumes the frame with the next time slot.
CSMA
CSMA/CD
Carrier Sense Multiple Access with Collision Detection (CSMA/CD) is a network
protocol for carrier transmission that operates in the Medium Access Control (MAC)
layer.
It senses or listens whether the shared channel for transmission is busy or not, and
defers transmissions until the channel is free.
The collision detection technology detects collisions by sensing transmissions from
other stations.
On detection of a collision, the station stops transmitting, sends a jam signal, and then
waits for a random time interval before retransmission..
CSMA/CD
The algorithm of CSMA/CD is:
• When a frame is ready, the transmitting station checks whether the channel is idle or
busy.
• If the channel is busy, the station waits until the channel becomes idle.
• If the channel is idle, the station starts transmitting and continually monitors the channel
to detect collision.
• The station resets the retransmission counters and completes frame transmission.
CSMA/CD
The algorithm of Collision Resolution is:
• The station continues transmission of the current frame for a specified time along with a
jam signal, to ensure that all the other stations detect collision.
• If the maximum number of retransmission attempts is reached, then the station aborts
transmission.
• Otherwise, the station waits for a backoff period which is generally a function of the
number of collisions and restart main algorithm.
CSMA/CD
CSMA/CA
Carrier Sense Multiple Access with Collision Avoidance (CSMA/CA) is a network
protocol for carrier transmission that operates in the Medium Access Control (MAC)
layer.
In contrast to CSMA/CD (Carrier Sense Multiple Access/Collision Detection) that deals
with collisions after their occurrence, CSMA/CA prevents collisions prior to their
occurrence.
When a frame is ready, the transmitting station checks whether the channel is idle or
busy.
If the channel is busy, the station waits until the channel becomes idle.
If the channel is idle, the station waits for an Inter-frame gap (IFG) amount of time and
then sends the frame.
CSMA/CA
Disadvantages
• Operation at high traffic load is problematic.
• Variable/Unbounded delay-not well suited for real-time applications.
• Substantial analog component (collision detection).
IEEE 802.11
IEEE has defined the specifications for a wireless LAN, called IEEE 802.11, which covers
the physical and data link layers
Architecture : The standard defines two kinds of services: the basic service set (BSS) and
the extended service set
(ESS)