Title: COE 341: Data
1COE 341 Data Computer CommunicationsDr.
Marwan Abu-Amara
- Chapter 7
- Data Link Control Protocols
2Contents
- Error Control
- Stop-and-Wait ARQ
- Go-Back-N ARQ
- Selective-Reject ARQ
- Flow Control
- Stop-and-Wait flow control
- Sliding-Window flow control
- High-Level Data Link (HDLC)
3What is Data Link Control
- The logic or procedures used to convert the raw
stream of bits provided by the physical layer
into a reliable connection - Requirements and Objectives
- Frame synchronization
- Error control
- Flow control
- Addressing
- Multiplexing data and control on connection
- Link management
4Error Flow Control
- We now study two main functions of the data-link
layer - Error control
- Flow control
- Why Error Flow Control together?
- We usually lump Error Control and Flow Control
discussions together because the data-link
protocols used for error control are also used
for flow control
5Error Control Definition
- Error Control is the second type of methods used
to handle errors in frames - First type is FEC
- Error Control methods are those that use
retransmission in the case an error occurs in a
frame - This process is called Automatic Repeat Request
(ARQ) - In general, a retransmission is needed if a
- Frame is erroneous
- Frame is lost (i.e. does not arrive or arrives
too late) - There are several reasons for this to happen
(e.g. existence of noise, network congestion)
6Flow Control Definition
- We define Flow Control as The set of procedures
used to restrict the amount of data that a TX can
send before waiting for an acknowledgement from
the RX (per Forouzan) - This is to avoid overwhelming the RX by the flow
of data from TX - RX does not absorb the received data instantly
- It buffers (temporarily stores) the data it
receives to do some processing before sending it
upward to higher layers - Without flow control, the RX buffer may overflow
and data gets lost
7Flow Control
- Assume
- No frames lost
- No frames arrive in error
- Frames arrive in the same order they were sent,
following a variable propagation delay
8A Model of Frame Transmission
Loss
Only one frame traveling on the link at any
given time
Error
9Error Flow Control Protocols
- There are three main types of error control
protocols (ARQ-based) - Stop-and-Wait ARQ
- Sliding Window ARQ
- Go-back-N ARQ
- Selective-Reject ARQ
- There are two main types of flow control
protocols - Stop-and-Wait
- Sliding Window
10Categories of Error Control
11Categories of Flow Control
12Stop-and-Wait ARQ
- Stop-and-Wait ARQ is a simple protocol
- TX keeps a copy of the last frame sent
- After receiving the frame, RX sends back an ACK
- After receiving this ACK, TX sends another frame
and so on - Both Data ACK frames are alternately numbered
with 0 or 1 - Data Frame 0 is acknowledged by ACK 1
- Data Frame 1 is acknowledged by ACK 0
13Stop-and-Wait ARQ Normal Operation
14Stop-and-Wait ARQ Abnormal Operation
- Stop-and-Wait ARQ deals with encountered
anomalies as follows - Lost or Damaged Frames RX discards them silently
i.e. without sending Negative-ACK (NACK) back to
TX - RX keeps its current value for R (R var. defined
on prev. slide) - Lost or Damaged ACK
- TX discards damaged ACK
- TX keeps a timer, after sending a frame, within
which ACK must be received. Otherwise, ACK is
considered lost. - In both situations, Lost and Damaged ACK, the TX
sends the frame again
15Stop-and-Wait ARQ Lost Frame
16Stop-and-Wait ARQ Lost ACK
17Stop-and-Wait ARQ Delayed ACK
- Another abnormality TX receiving a late ACK
- Timer has already expired
- The ACK was considered lost
- Frame is re-sent again
- This frame will be duplicate at RX and discarded
- Also its ACK will be discarded when received back
at TX - Then the late ACK arrives
- Now TX can send the next frame
18Stop-and-Wait ARQ Delayed ACK
Lost
19Stop-and-Wait ARQ Piggybacking
- Piggybacking is a method that combines the data
and the ACK in one frame - It is useful in bidirectional communications
- Stations can send their data along with ACK to
data previously received - Piggybacking is faster and saves bandwidth
20Stop-and-Wait ARQ Drawback
- In Stop-and-Wait ARQ, the line is not efficiently
utilized because only one frame is sent at a time - Its ACK must be awaited for
- During this waiting period no frames are sent
- Inefficiency gets even worse when
- TX speed is high
- TX quickly sends frame then sits idle
- Propagation distance is high
- It takes longer for the frame and its ACK to
reach destination - Both cases leave the TX waiting idle for longer
times
21Stop-and-Wait Efficiency
- Let
- Tf Time to transmit a frame Lf / R
- TACK Time to transmit an ACK LACK / R
- TProp Propagation time (link distance) / V
- TProc Processing time
- We define the frame total time as (see next
slide) - Ttotal Tf 2 TProp TProc TACK
- The utilization of the link is defined as
- U (Tf)/(Ttotal)
22Stop-and-Wait Efficiency
- It is common to ignore TProc and TACK because
they are negligible compared to other times - In which case the utilization becomes
- U (Tf)/(Tf 2Tprop) 1/(1 2a)
- Where a Tprop/Tf
- a is called the length of the link in bits
length of medium in bits compared to frame length
(Lf) - Notice that for very small a (i.e. when 1st
transmitted bit reaches RX, source will still be
transmitting), U?? 100 - Notice that for very big a (i.e. frame
transmission is completed before 1st bit reaches
destination), U?? 0 - Efficient for links where a ltlt 1 (long frames on
a short link, i.e. fills link)
23Stop and Wait Efficiency Example
- Compare the efficiency of stop-and-wait error
control for two links using the parameter a - Frame size, L 1000 characters of 8 bits each,
8000 bits
- 200-m optical fiber link
- Data rate, R 1 Gbps
- Typical wave velocity, V 2 x 108 m/s
- Frame TX time, tf L/R 8000/(1x109) 8 ms
- Propagation time, tprop d/V
- 200/(2x108) 1 ms
- End of first frame reaches RX after 81 9 ms
from start - ACK takes 1 ms more to reach TX, which sends 2nd
frame after 10 ms - Utilization 8/10 80 (1/(2a1))
- Satellite link between 2 ground stations
- d 2 x 36,000 km, Data rate, R 1 Mbps
- Typical wave velocity, V 3 x 108 m/s
- Frame TX time, tf L/R 8000/(1x106) 8 ms
- Propagation time, tprop d/V
- 2x36x106/(3x108) 240 ms
- End of first frame reaches RX after 8240 248
ms from start - ACK takes 240 ms more to reach TX, which sends
2nd frame after 488 ms - Utilization 8/488 1.6 (1/(2a1))
24Sliding Window Protocol
- Stop-and-Wait can be very inefficient when a gt 1
- Protocol
- Assumes full duplex line
- Source A and Destination B have buffers each of
size W frames - For m-bit sequence numbers
- Frames are numbered 0, 1, 2, , 2m-1, 0, 1,
(modulo 2m) - ACKs (RRs) are numbered 0, 1, 2, , 2m-1, 0, 1,
(modulo 2m) - A is allowed to transmit up to W frames without
waiting for an ACK - B can receive up to W consecutive frames
- ACK J (or RR J), where 0 ? J ? 2m-1, sent by B,
means B has received frames up to frame J-1 and
is ready to receive frame J - B can also send RNR J B has received all frames
up to J-1 and is not ready to receive any more - Window size W, can be less or equal to 2m-1
25Sliding Window Protocol
- Example of Sliding-Window-Protocol m 3 bits, W
7
- Observations
- A may Tx W 7 frames (F0, F1, , F6)
- After F0, F1, F2 are Tx-ed, window is shrunk
(i.e. can not transmit except F3, F4, , F6) - When B sends RR3, A knows F0, F1 F2 have been
received and B is ready to receive F3 - Window is advanced to cover 7 frames (starting
with F3 up to F1) - A sends F3, F4, F5, F6
- B responds with RR4 when F3 is received A
advances the window by one position to include F2
W distance between first unacknowledged
frame and last frame that can be sent
26Go-back-N ARQ
- Go-back-N ARQ improves the efficiency of the line
by sending up to W frames before worrying about
ACK - This is called Pipelining (several tasks are
started before the 1st is finished) - For this, the frames must be sequentially
numbered - Sequence number must be included in the header of
the frame - If m bits are reserved for sequence number then
the sequence numbers range from 0 to 2m 1 - Example
- m 3 bits, then seq. numbers range is 0-7 and
could be used as - 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
0, 1,
27Go-back-N ARQ Sliding Window
- At the TX side, to hold the outstanding frames
until they are individually ACK, we use a window - The window size W cannot exceed 2m 1
- W is fixed in this protocol but may be variable
in others (e.g. TCP) - Each time a proper ACK is received for a frame
the window slides past this frame, hence the name
Sliding Window - The acknowledged frames can be purged out of the
TX memory - As an example, next slide shows that frame 0 and
1 have been acknowledged - So the sliding window slides just past them in (b)
28TX Sliding Window
In (b), frame 0 and frame 1 were properly
acknowledged
29RX Sliding Window
- At the RX side, the size of the window is always
1 - The RX window is centered on the next expected
frame number - If any other frame arrives (i.e. out of sequence
arrival), it is immediately discarded - If the right frame arrives, the window slides
past it to zoom on the next expected frame
30RX Sliding Window
31Go-back-N ARQ Control Variables
- TX keeps track of three variables
- S Sequence number of the recently sent frame
- SF Sequence number of the first frame in the
window - SL Sequence number of the last frame in the
window - The frame size W is related to these variables
by - W SL SF 1
- On the other hand the RX has only one variable
- R Expected frame sequence number
32Go-back-N ARQ TX RX Control Variables
33Timers Acknowledgments
- TX sets a timer for each frame sent
- RX has no timers
- RX sends an ACK if a frame arrives with no errors
and in order - If RX receives damaged or out of sequence frame,
it silently discards them until it receives the
expected frame - The silence of the RX causes the TX timer to
expire - This in turn causes the TX to go back and send
all frames starting from the non-acknowledged
frame - This is why it is called Go-back-N ARQ
- Example
- If TX has already sent frame-6 but the timer for
frame-3 expires without receiving an ACK for it,
the TX goes back and send frames 3, 4, 5, 6
34Go-back-N ARQ Normal Operation
35Go-back-N ARQ Lost Frame Operation
Here, ACK2 acknowledges frames 0 1 at the same
time
36Quiz Window Size Condition for Go-back-N ARQ
- Earlier, we mentioned that the size of the window
must be W ? (2m 1) i.e. W lt 2m where m is
the number of bits reserved (in the frame
overhead) for the sequence number - By comparing the figures across explain the need
for this condition
37Sliding Window Protocol
- Animation for Sliding Window protocol
- Sliding Window Protocol Simulation
(http//www.cs.stir.ac.uk/kjt/software/comms/jasp
er/SWP3.html)
38Example Problem 7-9
- Two neighboring nodes (A and B) use a
sliding-window protocol with a 3-bit sequence
number. As the ARQ mechanism, go-back-N is used
with a window size of 4. Assuming A is
transmitting and B is receiving, show the window
positions for the following succession of events - Before A sends any frames
- After A sends frame 0, 1, 2 and B acknowledges 0,
1 and the ACKs are received by A - After A sends frames 3, 4, and 5 and B
acknowledges 4 and the ACK is received by A
39Example Problem 7-9 - Solution
b)
c)
40Sliding Window Protocol - Piggybacking
- When using sliding window protocol in full duplex
connections - Node A maintains its own transmit window
- Node B maintains its own transmit window
- A frame contains data field ACK field
- There is a sequence number for the data field,
and a sequence number for the ACK field
41Selective-Repeat ARQ
- Go-back-N ARQ simplifies the job of the RX
- RX keeps track of one control variable R only
- Out-of-sequence frames are simply dropped, not
buffered - However, this protocol is inefficient for noisy
links where the probability of damaged frames is
high - This means many retransmissions will occur which
uses up the bandwidth of the link - For noisy links, a more efficient mechanism is
used in which only the damaged frame is
retransmitted (not all N frames) - It is called Selective-Repeat ARQ
42Selective-Repeat ARQ TX RX Windows
- Window configuration for the TX is the same as
for Go-back-N ARQ - However, the window size should be W ? (½ ? 2m)
i.e. W ? 2(m-1) - RX window must have the same size as the TX
- This is a major difference with Go-back-N ARQ
where window W 1 for the RX - RX window specifies a range of a acceptable frame
sequence numbers - Also, in selective-repeat ARQ the RX uses
negative ACK (NACK) to report the sequence of a
damaged frame to the TX
43Selective-Repeat ARQ TX RX Control Variables
Here, S SF
44Selective-Repeat ARQ Operation Lost Frame Example
Here, ACK2 acknowledges frames 0 1 at the same
time
0
45Quiz Window Size Condition for Selective-Repeat
ARQ
- Earlier, we mentioned that the size of the window
must be W ? 2m 1 where m is the number of
bits reserved (in the frame overhead) for the
sequence number - By comparing the figures across explain the need
for this condition
46Sliding Window Protocol - Efficiency
- Refer to Appendix A
- When window size is W (for error free), link
utilization, U, is given by - where a Tprop/Tf (i.e. length of link in
bits) - Sliding window protocol can achieve 100
utilization if W ? (2a 1) - The smaller the W needed the better! (Why?)
- To get high value for U, small value for a is
needed as well !!
47Sliding Window Efficiency Example
- Compare the efficiency of Sliding Window flow
control for two links using the parameter a - Fame size, L 1000 characters of 8 bits each,
8000 bits
- 200-m optical fiber link
- Data rate, R 1 Gbps
- Typical wave velocity, V 2 x 108 m/s
- Frame TX time, tf L/R 8 ms
- Propagation time, tprop d/V 1 ms
- a tprop / tf 0.125
- 100 link utilization is achieved with window
size W - W ? (2 a1) ? (2 x 0.125 1) ? 1.25
- i.e. W 2 (A window of just 2 frames)
- Satellite link between 2 ground stations
- d 2 x 36,000 km, Data rate, R 1 Mbps
- Typical wave velocity, V 3 x 108 m/s
- Frame TX time, tf L/R 8 ms
- Propagation time, tprop d/V 240 ms
- a tprop / tf 30
- 100 link utilization is achieved with
window size W - W ? (2 a1) ? (2 x 30 1) ? 61
- W 61, k 6 bit
(Large window and buffer sizes) - For k 3 bits, W 7
- Utilization U W/(2a1) 7/(61)
11.5 gt 1.6 for Stop and wait.
48Stop-and-Wait Sliding Window as Flow Control
Protocols
- Problem
- Qualitatively explain how the Stop-and-Wait and
the Sliding Window protocols could be used for
flow control - Hint
- Think about the use of ACK and when the RX could
send it back to the TX
49High-Level Data Link Control Protocol (HDLC)
- One of the most important data link control
protocols and it is the basis for many data link
control protocols. - The job of the HDLC layer (Link Layer, Layer 2)
is to ensure that data passed up to the next
layer has been received exactly as transmitted
(i.e error free, without loss and in the correct
order) - Another important job is flow control, which
ensures that data is transmitted only as fast as
the receiver can receive it. - There are two distinct HDLC implementations
- HDLC NRM (see SDLC), and
- HDLC Link Access Procedure Balanced (LAPB)
- Usually when referring to HDLC people mean LAPB
or some variation
50High-Level Data Link Control Protocol (HDLC)
- To satisfy a variety of applications, HDLC
defines three types of stations, two link
configurations, and three types of data transfer
modes of operation. - Station types
- Primary Station (PS)
- Responsible for controlling the operation of the
link - Frames issued by the PS are called commands
- Secondary Station (SS) Frames issued by the SS
are called responses operates under the control
of a primary station - Combined Station issues commands and responses
- Link configurations
- Unbalanced one primary plus one or more
secondary - Balanced two combined stations
51High-Level Data Link Control Protocol (HDLC)
- Transfer modes
- Normal Response Mode (NRM) used in unbalanced
config. secondary may only tx data in response
to a command from primary - Asynchronous Response Mode (ARM) used in
unbalanced config. Secondary may initiate data
tx without explicit permission primary still
retains line control (initialization, error
recovery, ) - Asynchronous Balanced Mode (ABM) used in
balanced config. either combined station may tx
data without receiving permission from other
station - Animation for HDLC
52HDLC Applications
- NRM
- Point-multipoint (multi-drop line) one computer
(primary) polls multiple terminals (secondary
stations) - number of terminals are connected to a host
computer - ARM rarely used
- ABM most widely used (no polling involved)
- Full duplex point-to-point
53HDLC NRM
54HDLC ABM
55HDLC Frame Structure
56HDLC Frame Format
- Flag
- Size 1 Byte
- Special pattern 0 1 1 1 1 1 1 0 used as frame
begin/end and synch. - Used in Header and trailer
- Address
- Size 1 Byte (or more for larger networks)
- If primary station created the frame, the address
is that of the destination secondary station - If secondary station created the frame, the
address is that of the source secondary station - Networks not using primary/secondary (e.g.
Ethernet) use 2-Byte address (source/destination) - Control
- Size 1 or 2 Bytes
- Used for error flow control
- Information
- Size Varies from network to network. Always
fixed within a network - Contains user data from Network layer or Network
Management information - FCS
- Size 2 or 4 Bytes
- Implements ITU-T CRC for error detection
57HDLC Frame Structure Flag Field
- Flag Field unique pattern 01111110
- Used for synchronization
- To prevent this pattern form occurring in data ?
bit stuffing procedure is used - Tx-er inserts a 0 after each 5 1s
- Rx-er, after detecting flag, monitors incoming
bits when a pattern of 5 1s appears the
6th/7th bit are checked - If 0, it is deleted
- If 10, this is a flag
- If 11, this is an ABORT
- Pitfalls of bit stuffing one bit errors can
split one frame into two or merge two frames into
one
58HDLC Data Transparency
- If the data field of an HDLC frame contains a
pattern identical to the flag pattern (01111110),
the RX will interpret it as end-of-frame flag - Next bits will be considered part of the next
frame - This is called lack of Transparency
- Bit Stuffing is the process of adding one extra 0
whenever there are five consecutive 1s in the
data so that the receiver does not mistake the
data for a flag
59HDLC Bit Stuffing Removal
60HDLC Bit Stuffing
- Problems With bit stuffing, Single-bit errors
could split a frame into 2 or merge two frames
into 1.
01111100
Frame Splitting
(Bit stuffed)
01111110
01111110
Frame Merging
(Bit stuffed)
01111100
61HDLC Frame Structure Address Field
Extended Address Field
- Address field identifies the secondary station
that transmitted or is to receive frame - Not used (but included for uniformity) for
point-to-point links - Extendable by prior arrangement
- Address 11111111 (single octet) used by the
primary to broadcast to all secondary stations
62HDLC Frame Structure Control Field
- Three types of frames I, S, and U
- Information frame (I) carry user data (upper
layers) flow and error control info is
piggybacked on these frames as well - Supervisory frame (S) carry flow and error
control info when piggybacking is not used - Unnumbered frame (U) provide supplementary link
control - First 2 bits of the control field determine the
type of frame, the remaining are organized as
shown in figure 7.7.c and d (next slide) - Poll/Final (P/F) bit
- In command frames (P) used to solicit response
from peer entity - In response frames (F) indicate response is the
result of soliciting command
63HDLC Frame Structure Control Field
- Extension of sequence number
- 7-bit sequence numbers rather than 3-bit ones
- Set-mode command ? extends control field to 16
bit for S and I frames - Unnumbered frames always use 8-bit
64HDLC Frame Structure Information/FCS Fields
- Information field
- Present ONLY in I-frames and some U-frames
- Contains integer number of octets
- Length is variable up to some system defined
maximum - FCS field
- CRC error detecting code
- Calculated from ALL remaining bits in frame
(excluding flag field) - Normally 16 bits (CRC-CCITT polynomial
X16X12X51), or - 32-bit optional FCS using CRC-32
65HDLC Frames
- HDLC uses Synchronous transmission
- HDLC defines three types of frames
- Information frames (I-frames)
- Used to transport user data and user control
information relating to the user data (e.g.
piggybacking) - Supervisory frames (S-frames)
- Used to transport control information only
- Unnumbered frames (U-frames)
- Used in the link management
66HDLC Generic Frame Format
Indicates that the first transmitted field is the
Header flag, then the address, then the control
Trailer
Header
67HDLC I, S U Frames Format
68HDLC I-Frames
- I-frames are designed to carry user data from
Network-layer - They can include flow error control information
(piggybacking) - The bits of the I-frame Control field are
- First bit is always 0. It means it is an
I-frame - Next 3-bits, called N(S), define the sequence of
the frame - So possible sequences are 0,1,2,3,4,5,6,7
- Next bit is called P/F (Poll or Final)
- When a primary station polls other stations, it
sets this bit to 1 - When a secondary station responds to a poll, it
sets this bit to 1 - Next 3-bits, called N(R), define the value of the
ACK when piggybacking is used
69HDLC I-Frames
70HDLC S-Frames
71HDLC U-Frames
72U-frame control command and response
Command/response Meaning
SNRM Set normal response mode
SNRME Set normal response mode (extended)
SABM Set asynchronous balanced mode
SABME Set asynchronous balanced mode (extended)
UP Unnumbered poll
UI Unnumbered information
UA Unnumbered acknowledgment
RD Request disconnect
DISC Disconnect
DM Disconnect mode
RIM Request information mode
SIM Set initialization mode
RSET Reset
XID Exchange ID
FRMR Frame reject
73HDLC Operation
- HDLC operation consists of the exchange of
I-frames, S-frames, and U-frames between two
stations. - Table 7.1 list types of Control/Response
functions for various frame types - The operations of HDLC involve three phases
- Initialization (by either side) U-Frames
- Both agree on various options
- Data Transfer (by the two sides) I- and S-Frames
- Exchange of user data and control info for flow
and error control - Disconnect (by either side) U-Frames
- Signaling termination of operation
74HDLC Operation
- Initialization
- (Link Setup Disconnect)
- Issue SABME command and starts timer
- B responds with UA (or DM if request is rejected)
- A receives UA and initializes its variables
- To disconnect issue DISC command
- Followed by UA
SABME Set Asynchronous balanced/extended
mode7-bit sequence
75HDLC Operation
- Data Transfer
- Once initialization is complete a logical path is
established. - Both sides start to send I-frames (Full-duplex
exchange) starting with seq. number 0 - N(S), N(R) both are seq. number to support flow
and error control - N(R) is the ACK for the I-frame received it
enables the HDLC module to indicate which number
I-frame it expect to receive next. - RR is used (S-frame) when there is no reverse
user data (I-frame) traffic
76HDLC Operation
- Disconnect
- Either side can issue a DISC frame to request
disconnect - The remote entity MUST accept the request by
sending UA. - Any outstanding I-frame will be lost.
- Busy condition Notice the use of P/F bit.
- When A is unable to keep up with the speed of the
transmitter B or buffer is full. - A sends RNR, to halt the transmission of B
- To check the readiness of A, periodically B sends
RR frame with P set. - Once the condition of being busy is cleared A
responds with F1
77HDLC Operation
- Reject Recovery
- I-frame 4 was lost
- B receives I-frame 5 (out of order) responds
with REJ 4 - A resend I-frame 4 and all subsequent frames
(Go-back-N) - Timeout Recovery
- A sends I-frame 3 but it is lost
- Timer expires before acknowledgement arrives
- A polls Node B
- B responds indicating it is still waiting for
frame 3 B set the F bit because this a response
to As solicitation
78HDLC Example Piggybacking w/o Errors
- Next slide shows an exchange using piggybacking
when there is no error - Station A begins the exchange of information with
an I-frame numbered 0 followed by another I-frame
numbered 1 - Station B piggybacks its acknowledgment of both
frames onto an I-frame of its own - Station Bs first I-frame is also numbered 0
N(S) field and contains a 2 in its N(R) field,
acknowledging the receipt of As frames 1 and 0
and indicating that it expects frame 2 to arrive
next - Station B transmits its second and third I-frames
(numbered 1 and 2) before accepting further
frames from station A - Its N(R) information, therefore, has not changed
B frames 1 and 2 indicate that station B is still
expecting As frame 2 to arrive next
79HDLC Example Piggybacking w/o Errors
80HDLC Example Piggybacking with Errors
- Suppose frame 1 sent from station B to station A
has an error - Station A informs station B to resend frames 1
and 2 (the system is using the Go-Back-N
mechanism) - Station A sends a reject supervisory frame to
announce the error in frame 1 - Next slide shows the exchange
81HDLC Example Piggybacking with Errors