Anda di halaman 1dari 10

Datalink layer: Flow and Error Control Datalink layer: Flow and Error Control

flow control specifies how much data the Sender can transmit before
receivingpermission to continue fromtheReceiver 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
framesbytheSender frames by the Sender
since flow control provides the Receivers acknowledgement (ACK) of
correctly-received frames, it is closely linked to error control
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
than the Receiver can process them signal the Sender to slow down to a p g
rate acceptable to the Receiver
this signal can be explicit or implicit (e.g. delay sending ACK to Sender)
basic idea of error control: ACK every correctly-received frame and
negatively acknowledge (NAK) each incorrectly-received frame
Sender keeps copies of un-ACKed Frames to re-transmit if required
1
want: packets (inside frames) passed to Receivers Network layer in order
Stop-and-wait flow control Stop-and-wait flow control
Sender waits for ACK after each frame transmission:
ACK can be a frame
by itself, or a control by itself, or a control
field in data frames
going from Receiver to
Sender (piggybacking) Sender ( piggybacking )
Note: wait times may
f diff t f vary for different frame
transmissions, as is the
case here can talk
about average wait time
Ad t i li it Di d t i ffi i ( it ti )
2
Advantage: simplicity. Disadvantage: inefficiency (wait times).
Sliding window flow control Sliding window flow control
Sender can transmit several frames continuously before needing an ACK
if ACK receivedbySender beforecontinuoustransmissionisfinished, Sender if ACK received by Sender before continuous transmission is finished, Sender
can continue transmitting
an ACK can acknowledge the correct receipt of multiple frames at the Receiver
FramesandACKsmust benumbered: Frames and ACKs must be numbered:
each Frames number is 1 greater than the previous Frame
each ACKs number is the number of the next Frame expected by the Receiver
Number of frames that
can be transmitted
without an ACK
Frames may be acknowledged by the Receiver at any time, and may be transmitted
by the Sender as long as the Window hasnt filled up
Framesarenumberedmodulo n from0ton 1: 0 1 n 1 0 1 n 1 0 1
3
Frames are numbered modulo-n, from 0 to n-1: 0, 1,, n-1, 0, 1,,n-1, 0, 1,
Size of the Window is n-1: 1 less than the number of different Frame numbers
Sliding window flow control (cont ) Sliding window flow control (cont.)
Senders sliding window: g
if Sender receives
e.g. ACK 4, then it
knows Frames up knows Frames up
to and including
Frame 3 were
correctly received correctly received
Receivers sliding window:
Receivers window
t th b represents the number
of un-ACKed Frames
4
Sliding window flow control: Example (assume no errors) Sliding window flow control: Example (assume no errors)
Window size = 7
5
Note: neither Sender nor Receiver has this kind of global picture
Sliding window flow control: Example (cont ) Sliding window flow control: Example (cont.)
Sender
behaviour
6
Sliding window flow control: Example (cont ) Sliding window flow control: Example (cont.)
Receiver
behaviour
7
Frame Correct First Time
Could try and get everything through correctly
If weknewpbthenwecouldworkout aparitycorrectingscheme If we knew pb then we could work out a parity correcting scheme
to do this.
Generallyhavetoaddsubstantial overheadevenfor fairlylowBit Generally have to add substantial overhead even for fairly low Bit
Error Rates (BER)
However for most networkswedonot knowinadvancethe However for most networks we do not know in advance the
properties of the links
We would also like our scheme to deal well with all types of links yp
as best as is possible.
Use a different philosophy to do this.
Automatic Repeat Request (ARQ)
Schemes
Send frames and find out is they are in error by using error
detectionschemes detection schemes
Then if correct release to higher layers, if in error then get the
transmitter toretransmit it again. transmitter to retransmit it again.
The most common error detection schemes are based on the use of
Polynomial Codes, which involves the computation of Cyclic y , p y
Redundancy Check, CRC.
This will tell is the frame is good or not, at least to many more
orders of reliability than the frame error probability.
Number Everything
Have to number the frame that is sent.
If theframeCRC isreceivedokaythensendanAcknowledgement If the frame CRC is received okay then send an Acknowledgement
(ACK) back to the transmitter.
If theCRC hasaremainder thenwecansendbacktothe If the CRC has a remainder then we can send back to the
transmitter a Negative ACK or NACK.
If wemissaframethenthetimer kicksin. If we miss a frame then the timer kicks in.
The sequence numbers are put in the control field which also tells
us which type of frame we have. yp
N(S) sent frame number
N(R) next requested frame ( ) q
Mathematical Definitions
Time to transmit a frame is TRANSF ,where
TRANSF =lengthof theframeinbits/ bit rateof thelink TRANSF =length of the frame in bits / bit rate of the link.
A ACK i t dl t h An ACK is expected later, where
T TRANSF+ti f ti + i i + Ts = TRANSF+time for propagation +receiver processing +
reverse transmit +propagation +transmitter processing
The hope is that before we run out of numbers to put in the frames we
will haveanACK will have an ACK.
The size of the link can be given by the ratio of round trip time to
TRANSF whichisdenotedbya TRANSF which is denoted by a
a =(Ts)/ TRANSF
Examples of delays
Terrestrial low speed link
If theframesizeis1200bits linkspeedis96kb/s frame If the frame size is 1200 bits, link speed is 9.6 kb/s, frame
length TRANSF =125 ms. If link length is 100 km, speed of
light is3E+8m/s, propagationtimeis0.33ms, if processing light is 3E 8 m/s, propagation time is 0.33 ms, if processing
time is small, but the ACK comes back in another frame, a =2
Terrestrial high speed link
A high speed ATM link with link speed of 620 Mb/s, the frame g p p ,
length, TRANSF =0.7 us. If same length of cable, a >>1
Satellite low speed link
Satellites are generally about 36,000 km's above earth. g y
Propagation delay is 120 ms up and the same down, a =6
Error Control: ARQ (Automatic Repeat Request) schemes Error Control: ARQ (Automatic Repeat Request) schemes
if error(s) detected in received Frame, return NAK to Sender
NAK canbeexplicit or implicit (SendersTimeout timer expires) NAK can be explicit or implicit (Sender s Timeout timer expires)
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
i t Ti t l th t dd l f S d t i 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 Receivers
kl il h d k hi (b i i ) Network layer until the Sender knows this (by getting ACK for it)
3 types of ARQ scheme:
Stop-and-wait ARQ extensionof Stop-and-wait flowcontrol 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 receivedout of order Framesare
13
Selective repeat ARQ correctly-received out-of-order Frames are
stored at Receiver until they can be re-assembled into correct order
Stop-and-wait ARQ damaged data frame Stop-and-wait ARQ, damaged data frame
also known as ABP
(Alternating Bit Protocol)
0
Frame OK
Frame OK
Frame not OK
1
Frame OK
Frame not OK
0
Know:
0
14
Stop-and-wait ARQ lost data frame Stop-and-wait ARQ, lost data frame
0
Frame OK
15
Stop-and-wait ARQ lost ACK Stop-and-wait ARQ, lost ACK
0
0
Frame OK
0
2nd copy
discarded,
even though
Frame OK
Q: why does Receiver send ACK 0 for copy of data Frame 1 ?
16
Stop-and-wait ARQ: Performance Analysis Stop-and-wait ARQ: Performance Analysis
parameters:
Frametransmissiontimeat Sender isTRANSF Frame transmission time at Sender is TRANSF
ACK/NAK transmission time at Receiver is TRANSA
if ACKs are piggybacked TRANSF = TRANSA, assuming Frames
haveequal (average) lengthsinbothdirections have equal (average) lengths in both directions
link propagation delay is PROP
Frame processing time at Sender or Receiver is PROC
b bilit f F i S d R i di ti i probability of Frame error in Sender-Receiver direction is p
probability of Frame error in Receiver-Sender direction is q
Sender times out after TIMEOUT
d h dl l k l k i idl assume Sender has an endless supply of Network layer packets to transmit, so idle
time at Sender is 0
error freepacket deliverytakesT = TRANSF + TRANSA + 2*(PROP + PROC) error-free packet delivery takes T
S
= TRANSF + TRANSA + 2*(PROP + PROC)
and occurs with probability (1-p)*(1-q)
errored delivery takes T
F
and occurs with probability r = p+(1-p)*q
17
y
F
p y p ( p) q
r = 1-(probability of error-free delivery), as expected
Sender
Receiver
TRANSF
PROP
PROC PROC
TRANSA
PROP
ACK
PROC
Sender knows
Frame was Frame was
received
correctly
18
time time
Sender
Receiver
TRANSF
PROP
PROC PROC
TRANSA
PROP
NAK
PROC
Sender knows
Frame must be Frame must be
re-transmitted
T
F
= T
S
here
19
time time
Sender
Receiver
TRANSF
lost
TIMEOUT
Sender knows
Frame must be Frame must be
re-transmitted
T
F
= TRANSF
+ TIMEOUT here
20
time time
+ TIMEOUT here
Sender
Receiver
TRANSF
lost
TIMEOUT ACK
Sender knows
Frame must be Frame must be
re-transmitted
T
F
= TRANSF
+ TIMEOUT here
21
time time
+ TIMEOUT here
Stop-and-wait ARQ: Performance Analysis (cont ) Stop-and-wait ARQ: Performance Analysis (cont.)
average number of Frame transmissions to successfully deliver 1 packet to
Receiver isE = 1/(probability of error-free delivery) = 1/[(1-p)*(1-q)] = 1/[1-r] Receiver is E 1/(probability of error free delivery) 1/[(1 p) (1 q)] 1/[1 r]
therefore average packet delay in ARQ scheme is D = (E-1)*T
F
+ T
S
thereforeaverage packet throughput = 1/D andefficiency = TRANSF/D therefore average packet throughput = 1/D and efficiency = TRANSF/D
remember: efficiency is the fraction of the time newpackets are delivered
special cases:
symmetrical case: p = q in this case, E = 1/(1-p)
2
no errors in ACKs/NAKs: q = 0 in this case, r = p and E = 1/(1-p)
optimal choice of TIMEOUT = TRANSA + 2*(PROP + PROC) in this
case, T
S
= T
F
and therefore D = E*T
S
Sender and Receiver processing time negligible: PROC = 0
22
Throughput versus BER for Stop
and Wait
no errors in ACKs/NAKs: q = 0 in this case, r = p and E = 1/(1-p)
and optimal choice of TIMEOUT = TRANSA + 2*(PROP + PROC) in this
T T d h f D E*T case, T
S
= T
F
and therefore D = E*T
S
D = T
S
/(1-p)
a =3
Packet Length 10,000 bits
a =11
Log(BER)
a =101
Log (BER)
Go-Back-N ARQ Scheme
Transmit frames continuously if possible.
Noutstandingframesat most onthelink N outstanding frames at most on the link.
As we are using a Modulo-N numbering scheme we need a big
enoughN(S) andN(R) toachievegoodperformance enough N(S) and N(R) to achieve good performance.
It is possible to have sequence number starvation where you run
out of numbers. out of numbers.
If a frame is received with a remainder, or if N(S) skips a number,
then we have an error, so roll back the clock and retransmit. ,
Go-back-n ARQ damaged data frame Go-back-n ARQ, damaged data frame
NAK 3 means
re-transmit
Frame 3 (also
tells Sender that
all Frames before all Frames before
Frame 3 were
received correctly)
Receiver only accepts correctly-received Frames in the correct order
25
Receiver only accepts correctly received Frames in the correct order
(so Receiver doesnt have to buffer any Frames and re-order them)
Go-back-n ARQ lost data frame Go-back-n ARQ, lost data frame
Frame 3 discarded even though it was correctly received
26
Frame 3 discarded even though it was correctly received
BECAUSE Receiver was expecting Frame 2 (same for Frame 4)
Go-back-n ARQ lost ACK Go-back-n ARQ, lost ACK
copies
discarded
}
ACK 3
27
Go-back-n ARQ: Performance Analysis Go-back-n ARQ: Performance Analysis
parameters: same as before
assumeoptimumchoiceof TIMEOUT = TRANSA + 2*(PROP + PROC) assume optimum choice of TIMEOUT TRANSA 2 (PROP PROC)
assume Window is large enough that Sender can transmit continuously if there
are no transmission errors
can show average packet delay is D = [TRANSF + r*TIMEOUT] / (1-r)
where r = p+(1-p)*q as before
th f k t th h t (1 ) / [TRANSF + *TIMEOUT] d therefore average packet throughput = (1-r) / [TRANSF + r*TIMEOUT] and
efficiency = [(1-r)*TRANSF] / [TRANSF + r*TIMEOUT]
notethat asr 0, efficiencyof Go-back-n1(or 100%): thisshowsthat Go- note that as r 0, efficiency of Go back n 1 (or 100%): this shows that Go
back-n is capable of continuously delivering packets in the absence of errors
under these conditions, you can show that the efficiency of Stop-and-wait
ARQ is [(1-r)*TRANSF] / [TRANSF + TIMEOUT]
Stop-and-wait ARQ efficiency TRANSF / [TRANSF + TIMEOUT] as
0 thi h th b ilt i i ffi i f th St d it h
28
r 0: this shows the built-in inefficiency of the Stop-and-wait approach
Selective Repeat
Why go back and retransmit all the frames? Some might be good
Onlyretransmit thebadframes! Only retransmit the bad frames!
Improvement over Go Back N
Att i th th ti l i th h t Attains the theoretical maximum throughput
Out of order frames so must reorder them
M l t itt d i l h d d More complex transmitter and receiver so only use when needed
Selective repeat ARQ damaged data frame Selective repeat ARQ, damaged data frame
may be (slightly) more efficient
than Go-back-n ARQ, but also Q
much more complicated
i error in
Frame 2
}
stored at
}
stored at
Receiver
but cannot
be ACKed (yet)
Sender must be able to
When frame 2 received correctly Receiver can deliver the packets in
Sender must be able to
select certain Frame(s)
for re-transmission
30
When frame 2 received correctly, Receiver can deliver the packets in
Frames 2-5 to its Network layer and send ACK 6 back to Sender.
Lost or damaged ACK/NAK handled similarly to Go-back-n ARQ.
Comparison of Throughput: Comparison of Throughput:
Stop & Wait, Go Back N, Selective
Repeat
S l i R Selective Repeat
Go Back N
Packet Length 10,000 bits
Stop and Wait
g ,
Log (BER)
p
Optimum Frame Size
Classic tradeoff for frame size
Small framesgivelowframeerror probability but givehigh Small frames give low frame error probability, but give high
overhead
Largeframesgivehighframeerror probability but givelow Large frames give high frame error probability, but give low
overhead
Inbetweenhaveanoptimumframesizefor eachapplication. In between have an optimum frame size for each application.
Mathematical Analysis
If there are l bits of information in the frame and l bits of
overhead.
p =1 - ( 1 - pb)
( l +l )
The maximum throughput for the Go-Back-N is:
=( 1 - p ) / [ 1 +( a - 1 ) p ] ( p) [ ( ) p]
Of this only l / ( l +l) bits are actually information: y ( ) y
=( 1 - p ) / [ 1 +( a - 1 ) p ] . l / ( l +l)
Find the optimum frame size, l opt, by differentiating this w.r.t. l
and solve. Will depend on header length, l, & bit error rate, pb. p g p
O ti F L th BER Optimum Frame Length vs BER
for 6 Byte header
b opt
p l l l ' '
Log (BER)
High-level Data Link Control (HDLC) protocol High-level Data Link Control (HDLC) protocol
HDLC standardised
by ISO in 1979
now accepted by most
other standards bodies
(ITU T ANSI ) (ITU-T, ANSI, )
X.25 packet-switching networks
use a subset of HDLC called
LAPB (Li k A P d LAPB (Link Access Procedure,
Balanced) e.g. in ISDN
3 types of end-stations: yp
Primary sends commands
Secondary can only respond
to Primarys commands
Combined can both command
and respond
3 types of configuration
35
3 types of configuration
(Note: no balanced multipoint)
High-level Data Link Control (HDLC) protocol: Modes High-level Data Link Control (HDLC) protocol: Modes
mode = relationship between 2 communicating devices;
describes who controls the link describes who controls the link
NRM = Normal Response Mode
ARM = Asynchronous Response Mode y p
ABM = Asynchronous Balanced Mode
i ARM d i iti t t i i if th li k i idl b t th
Either Any
in ARM, a secondary may initiate a transmission if the link is idle, but the
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
P i i NRM b t d t d i i f th P i i ARM
36
Primary in NRM, but doesnt need permission from the Primary in ARM
High-level Data Link Control (HDLC) protocol: Frames High-level Data Link Control (HDLC) protocol: Frames
3 types of Frames are yp
defined (what is it about
the number 3?!?!):
I-Frame transports user I Frame transports user
data and control info.
about user data (e.g. ACK)
S Frame supervisory S-Frame supervisory
Frame, only used for
transporting control info.
U F b d U-Frame unnumbered
Frame, reserved for
system management
(managing the link itself)
37
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
Frame can be used as the start-flag of the next Frame f g f
flag flag
Control field: ARQ is Go-back-7 (or Go-back-127 in extended mode)
N(S), N(R) 3 bits long
window size = 7;
in extended mode,
N(S), N(R) 7 bits long
window size = 127
FCS = Frame Check
Sequence (or Checksum):
38
Sequence (or Checksum):
2-byte or 4-byte CRC
Datalink layer in the Internet Datalink layer in the Internet
point-to-point links 2 main possibilities:
Serial Line IP (SLIP): defined in 1988
simple, character-oriented transmission: IP packet + framing flag
no error detection; no user authentication; only supports IP; doesnt
support dynamic IP address assignment support dynamic IP address assignment
Point-to-Point Protocol (PPP): defined in 1994
character-oriented transmission: HDLC-like framing (similar to X.25),
Link Control Protocol (LCP) Network Control Protocol (NCP) Link Control Protocol (LCP), Network Control Protocol (NCP)
supports: error detection; user authentication; multiple network
protocols e.g. IP, IPX, CLNP; dynamic IP address assignment
most LANs have a broadcast
channel need Medium
Access Control (MAC) &
Logical Link Control (LLC)
sublayers (details later)
39
PPP Example: user wants to send Network layer data PPP Example: user wants to send Network layer data
negotiate options for establishing
the link (using LCP packets)
i h i i l using some authentication protocol
(e.g. user sends username & password)
negotiate options for Network negotiate options for Network
layer activity , then send data
(using NCP packets)
house cleaning for closing
40
house-cleaning for closing
the link (using LCP packets)

Anda mungkin juga menyukai