Ch03-Data Link Layer Protocols
Ch03-Data Link Layer Protocols
Content
❑Chapter 3: Data Link Layer Protocols
❖Flow Control
❖Error Control
❖Connection Management
❖Data Link Protocols
❑Chapter 4: Telecommunication Networks
❖802.x standard and TCP/IP Model
❖Ethernet, Token Pass, Token Ring
❖IP Addressing: Classfull and VLSM
❖Network devices
❖Switching and Routing
❖STP, VLAN
Framing
❑The data link layer needs to pack bits into frames, so
that each frame is distinguishable from another.
❖Fixed-Size Framing
❖Variable-Size Framing
Error Control
❑Forward Error Control (FEC)
❖Usually used in real-time application (e.g. voice, video)
❖Accept errors if can not correct
❖List some FEC methods? (e.g. BSC, Hamming)
❑Error Detection + ARQ (Automatic Retransmission Request)
❖Require absolutely correct data transmission
❖Used in non real-time application (e.g. email, file
transmission)
❖2 basic ARQ protocols:
• Stop-and-Wait (Idle) ARQ: Bisync (IBM), XModem
• Continuous RQ:
– Go-back N: e.g. HDLC, V.42
– Selective-Repeat: TCP, Service Specific Connection Oriented
Protocol
Notations
I -frame
P S
ACK frame or NAK frame
Idle RQ
❑ Principle:
❖ P can have only 1 I-frame
outstanding (awaiting for
an ACK) at a time
❖ On receipt of an error-free
ACK frame, P transmits
another I-frame
❖ If S receives an I-frame or
P receives an ACK
containing transmission
error: the frame is
discarded
❖ If P does not receive an
ACK within a given timeout
interval: retransmits the
waiting I-frame
❖ If an ACK is corrupted, the
S receives another copy of
the frame and it is rejected
by S.
Idle RQ
❑ Implicit retransmission
❖ P has to wait a timeout
interval before retransmission
❖ What is the drawback of this
mechanism? How to improve
❑ Explicit retransmission
❖ If S receives a corrupted I-
frame: return an NAK to P
❖ If P receives an ACK, stop the
timer, and transmit the next
frame.
❖ If P receives a NAK, retransmit
the I-frame
❖ If P does not receives ACK or
NAK during a timeout interval,
do the retransmission by timer
Idle RQ
❑Advantages :
❖Send and Wait (Stop and Wait)
❖Small buffers: both P and S
keeps only 1 frame
❑Disadvantages:
❖Low link utilization
❖Used in transmission of
printable characters
❖Half-duplex applications
❑Notation:
❖N(S): send sequence number
❖N(R): receive sequence
number
Idle-RQ
❑ Link utilization:
❑ In case BER=0:
Tix Tix 1 1
U= = =
Tt Tix +2Tp 1+2Tp /Tix 1+2a
Idle-RQ
❑ Remember:
Tp
a= (length of the link in bits)
Tix
▪ If a < 1 (i.e. Tix > Tp ): when
1st transmitted bit reaches S,
P will still be transmitting.
Hence U is close 100%
▪ If a > 1 (i.e. Tix < Tp) frame
transmission is completed
before 1st bit reaches S.
Hence U is low.
a>1 a<1
❑ Idle-RQ is efficient for links
where a << 1 (long frames
compared to propagation
time)
Idle-RQ
❑ In case BER>0 (channel with errors): in order to transmit 1 I-
frame successfully, sender needs to retransmit Nr frames:
Tix Tix 1 1
U= = = =
Nr .Tt Nr (Tix +2Tp ) Nr (1+2Tp /Tix ) Nr (1+2a)
❑ If we call Pf is the FER, and 1 frame has Ni bits:
Pf =1-(1-BER)Ni
❑ Probability that i transmission are needed to deliver frame
successfully ( i-1 transmission in error and the ith transmission is
error free ):
E[# of transmission in error]= (i-1).Pr [ # of trans. in error = i-1]
i=1
Pf
= (i-1).P .(1-Pf ) = (1-Pf ).Pf (i-1).P =
f
i-1
f
i-2
Idle-RQ
❑ Number of transmissions:
Pf 1
Nr =1+ =
1-Pf 1-Pf
❑ Utilization:
1-Pf
U=
(1+2a)
❑ Total average delay per frame if using Implicit scheme?s
❑ Utilization Performance when working with high speed and long
propagation delay?
Tt
Idle-RQ: Example
❑A series of 1000-bit frames is to be transmitted using
an idle RQ protocol. Determine the link utilization for
the following types of data link assuming a data
transmission rate of (i) 1 kbps and (ii) 1 Mbps. The
velocity of propagation of the link is 2.108 m/s and
the BER is negligible
❖A twisted pair cable 1 km in length
❖A leased line 200 km in length
❖A satellite link of 50,000 km
❑Solution?
Idle-RQ: Communication
❑Usually, Idle-RQ is used in
unidirectional communication.
❑If using bidirectional
communication?
❖Both sender and receiver have to
send and acknowledge data
❑Piggy back methods:
❖outstanding ACKs are placed in the
header of information frames
❖save bandwidth since the overhead
from a data frame and an ACK
frame (addresses, CRC, etc) can be
combined into just one frame
Continuous RQ
❑ Continuous RQ improves the link utilization at the expense of
increased buffer storage requirements.
❑ Principle:
❖ P sends I-frames continuously without waiting for an ACK to be returned
❖ Since more than 1 I-frames is waiting ACK, P retains a copy of each I-frame
transmitted in a retransmission list (using FIFO)
❖ S returns an ACK for each correctly received I-frame
❖ Each I-frame contains a unique identifier which is returned is the
corresponding ACK-frame
❖ On receipt of an ACK, the corresponding I-frame is removed from the
retransmission list by P
❖ Frames received free of errors are placed in the link receive list to wait
processing
❖ On receipt of the next in-sequence I-frame expected, S delivers the
information content within the frame to the upper layer
❖ In the event of frames being received out of sequence, S retains these in
the link receive list until the next in-sequence frame is received.
Continuous RQ
Continuous RQ
❑In the absent of errors, the link utilization of
continuous RQ is approximately 100%
❑In all continuous RQ schemes, corrupt frames are
discarded and retransmission requested only after
the next error-free frame.
❑When errors occur:
❖S detects and requests the retransmission of just those
frames in the sequence that are corrupted: Selective
Repeat
❖S detects the receipt of an out-of-sequence I-frame and
requests P to retransmit all outstanding unacknowledged I-
frames from the last correctly received: Go-back-N
Continuous RQ
❑Selective Repeat: can be implemented in 2 ways:
❖S acknowledges correctly received frames and P
determines from the sequence of ACK-frames received
that a frame has been lost: implicit retransmission
❖Or S returns NAK for a frame that is missing from the
sequence: explicit request
Continuous RQ
❑ Selective Repeat: implicit retransmission, I-frame is corrupted
❖ Assume I-frame N+1 is corrupted
❖ S returns a ACK for each correctly received I-frame as before
❖ S returns ACK-frame for I-frames N,N+2,N+3,…
❖ On receipt of ACK for I-frame N+2, P detects that frame N+1 has not
been acknowledged
❖ To allow for the possibility of more than one I-frame being corrupted,
on detecting an unacknowledged frame P enter the retransmission
state.
❖ When in this state, the transmission of the new frames is suspended
until all unacknowledged frames have been retransmitted
❖ P removes I-frame N+2 from the retransmission list and retransmits I-
frame N+1 before transmitting frame N+5
❖ On receipt of I-frame N+1, the contents of the queued frames in the link
receive list are delivered by S
Continuous RQ
❑ Selective Repeat:
implicit retransmission
❖ Corrupted I-frame
Continuous RQ
❑Selective Repeat: implicit retransmission, ACK(N) is
corrupted
❖On receipt of ACK-frame N+1, P detects that I-frame N is
still awaiting acknowledged and hence retransmits it
❖On receipt of the retransmitted I-frame N, S determines
from its receive sequence variable that this has already
been received correctly and is therefore a duplicate
❖S discards the frame but returns an ACK for it to ensure P
removes the frame from the retransmission list.
Continuous RQ
❑ Selective Repeat:
implicit retransmission
❖ Corrupted ACK-frame
Continuous RQ
❑Selective Repeat: explicit retransmission
❖ Use an explicit NAK to request for a specific frame to be retransmitted.
The NAK-frame is also known as selective reject.
❑Principle:
❖ An ACK acknowledges all frames in the retransmission list up to and
including the I-frame with the sequence number the ACK contains
❖ Assume I-frame N+1 is corrupted
❖ S returns an ACK for I-frame N
❖ When S receives I-frame N+2 it detects I-frame N+1 is missing and hence
returns a NAK containing the identifier of the missing I-frame N+1
❖ On receipt of NAK N+1, P interprets this as S is still awaiting I-frame N+1
and hence retransmits it
❖ When S returns a NAK, it enters the retransmission state
❖ When in the retransmission state, the return of ACK-frames is suspended.
Continuous RQ
❑ Principle:
❖ On receipt of I-frame N+1,
S leaves the retransmission
state and resumes
returning ACK-frames.
❖ ACK N+4 acknowledges all
frames up to including
frame N+4
❖ A timer is used with each
NAK to ensure that if it is
corrupted (and hence
frame N+1 is not received),
it is retransmitted
❑ Selective Repeat: explicit
request:
❖ Correct Operation
Continuous RQ
❑ Effect of NO retransmission
state:
❖ Assume I-frame N+1 is again
corrupted
❖ S returns NAK N+1 but this
time it is corrupted
❖ On receipt of ACK N+3, this
would acknowledges all
frames including I-frame
N+1 and hence this frame
will not be retransmitted
❖ I-frame N+1 would be lost
❖ Although S receives a
correct copy of each frame
sent by P, the order of
reception is not maintained
(S receives frames
N+2,N+3,N+4 and N+1)
Continuous RQ
❑ Selective Repeat is used primarily when either the frames
being transmitted are self-contained entities (the order is not
important)
❑ In many application, frames must be delivered in order. Hence,
Selective Repeat requires large buffer for storing ordered
frames
Continuous RQ
❑ Go-back-N: the secondary detects an out-of-order sequence frame, it informs
the primary to start to retransmit frames from a specified frame number. It
does this be returning a special NAK frame known as a reject.
❑ Principle:
❖ Assume I-frame N+1 is corrupted
❖ S receives I-frame N+2 out of sequence
❖ On receipt of I-frame N+2, S returns NAK N+1 informing P to go back and
start retransmit from I-frame N+1
❖ On receipt of NAK N+1, P enters the retransmission state
❖ When in this state, it suspends sending new frames and starts to retransmit
the frames waiting acknowledgement in the retransmission list
❖ S discards frames until it receives I-frame N+1
❖ On receipt of I-frame N+1, S resumes accepting frames and returning
acknowledgements
❖ A timeout is applied to NAK frames by S and a second NAK is returned if
the correct in-sequence I-frame is not received in the timeout interval
Continuous RQ
❑ Go-back-N:
❖ I-frame
corrupted
Continuous RQ
❑ Go-back-N:
❖ Corrupted ACK
❑ Principle:
❖S receives each transmitted I-
frame correctly
❖Assume ACK-frames N and N+1
are both corrupted
❖On receipt of ACK N+2, P detects
that there are 2 outstanding I-
frames in the retransmission list
(N and N+1)
❖Since it is an ACK rather than
NAK, P assumes that the 2 ACKs
for I-frames N and N+1 have both
been corrupted and hence
accepts ACK-frame N+2 also as
an acknowledgement for the
outstanding frames
Continuous RQ
❑ Link Utilization:
❖ In general, the link utilization U for a send window K:
• If K 1+2a :
U=1
• If K 1+2a :
K.Tix K.Tix K
U= = =
Tt (Tix +2Tp ) (1+2a)
Continuous RQ
❑ Link Utilization:
❖ Using Go-back-N: impact by choosing K
• If K 1+2a:
(1+2a).(1-Pf ) 1-Pf
U= =
(1+2a).(1+Pf (K-1)) 1+Pf (K-1)
• If K 1+2a:
K.(1-Pf ) K.(1-Pf )
U= =
(1+2a)+(1+2a).Pf .(K-1) (1+2a).(1+Pf (K-1))
❑ Solution?
❑Solution?
Timeout
❑ Timeout mechanism:
❖A separate timer is started each time I-frame is transmitted
by P, and is stopped when an ACK indicating its correct
receipt is received
❖If an ACK for an I-frame is not received before it timeout
interval expires, the frame is retransmitted
❖The timeout interval must be greater than the worst-case
propagation delay between transmitting a frame and
receiving the associated ACK
❖S may receive multiple copies due to corrupted ACK-frames
• With Go-back-N: this is not the problem. The N(S) in the duplicate
frames will not equal to the current V(R) held by S and will be
discarded
• With Selective Repeat: S retains a ordered list of the last N correctly
received I-frames. In this way, S can check if a received frame is a
duplicate of an already correctly received frame or a new frame.
Timeout
Flow control
❑ Control the data transmission rates of characters or
frames on a link so that the receiver always has
sufficient buffer storage resources to accept them prior
to processing
❑ Two kinds: X-ON/X-OFF and Sliding Window
❑ X-ON/X-OFF:
❖When the receive buffer at S is overflowed, S sends X-OFF
back to P, P stops the data transmission
❖When S escape the overload state, it will return X-ON to P
to inform its ready state for receiving data. P will continue
to transmit data to S
❖For example: in RS232, CTS/RST pins are used for flow
control
Flow control
❑ Sliding window:
❖ Send window size
(K): define the
maximum number
of frames can be
transmitted
❖ Has UWE and LWE
to control the
window length
❖ Receive window: the
maximum number
of frame buffers
required at S
Sequence Number
❑ All previous example: assuming that the next frame sequence
is simply equal to the last sequence + 1: sequence number go
to infinitive
❑ Need to define the maximum limit on the number of I-frames
being transferred across a link: limit the size of the link
retransmission and receive list, and limit the range of
sequence numbers to define frames uniquely
❖ Idle RQ: both send and receive window are 1. Hence 2 identifiers are
required to allow S to determine the last I-frame and the new I-frame.
❖ Go-back-N: send window is K: the identifier must be K+1.
❖ Selective Repeat: send and receive windows are K. Hence the
identifiers must not be less than 2K
Sequence Number
❑ The send window is 3
❑ P sends full of window: 3
I-frames
❑ 3 ACKs returned by S are
all corrupted
❑ P times-out each I-frame
and retransmits them
❑ S discards each duplicate
I-frame and returns a NAK
indicating I(3) is the next
frame
❑ Since the sequence
number in the NAK is
equal to V(S), P takes this
as an acknowledgement
for the 3 waiting frames,
therefore reopening the
windows
Sequence Number
❑ In practice, since the
identifier of a frame is in
binary form, a set number of
binary digits must be
reserved for its use.
❑ For example, with a send
window of 3 and Go-back-N is
used, 2 binary digits are
required for the send and
receive sequence numbers
yielding 8 possible identifiers:
0..7. The send and receive
sequence variables are then
incremented modulo-8 by P
and S, respectively
Sequence Number
lower
Window size = 7 window
edge upper
window
7 0 0 edge
7 7 0
6 1 6 1 6 1
5 2 5 2
tx 1 frame tx 1 frame 5 2
4 3 4 3 4 3
tx 1 frame
7 0 7 0
tx 1 frame 7 0
6 1 6 1 6 1
5 2 5 2
receive ACK0 5 2
4 3 4 3 4 3
max window size
max window size can’t transmit
can’t transmit
Connection Management
DLP
DLP
Share bus
DLP
Protocol Classification
❑ Character-oriented Protocols:
❖ Asynchronous transmission
• XMODEM, YMODEM
• Simplex Protocol: Kermit protocol
❖ Synchronous transmission:
• Half-duplex protocol: BSC
• Full-duplex protocol: APRANET IMP-to-IMP protocol
❑ Bit-oriented Protocols
❖ High-level Data Link Control: single link procedure
❖ Link access procedure version B (LAPB): extension of LAPA, used in
X.25 networks
❖ Multilink procedure: extension of LAPB
❖ Link access procedure for modems (LAPM): used in error correction
modems (e.g. V32)
❖ Link access procedure for D-channel (LAPD): used in ISDN networks
Simple frame
with header SYN SYN SOH Header Data (128bytes) ETX BCC
Multi-block SYN SYN SOH Header STX Data IBT BCC STX Data ETX ETX
BCC
frame
Data block
❑ Select operation
❖ Master sends data to a specific slave
❖ Put the slave address in the Select control
frame
❖ If the Slave is unready: reply by NAK.
Otherwise, return ACK
❑ Protocol performance:
❖ Low link utilization (Idle RQ),
used with multi-drop links,
operating at data rates up to
64 kbps
❖ Average time to poll each
station:
Tmin
Tavr =
1-Mr .Tix
❖ Tmin: the minimum time to poll
all stations, Mr is the average
rate at which messages are
generated
Example
❑ A BSC protocol is to be used to control the flow of messages between a
computer (Master station) and 10 block-mode terminals (secondaries) over
a multipoint data link. The link data rate, R, is 10 kbps and the average
length of a message, Ni, is 1000 bits. If a poll message and its associated ACK
is 30 bits and the total time to process these messages is 1ms, determine
the average time each terminal will be polled if the average rate at which
messages are generated is:
❖ 1 message per minute
❖ 6 message per second
The bit error rate and signal propagation delay times of the link can be assumed
to be negligible
❑ Solution:
❖ Tix=100ms
❖ Time to transmit a poll and its ACK: 30/104=3 ms
❖ Time to poll a single secondary: 3 + 1 = 4 ms
❖ Minimum time to poll all secondaries: Tmin=10x4 = 40 ms
❖ Mr = 1 msg/minute = 10-3/60 msg/ms: Tavr=40 ms
HDLC
❑ High-level Data Link Control (HDLC) is a
bit-oriented protocol for communication
over point-to-point and multipoint links.
❑ Support full-duplex, transparent mode
operation
❑ Variations: LAPB, LAPD, LAPM
❑ Used in Frame Relay, PPP
❑ Primary station
❖ Control the operation of the data link
❖ Send the command frames
❑ Secondary station
❖ Controlled by Primary station
❖ Send the response frames
❑ Combined station (Both Primary and
Secondary)
❖ Can send commands or responses
HDLC
❑ Operational modes:
❖ Normal Response Mode (NRM)
• Used in unbalanced configuration
• Slave stations (secondaries) can transmit only when specially instructed
by the master (primary) station.
• The link may be point-to-point, multipoint (only 1 primary allowed)
❖ Asynchronous Response Mode (ARM)
• Used in unbalanced configuration
• Allow a secondary to initiate a transmission without receiving
permission from the primary
• Normally used in point-to-point configuration and duplex links
❖ Asynchronous Balanced Mode (ABM)
• Mainly used on duplex point-to-point links
• Each station has an equal status and performs both primary and
secondary functions
HDLC
❑ Frame formats: both data and control messages are carried in a standard format
frame.
HDLC
❑ Address Field:
❖Depending on operational mode. In NRM mode, multi-drop line: each
station has 1 unique address. If the primary wants to connect with the
slave, it will put the slave address in this address field. Certain
addresses known as group address can be assigned to more than one
secondary. If the address is all bits 1: broadcast address.
❖Not used in ABM mode (point-to-point). Instead, it is used to indicate
the direction of commands and their associated responses
❖8 bit in length, can be expanded with multiple of 7 bits. Last octet will
have the first bit equal to 1
HDLC
❑Control field: There are 3 frame types in HDLC:
❖ Unnumbered frames (U—frame): used for such functions as link setup
and disconnection. They do not contain any acknowledgement
information
❖ Information frame (I-frame): carry the actual information. I-frames can
be used to piggyback acknowledgement information if the operational
mode is ABM or ARM
❖ Supervisory frame (S-frame): are used for error and flow control and
hence contain send and receive sequence numbers
HDLC
❑ Control field:
❖1 byte or 2 bytes in length
❖1 or 2 first bits define the frame type (S,I,U)
❖N(S): send sequence number
❖N(R): receive sequence number
❖P/F: Poll or Select depending on the context:
• Command: bit P, request the response from a secondary
• Response: bit F, indicating this is the response to a command
o Primary to Secondary: If
P=1, address is destination
00
o Secondary to Primary: If 10
F=1, address is source 01
11
HDLC
HDLC
❑Extended control bit field definitions
HDLC
❑Information field:
❖Contained in I-frame and U-frame
❖Variable length
❖Multiple of bytes
❑FCS field:
❖Error detection
❖CRC 16 or CRC32
HDLC
❑Link Management
❖Setup connection
❖Disconnection
HDLC
❑ Data transfer:
❖ V(S) indicates the next
send sequence
number N(S), which is
allocated to an I-frame
transmitted by that
station
❖ V(R) is the send
sequence number of
the next in-sequence
I-frame expected by
that station
❖ At receiver, if N(S)=
V(R): receive correct
sequenced frame
❖ Bit P means: this
frame needs an
response from the
receiver (by bit F) a. with RR frames only and Go-back-N strategy
HDLC
❑ Data transfer:
❖ Negative
Acknowledgement
❖ Go-back-N
❖ Using REJ/RR
HDLC
❑ Piggyback without errors:
❖ Example: an exchange using piggybacking. Node A
begins the exchange of information with an
I-frame 0 followed by another I-frame 1.
❖ Node B piggybacks its acknowledgment of both
frames onto an I-frame of its own. Node B’s first I-
frame is also numbered 0 [N(S) field] and contains a 2
in its N(R) field, acknowledging the receipt of A’s
frames 1 and 0 and indicating that it expects frame 2
to arrive next. Node B transmits its second and third I-
frames (numbered 1 and 2) before accepting further
frames from node A. Its N(R) information, therefore,
has not changed: B frames 1 and 2 indicate that node
B is still expecting A’s frame 2 to arrive next. Node A
has sent all its data. Therefore, it cannot piggyback an
acknowledgment onto an I-frame and sends an S-
frame instead. The RR code indicates that A is still
ready to receive. The number 3 in the N(R) field tells
B that frames 0, 1, and 2 have all been accepted and
that A is now expecting frame number 3.
HDLC
❑ Piggyback with errors:
❖ Example: an exchange in which a frame is
lost. Node B sends three data frames (0, 1,
and 2), but frame 1 is lost.
❖ When node A receives frame 2, it discards it
and sends a REJ frame for frame 1. Note that
the protocol being used is Go-Back-N with
the special use of an REJ frame as a NAK
frame. The NAK frame does two things here:
It confirms the receipt of frame 0 and
declares that frame 1 and any following
frames must be resent.
❖ Node B, after receiving the REJ frame,
resends frames 1 and 2. Node A
acknowledges the receipt by sending an RR
frame (ACK) with acknowledgment number
3.
HDLC
❑ Some other cases: