Chapter 3
Chapter 3
The data link layer uses the services of the physical layer to send and receive bits over communication
channels. It has a number of functions, including:
3. Regulating the flow of data so that slow receivers are not swamped by fast senders.
To accomplish these goals, the data link layer takes the packets it gets from the network layer and
encapsulates them into frames for transmission. Each frame contains a frame header, a payload field for
holding the packet, and a frame trailer, as shown in figure below:
• The DLL will make no attempt to detect the loss of or recover a lost frame.
• This service is useful for low error rate networks and for real-time traffic where late data is worse than
no data.
• If it hasn’t arrived correctly (or within the correct time) it can be resent.
• There is no requirement for such an acknowledgement service to be implemented by the Data Link
Layer.
Framing:
Encapsulates datagram into frame, adding header, trailer.
“MAC” addresses used in frame headers to identify source, destination
Flow Control:
Pacing (speed) between adjacent sending and receiving nodes
Error Control:
a. Error Detection:
Errors caused by signal attenuation, noise are detected by the receiver.
b. Error Correction:
Correction can be done by receiver by Forward Error Correction method.
Or by Backward Error Correction Method. i.e. Retransmission
Framing:
• Translates the physical layer's raw bit stream into discrete units called frames.
• The Process of creating Frames by the Data Link Layer is known as Framing.
Types of Frames:
Character Count:
• We use a field in the header to specify the number of characters in the frame.
• Destination sees the character count, it knows how many characters to follow.
Fig: A byte stream (a) without error (b) with one error
The main disadvantage of this method is that, an error can change the character count.
And if the wrong character count is received than the receiver will get out of synchronization
and will be unable to locate the start of the next frame. This method is rarely used today.
This method solves the problem of resynchronization after an error by having each
frame start and end with special bytes. Often the same byte, called a flag byte, is used as both
the starting and ending delimiter. Two consecutive flag bytes indicate the end of one frame and
the start of the next. Thus, if the receiver ever loses synchronization it can just search for two
flag bytes to find the end of the current frame and the start of the next frame.
However, there is a still a problem we have to solve. It may happen that the flag byte
occurs in the data, especially when binary data such as photographs or songs are being
transmitted. This situation would interfere with the framing. One way to solve this problem is
to have the sender’s data link layer insert a special escape byte (ESC) just before each
‘‘accidental’’ flag byte in the data. Thus, a framing flag byte can be distinguished from one in
What happens if an escape byte occurs in the middle of the data? The answer is that it,
too, is stuffed with an escape byte.
Fig: (a) A frame delimited by flag bytes (b) four examples of byte sequence before and
after byte stuffing
• We could have problems with two machines communicating where one uses 8-bit characters
and one uses 16-bit characters.
• Most DLL protocols use a combination of character count with another method for extra
safety. This increases the chances of catching an error.
• At the start and end of each frame is a flag byte consisting of the special bit pattern 01111110
• Whenever the sender's data link layer encounters five consecutive 1s in the data, it
automatically stuffs a zero bit into the outgoing bit stream. This technique is called bit stuffing
• When the receiver sees five consecutive 1s in the incoming data stream, followed by a zero
bit, it automatically de-stuffs the 0 bit.
• The boundary between two frames can be determined by locating the flag pattern.
(c) The data as they are stored in the receiver’s memory after destuffing.
The last method of framing is to use a shortcut from the physical layer. This method is
only applicable to networks in which the encoding on the physical medium contains some
redundancy. This redundancy means some signals will not occur in regular data. This means
there is possibility that many signals are not being used and just are reserved.
We can use some reserved signals to indicate the start and end of frames. In effect, we
are using ‘‘coding violations’’ to delimit frames. The beauty of this scheme is that, because they
are reserved signals, it is easy to find the start and end of frames and there is no need to stuff
the data.
Note:
Many data link protocols use a combination of these methods for safety. A common
pattern used for Ethernet and 802.11 is to have a frame begin with a well-defined pattern
called a preamble. This pattern might be quite long (72 bits is typical for 802.11) to allow the
receiver to prepare for an incoming packet. The preamble is then followed by a length (i.e.,
count) field in the header that is used to locate the end of the frame.
• We also have to deal with making sure that the frames make it to their destination.
• The receiver sends back a control frame acknowledging the received frame and the condition of the
frame.
• A timeout can occur if the acknowledgement doesn’t arrive, resulting in the frame being resent.
• Resending the frame can also cause problems – what happens when the same frame is received twice?
• We can also sequentially number the frames to prevent this problem.
• Error control in the data link layer is based on automatic repeat request, which is the retransmission of
data
Burst error:
o 2 or more bits in the data unit have changed from 1 to 0 or from 0 to 1.
o Burst error is more likely to occur than a single-bit error
Parity Check:
The parity check is done by adding an extra bit called parity bit to the data to
make no. of 1’s either even in case of even parity or odd in case of odd parity.
While creating a frame, the sender counts the no. of 1’s in it and adds the parity
bit in the following way:
In case of even parity; if the number of 1’s is even then parity bit value is zero.
If the number of 1’s is odd then parity bit value is 1.
In case of odd parity if a number of 1’s is odd then parity bit value is zero. If a
number of 1’s is even then the parity bit value is 1.
On receiving a frame, the receiver counts the no. of 1’s in it. In case of even parity
check if the count of 1’s 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.
Checksum:
The sender adds the bits of the data to get the sum; it then computes the 2’s
compliment of the sum to get the checksum and sends the checksum along with the dataframe.
The receiver adds all the data bits along with the checksum. If the result is zero the received
frame are accepted otherwise they are discarded.
If the receiver detects any error in the incoming frame, it requests the sender to
retransmit the frame. It is relatively simple technique. But it can be effectively
used only where retransmission is not expensive. For e.g. in fiber optic cables. It
is also called Automatic Repeat Request (ARQ) technique.
If the receiver detects any error in the incoming frame, it executes error
correcting codes that generates the actual frames. This saves bandwidth for
retransmission.
Possible if the number of error is small i.e. if there are too many
errors, the frames needs to be retransmitted. Some of the codes are
Hamming codes, Binary Convolutional codes, low density parity check
codes etc.
Hamming Codes:
Hamming code is a block code that is capable of detecting up to two simultaneous bit
errors and correcting single-bit errors. It was developed by R.W hamming for error correction.
In this coding method, the source encodes the message by inserting redundant bits
within the message. These redundant bits are extra bits that are generated and inserted at
specific positions in the message itself to enable error detection and correction. When the
destination receives this message, it performs recalculations to detect errors and find the bit
position that has error.
2^r ≥ m+r+1
Suppose we have 4 data bits, then redundant bits can be calculated as:
The positions of these bits is given by the formula 2^n, where n = {0,1,2,3,..}
These redundant bits are parity bits. By default, we use even parity for the
calculation of these bits.
Thus, r1 = “parity value will be 1, if the no. of 1’s for positions 3,5,7.. is
odd”
r2= “parity value will be 1, if the no. of 1’s for positions 3,6,7.. is
odd ”
r3= “parity value will be 1, if the no. of 1’s for positions 5,6,7.. is
odd”
Parity bits are calculated upon the data bits and the redundant bits using same
rule as above:
c2 = parity (2,3,6,7)
c3 = parity (4,5,6,7)
Now, the error can be detected by the receiver if there is any with the help of
the parity checking. i.e. if the values of c1, c2 and c3 are 0’s then there is no error, else
there is an error.
c3.c2.c1
This error position is calculated simply by the decimal value of the bits c1c2c3.
c3.c2.c1
i.e. if c3c2c2 = 101, the error bit will be 5, and this bit needs to be flipped to get
the correct message
When a receiver receives a damaged frame, it discards it and keeps its value of R.
After the timer at the sender expires, another copy of frame 1 is sent.
Piggybacking:
1 2 3 4 5 6 1 2 3 4 5 6
It uses the principle of protocol pipelining in which the multiple frames can be
sent before receiving the acknowledgment of the first frame. If we have five
frames and the concept is Go-Back-3, which means that the three frames can be
sent, i.e., frame no 1, frame no 2, frame no 3 can be sent before expecting the
acknowledgment of frame no 1. If the acknowledgment of a frame is not received
within an agreed-upon time period, then all the frames available in the current
window will be retransmitted.
The Go-back-N ARQ protocol works well if it has fewer errors. But if there is
a lot of error in the frame, lots of bandwidth loss in sending the frames again. So,
we use the Selective Repeat ARQ protocol. In this protocol, the size of the sender
window is always equal to the size of the receiver window.
If the receiver receives a corrupt frame, it does not directly discard it. It
sends a negative acknowledgment to the sender. The sender sends that frame
again as soon as on the receiving negative acknowledgment. So unlike Go-Back-N
ARQ, instead of sending the whole frames after not receiving ACK of any frame
afterward, it only sends the frame whose Negative acknowledgement is received
by the sender.
As there could be frames out of order in the receiving side, it requires
sorting to sort the frames.
Operation:
HDLC operation consists of the exchange of I-frames, S-frames, and U-
frames between two stations. The operation of HDLC involves three phases. First,
one side or another initializes the data link so that frames may be exchanged in an
orderly fashion. During this phase, the options that are to be used are agreed
upon. After initialization, the two sides exchange user data and the control
Flag Field: It marks the beginning and end of the PPP frame. Flag byte is
01111110.
Address: always 11111111, which means all stations can accept the frame.
Control Field: It is also of 1 byte. The value is always 00000011 to show that the
frame does not contain any sequence number and there is no flow control or
error control.
Protocol field: tells what kind of packet is in payload. Codes stating with 0’s are
for IPv4, IPv6, IPX etc. and codes stating with 1’s are for PPP configuration
protocols such as LCP and NCP.
Payload Field: Its length is variable. It carries user data or other information.
FCS Field: It stands for Frame Check Sequence. It contains checksum. It is either 2
bytes or 4 bytes.
PPP uses several other protocols to establish link, authenticate users and to carry
the network layer data:
Random no.
LLC provides flow control, acknowledgement and error control. The LLC sub-
layer acts as an interface between the medium access control sub-layer and the
network layer.
The main functions of MAC sub-layer are:
ALOHA
CSMA (Carrier Sense Multiple Access)
CSMA/CD (Carrier Sense Multiple Access with Collision Detection)
CSMA/CA (Carrier Sense Multiple Access with Collision Avoidance)
ALOHA:
• Any terminal is allowed to transmit without considering whether channel is idle
or busy
• If packet is received correctly, the base station transmits an acknowledgement.
• If no acknowledgement is received,
it assumes the packet to be lost
it retransmits the packet after waiting a random time
There are two different versions of ALOHA:
Pure ALOHA
Slotted ALOHA
Pure ALOHA:
In pure ALOHA, stations transmit frames whenever they have data to send.
When two stations transmit simultaneously, there is collision and frames
are lost.
In pure ALOHA, whenever any station transmits a frame, it expects an
acknowledgement from the receiver.
If acknowledgement is not received within specified time, the station
assumes that the frame has been lost.
If the frame is lost, 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.
Slotted ALOHA:
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, station waits until it becomes idle.
When the station detects an idle channel, it immediately transmits the
frame.
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.
More subtly, the propagation delay has an important effect on collisions.
There is a chance that just after a station begins sending, another station
will become ready to send and sense the channel. If the first station’s signal
has not yet reached the second one, the latter will sense an idle channel
and will also begin sending, resulting in a collision.
The protocol is called 1-persistent because the station transmits with a
probability of 1 when it finds the channel idle.
Non-Persistent CSMA
CSMA/CD
Half Duplex
CSMA with Collision Detection
In this protocol, the station senses the channel before transmitting the
frame. If the channel is busy, the station waits.
Additional feature in CSMA/CD is that the stations can detect collisions.
The stations abort their transmission as soon as they detect collision.
In CSMA/CD, the station that sends its data on the channel continues to
sense the channel even after data transmission.
If collision is detected, the station aborts its transmission and waits for a
random amount of time & sends its data again.
As soon as a collision is detected, the transmitting station releases a jam
signal.
Jam signal alerts other stations. Stations are not supposed to transmit
immediately after the collision has occurred.
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 idle, it may be possible that some distant station
may have already started transmitting.
Therefore, the purpose of IFS time is to allow this transmitted signal to
reach its destination.
If after this IFS time, channel is still idle, the station can send the frames.
Contention Window
The Preamble - This consists of seven bytes, all of the form "10101010".
This allows the receiver's clock to be synchronized with the sender's.
The Start Frame Delimiter - This is a single byte ("10101011") which is used
to indicate the start of a frame.
The Destination Address - This is the address of the intended recipient of
the frame. The addresses in 802.3 use globally unique hardwired 48 bit
addresses.
The Source Address - This is the address of the source, in the same form as
above.
The Length - This is the length of the data in the Ethernet frame, which can
be anything from 0 to 1500 bytes.
Data - This is the information being sent by the frame. Padding is
performed to make a minimum size of the frame to 64 bytes.
Checksum - This is used for error detection and recovery.
VLANs are used to divide a physical LAN into multiple broadcast domains
(logically) to isolate services with the aim of improving the security and
management of the network.
Hosts within a VLAN can directly communicate only with other hosts in
the same VLAN and must use a router to communicate with hosts in
other VLANs.
Broadcast frames will only be switched to the same VLAN.
Unlike other LAN types, which physically connect computers to LAN
segments, VLANs assign computers to LAN segments by software.
The IEEE has defined an extended Ethernet frame format, 802.1Q, for
frames crossing a VLAN trunk. The 802.1Q frame consists of the
standard Ethernet frame with a four-byte VLAN tag added into the
header that carries the identity of the VLAN to which the frame belongs.
IEEE 802.4 (Token Bus):
802.3 suffered difficulty and gave poor performance under heavy load.
Token passing protocols were proposed and were found to be very
attractive for situations with heavy load.
The basic idea is to generate a token in the network.
A token is a small message that circulates among the stations of a computer
network providing permission to the stations for transmission.
If a station has data to transmit when it receives a token, it sends the data
and then passes the token to the next station; otherwise, it simply passes
the token to the next station.
Frame Structure:
If a station fails, entire architecture will fail. To avoid this bypass relays
are used. If a station is powered down the relays close thereby removing
the station from the ring and maintaining the ring.
The starting and ending delimiter fields mark the beginning and ending of
the frame.
The access control byte contains the token bit, and also the monitoring bit,
priority bits and reservation bits.
The frame control byte, distinguishes data frames from various possible
control frames.
The frame status byte contains A and C bits.
A C Significance
0 0 Destination not present or not powered up
1 0 Destination present but frame not accepted
1 1 Destination present and frame copied.
Preamble: used to synchronize the individual clocks on the ring since there is no
master clock in FDDI.
Starting delimiter: 1 byte that marks the beginning of the frame.
Frame control: 1 byte that specifies whether this is a data frame or control frame.
Destination address: 6 bytes that specifies address of destination station.
Source address: 6 bytes that specifies address of source station.
Info (Data): A variable length field that carries the data from the network layer.
FCS: 4 bytes frame check sequence for error detection.
Ending delimiter: 1 byte that marks the end of the frame.
Frame status: has the Address Recognized (A) and Frame Copied (C) and Error (E)
indicators which are either Set (S symbol) or Reset (R symbol).
Wireless LANs provide high speed data communication in small areas such
as building or an office. WLANs allow users to move around in a confined
area while they are still connected to the network
Use CSMA/CA (Carrier Sense Multiple Access with Collision Avoidance)
A station wishing to transmit shall first sense the medium.
If the medium is busy, the station shall defer until the end of the current
transmission.
After deferrals, the station shall select a random back off interval and shall
decrement the back off interval counter while the medium is idle.
By: Er. Saurav Raj Pant, IOE - TU
If the medium is idle, after any deferrals or back offs, prior to data
transmission, RTS/CTS short frames are exchanged. (optional mechanism)
802.11b Standard
802.11a Standard:
Extension of 802.11b
Extended throughput up to 54 Mbit/s.
Using the same 2.4 GHz band as 802.11b.
802.11g hardware is fully backwards compatible with 802.11b hardware.
Uses OFDM
2019
2.4 and 5 GHz
Wifi 6E uses 6GHz
MU-MIMO available in downlink and uplink direction.
Uses OFDMA.
Note: In OFDM all subcarriers of the symbol are used for providing data to a
specific user whereas in OFDMA the sub-carriers of each symbol can be divided
into multiple users thus enabling better use of radio resources.