02.1 - WAN Protocol - HDLC
02.1 - WAN Protocol - HDLC
Computer Networks
Flow Control
• Ensuring the sending entity does not overwhelm
the receiving entity
—Recipient needs some time to process incoming
packets
—If sender sends faster than recipient processes, then
buffer overflow occurs
• flow control prevents buffer overflow
1
Performance Metrics and
Delays (Section 5.3)
• Transmission time (delay)
—Time taken to emit all bits into medium
• Propagation time (delay)
—Time for a bit to traverse the link
• Processing time (delay)
—time spent at the recipient for processing
• Queuing time (delay)
—waiting time at the queue to be sent out
transmission
time
2
Stop and Wait Flow Control
• Source transmits frame
• Destination receives frame and replies with
acknowledgement
• Source waits for ACK before sending next frame
• Destination can stop flow by not sending ACK
• Works well for large frames
• Inefficient for smaller frames
3
Figure 5.6
Stop and Wait Link Utilization
4
Sliding Window Flow Control
(W = 7)
5
Sliding Window Enhancements
in Implementation
• Receiver can acknowledge frames without
permitting further transmission (Receive Not
Ready)
• Must send a normal acknowledge to resume
• If duplex, use piggybacking
—frame has both data and ack fields
—If no data to send, use acknowledgement frame
—If data but no acknowledgement to send, send last
acknowledgement number again
6
Sliding Windows Performance -
2
7
Types of Errors
• Single bit errors
—isolated errors
—affects (flips) one bit, nearby bits are not altered
—not so common in real life
• Burst errors
—a sequence of bits are affected
—most common case
—a burst error of length B is a contiguous sequence of
B bits in which the first and the last and some
intermediate bits are erroneously flipped.
• not necessarily all bits between the first and the last one
Error Detection
• Additional bits added by transmitter as error
detection code
—receiver checks this code
• Parity
—single bit added to the end of the data
—Value of parity bit is such that data has even (even
parity) or odd (odd parity) number of ones
—Even number of bit errors goes undetected
• thus not so useful
8
Error Detection Process using
Cyclic Redundancy Check
F= F’=
9
Cyclic Redundancy Check (CRC)
• Standard CRCs (generators are standard)
—checks all single, double and odd number of errors
—checks all burst errors with length less than or equal
to the length of FCS (n-k)
—checks most of the burst errors of longer length
• for bursts of length n-k+1 (length of generator), probability
of an undetected error is 1/2n-k-1
• for longer bursts, probability of an undetected error is 1/2n-k
Error Control
• Actions to be taken against
—Lost frames
—Damaged frames
• Automatic repeat request (ARQ) mechanism
components
—Error detection
—Positive acknowledgment
—Retransmission after timeout
—Negative acknowledgement and retransmission
10
Automatic Repeat Request
(ARQ)
• Stop-and-wait ARQ
• Go-back-N ARQ
• Selective-reject (selective retransmission) ARQ
11
Stop-and-Wait ARQ –
Example
12
Go-Back-N ARQ
• Based on sliding window
• If no error, ACK as usual with next frame
expected
—ACKi means “I am ready to receive frame i” and “I
received all frames between i and my previous ack”
• Sender uses window to control the number of
unacknowledged frames
• If error, reply with rejection (negative ack)
—Discard that frame and all future frames until error
frame received correctly
—Transmitter must go back and retransmit that frame
and all subsequent frames
Go-Back-N ARQ -
Damaged Frame
• Receiver detects error in frame i
• Receiver sends rejection-i
• Transmitter gets rejection-i
• Transmitter retransmits frame i and all
subsequent frames
13
Go-Back-N ARQ - Lost Frame (1)
• Frame i lost
• Transmitter sends i+1
• Receiver gets frame i+1 out of sequence
• Receiver sends reject i
• Transmitter goes back to frame i and
retransmits it and all subsequent frames
14
Go-Back-N ARQ- Damaged
Acknowledgment
• Receiver gets frame i and send acknowledgment
(i+1) which is lost
• Acknowledgments are cumulative, so next
acknowledgement (i+n) may arrive before
transmitter times out on frame i
==> NO PROBLEM
• If transmitter times out, it sends
acknowledgment request with P bit set as
before
15
Go-Back-N ARQ -
Example
Selective Reject
• Also called selective retransmission
• Only rejected frames are retransmitted
• Subsequent frames are accepted by the receiver
and buffered
• Minimizes retransmission
• Receiver must maintain large enough buffer
• Complex system
16
Selective Reject -
Diagram
Issues
• RR with P=1 is from HDLC standard
—pure protocol just have retransmissions after timeout
• as explained in Tanenbaum
17
Issues – Window Size
• Given n-bit sequence numbers, what is Max
window size?
—go-back-n ARQ 2n-1
• Why?
• what about receiver’s window size?
– It is 1, why?
—selective-reject(repeat) 2n-1
• Why?
18
Issues - Performance
• Notes on board
• Appendix at the end of Chapter 14
—selective reject ARQ is not in the book
19
HDLC Station Types
• Primary station
—Controls operation of link
—Frames issued are called commands
• Secondary station
—Under control of primary station
—Frames issued called responses
• Combined station
—May issue commands and responses
20
HDLC Transfer Modes (1)
• Normal Response Mode (NRM)
—Unbalanced configuration
—Primary initiates transfer to secondary
—Secondary may only transmit data in response to
command from primary
—Terminal-host communication
• Host computer as primary
• Terminals as secondary
—not common
21
Frame Structure
• All transmissions in frames
• Single frame format for all data and control
exchanges
22
Flag Fields
• Delimit frame at both ends
• 01111110
• Receiver hunts for flag sequence to synchronize
• Bit stuffing used to avoid confusion with data
containing 01111110
—0 inserted after every sequence of five 1s
—If receiver detects five 1s it checks next bit
• If 0, it is deleted
• If 1 and seventh bit is 0, accept as flag
—If sixth and seventh bits 1, sender is indicating abort
23
Address Field
• Identifies secondary station that sent or will
receive frame
• Usually 8 bits long
• May be extended to multiples of 7 bits with prior
agreement
—leftmost bit of each octet indicates that it is the last
octet (1) or not (0)
Frame Types
• Information - data to be transmitted to user
—Acknowledgment is piggybacked on information
frames
• Supervisory – ARQ messages
(RR/RNR/REJ/SREJ) when piggyback not used
• Unnumbered - supplementary link control
functions. For examples,
—setting the modes
—disconnect
24
Control Field Diagram
Poll/Final Bit
• Use depends on context. A typical use is below.
• Command frame
—P bit set to 1 to solicit (poll) supervisory frame from
peer
• Response frame
—F bit set to 1 to indicate response to soliciting
command
25
Information Field
• Only in information and some unnumbered
frames
• Must contain integral number of octets
• Variable length
26
HDLC Operation
• Exchange of information, supervisory and
unnumbered frames
• Three phases
—Initialization
—Data transfer
—Disconnect
Initialization
• Issue one of six set-mode commands
—Signals other side that initialization is requested
—Specifies mode (NRM, ABM, ARM)
—Specifies 3- or 7-bit sequence numbers
• If request accepted HDLC module on other side
transmits unnumbered acknowledged (UA)
frame
• If request rejected, disconnected mode (DM)
sent
27
Data Transfer
• Both sides may begin to send user data in I-frames
— N(S): sequence number of outgoing I-frames
• modulo 8 or 128, (3- or 7-bit)
— N(R) acknowledgment for I-frames received
• I-frame expected next
• S-frames also used for flow and error control
— Receive ready (RR) frame acknowledges last I-frame received
• Indicating next I-frame expected
• Used when no reverse data
— Receive not ready (RNR) acknowledges, but also asks peer to suspend
transmission of I-frames
• When ready, send RR to restart
— REJ initiates go-back-N ARQ
• Indicates last I-frame received has been rejected
• Retransmission is requested beginning with N(R)
— Selective reject (SREJ) requests retransmission of single frame
Disconnect
• Send disconnect (DISC) frame
• Remote entity must accept by replying with UA
—Informs layer 3 user connection terminated
28
Examples of Operation (1)
29
Other DLC Protocols
(LAPB,LAPD)
• Link Access Procedure, Balanced (LAPB)
—Part of X.25 (ITU-T)
—Subset of HDLC - ABM (Async. Balanced Mode)
—Point to point link between user and packet switching
network node
—HDLC frame format
• Link Access Procedure, D-Channel (LAPD)
—Part of ISDN (ITU-T)
—ABM
—Always 7-bit sequence numbers (no 3-bit)
—always 16-bit CRC
—16-bit address field
30
Other DLC Protocols (LLC)
• LLC Services
—3 alternatives
—Connection Mode Services
• Similar to HDLC ABM
—Unacknowledged connectionless services
• no connection setup
• No flow-control, no error control, no acks (thus not reliable)
• good to be used with TCP/IP. Why?
—Acknowledged Connectionless Service
• No connection setup
• reliable communication
31