Datalink - Layer 2
Datalink - Layer 2
• flow control specifies how much data the Sender can transmit before Sender waits for ACK after each frame transmission:
receiving permission to continue from the Receiver
• error control allows the Receiver to tell the Sender about frames damaged
or lost during transmission, and coordinates the re-transmission of those ACK can be a frame
frames by the Sender by itself, or a control
• since flow control provides the Receiver’s acknowledgement (ACK) of field in data frames
correctly-received frames, it is closely linked to error control going from Receiver to
Sender (“piggybacking”)
• basic idea of flow control: even if frames are received error-free, the
Receiver will be forced to drop some of them if the Sender transmits faster Note: wait times may
than the Receiver can process them ⇒ signal the Sender to slow down to a vary for different frame
rate acceptable to the Receiver transmissions, as is the
• this signal can be explicit or implicit (e.g. delay sending ACK to Sender)
case here ⇒ can talk
• basic idea of error control: ACK every correctly-received frame and about average wait time
negatively acknowledge (NAK) each incorrectly-received frame
• Sender keeps copies of un-ACKed Frames to re-transmit if required
• want: packets (inside frames) passed to Receiver’s Network layer in order Advantage: simplicity. Disadvantage: inefficiency (wait times).
1 2
Note: neither Sender nor Receiver has this kind of “global picture”…
5 6
Sliding window flow control: Example (cont.) Error Control: ARQ (Automatic Repeat Request) schemes
• if error(s) detected in received Frame, return NAK to Sender
Receiver • NAK can be explicit or implicit (Sender’s Timeout timer expires)
behaviour
• Sender keeps a copy of each un-ACKed Frame to re-transmit if required
• ACK received by Sender for Frame ⇒ discard copy
• NAK received by Sender for Frame ⇒ decide how to re-transmit Frame
• Sender starts Timeout timer for each Frame when it is transmitted
• appropriate Timeout value = the expected delay for Sender to receive
ACK for the Frame (in practice, set Timeout slightly larger than this…)
• packet is not considered to be delivered successfully to the Receiver’s
Network layer until the Sender knows this (by getting ACK for it)
• 3 types of ARQ scheme:
• Stop-and-wait ARQ – extension of Stop-and-wait flow control
• Sliding window ARQ – extension of sliding window flow control:
• Go-back-n ARQ – Receiver must get Frames in correct order
• Selective repeat ARQ – correctly-received out-of-order Frames are
stored at Receiver until they can be re-assembled into correct order
7 8
Stop-and-wait ARQ, damaged data frame Stop-and-wait ARQ, lost data frame
also known as ABP
(Alternating Bit Protocol)
Frame OK
0
Frame OK Frame OK
0
1
Frame not OK
Know:
0 Frame OK
9 10
TRANSF TRANSF
PROP PROP
PROC PROC
ACK TRANSA NAK TRANSA
PROP PROP
PROC PROC
Sender knows Sender knows
Frame was Frame must be
received re-transmitted
correctly
TF = TS here
time time time time
13 14
TRANSF TRANSF
lost
} copies
discarded
ACK 3
High-level Data Link Control (HDLC) protocol High-level Data Link Control (HDLC) protocol: Modes
• mode = relationship between 2 communicating devices;
! HDLC standardised
by ISO in 1979 describes who controls the link
! now accepted by most • NRM = Normal Response Mode
other standards bodies • ARM = Asynchronous Response Mode
(ITU-T, ANSI, …)
! X.25 packet-switching networks • ABM = Asynchronous Balanced Mode
use a subset of HDLC called
LAPB (Link Access Procedure,
Balanced) – e.g. in ISDN
! 3 types of end-stations:
• Primary – sends commands
• Secondary – can only respond Any Either
to Primary’s commands
• Combined – can both command • in ARM, a secondary may initiate a transmission if the link is idle, but the
and respond transmission must still be sent to the Primary for relaying to another secondary
as in NRM: only difference is that secondary needs permission from the
! 3 types of configuration Primary in NRM, but doesn’t need permission from the Primary in ARM
(Note: no balanced multipoint)
23 24
High-level Data Link Control (HDLC) protocol: Frames High-level Data Link Control (HDLC) protocol: Frames
Frame format: in back-to-back Frame transmissions, the end-flag of one
!3 types of Frames are Frame can be used as the start-flag of the next Frame
defined (what is it about
the number 3?!?!):
• I-Frame – transports user
data and control info.
about user data (e.g. ACK) flag flag
• S-Frame – supervisory
Frame, only used for Control field: ARQ is Go-back-7 (or Go-back-127 in “extended mode”)
transporting control info. N(S), N(R) 3 bits long
• U-Frame – unnumbered ⇒ window size = 7;
Frame, reserved for in “extended mode”,
system management N(S), N(R) 7 bits long
(managing the link itself) ⇒window size = 127
FCS = Frame Check
Sequence (or Checksum):
2-byte or 4-byte CRC
25 26
Datalink layer in the Internet PPP Example: user wants to send Network layer data
! point-to-point links – 2 main possibilities:
• Serial Line IP (SLIP): defined in 1988
simple, character-oriented transmission: IP packet + framing flag negotiate options for establishing
the link (using LCP packets)
no error detection; no user authentication; only supports IP; doesn’t
support dynamic IP address assignment using some authentication protocol
• Point-to-Point Protocol (PPP): defined in 1994 (e.g. user sends username & password)
character-oriented transmission: HDLC-like framing (similar to X.25),
Link Control Protocol (LCP), Network Control Protocol (NCP) negotiate options for Network
layer activity , then send data
supports: error detection; user authentication; multiple network (using NCP packets)
protocols e.g. IP, IPX, CLNP; dynamic IP address assignment