R19 CNSA - Unit 2

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 94

COMPUTER NETWORKS

& SYSTEMS APPROACH

UNIT – II
LINK LAYER
Contents

• Link layer Services


• Framing
• Error Detection
• Flow control
• Noiseless Channels
• Noisy Channels
• HDLC
• Point to Point Protocol
The Data Link Layer
• Essential property of a channel is that the bits are delivered in exactly
the same order in which they are sent.

• For ideal channel (no distortion, unlimited bandwidth and no delay),


the job of data link layer would be trivial. But limited bandwidth,
distortions and delay makes its job very difficult.

• Functions of Data Link Layer:


1. Providing a well-defined service interface to the network layer.
2. It adds reliability by detecting transmission errors.
3. Regulates the flow of data so that slow receivers are not
swamped by fast senders.
The Data Link Layer
• Data Link layer
- Takes the packets from network layer
- Encapsulates them into frames
• Each frame has a
- frame header
- field for holding the packet
- frame trailer
• Frame Management is what Data Link Layer does.
Framing
• Stream of data bits provided to data link layer may be corrupted during
transmission. Errors could be:
- Number of received bits does not match with number of
transmitted bits
- Change in bit value

• Transmission at data link layer starts with breaking up the bit stream
- Into discrete frames
- Computation of a checksum for each frame and
- Include the checksum into the frame before it is transmitted

• Receiver computes its checksum for a receiving frame and if it is


different from the checksum that is being transmitted; then it has to
deal with the error.
Types of errors
• Single bit error - Only one bit in the data unit has changed.

• Burst error - Two or more bits in the data unit have changed.
Error Detection and Correction - Redundancy
• To detect or correct errors, extra (redundant) bits are added along
with the data.
• Two basic strategies to deal with errors:
- Include only enough redundancy to allow the receiver to
deduce that an error has occurred (but not which error).
Error detecting codes.

- Include enough redundant information to enable the receiver


to know the exact no. of bits corrupted and their location in the
message.
Error correcting codes.
Error Correction

The two most common error correction mechanisms are:

1. Error correction by Retransmission.


- When an error is discovered, receiver asks the sender to
retransmit the entire data unit.

2. Forward Error Correction.


- Receiver can use an error-correcting mode or guess the
message by using redundant bits, which automatically
corrects certain errors.
Error Coding
• Error Coding is a method of detecting and correcting the errors to
ensure information is transferred intact from source to destination.

• Redundancy is achieved through various coding schemes where


relationship between redundant bits and actual data bits must be
known to both sender and receiver to detect and correct errors.

• Ratio of redundant bits to data bits and robustness of the process are
important in coding schemes.

• Two categories of coding techniques:


- Block Coding
- Convolution Coding
Modular Arithmetic
• In coding, we need to use modulo-2 arithmetic. Operations in this
arithmetic use XOR for both addition and subtraction.

• In modulo-N arithmetic, we use only the integers in the range 0 to N−1.


If a number is greater than N, it is divided by N and remainder is the
result.
- Ex: If the modulus is 12, we use 0-11 inclusive.
- Modulo 12 arithmetic works like clock arithmetic.
- In clock arithmetic, if we add 2 hours to 11:00, we get 1:00.
Block Coding
• In block coding, we divide our message into blocks, each of ‘k’ bits,
called Datawords.

• We add ‘r’ redundant bits to each block to make the length n = k + r.


The resulting n-bit blocks are called Codewords.

Datawords and Codewords in Block Coding


Block Coding
• In Block Coding, errors are detected using 2 conditions.
- Receiver has (or can find) a list of valid codewords.
- Original codeword has changed to an invalid codeword.

Process of error detection in block coding


Example
• Let us assume that k = 2 and n = 3. Table shows the list of datawords and
codewords. Assume the sender encodes the dataword 01 as 011 and sends it to
the receiver. Consider the following cases:

• The receiver receives 011. It is a valid codeword. The receiver extracts the
dataword 01 from it.

• The codeword is corrupted during transmission and 111 is received. This is not a
valid codeword and is discarded.

• The codeword is corrupted during transmission, and 000 is received. This is a


valid codeword. The receiver incorrectly extracts the dataword 00. Two
corrupted bits have made the error undetectable.
Example (Contd.)
• By adding more redundant bits to previous example, see if the receiver can
correct an error without knowing what was actually sent.

• We add 3 redundant bits to the 2-bit dataword to make 5-bit codeword. Table
shows the datawords and codewords.

• Assume the dataword is 01. The sender creates the codeword 01011.
• The codeword is corrupted during transmission, and 01001 is received. First,
the receiver finds that the received codeword is not in the table. This means an
error has occurred.
• The receiver, assuming that there is only 1 bit corrupted, uses the following
strategy to guess the correct dataword.
Example (Contd.)
• Comparing the received codeword with the first codeword in the table (01001
versus 00000), the receiver decides that the first codeword is not the one that
was sent because there are two different bits.

• By the same reasoning, the original codeword cannot be the third or fourth
one in the table.

• The original codeword must be the second one in the table because this is the
only one that differs from the received codeword by 1 bit. The receiver
replaces 01001 with 01011 and consults the table to find the dataword 01.
Hamming Distance
• One of the key concepts in coding for error control is Hamming distance.
• The Hamming distance between two words is the number of differences
between the corresponding bits.
• The minimum Hamming distance, dmin is the smallest Hamming distance
between all possible pairs in a set of words which is used for designing a
code.
Ex: Let us find the Hamming distance between two pairs of words.

1. The Hamming distance d(000,011) is 2 because

2. The Hamming distance d(10101, 11110) is 3 because


Example
 Find all hamming distances in the below table:

Solution:

The dmin in this case is 3.


Error Detection & Correction
•Error Detection:
•To guarantee the detection of up to ‘s’ errors in all cases, the minimum
Hamming distance in a block code must be dmin = s + 1.
•The minimum Hamming distance for the previous example is 3.
•This code guarantees detection of up to 2 errors.

•Error Correction:
• To guarantee the correction of up to ‘t’ errors in all cases, the minimum
Hamming distance in a block code must be dmin = 2t + 1.

• A code scheme has a Hamming distance dmin = 5. What is the error


detection and correction capability of this scheme?
Linear Block Codes
• Almost all block codes used today belong to a subset called Linear Block
Codes. A linear block code is a code in which the exclusive OR (XOR)
(modulo-2 addition) of any two valid codewords creates another valid
codeword.

Simple Parity-Check code


•A Simple Parity-Check (1-Dimensional Parity Check) code is a single-bit
error detecting code in which n = k + 1 with dmin = 2.

•Even parity – ensures that a codeword has an even number of 1’s.


•Odd parity – ensures that there are odd number of 1’s in the codeword.

• A simple parity-check code can detect an odd number of errors. It


cannot correct any errors.
Simple Parity-Check code
Simple Even Parity-Check code C(5,4)
Encoder and decoder for simple parity-check code

r0 = a0 + a1 +a2 +a3 s0 = b3 +b2 +b1 +b0 +q0


Example
Let us look at some transmission scenarios. Assume the sender sends the dataword 1011.
The codeword created from this dataword is 10111 (assuming even parity), which is sent
to the receiver. We examine five cases:
1. No error occurs; the received codeword is 10111. The syndrome is 0. The dataword 1011
is created.

2. One single-bit error changes a1 . The received codeword is 10011. The syndrome is 1. No
dataword is created.

3. One single-bit error changes r0 . The received codeword is 10110. The syndrome is 1. No
dataword is created.

4. An error changes r0 and a second error changes a3 .The received codeword is 00110. The
syndrome is 0. The dataword 0011 is created at the receiver. Note that here the dataword
is wrongly created due to the syndrome value.

5. Three bits a3, a2, and a1 are changed by errors. The received codeword is 01011. The
syndrome is 1. The dataword is not created. This shows that the simple parity check,
guaranteed to detect one single error, can also find any odd number of errors.
Two-dimensional parity-check code
• Performance can be improved by using two-dimensional parity check.

• In this method, data word is organized in rows and columns.

• Data to be sent are put in separate rows and columns.

• For each row and each column, 1 parity-check bit is calculated.

• The whole table is sent to the receiver, which finds the syndrome for
each row and each column.
Two-dimensional parity-check code
Two-dimensional parity-check code
Hamming Codes
• Single parity bit can only detect error, not correct it.

• Hamming code is an important error correcting code that requires more than a
single parity bit.

• Hamming codes are codewords formed by adding redundant check bits, or


parity bits to a data word.

• All Hamming codes discussed in this unit have dmin = 3.

• Hamming Code is denoted by C(n,k), where n = 2m – 1 and k = n – m.


Structure of the encoder and decoder for a Hamming code

r0 = a2 + a1 + a0 s 0 = b2 + b 1 + b 0 + q 0
r1 = a3 + a2 + a1 s1 = b3 + b2 + b1 + q1
r2 = a1 + a0 + a3 s2 = b1 + b0 + b3 + q2
Logical decision made by the correction logic analyzer:

• If q0 is in error, s0 is the only bit affected; the syndrome is 001.


• If b2 is in error, s0 & s1 are the bits affected; the syndrome is 011.
• If b1 is in error, all 3 syndrome bits are affected; the syndrome is 111.

If two errors occur during transmission, the created dataword might


not be the right one.
Hamming code C(7, 4); n = 7, k = 4
Example
Let us trace the path of three datawords from the sender to the
destination:

•The dataword 0100 becomes the codeword 0100011. The codeword


0100011 is received. The syndrome is 000, the final dataword is 0100.

•The dataword 0111 becomes the codeword 0111001. The received


codeword is 0011001. The syndrome is 011. After flipping b2 (changing 1
to 0), the final dataword is 0111.

•The dataword 1101 becomes the codeword 1101000. The codeword


0001000 is received. The syndrome is 101. After flipping b0, we get 0000,
the wrong dataword. This shows that our code cannot correct two errors.
Burst Errors
• Burst errors are very common, particularly in wireless environments
where a fade will affect a group of bits in transit.

• One way to counter burst errors, is to break up a transmission into


shorter words and create a block (one word per row), then have a parity
check per word.

• The words are then sent column by column. When a burst error occurs,
it will affect 1 bit in several words as the transmission is read back into
the block format and each word is checked individually.
Burst error correction using Hamming code
Checksum
• In checksum error detection scheme, the data is divided into ‘k’
segments each of ‘m’ bits.
• In the sender’s end the segments are added using 1’s complement
arithmetic to get the sum.
• The sum is complemented to get the checksum.
• The checksum segment is sent along with the data segments.
• At the receiver’s end, all received segments are added using 1’s
complement arithmetic along with the checksum to get the sum.
• The sum is complemented. If the result is zero, the received data is
accepted; otherwise it is discarded.
• The checksum detects all errors involving an odd number of bits. It also
detects most errors involving even number of bits.
Example
Cyclic Codes
• Cyclic codes are special linear block codes with one extra property.

• In a cyclic code, if a codeword is cyclically shifted (rotated), the resultant


is another codeword.

A cyclic code with C(7, 4)


 Cyclic Redundancy Check (CRC) Code
• A Cyclic Redundancy Check (CRC) is an error-detecting code
commonly used in digital networks and storage devices to detect
accidental changes to raw data.
• Blocks of data entering these systems get a short check value
attached, based on the remainder of a polynomial division of their
contents.
• On retrieval, the calculation is repeated and, in the event the check
values do not match, corrective action can be taken against data
corruption.
CRC Encoder and Decoder
Division in CRC Encoder
Division in the CRC decoder for two cases
Data Link Layer

• Two main functions of Data Link Layer (DLL) are:


- Data link control: Deals with the design and procedures of
communication between two adjacent nodes.
- Medium access control: Defines how to share the link.

• Data link control functions are:


- Framing
- Flow control
- Error control
- Protocols implemented for reliable transmission
Framing
• The data link layer needs to pack bits into frames, so that each frame is
distinguishable from another.

• Framing in DLL separates message from one source to a destination or


from other messages to other destinations by adding addresses.

• It is done to make flow control and error control efficient. Frames can be
of fixed or variable size.

• Fixed-Size Framing – no boundaries for frames, size is used as the


delimiter.

• Variable-Size Framing – defines beginning and end of the frame. Two


approaches:
- Character oriented approach
- Bit oriented approach
Character Oriented Protocols
• Data to be carried are 8-bit characters. Header and trailer are also
multiples of 8-bits.
• Separation of frames is done by adding 1-byte flag at the start and end of
the frame.
• Flag – protocol dependent special characters.
• For text messages – flag could be any character not used for text comm.
• For audio, video and graph – flag could also be a part of message, that
makes the receiver think it has reached the end of the frame.
• Byte stuffing is done to fix this problem, where a special byte (ESC
character) is added to data when there is a character with same pattern
as flag.
• When receiver finds ESC character, it removes it from data and treats the
next character as data and not a delimiting flag.
• It allows presence of flag in data but creates another problem i.e., what
if the ESC character is also a part of the text?
• An extra ESC is added to show the second one is part of the text.
A Frame In A Character-Oriented Protocol

Byte stuffing -
Process of adding
1 extra byte
whenever there is
a flag or escape
character in the
text.
Bit Oriented Protocols
• Data section of a frame is a sequence of bits to be interpreted as text,
graphic, audio, video and so on..
• In addition to header and possible trailers, a delimiter is used to
separate one frame from the other.
• Most protocols use a special 8-bit pattern flag 01111110 as delimiter.
• If the flag pattern appears in the data, we stuff 1 bit to prevent the
pattern from looking like a flag – BIT STUFFING.
• If a 0 is followed by 5 consecutive 1’s, an extra 0 bit is added regardless
of the next bit.
• This guarantees that the flag sequence does not appear in the frame.
A Frame In a Bit-Oriented Protocol

Bit stuffing is the


process of adding one
extra 0 whenever five
consecutive 1’s follow a 0
in the data, so that the
receiver does not
mistake the pattern
0111110 for a flag.
Flow and Error Control
• The most important responsibilities of the data link layer are flow control
and error control. Collectively, these functions are known as data link
control.

• Flow control refers to a set of procedures that tells the sender how much
data it can send before waiting for an acknowledgment from the receiver.

• The flow of data must not be allowed to overwhelm the receiver. Most of
the receivers are provided with buffers for storing incoming data until
they are processed. If buffer is full, receiver asks to halt the transmission.

• Error control is detection and correction of lost or damaged frames. Error


control in the data link layer is based on Automatic Repeat Request
(ARQ), which is the retransmission of data.
Taxonomy of Protocols
DLL uses protocols to combine framing, flow control and error control for
the delivery of data from one node to other.
Noiseless Channels
• Noiseless channel - An ideal channel in which no frames are lost,
duplicated, or corrupted.

• Two protocols for this type of channel.

• Simplest Protocol – has no flow or error control.

• Stop-and-Wait Protocol – sender sends one frame, stops until it


receives confirmation from receiver and then sends the next frame.
Simplest Protocol

• Unidirectional protocol.

• Sender cannot send a frame until network layer has packet to send.
• Receiver cannot deliver packet to network layer until a frame arrives.

• Protocol includes certain events.


• No action is taken until a request from network layer at sender
and a notification from physical layer at receiver.
• Procedures at both sites are constantly running as they don’t know
when the event occurs.
Design of Simplest Protocol with no flow or error control
Simplest Protocol
Flow diagram
Stop-and-Wait Protocol
• If frames arrive at the receiver faster than they can be processed, they
must be stored until their use. Receiver may not have enough buffer
space (may receive data from other sources also) which results in
discarding of frames or denial of service.
• Hence, receiver sends feedback to the transmitter to prevent
overwhelming of the receiver (asks sender to slow down).
• In this protocol, sender sends a frame, stops until it receives the
confirmation from the receiver and then sends the next frame.
• Stop-and-Wait Protocol adds flow control to Simplest protocol.
Design of Stop-and-Wait Protocol
Stop-and-Wait Protocol
Flow diagram
Noisy Channels
• Stop-and-Wait Protocol gives us an idea of how to add flow control to its
predecessor. But noiseless channels are non-existent.

• Three protocols that use error control.

- Stop-and-Wait Automatic Repeat Request

- Go-Back-N Automatic Repeat Request

- Selective Repeat Automatic Repeat Request


Stop-and-Wait Automatic Repeat Request
• It adds simple error control mechanism to the Stop and Wait protocol.

• To detect and correct corrupted frames in Stop-and-Wait ARQ, redundant bits


are added.

• When the frames arrive at receiver, they are checked and if it is corrupted, it is
silently discarded. Detection is manifested by the silence of the receiver.

• Error correction in Stop-and-Wait ARQ is done by keeping a copy of the sent


frame and starts a timer. It retransmits the frame if ACK is not received before
the timer expires.

• It is difficult to identify lost frames than corrupted frames. In Stop-and-Wait


ARQ, we use sequence numbers (based on modulo-2 arithmetic) to number the
frames so that we can identify lost or duplicated frames.

• In Stop-and-Wait ARQ, the acknowledgment number always announces in


modulo-2 arithmetic the sequence number of the next frame expected.
Design of the Stop-and-Wait ARQ Protocol
Flow Diagram
Go-Back-N ARQ Protocol
• To improve the efficiency of transmission, multiple frames must be in
transition (pipeline) while waiting for acknowledgement.

• Go-Back-N lets multiple frames to be outstanding to keep the channel


busy while sender is waiting for ACK.

• Receiver has buffer ‘W’ long and we can send up to ‘W’ frames without
ACK.

• Each frame is numbered. ACK includes number of next frame expected.


Sequence Numbers
• Frames from a sender are numbered sequentially. We need to set a limit
since we need to include the sequence number of each frame in the header.

• If header of frame allows m-bits for sequence number, the sequence


numbers range from 0 to 2m – 1.
• Example for m = 3, sequence numbers are: 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4,
5, 6, 7.

• Sliding window defines the range of sequence numbers that is the concern
of sender and receiver.

• The send window is an imaginary box with three variables: S f, Sn, Ssize.

• Receiver has only one variable, Rn, that holds the sequence number of the
frame it expects to receive.
Sender Sliding Window

• At the sending site, to hold


the outstanding frames
until they are
acknowledged, we use the
concept of a window.
• The size of the window is at
most 2m-1 where ‘m’ is the
number of bits used for the
sequence number.
• The window slides to
include new unsent frames
when the correct ACKs are
received.
Receiver Sliding Window
• Size of the window at the receiving site is always 1 in this protocol.
• Receiver is always looking for a specific frame to arrive in a specific
order.
• The window slides when a correct frame has arrived. Sliding occurs one
slot at a time.
• Any frame arriving out of order is discarded and needs to be resent.
• Receiver window slides as shown in fig. Receiver is waiting for frame 0
in part ‘a’.
Send window for Go-Back-N ARQ
Receive window for Go-Back-N ARQ
Acknowledgement
• Receiver sends positive ACK, if a frame arrived safe and in order.

• If the frames are damaged/out of order, receiver is silent and discard all
subsequent frames until it receives the one it is expecting.
• The silence of the receiver causes the timer of the unacknowledged frame to
expire. Then the sender resends all frames, beginning with the one with the
expired timer.
• For example, suppose the sender has sent frame 6, but the timer for frame 3
expires (i.e. frame 3 has not been acknowledged), then the sender goes back and
sends frames 3, 4, 5, 6 again. Thus it is called Go-Back-N-ARQ.
• The receiver does not have to acknowledge each frame received, it can send one
cumulative ACK for several frames.
Go-Back-N ARQ, Normal Operation
• The sender keeps track of the outstanding frames and updates the
variables and windows as the ACKs arrive.
Go-Back-N ARQ, lost Frame
• Frame 2 is lost.
• When the receiver receives frame 3, it discards frame 3 as it is expecting
frame 2 (according to window).
• After the timer for frame 2 expires at the sender site, the sender sends
frame 2 and 3 (go back to 2).
Go-Back-N ARQ, Sender Window Size
• Size of the sender window must be less than 2m .
• Size of the receiver is always 1.
• If m = 2, window size = 2m – 1 = 3.
• Fig. compares a window size of 3 and 4.

Accepts as
the 1st
frame in
the next
cycle-an
error
Design of Go-Back-N ARQ
Selective Repeat ARQ
• Go-Back-N ARQ is inefficient for a noisy link.
• In a noisy link, frames have higher probability of damage, which means
the resending of multiple frames is necessary.
• This resending consumes the bandwidth and slows down the
transmission.

Solution:
• Selective Repeat attempts to retransmit only those frames that are
actually lost (due to errors).
– Receiver must be able to accept frames out of order.
• It defines a Negative Acknowledgement (NAK) that report the sequence
number of a damaged frame before the timer expires.
• It is more efficient for noisy link, but the processing at the receiver is
more complex. Size of the window is (2m-1).
Selective Repeat ARQ, sender and receiver windows
• The window size is reduced to one half of 2m
• Sender window size = receiver window size = 2m/2
• Window size = 2m-1
• If m = 2, Window size = 4/2=2
• Sequence number = 0, 1, 2, 3
Selective Reject (NAK)
• Also called selective retransmission
• Only rejected frames are retransmitted
• Subsequent frames are accepted by the receiver and buffered
• Minimizes retransmission
• Receiver must maintain large buffer
Send and Receive window for Selective Repeat ARQ
Selective Repeat ARQ, lost frame
• Frames 0 and 1 are
accepted when received
because they are in the
range specified by the
receiver window. Same
for frame 3.

• Receiver sends a NAK2


to show that frame 2 has
not been received and
then sender resends
only frame 2 and it is
accepted as it is in the
range of the window.
Selective Repeat ARQ, Sender window size
• Size of the sender and receiver windows must be at most one-half of 2 m.
• If m = 2, window size should be 2m/2 = 2.
• Figure compares a window size of 2 with a window size of 3.
• Window size is 3 and all ACKs are lost, sender sends duplicate of frame 0, window
of the receiver expect to receive frame 0 (part of the window), so accepts frame 0,
as the 1st frame of the next cycle – which is an error.
Design of Selective Repeat ARQ
Piggybacking
• In two way communication, whenever a data frame is received, the
receiver waits and does not send the control frame (acknowledgement)
back to the sender immediately.

• The receiver waits until its network layer passes in the next data
packet. The delayed acknowledgement is then attached to this
outgoing data frame.

• This technique of temporarily delaying the acknowledgement so that it


can be hooked up with the next outgoing data frame is known as
Piggybacking.
Piggybacking
• The major advantage of Piggybacking is better use of available channel
bandwidth.

• It improves the efficiency of bidirectional protocols since control information flow


is in both directions.

• Instead of sending an acknowledgement in an individual frame it


is piggybacked on the data frame. In the data frame itself, we incorporate one
additional field for acknowledgment (called ACK).

• Every node has two windows: Send and Receive both using the same algorithms.

• 3 types of events are involved:


- Request : Uses only send window at each site.
- Arrival : When a frame arrives, site has to handle control information and
frame itself. Uses both send and receive windows.
- Time-out
Design of Piggybacking in Go-Back-N ARQ
HDLC & Point-to-Point Protocol
• High-level Data Link Control (HDLC) is a bit-oriented protocol for
communication over point-to-point and multipoint links. It implements
the ARQ mechanisms.

• Although HDLC is a general protocol that can be used for both point-to-
point and multipoint configurations, one of the most common protocols
for point-to-point access is the Point-to-Point Protocol (PPP).

• PPP is a byte-oriented protocol.

• PPP is a byte-oriented protocol using byte stuffing with the escape byte
to be 01111101.
High-level Data Link Control
HDLC Station Types:

• Primary station: Controls operation of link. Frames issued are called


Commands.

• Secondary station: Under control of primary station. Frames issued are


called Responses.

• Combined station: May issue both commands and responses.


HDLC Link Configurations and Transfer
Modes
Normal Response Mode (NRM)
• Unbalanced configuration: Primary initiates transfer to secondary.
Secondary may only transmit data in response to command from primary.
HDLC Link Configurations and Transfer Modes
Asynchronous Balanced Mode (ABM)
• Balanced configuration: Either of the stations may initiate transmission
without receiving permission.
• In ABM the link is point-to-point.
HDLC Frame Types
• I-Frame: Information frames (user data and control data)
• S-Frame: Supervisory frames (control information)
• U-Frame: Unnumbered frames (control information for managing the
link itself)
HDLC Frame

Flag: 8-bit and the sequence 01111110 identifies the beginning and end of
the frame. Serves as synchronization pattern for receiver.
FCS: Frame Check Sequence is error detection field. Contains 2/4-byte CRC.
Address: Contains the address of the secondary station.
If ‘primary’ created the frame, it contains to address else a from address. It
can be one byte (last bit is 1) or more . If the address is more than one byte,
all bytes end with zero except the last byte ends with 1. Ending each
intermediate byte with 0 indicates to the receiver that more address bytes
are to come.
Control Field: Determine the type of frame and defines its functionality
(used for flow and error control). It is 1 or 2 byte long.
Control field format for different frame types
I-Frame

• Information: Contains the user’s information.

• Control field:
- The first bit (0) defines the frame type (I-Frame).
- N(S): Defines the sequence number of the frame.
- N(R): Acknowledgment number when piggybacking is used.
- P/F: Valid only if set to 1 and has dual purpose:

- Poll: Frame sent by the primary station (the address field contains the address of the
receiver) to secondary.

- Final: Frame sent by secondary station (the address field contain the address of the sender)
to primary.
S-Frame Control Field in HDLC

The Code field define four types of S-frames:

1. Receiver Ready (RR): 00 - receiver acknowledges the receipt of a safe frame and
ready to accept more frames.

2. Receiver Not Ready (RNR): 10 - receiver not ready to accept more frames because
it is busy.

3. Reject (REJ): 01 - This is NAK Frame that can be used in ‘Go-Back-N’ to improve
the efficiency by informing the sender that the last frame is lost or damaged.

4. Selective Reject (SREJ): 11 - NAK frame used in ‘Selective Repeat’.


U-Frame Control Field in HDLC
HDLC: Example
• Connection and disconnection
Point-to-Point Protocol: PPP
• Most common protocols for point-to-point access.
• Many Internet users who need to connect their home computer to the
server of an ISP use PPP.
• A point-to-point link protocol is required to control and manage the
transfer of data.
• PPP defines/provides
- the format of the frame to be exchanged between devices
- how two devices negotiate the establishment of the link and the
exchange of data
- how network layer data are encapsulated in the data link frame
- how two devices can authenticate each other
- multiple network layer services
- connection over multiple links
- network address configuration
• But, several services are missing for simplicity
- no flow control, simple error control (detection and discard), no
sophisticated addressing for multipoint configuration.
PPP Frame
• Flag: 01111110 the same as HDLC, but is treated as a byte because PPP is a
byte-oriented protocol
• Address: 11111111 (broadcast address)
• Control: No need because PPP has no flow control and limited error control
• PPP is a byte-oriented protocol using byte stuffing with the escape byte
01111101
PPP: Transition States

Dead: Link not in use, no


carrier detected
Establish: When node starts
communication, connection
goes into this phase
Authenticate: Optional, several
packets are sent for
authentication if agreed
Network: Negotiation for
Network layer protocols takes
place
Open: Data transfer takes place
Terminate: Connection
terminated

You might also like