0% found this document useful (0 votes)
106 views25 pages

Chap 3 CN

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views25 pages

Chap 3 CN

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

184 THE DATA LINK LA YE R

3.1 DATA LINK LAYER DESI


GN ISSU ES
The da ta link layer has a numb
er of specific fun cti on s it ca n
.
functions me c. lud carry out. 1n
ese
l . Providing a well-defined ser
vice int ed ac e to the ne tw ork
layer.
2. Deali.ng wi th transmission err
ors.
3. Re-gulating the flow of data
so tha t slow rec eiv ers are no t
by fast senders. swamped
To accomplish these go al~ the
data li~ lay er tak es the pack~
ne tw ork lay er a,ld encapsula ts_ it gets from the
tes them 1oto fra me s fo r transi
contains a frame header, a n1ss1on. Each fram
payload field for ho ldi ng the
,trailer., as illustrated in Fig. 3-1 pa ck et, and a fram:
. F ~e ma na ge me nt for ms the
da ta lin k lay er does. In the he art of what the
following sections we wi ll ex
.mentioned issues in detail. am ine all the above-

Sendi'Q machine

\ p- I
Receiving machine

I
I
,- -- -- -- ,- -~ -- -- ,,- -- -~ / Frame
\ Pac ket

E I 1
Pa ya d-
L_ _
I I
T~ ~. Header Payload field Trailer
_ _ _J
Flp re 3-1. Relationship betwe
en packets and frames.
Although this chapter is explic
itly ab ou t the da ta lin k·lay er
pro toc olS, many of the princi antl the data link
flow control. ples we will stu dy he re su ch
are &,,..._ ... · as err or control and
10-U.l
ne tw ~...,~ the I!.~ -.-. !lU m transp ort '
an d oth er ·p rot oc ols as well. · 01an Y
Via u, se 1 UJ.LuOOs arc found In fact, 10 .
only in the up pe r lay ers an d • h data
lin k lay er. However, no ma tte not 10 t e ,
r where they are fou nd the
mucb the same, so it does not rea principles are pre_tl (
lly matter where we s~ dy the
lay er they of~ show up in the m. In th e.d~ta ,1l~~d
pla ce to ex.ammc them in detail ir sim ple st an d pu res t for ms , ma kin g th1 s a g
.

3.1 .1 Serv'ices Pr ov ide d to the


Network La ye r
The f · ·.
The pn·nc~? °n °!
th~
1v ., serv1cc isdat a link layer is to pro vid e ser vic
tra es to the
\.- t,nc'I
machine to ,the ne tw ort L- - nst . d net wor ·(11111·1'
cmng ata fr<>m the ne tw ork lay on the ~ 111 .
is an entity, call it proc:yer .00 er 01 arh '
8 the destination machine. On the 1
- SS, •n the network. lay so~rc~l the' tl.tl•
er tha t ha nd s som e bit s
DATA LINK LA YER DESIGN ISSUES
5f:C, 3.l 185
for transmission to the destination. The . b th
tinl< la~e~ bits to the destination machine so they Jo ~f end data link layer is to
tf81'5";1t er there, as shown in Fig. 3-2(a). The ac~an I e ha _over to the net- w
wodc fayfig. 3-2{b), but it is easier to think in t ua , transm1ss1on foll ows the
nath o . . . erms of two data 1· .k I
r- ses conunumcatmg using a data link protocol F h. . m ayer
p~tles use the model of Fig. 3-2(a) throughout this ~h o; t ts reason, we will im-
phCt Y aper.
Host 2 Host 1 Host 2

l
~,.., 1
~ .-- l~- 1
~,..; l
~,.., 1
-,..;

~-

4 4 4
4

u 3 3 4
It 3
II
3
Virtual -
data path 2
) 2 2
2
'---· ---------- -
1
1 1
Actual
data path ,I

(b)
(a)

Figure 3-2. (a) Virtual communication. (b) Actual communication.


. The data link layer can be designed to offer various services. The actual serv-
ices offered can vary from system to system. Three reasonable possibilities that
are commonly provided are
l . Unacknowledged connectionless service.
2· Acknowledged connectionless service.
3. Acknowledged connection-oriented service.
Let U
us co nsi'de· r each of these in turn.
thin Racknow)edged conriectionless service consists of having the source ma- th
deste &.eod independent frames to the destination machine wi thout having <
5
fore~~n machine acknowledge them. No logical connection is e 1ablished th be-
0
'Uernarid or released afterward. If a frame is lost due to noise on e ltn~. "
01as, :~ 18
rruide
to detect the loss or recover from it in the data link layer. Tht5
left to h_serv1ce is appropriate when the error rate is very tow so that reco~et) .1s
tgher I . . . t'f1c such w, vmce. tn
ayers. It 1s also appropriate for real -tune tra •
186 THE DAT A LIN K LA YER
CHAP. 3
which late data are worse than bad data. Most
LAN s use unacknowl edged con.
nectionless service in the data link layer.
The next step up in terms of reliability is ~cknow .
le~ged conne~tionless serv.
ice. When this service is offered, there are still
no lo~1cal connection s used, but
each frame sent is individually acknowledged.
In this way, the sender know
wheth~r a frame has arrived correctly. If it has
not arrived wi~hin a specified tirn~
interval, it can be sent again. This service is usef
ul ove r unr eha ble channels, such
as wireless systems.
It is perhaps worth emphasizing that providing
acknowledgements in the data
link layer is just an optimization, never a requirem
ent. The network layer can al-
ways send a packet and wait for it to be acknow
ledged. If the acknowledgement
is not forthcoming before the timer expires, the
sen der can just send the entire
message again. The trouble with this strategy
is that frames usually have a strict
max imu m length imposed by the hardware and
netw ork layer packets do not. If
the average packet is broken up into, say, 10 fram
es, and 20 perc ent of all frames
are lost, it may take a very long time for the pac
ket to get through . If individual
frames are acknowledged and retransmitted, enti
re packets get through much fast-
er. On reliable channels, such as fiber,
the overhead of a heavyweight data link
protocol may be unnecessary, but on wireless cha
nnels, with their inherent unreli-
ability, it is well worth the cost.
Getting bac k to our services, the most sophisticat
ed service the data link layer
can pro vide to the network layer is connection-ori
ented service. Wit h this service,
the sourc.e and destination machines establish
a con nec tion befo re any data are
transferred. Each frame sent over the connec
tion is numbered, and the data link
laye r guarantees that sach frame sent is indeed
received. Furthermore, it guaran-
tees that eac h fram e is received exactly
once and that all frames are received in
the righ t ord er. With connectionless service,
in contrast, it is 'conceivable that a
lost ack now ledg eme nt causes a packet to be sent
several tim es and thus rece ived
sev eral times. Connection-oriented service, in
contrast, pro vide s the network lay-
er pro cess es with the equivalent of a relia
ble bit stream.
Wh en connection-oriented service is used, tran
sfers go through three disti_nct
pha ses. In the first phase, the coM ecti on is
established by having both sides ini-
tialize variables and counters needed to keep
trac k of whi ch frames have been
received and which ones have not. In the second
phase, one or more frame~_arr
actu ally transmi tted . In the third and final pha
se, the con nec tion is rele ased, tree-
ing up the variables, buffers, and other resource
s used to maintain the connectn)[l .
. Con sid~r a typical, example:_a WA N subnet con
sist ing of routers connectel_1 ~: ~
po1nt-to-pomt leased tele phone Ime s. When a fram
e arrives at a router, the hit 1
war e che cks it for erro rs (using techniques we
will stud y late in this chapter) . I_het:
pas ses the frame to the data link layer softwar
e (which might be embedd ed 111 .• .
chip on the network interface board). The data
. 1s
· t h e fram link layer software checks to see tll
t h 1s e exp ected , an d 1·f so, give
· · s the
· packet con
tained in the paytoa
field to the routing software. The rout1ng soft . l,
ware then chooses the appropn att
1
DATA LINK LA YER DESIGN ISSUES
58C. 3· 187
in )ine and. pa~ses the packet back do wn to the data I.ink J , .,
outgo thg n transmits it. The flow over two routers is sh . p· ayer softwau\
which e own m ig . 3-3.
Router

~
oata link Routing
layer process

Data link
Frames Packets protocol
here here

Transmission
line to a router

Figure 3-3. Placement of the data link protocol.


The routing code frequently wants the job done right, that is, with reliable,
sequenced connections on each of the point-to-point lines. It does not want to be
bothered too often with packets that got lost on the way. It is up to the data link
protocol, ·shown in the dotted rectangle, to make unreliable communication lines
look perfect or, at least, fairly good. As an aside, although we have shown multi-
ple copies of 't he data link layer software in each router, in fact, one copy handles
all the lines, with different tables and data structures for each one.
3·1.2 Framing

. Te Provide service · to the network layer, the data link layer must use the serv-
~ce Pf?vided to it by the physical layer. What the physical layer does is accept a

f~
:~teed
aw btt Siream and attempt to deliver it to the destination. This bit stream is not
0 to be error free. The number of bits received may be less tha_n ._ ~qual
vaJu mo~e than the number of bits transmitted , and they may have ditterenc
; ~ It 18 up to the data link layer to detect and, if necessary, c?ITect errors ..
discJi e usual approach is for the data link layer to brea k the btt st ream up mtl)
i~rn:: .frame~ and compute the checksum for each. fra me. _tCl~~c ~~um ,~go_r-
hon tl · 111 be dtscussed lat:er in this c hapte r.) When a trnme arnves c\t th e d~~ttrM
1e check
f•rorn' the . · . . 1 , ttll t, Jtl tert>nt
sum 1s recomputed. It the ne wly-compute<1 l:1,\e1.: "' s t
,1,,
- ,. .
0 ccurr one contained in the frame, the data link laye r knows t_h at ~•11 cnor h.t.-.
biy a1::i : 0 : . lakes steps to deal with it (e .g ., d iscarding th<> bad tram,· auJ P0 " '
8
n 108 back an error report) .
18 8 TH E DA T A LI NK LA
YE R CH AP . 3
Br ea ki ng ·the b1.t stream
. up 1·nto fram.
es is m ore difficult th an
it at fi rst ap pears
0 ne w ay to ach1e h' fram i· ng .
is to msert tim
th e ~paces betw een wove t 1s e ga ps be tw ee n fr am es , m uc h hk. .
rds in ordinary text. H 1 e
gu ar an te es about timing, ow ev er ,. ne tw or ks rare
so it is possible these ga y m ake any
er ga ps might be inserte ps m ig ht be sq ue ez ed ou
d durin t or oth-
Si nc e it is too risky to g transmission.
count on timing to ~a
fr am e, ot he r methods
have been devised. In rk t? e start a~d en d of
this se cu on w e will lo each
m et ho ds : ok at fou r
1. Ch ar ac te r count.
2. Fl ag bytes with byte
stuffing.
3. St ar tin g and ending
flags, with bi t stuffing.
4 . Ph ys ic al la ye r codi
ng violations.
Th ~ first fra m in g m et ho
d uses a field in the he
ch ar ac te rs in th e frame. ad er to sp ec ify th e num
W he n the data lin k laye ber of
.a ct er co un t, it kn ow s ho r at th e de st in at io n se es the
w many characters follo char-
frame is . T is te ch ni qu w and he nc e w he re th e
e is shown in Fi g. 3-4( en d of the
an d 8 charac.~er s, respec a) for four fram~s of siz
tively. es 5, 5, 8,

Character c o u n
t~
On e character
tal \s \ 1 \2\3\4\ s\ s\1\e\ g\e\o\
1 \2\3\4\s\s\e\1\e\9\ o\ 1 ~
F"1'ame '1 Frame 2
I
5 characters 5 characters Frame 3
8 characters Frame 4
8 characters
Error

(b) \ s\1 \2 \3 \4 \1

Frame 1
fu 1 \ I
a \ 0 \ a o \ 1J:_2 \ 3 \ 4\ s \ & \ e \ 1 \ e\ 9 \ o \ 1 \
2 I 3]
Frame 2 •· Now a
(Wrong) character count
Figure J. 4, A ch aracte r
stream. (a) W ith ou t err
ors. (b) W ith on e error.
. Th e tro ub le w ith th is
~lgo rithm is th at the co
s1o n er ro r. Fo r ex ampl un t ca n be ga rb le d by 1 11
e, tf the ch ar ac te r coun a
4(b ) beco m es a 7 , th t of 5 in th e seco nd fr am tr~n~~ ~~
e de st ination w ill ge t e of Ftg. -
un ab le to lo cate the st out of sy nchr on iz at io n
art of th e ne xt fran1e . and will ~,
th e de st inat io n kn ows Even if the ch ecks um
th at the fram e is ba d, it is inco nect so
ne xt frame starts . Se nd still ha s no way of telling
ing a fra me back to the wh ere ~he
do es not he lp either, sin so urce as ki ng fo r a re tra
ce the destinatio n do es nsm is s 100
not kno w ho w m an y ch
arac ters to
-
DATA LINK LAYER DESI ON
sEC. 3.1 Iss ue s
. . 189
1,ip over to get to the stadn of the retra nsm1ss 1on F .
siv . od . I . or this reason, the ch
count meth ts rare ~ use anymo
re. aracter
ond framm g me tho d get s a d
1be sec . roun the probl em of resynchron· .
hav mg eac h fram e sta rt and end wit_h . · 1zat1on
er an error by . b cial bytes. In the
aft ferent ; but m. recespe past,
the starting an d en dmg ytes were dif nt
mo st pro tocoJ
th e sam e byte , ca 11 ed a flag byte b h st years
hav ede us
~s ot !he arting and end ing dehm~
·ter as sho wn in Fig. . 3-5(a) as FLAG . In th' ts way if th .
l. ' . .
rch for the flag byte ~o fin~ rece ive r ever lose s syn -
cbfO Dizatio n, 1t can J~s t sea th
bytes ind ica te the d f e end of the curren t
sec uti ve flag
[ram e. Tw o con en o one frame and start of the
next one.

/FJG/ Header I Payload field I Trailer IFLAGI


(a)
After stuffing
Original characters

08 0 - [~] I I ESC /FLAG/I~

0EJ0 -0EJEJG
0EJ80-0EJEJEJB 0
0EJEJ0-0EJEJEJ EJ 0 (b)
ples of byte se-
(b) Four exam
bytes.
Figure 3-5. (a) A frame delimited by flag
.
quences before and after byte stuffing. d hen bin ary data, such as obJpen e~t
A . h
r o w . d · It ni·iy eas il) hap
senous problem occ urs with this me tte ' ~
Prog r!un . g-pom . t numbers, are et·ng transm1
b . . r·on will usu al! \- 1nter-
th n - 11 s or tlo atm · h d ta Tht s sJtu a l •
sen der
·,
s d.H.1
uLctt th, 11- urs m t e. a · .. to hav e the
~ Ha g by te's bit pat tern occ
fi
solve this problemtore _1s ' h .. ,u:cidental " tt1g
~re Wtth the framing One way to eaL
(ESC) 1·ust be nd removes the e~~·apt> b) ce
ink J, . . esc ape byt e - . ·.
b' _ayer insert a spe cial
recei~in~ \n iqu e is n dk,l b}le stuff·
~te m the data. The data link ]ayer on the er. T '~ ; ~ c 1n he dis tinguish ed ttom
lay
I ore the data are given to the network c
bg character stuffing. Thus,
?r a framin~ fl ag_. y t: b' ce beforr it.
b) tc ""':Ur'.'~/~.
ne~ the data by the absenc e or presen
0 ce ol an es_c ~P: n :scape
Wh al ha~p~n~ s stuffoJ with "" ct"{;,~, are
J;,ut'
llJiddJ f course, the next qu estion is: t ou pl.,~
at it, o ,·eq.ltence, wherea s a•xa
1'h,, e of the data? The answer is t·th. escape ~ dara. Son e
1
rn . ., ~
us a an . II . 1 the c:
inct· . , ny single escape byte is part o d natura Y u
8 that a single escape occ urre ·
1cate
THE D A T A L IN K
LAYER
190 Ci-IA?
•n Fig. ) In all cases, the by te sequ en ce de li ve re d af . \
shown 1 3-S(b · . .. te r de st f .
rl th e sart,e as t he o ngtna1 byte se qu ence. · u fing
~xacJe byte-stuffing d pi cted in Fi·g. 3- 5 · - r h
sch e: ~ th :t mos t ho is a s ig t s1· m ph·hc · at I\

m e co m pu te rs u_s io
sed in the PPP proto_ e t~ comrnun ic: t~)f
one u . provider. W w ill di sc u ss lhe
their Internet servic e P P P la te r m th is ch ap te
e f ·og this fr am . h d · th · · r. ¼1th
A major di sadvanta
ge o uNs1 t all ch ar in g m et o is at It 1s cl os ely t'
the use of 8-b.it l -harac ters. 0 ac te r co de s us e
16-bit characters, A 8- bi t ch ar acte ieu
s ne tw or k s d ev el
lri
example. UNIC ODE r~. h
~ses h ra ct"r co de op ed , th e di \ad ·, ir
tag:es of embedding le ng th in th e fr am
more and more obvi _t e .c .a a ,;e w te ch ni qu e ha d in g m ec ha ni sm be \a n.
ous. so to be de ve lo pe d
trary sized charac te to allowcainbe
rs. ar 1.
The new tee hm.que allows data fr am es • b.
· to co nt am an ar 1trary
and a11ows character codes with an ar bi.tr ar y number of b.
works like this. Each nu m be r o f bi.ts
frame begins an d en · h · pe r character. It\It
tin fac~ a flag byte). d,s w it a_ sp ec 1a ' l b
Whenever the se nd 1t pa ttern, 0111 l I
secutive 1s in the da er s da ta l_m~ la ye 10
ta, it automatically r en cou~1ter s fi ve con-
This bit stuffing is st uf fs a O bi t m to
analogous to byte st th e ou tg oi ng bit str
into the outgoing char uf fi ng , in w hi ch eam.
acter stream be fo re an es ca pe byte is
When the receiver se a fl ag by te in th e stu ffe d
es five co ns ec ut iv e da ta .
it automatically dest in co m in g l bi ts ,
uffs (i.e., deletes) th fo ll ow ed by a Obit.
transparent to the ne e O bi t. Ju st as by te st uf
twork layer in bo th fi ng is complete\
co m pu te rs , so is
data contain the flag
pa ttern , 01 11 bi t st uf fi ng . If the 1
store.din th 1110, th is fl ag is tr user
e receiver's memor an sm it te d as Ol l
stuffing. y as 01111110. F 111010 but
ig ur e 3- 6 gi ve s an
exampl e of bit
(a) O 1 1 O 1 1 1 1
11 1111111111
oo 1 o
(b) O 1 1 O 1 1 1 1 1
O 111110 1111
1 O 1 OO 1 O

" 'Stuffetd bits/


(c) O 1 1 0 1 1 1
111111 111111100 1
"1iw-e 3-6. lfa stuff 0
~ lille . k) Th e dat: n.ugs. th(
1ng a) The orig
' ey are st indal· da ta . (b) Th e da ta as th ey ap
.
ore m the re ce iv pe ar l,n
Wilb bi.t ~tuft" er 's m em ory at·.ter s• ff-
O&n11,.ed by t! de tu
ing, the houn dar b
ha ~ \o do • k fl ag pa
be lte rn Th y ~~wee n two fr am
)Ul\dijj' it~ !M;an· th .
i~
e in . us , it the r es ca n be un ainbi. i, \, t,',
pu t fur fl· , , . t-u~'l tll \
1\ e \ast ~ ~ , er Within
4
ec et ve r lo se s tr ac
k ot- w hei·c- it. l ' • •.111 1
ing on the h e~ od th e ~g /~ qu ences, si nc e th ey ca 11 :
encr"' - p Ys1l:al rnof frarnin . u a. n on ly o cc t11 .1t
. ~ ct· . g is on \y a 1·
and a ob\ 'bit. of data by e 1um ~(.)n t· · PP 1cable to ne tw ,
. ·h tl\ l~L't , ·1'J\ ,
it H, a low , Ul) tn. tttns so m e or ks in wh
g 2 ph .· . d H. .l '
-h,gh Pair. T t :~ te al . re undanc y . F or ex ai np 1e . .'-.o, \\_\l1" 1 111
btts. Normally a l )'' \ •
le sc he
me m ea ns th at ev '
bi t is a hi~h .
11-111 "
1

er y data bi·t hi.1 :-. ' 1


DATA LINK LA YER DESIG N ISSUES 191
5BC· 3, l
. he middle, making it easy for the receive r to locate the bit boundari es .
tioO 10 t b'10 ations high-hig h and low-low are not used fo r data but are u<,ed for
Th~ corn
I
. . frames in some protoco s ..
deh 1111 u;~inal note on framing, many data link protoco ls . use a combina tion of a
As count with one of the other methods for extra safety. Wh en a fram e
ch~acterhe count field is used to locate the end of the frame . Only if the appro pri -
aJ11ve~~titer is present at that position and the checksum is correct is the fram e
ate deedtrnas valid. Otherwis e, the input stream is scanned fo r the next delimi ter.
accep~
. Error Control
3_1 3
Having solved the problem of marking the start and end of each frame. we
me to the next problem: how to make sure all frames are eventual l y delivered to
:e network layer at the destinati on _and in the proper order. Suppose tha_t ~e
sender just kept outputtin g frames without regard to whether they were arn v1ng
properly. This might be fine for unackno wledged connecti onless service. but
would most certainly not be fine for reliable, connecti on-orien ted service .
The usual way to ensure reliable delivery is to provide the sender with so me
feedback about what is happenin g at the other end of the line. Typicall y , the pro-
tocol calls for the receiver to send back special control frames bearing posi tive or
negative acknowl edgemen ts about the incoming frames. If the sender receives a
positive acknowl edgemen t about a frame, it knows the frame has arrived safely .
On the other hand, a negative acknowl edgemen t means that somethin g has gone
wrong, and the frame must be transmitt ed again.
An additiona l complica tion comes from the possibili ty that hardwar e tro ubles
may cause a frame to vanish complete ly (e.g. ; in a noise burst). In this case. the
receiver will not react at all, since it has no reason to react. It should be clear that
a ,protocol in which the sender transmits a frame and then waits for an acknowl -
edge,ment, positive or negative , will hang forever if a frame is e ver lost d ue to, for
exam.pie, malfunct ioning hardware .
Wh This possibilit y is dealt with by introduc ing timers into the data link layer.

:t · en the sender transmits a frame, it generally also starts a timer. The timer is
to expire after an interval long enough for the frame to reach th e destinati on.
N processed there, and have ·the acknowl edgemen t propagat e back to the sen<ler.
b;~ly, the fr~me will be correctly received and the acknowl edge ment will ge t
H fore the timer runs out, in which case the timer w ill be canceled .
off a~w~ver, if e ither the frame or the ac kno wledgem ent is lost, the ti rner ,, ill g\,
tra~ srn~rting the sender to a po te ntial pro ble n1. T he obvious solution is tr~ Ju , t
t!rn~s t~e~~e. ~~ame again . Ho we ver_, whe~ fra mes may be tn._m smittt"d n\ll ltip k
1
times and , ~ .a· dange r th at the rece ive r w ill acce pt the sa mt· t1ame t,, o 0 1 m1..Ht'
~ening, it fts:i-s it t_o the ne twork laye r ~1ore than once . Tn pre, t· nt th i: fr1.. ,~n h"lp
so that th ge_ne,ally necessary to ass1.g n seque nce numben, 11..) l'll tgorng tra nws .
.
' . u1. s I1 rctra nsnu. ss10ns
e receive r ca n d 1strng . .
trom nn gurnb .
192 TH E DA TA LIN K LA YE R
CH AP . 3
•.
The whoIe issu e o f managing the timers and seq uen ce num bers so as to ensure
· lt'm . .
that each frame 1s u 1 ately passed to the net.wo rk lay er at the destma tton exactly
.
once no more and no less is an imp orta nt par t of the dat a hnk lay er , s duties .
er in' this chapter, we will, look at a ser . . . . Lat-
ies of inc rea sm gly sop his tica ted exa
to see how this management is don e. mp les

3.1 .4 Flow Co ntr ol

Another important design issue tha t occ


urs in the dat ? link lay er (an d higher
layers as well) is what to do with a
sen der tha t syst~ma_t1cal~y wa nts to_
frames faster than the receiver can acc transmit
ept them. Thi s s1tuatton can eas ily
wh en the sender is running on a fast occur
(or ligh tly loa ded ) com put er and the
is run nin g on a slow ( or heavily loa ded receiver
) ma chi ne. Th e sen der kee ps pum pin
frames out at a hig h rate until the rec g the
eiv er is com ple tely swa mp ed. Ev en
tran sm issi on is erro r free, at a cer tain if the
poi nt the rec eiv er wil l sim ply be una
han dle the frames as they arrive and ble to
wil l star t to los e som e. Cle arly , som
has to be don e to pre ven t this situatio ething
n.
Tw o approaches are com mo nly used.
In the first one , feedback-based flow
con tro l, the receiver sen ds bac k info rma
tion to the sen der giv ing it per mis sio
sen d mo re dat a or at lea st telling the n to
sen der how the rec eiv er is doi ng.
sec ond one , rate-based flow contro In the
l, the pro toc ol has a bui lt-i n me cha nis
limits the rate at wh ich senders ma y m that
tran sm it data, wit hou t usi ng fee dba ck
the receiver. In this cha pte r we wil from
l stu dy fee dba ck- bas ed flo w con tro l
bec aus e rate -ba sed sch em es are nev er schemes
use d in the dat a link lay er. We wil l
rate -ba sed sch em es in Chap. 5. loo k at
Va riou s feedback-based flow con trol
sch em es are kno wn , but mo st of the
use the sam e basic principle. The m
pro toc ol con tain s wel1-defined rule
when a sen der may transmit the nex s about
t frame. The se rul es oft en pro hib it
~°:1 being sent until the receiver has granted permissio frames
plicitly. For exa mp le, wh en a con nec n, eith er imp lici tly or ex-
tion is set up, the rec eiv er mig ht say
ma! send me n frames now, but after they hav e bee n : "Y ou
until I have told you to continue.'' We sen t, do not sen d any more
wiH exa min e the det ails sho rtly .

3.2 ER RO R DETECTION AND CO RR


EC TI ON
. As we saw in Chap. 2, the tele
mterofftce trunks and the loc al loopho ne sys tem has thre e parts: the swi tch
es, the
. de • · . ·
· ps. The fi1rst two are now alm ost ·
ta I m most veloped countr' · ,-
enti re ly d1g ·
· d - . 1e Th 1
_s.
pairs an · w111 con tinu e to be so fi · e ocal loo ps are still ana log twi sted cop .
ing the m Wh 'l · pei
local 1 .
or yea
1 e erro rs are rare on the di rs due to the enormous exp ense of rep lav·
·
oops. F urt h.enn ore , wir
.
eless .
gita1 par t, the y are still com mo n on tl· ,
,c.
and th h • .
e error rates ere are orders of com mu •
mc atto n is bec om ing mo re cornrn on.
· ma gni tud e wo rse tha n on the inte rof .. ··b
fice lt ct ·
sEC. 3.2 ERROR DETEC TION AND CORRE CTION 193
~ many
transmi ssion errors are goi·ng to be w1·th us 1or
trllnks · The conclus ion is:
ears to come. We have to learn how to deal with them
y As a result of the phys~cal process es that generate them, errors on some media
(e.g., radio) tend to come m burs~s rather than singly. Having the errors come in
bursts has both _advantages and disadva ntages over isolated single-bit errors. On
the advanta~e s~de, comp~t er data are always sent in blocks of bits. Suppos e that
the block size is l 000 bits and the error rate is 0.001 per bit. If errors were
independent, mo st blocks would contain an error. If the errors came in bursts of
100 however, only one or tw? blocks in 100 would be affected, on average. The
disadvantage of burst errors 1s that they are much harder to correct than are iso-
lated errors.

3.2.1 Error-Correcting Codes

Networ k designe rs have develop ed two basic strategies for dealing with er-
rors. One way is to include enough redundant information along with each block
of data sent, to enable the receiver to deduce what the transmitted data must have
been. _ The other way is to include only enough redundancy to allow the receive r
to de<;luce that an error occurre d, but not which error, and have it request a
retransmission. The former strategy uses error-correcting codes and the latter
uses error-detecting codes. The use of error-correcting codes is often referred to
as forward error correction.
Each of these techniq ues occupies a different ecological niche. On channel s
that are highly reliable , such as fiber, it is cheaper to use an error detecting c<Xie
and just retransm it the occasio nal block found to be faulty. Howeve r, on channel s
such as wireless links that make many errors, it is better to add enough redun-
dancy to each block for the receive r to be able to figure out what the original
block was, rather than relying on a retransmission, which itself may be in error.
To underst and how errors can be handled, it is necessary to look closely at
what an error really is. Normally, a frame consists of m data (i.e., message) bits
and r redundant, or check, bits. Let the total length be n (i.e., n = m + r ). An n-
bit unit contain ing data and check bits is often referred to as an n-~it _c odew~r d .
Given any two codewo rds, say, I 000 I 00 I and IO 1 I 0001 , 1t 1s poss1 ble to
detennine how many corresp onding bits differ. In this case, 3 bits differ. To
determine how many bits differ, just exclusive OR the two codewords and count
the number of I bits in the result, for example :
10001001
10110001
001110 00
The n~ber of bit positions in which two codewo~ds di f~·er is called the Ham-
ming distance (Hamming, 1950). Its signific ance 1s that 1f two codewords are a
II
TtfBDATA
LINK LA YER CHAP. 3 sec- 3.2 ERROR DETECTION AND
CORRECTION
t'4 . d single-bit errors to convert one 1n1
. · h thc m data b'its. Each chec k b. f 195
. will requ1re 0 filled up wit
11 · I d' · If b It orces th e ·
panty of some coll .
· dii.tanct' d apart. • of bits, me u· mg ttse ' to e even (or odd J· Ab'1t may b - ect1on
. r·ons all zm possible data messages, are T h'
Hamnung ·
otbCf . · - app1IC8 I · • itY compu tations. of see w tch check bit~ the data bit..ine inc•1uded . . in several par-
tilt ~ data ~ sm1ss1on k b'ts are computed, not all of the 2n possibl rewrite k as a sum o powers of 2. For exampl 11 - 1 pos1t1on k contributes to
1" bu due the way the cheC -~m for computing the check bits, it is pos _e
10
+ 16. A bit is checked by just those check b.t

e. - + 2 + 8 and 29 = J + 4 +
1 s occumng · 8
l~~ · _.!, art used- Gi\'efl t!1e a)gOfthn legal codewords, and from this list find 1~• - JI is checked by bi ts I, 2, and 8). m its expansion (e.g.. bit
C\,~WUtu ~ lete list o e . . Th. d' . e
1..l a fO coc,stn1Ct a comp . d' ranee is m1mmum. IS !Stance IS the Harn When a codeword _arrives, the receiver initializes
l'"- ~ whOSC Harnnung is - amines each check bit, k (k = I, 2 4 8 J a c_ounter to zero. It then
_ of the complete code. . ex . • · · · · · • to c;ee 1f tt h th
1w-0
. · d rror-correcting properties of a code depend on its If not the receiver adds k to the counter If the . as e correct parity.
ming di~ ' . . . · counter 1s zero afte 11 th
-dctectJDg an e d errors, you n~d a d'1stance d + 1 code _because bits have been examined (1.e., if they were all corr t) h r a . e check
~~ . To deted
~ ft! distan(lethere . 00 way that d single-bit errors can change a vahd code-
as valid. If the counter is nonzero. it contains the n:~be· t Oef~~word 1s ac_cepted
I 2 · r uie mcorrect b1t F
1
"''lh such I code · id ~word When the receiver sees an invalid codeword ' 1·t example, 1'f c hec k b'its , , .and 8 are m error· the inverted b.1t 1s 11 because· .,t oris
word u,to 3110ther V81 wu<- • · • h
the only one c ec e k d b b
y .its 1, 2, and 8· f igure 3- 7 5hows some· 7-b,t. ASCU
CID !di dial uansmission error has occurred. S1mdarly, to correct d errors, you
I
need a distanee 'liJ + 1 code because that way th~ le~al codewords are so far apart characters e~codde~ asb _11 -bi_t _codewords using a Hamming code. Remember that
the data are ,oun m it pos1t1ons 3, 5, 6, 7, 9, 10. and 11.
!bat .even with d changes, the original codeword 1s stdl closer than any other code-
wad, ;o it CID be uniquely determined Char. ASCII Check 01ts

A5 a simple example of an error-detecting code, consider a code in which a


singlt. parity bk is appended to the data. The parity bit is chosen so that the H 100 1000
A\
00110010000
number of I bits in the codeword is even (or odd). For example, when 1011010 is a 110000 1 10111001001
sent in even parity, a bit is added to the end to make it 10110100. With odd parity m 1101101 111 01010101
m 11 01101 11101010101
10110IO becomes IOI 10I01. A code with a single parity bit has a distance 2 110 1001 0110101 1001
since any single-bit error produces a codeword with the wrong parity. It can b~ n 1101110 01 10101011 0
used to detect single errors. g 1100111 011 11 001 111
0100000 10011000000
As ~ simple example of an error-correcting code, consider a code with only 11000 11 1111100001 1
C
four valid codewords: 1101 11 1 1010101 1111
0
d 1100100 11111001100
OOO<XXXXXXl, OOOOOl Ill I, 11 lllOOOOO, and 1111111111 e 1100 101 00 111 000101
'
been OOOOOl l ll I. If.~=~
This code has a distance 5 which
codeword OOIXXXJOt t l '. means_ that It. can correct double errors. If the
the recei~er knows that the original must have
CKmlOOt 11, the error will bever, 8 triple error changes 0000000000 into
I . not corrected prope 1
Order of bit transmJSSIOn

Figure 3-7. Use of a Hamming code to correct ourst errors.

15 th
~IIIC that we want to desi . . r y. Hamming codes can only correct single errors. However. there a tnck at
~ 1 w,U allow all single erro : 8 code with m message bits and r check bits can be used to permit Hamm ino codes to correct burst errors. A sequence of k
n Illegal codewords at a did~-~ COfflleted. Each of the 2m legal messages has consecutive codewords are arra~ oed as a macn'(, one codeword per row. Nor-
tnVffliilg cach· of the n bits-uce 1 from it Th · I
the ., in the n-bit · ese are formed by systemaucal Y mally, the data would be transmi;ted one codeword at a time, from le~l to nght.
2 . · d ne column at a nme, start-
number legal .messages requires n + . codeword formed from it. Thus, each of To correct burst errors the data should be rram,rrune O 1
1
requ~ n J)atlems is 2", we m st~ patterns dedicated to it. Since the total ing with the leftmost c'olumn. Whe n all k bits ha\e been sent, _th e secoo<l co ~mn
. 'h th frame amves at the receiver.
oumbcr of ~ (m + r +I): 2, ~~ (n + 1)2"' S 2n. Using n =m + r, this
. . 7
IS sent, and so on as indicated in Fig . :,- - 'w en e f 1 th k
th · . ' ~ If a burst error o eng
This theort: . bus Deeded to.co~· . tvcn m, this puts a lower limit on the e matnx ts reconstructed. one column at a ume: been affected but the
Haauning(I9~i caJ loWer limit can . smgle errors.
~the
wilh bit t ai die
1
bits of the ~ fact, be achieved using a method due to
P<>wcrs of 2 (I 2 eod, bit 2 to its · w~ are numbered consecutively starting
occurs, at most l bit in each of the k codewords will haveth
Hit--·
- • 11 111ng code can correct one error per l:O
- de wordl~ks
so e en
u·re block can be
of km data bits immune
' l'CSlOfed. This method uses kr check bi ts to make b
4
· • , 8, 16 Ulllnedia&e ......
· etc.) arc check b' n~..t, and so on. The bits that are to 8 single burst error of length k or less.
ns. The rest (3, 5, 6, 7, 9, etc.) are
LINK LAYER Cl-!Ap_ 3
THE DATA
196 · SEC. 3.2 ERROR DETECTION AND C
. .
ting codes . which .are notor1._
0RR ECT!ON 197
d n wire less Imks modulo
, ., Error-Ottec 'd ly use o . Polyno rrn·al an· th met1·c 1·~ done
'l,J;
•• . odes are
w1 e d to copper wire or opttcal fiber
ugh .· lio~~
2 I of algeb raic
. according to th rue~
fi Id theo ry. 'fh ere are no carn.e~ for addition or borrow~ for e btr .
&ror.~ rrectt ng c prone when comdpbearehard to get anything thro d .
1e n and subtracti.on are identical to exclusive OR F 5u act ion. Both ad-
and error 1·t woul r, so erro r etect 1on anct d'tio • or example:
t is much lowe · h h occa sion al
ously nmsy -conccting codes, the error ra e 1· t e 1 1001101 I 00! 1()()1I
error mg wit

- - -- --
. there for dea I1II00oo
W itholll
ever. over cop!> · t:r WI•re or llyfiber.
more efficient . + 1100101 0 + I l()()J IOI 01010101
.ssion is usua - 10100110
- 10101 II I
h errors are ·isolated and the
rerransrni 'der a channel on whicbits. To provide error corre c. 01010001 Ill I 111 0 010101 I()
k •ze be 1000
. le example, consi
abit of data would bina II I 11010
emir.
As a
emir rate i
si;ro~ per bit. Let
k 10
the blkoc b'st~ are needed; •ah meg. I I b'
chec J
rel detect a block wit a smg
e - It error, one
Lon o di vision is carri ed out the ~ame way as it is ,n
t d u lo 2, as above. A divis . . or 1.s said ''to go ry exce d' the
int ,,pt that d subtr. ac-
tion for 1000-bit bloc . s. a block (IOO J ion e,is done mo as the · ·d1v1 ~or. 0 a 1v, end 1f the
bits. To meOync e every 1000 bloc ks, an
h
extr
d · dividend has as many btts .
uirc 10.000 check k ·u suffice. The
f
e erro r etec11on + od i~ emp loyed the send er a d
t
req
parity bit per bloc wi . d total over head or When the pol yno mial code meth recei ver must
low-
~in;O Ol bits per megabit of data, vers
us I 0,000 bits
gen erat or poly nom . C(xJ. in adva·nce. Both then high- and
ial,
bits) will
smiss have
ion to beodtrans
meth is on y agree upon a
the chec ksum for-,o me fram e
retran t be I. To compute
garbled by a order bits of the gene rator mus the fram e mu~t be longer than
a block and the block is badly the poly nom ial M (x ).
for a Hamming c~e. . . dd d to is only 0.5, which is with m bits , correspo ndin g to the end of the
will be dete cted idea is to append a checbum to
If a single panty bitbisb.al.t 11 ethat the error
bl 'f h bl k be the generator polynomia l. The d by the chec ksummed frame
I burst error ' the Th pro a y be improved considera y I eac oc to poly nom ial repre sente
odd can k b' h' h d · 'b frame in such a way that the frame, it tries
ong
hardly acceptable . e tangu s · · , as escn
d ed the rece iver gets the checksummed
lar matr ix n bits wide and its 1g ff- is divisible by G (x). When a tran, mis\ ion error .
sent 1s. regard ed as a rec mn and a _•xe to the a remainde r, there has been
above . A parity bit is comp uted sepa ratel y for e~ch colu dividing it by G (x). If there is the checksum is as follo i.. s:
time . Whe_n The algorithm for com pu ting
then transmitted one row at a
matrix as the last row. The matrix is a~~ one of them. 1s the low- order end
all the parity bits. If C (x). Append r zero btts to
the block arrives, the receiver checks Add 1t1o nal retransmis- I. Let r be the deg ree of and corre sponds to the
ssion of the bloc k. e so it now cont ains m + r bits
wrong. the receiver requests a retransmi is received without any parit y
of the fram
nom ial x'M (x).
sions are
. reque sted as needed until an entire block poly
errors stnng
sponding to Grx, 1mo the bit
of length n, since only I bit per
column 2. Divide the bit string corre modulo 2 divrs 10n
This method can detect a single burst tecte d, how ever , if the first correspondin g to x r M (x ). using
will be changed. A burst of length n
+ l will pass unde the b11
are correct. (A burSl ch is always r or fei..er b1ts 1 from
bit is invened, the last bit is inver ted, arri ~11 the othe r bits
t the fir;t
3. Subtract the rem ai nder (whi modu lo 2 ~ubtr acuo n. The
(x) using
wrong; it just implies that at leas string correspond ing to x r M
error does not imply that all the bits are long burs t or by multiple med fram e to be trans mine d. C11l Its pol:,no-
and last are wrong.) lf the block is
badly garbled by a result is the chec ksum
of the n colu mns will have the correct par- · mial T(x) .
'd , the1 o bility that
·5proba any
11y byr bursts
~hone
bloc k bein o acce pted whe n It
IS r . .S, so the probability
of a bad e,
' d not
shoul ace,bee~t, 01 011 011 using the generator
Figure 3-8 4 illustrate
s the calculati on for a frame 11 ...
s be adequate ' in practice, another
thde above schemthe e may some.time C (C lie G(x) == x + x + I ct· ._
d1v1s 1on
mctli~th_o~ghw1 . (m od u1O -" l b} G( r) In any
~
I • .
I a CR . ye . . 1ble
·
is Ill espre a(! use·
Ynonua code, also known as · r th at T (x ) is dl\'1s
ll.tdlllldancy Check' ·
s are base d upon treat ing bit stnngs as
It should be clea
p,oblem, if you dim inish the
. ed b) the rem,rn
d inde · d '::d, ,
what is, left JO.
over
by 1s941.1vbi-
the
rcJ>l'esentations of { /olynom1al code of O and l only . A k-bit fram ek -1~ ple. in bast' 10. if you di 1 . ·- 78.
- 10 ("07 879)
regar ded as the c:riic1en /. onula
t
ls wub
ist for a coef
pol
ficients.I ble by the divisor. For exam 2199 trom -..,1 0·-17g · what i,· 1elt over - .
lo o S Ynom1a With k terms, ranging
from x ~ema 10cter is 2399. By subtract ing
IS d' .. 'bl
.
. x_18· th uch a polynomial is s .
11
l. The high -ord er (leftm oS t) Whm kind, of mo~ w;JJ_ be
d~gree k - ..
~ e coeffi cient of x*- 1_aid to be of_ ficie nt of xk -2' and so on. >¥>st e by I 0. 94 I. th,~ mt'rhod. . . d of the bi t stnng
For example, 110001 has 6 b-U1e next b11 is the coef · -1 with Now let us anal yze the pow er of
- • ·urs so that a s to a bit that
in,1e·pond
thus • ·
COcffic1ents I 1 o 0, and l ·its sand 4 • repre ia .
d_etected? Imagine that a transm1ss 1on erroi
nom '. ' _
sents a six-t erm poly Ol l .
) L Llrres
· · •0. -x +x +xo _ • E h I b11111 .
f(r
b't error~ have occurred.
to T( x) artiving, T(x) + £(.r) am\ es. ·;ir£ ( •) k srn°

J h"s
A
"
r
· le ~Urst erro
fi ~ing c
· r is chara_
na1 I, W1th all other bi ts berng
.
tenz
0.
ed
·
by
111
3 n
·
1111
1 • e 1e-. 1
be en inverted If there are k I bits · ·tial• I· a mixt ure of Os and Is.
and a
LINK LA YER CHAP. 3
THE DATA SEC. 3.2 ERROR DETECTION AND CORRECTION
198 199
If there have been two isolated si ngle-bit ' + x J , where i >).
as E(x ) == xi(errors,
.
. ly, th'1s can be written E(x ) -x
Frt!TII
c,er,erator.
. 1101011011

~ atter 4 zen>
1 0011 . 1 1O101 1 0 1 1000 0
bits are appended-
Altematrve
is not divisible by x , a sufficient condition for
i-j
:u
d+ ~j
-
If we
that G(x) does not divide xk + I for any k up to th ou ~ errors to be detected
assu me that G(x)
is
1100001 010 . f e maximum value of 1. - 1. (.i.e.,
up to the maximum rame length ). Simple low-de gree po 1ynorruals .
that give. P:0 _
' ·
1.1101011 0110000
100 1 1I l
~
l . f
tection to long rames are known. For example x ts ... x 14 + 1 w·
xk + l for any value of k below 32,768. ' ' ill not d1 v1de
If there are an odd number of bits in error E (X ) contains a dd b f
10 0 1 1 5 2 b 2 ' no num er o
tenns (e.g. , x + x + l , ut not x + l). Interestingly, no polynomial with an odd
~ number of terms has x + I as a factor in the modulo 2 system. By making x + 1 a
OOOO 1 factor of G(x), we can catch all errors consisting of an odd number of inverted
~ bits. -
0 0 0 1 0 To see that no polynomial with an odd number of tenns is divisible by x + 1.
assume that E (x) has an odd number of terms and is divisible by x + I. Facwr
~
E(x) into (x + l) Q(x). Now evaluate £ (1 ) == ( I+ l)Q( I). Since I + I == o
0 0 1 0 1
(modulo 2), E( l) must be zero. If E (x) has an odd number of tenns, substituting I
0 0 0 0 0
for x everywhere will always yield I as the result. Thus. no polynomial with an
0 1 0 1 1 odd number of terms is divisible by x + I.
0 0 0 0 0 Finally, and most importantly, a polynomial code with r check bits will detect
all burst errors of length $ r. A burst error of length k can be represented by
x;(xk- I + .. . + I), where i detennines how far from the right-hand end of the
1 0 1 1 0
1 0 0 1 1 0
---- received frame the burst is located. If G (x) contains an x tenn. it will noc have
0 1 0 1 0 xi as a factor, so if the degree of the parenthesized expression is less
than the
0 0 0 0 0 degree of G(x), the remainder can never be zero. .
If the burst length is r + I , the remainder of the d_i:ision b) G(x) will be zero
th st
0 1 0 0
if and only if the burst is identical to G (x). By defi nmon of a bursL e fir "."d
0 0 last bits must be I , so whether it matches depends on Lhe r - I i~c_ermediace bi ts.
0 1 0 l f all combinations are regarded as equ all Y lI.keIY· the probab1hty of such an
incorrect frame being accepted as valid is w- · ,
1

0 0 0 0 0 _,.,..- Remainder r than , + bics occurs or


0 1 - th ouoh
1 1 1 0 It can also be shown that when an error burst lonee
when several shorter bursts occur. the probability of a bad frame gemng r
0

. II b' tt rn . are equally· dhkely.


Traflllniaed frame:
1101011011 111 0 unnoticed is w·, assuming that a ll pa e s . d- The one used in
· t rnatJonal stan ar s.
Certain polynomials have become in e
fltart3-1. Calculati00 IEEE 802 is
of the polynomial code checksum. s 7 5+r-l +x 2+x1+ 1
x·l2 +x26+ x23+ x22 +rl 6+x12+.r11+ .r 1u +x + .r + x .
. Upon l'e.Ceivin the . erty chat ic detects all bursts of
1s, it computes g checksummed )· that Among other desirable properties. it· has. the prop b . ot· bits
lion is simply J[<x )
+ £(x))IG(x) T(framc, the receiver divides it by ' uta·G(x I ..
ength 32 or less and all burs ts attel't tng ,ll1
odd num er ·
th checksum may seem com-
conw..;.._ G x)/G (x). ,,___ · x )IG(x) is O so the result of the lcornP . ls
. =-"' (x) as i •IJl!SC errors that h ' orn1a . Although the calculat ion required ro compute th:t a si mple shift register cir-
. If there has a ~ Will sli b . apPcn to correspond to po yn Plicated, Peterson and Bro wn ( 196 1) have s~i~w~he checksums in hardware. In
1
~ error. If G(x~ a 5:"1&le-bit
stD
!o:•all 0 ther_errors will be caught. . bit is
rn:;_<x) == x' '. where i determines which . all
cuit ~an be constructed _to cor~put_e a_nds v:~eI. Virtually all LANs use rt and
Practice, this hardware 1s ne,11 ly ,tl w.iy.
gle-bit ctrors w ~ two or 0
detected. terms, Jt will never divide E(x) , s point-to-point lines do, too, in some cases.
SEC. 3.3 ELF-.MENTA RY DATA LI
NK PROTocou;
TA LINK LA YER CHAP. 3 201
THED A traile r). so that the datali nk laye r V>ftware d
. h ct· d . nee not worry bo
that frames to be checksummed contain ran. rni al algo rr t m iscus_'i e earli er in th1, chapter m, ht a u1 II. I ne p<,lyno-
lOt
. has t,een assumed al orithms have been made under thi s as. Initi a ll y, the recei ver has nothino tn dr I g he used. fo r ex<1rnple .
11 f i...rksum g . · t b · t Just rns arou <l ,
thing to happen. I n the example protocol , of thI~ chapter we n>. II"'a1t1n~
c '
- da:.,des, h wn this assumption o e qutte wron g. fo r ,ome-
F,'11" · aJyses o ca~ d
an •
b1·ts. All~...-ction I data has s o .
data link layer 1s wait ing
. .
fo r 'iomethmg to ha n I in 1eate that the
dom of rea . tances undetected errors are much more
' 1995) . ppe by the procedure -:all
sumrnnon · ln"t""- some c1rcumsbl (Partridge et al.,
ueoce underpreviously wail fo r _even t ( & event ). Thi'i procedure only retum,
-. . when h
,i\s • conS((! t,een tboug pened (e.g ., a frame has am vedJ. Upon return th ,ornet mg ha, nap-
corolllOll than had ened. The se t of pos~ible events differ, for th~ Ve ,anable e· en/ tell, AlhJt ndp-
p anou, ;Jrh,t ,4,,~,1, r, he dc::,Ln ne<l
and will be de fime d separately fo r each protocol \i
' k I . Ole t at in J Tl( re roJ.li ~ .., t H.:
y DATA LINK PROTOCOL S situation. the d ala I tn ayer will not <;tt m a tieht lonp Jv,1Jt •

3.3 ELEMENTAR d b ·11 . ~ me ror J.n ;:·,ent J, ,. ..


have sug~es te . ut w1 recei ve _an interrupt. which will .::au~ ,1 , 0 ,too ,,,hate\e~
. f rotocols ' we will begin by ·looking at three proto- it was do in g a nd go handle_ the incoming frame . \ievertheJe,,. for ,i~oltc1t" ·,1, c::
. trod the subJect o P I will ignore a_ll the detall_s ot parallel _act1vny wnhm the data li nk layer and .1,:urne
To m u~ . For interested readers, a s1mu ator for these and
f . mg comp 1ex1ty.
we look that it is dedicated full time to handling just our one .:hannel
cols o mcreas . . ble via the Web (see the preface) . Before .
b I protocols 1s avai1a yin e,o When a fram e arri ves at the receiver. the hardware compute\ the . : neck,um
su sequen . . use ful to make
.ll IS explicit some of the assumptions underl
'
I the protocols. . . If the checksum is inc orrect (i. e .. there wa, a transm 1,.., 1on ;:- r . •he Jata mJ...
athe model of commum·cau·on • To start with ' we assume that m the physical. layer' layer is so informed (e vent = cksum _err ,. If the inb<;und frame: Jffi \e:.I undam-
·-1. and network layer are independent processes that communicate by
111 1
datl l ., ayer. · h · I d d 1· k aged, the data link layer is al so info nned r t'I ent = •rame -11r~· aL 1 ,, '.hat 11 .::an
passing messages back and forth. In ma~y ~ases, the _P ys1ca an ata . m layer
acquire the frame fo r inspection using from_ph nicul_.mer .\~ -,oon .i, tht:
processes will be running on a processor ms1d~ a special network VO chip and the receiving data link laye r has acquired an undamaged "rame. ,t ..:hec:.., the ~ ,ntrol
network layer code will be running on the mam CPU. However, other implemen- information in the header, and if everything 1<; all nght. ;:;a.,,e, :he pa.... Ket portion
tations are also possible (e.g., three processes inside a single VO chip; or the phy- to the network layer. Under no circumstance~ •~ J fr:une 1c:::1Jer ;:\e, ;!\en to J
sical and data link layers as procedures called by the network layer process). In network layer.
any event, treating the three layers as separate processes makes the disc ussion There is a good reason wh y the net\.\.ork la~er must ne-.er be given lff) pan of
conceptually cleaner and also serves to emphasize the independence of the layers. the frame header: to keep the network and dat:i link protocob .::ompletel) ,ep-
Another key assumption is that machine A wants to send a long stream of data arate. As long as the network layer knows nothing JI J.! l 1bou1 r.he Jata linJ.. pro-
to machine B. using a reliable, connection-oriented service. Later, we will con· tocol or the frame fo rmat. the~e thing-; can be .::hanged \\ 11.hout requtnng .::hJnge,
Mder
10
the case where B also wants to send data to A simultaneously. A is assumed to the network layer's software . Providing .1 ng1d mtcrface bet""een ne1""orJ...
have an infinite supply of data ready to send and never has to wait for data to layer and data link laye r greatly simplifie., the ~L'!l\.\.:J.re Je~1gn bcc.1u~e -:ommum-
be. produced. instead, when A' s data link. layer .asks for data, the network layer )is
al cation protocol s in d ifferent !avers can e\ohe mJepcndentl:
ways able to comply 1·mm.~:- I
We aIso assume that''""""14te hi
y. (This restnction ' too ' wiJl be dropped later.· h Figure 3-9 shows some d;claratiLmS lin C) ..:ommon to many ot the prowcol~
"1'\m-.. _, .
~uuuwucation errors but
mac th do not crash. That ,
nes is these protocols deal . wit d to be discussed later. Fi ve d:lla ~trudure:., Jre ddined there · boolewi. ieq.Jir.
crJted r,- pe Jnd on t,1l-.e on
rebooting. · not e problems caused by computers crashing an pac ke r, Jmm e....kind. and framt' ..\ h1>1 1Ic'ull .1~ .ill .'.num
h . ll ,
mte=-er · It) number
u~ed . the trame'>.,
A~ far as the data link I . . t e values true and fa/s t' . A St''f.Jlr 1:., J ~nu
. num bcr, run trom O..\ up, ,cker to anuh
face'° i_t from the network
th 1:Y:: ~s concerned, the packet passed across t_he inter·
e de~tJnauon's network, la y is pure data, whose every bit is to be delivered 10
so that we can te ll them apart. Thc>sc> :;c>yuc>nLe
including MAJC.SEQ. v. hich is Je tinc>J in c'JL'h protol.'Lli nc::edingdit.~, ~~ta link
th · . the ne1,~ 1)rl,, la\er Jn c.:
LnLerpret pan of the pac1. yer. The fact that the destination's network layer maY e u111t o f m fotm atio n exl.'h:inged bet,\ ecn - I our model i1
Wh 1o.et as a head • la - . . b . nc>l\\Llfl-. 1.1 ... a peer'>. nbe of vJriable
.f en the data link laye er ts of no concern to the data link layer. · a Yet o n the same . mach ine. or ct,, cc n ..' it ,\ould
r accepts
rame by 4"dcl'
cons· mg a dita link heade a packet, it encapsulates the packet 111 always contain s MAX.J'KT b, It' '> . but Illl)fc' re.1li:.-tlLJ 11 1
c~~~ of an embedded packe r and trailer to it (see Fig. 3-1 ) . Thus, a tra111c . / ·e ad. and i11/c1. the fir~t three of
mac . •ne w '
i
the oth:; (1n hth_e trai!erJ. lbe so~ control information (in the header). and ,1
rame IS the tr . ' I r l)fl
length. .
Wh . 'h . . . .
. -
A J r u m e is co mpo, eJ of four I tL·kh. {in, · ·'of_'-1·\\ h1..:
11
J the 1.1.,1
. . ·nntam actual daw Ill
1l lll,ly L
, ll <l the frame header.
hnk aye . I\.: (Onta1n cont ro l 1nl onnaut ll -'
10 1
-11hysic:.a{..J. . · e W11J assurne th . n ansmnted to the data ·edu res
·
1
'T'L U) er lo se d at ther . . .
e exist suitable library proc , . he transferred . T hese co nt rol fic•I J:- are L·L1lkc tl\e y La e
'ne tr.tnsmnting h n a frame . d
ardwarc corn....le ·iUl from_physicaUa yer to receive a ·traill~· , 1hr
·-,,u s and ap d
pen s the checksum (thus creaung
II A LINK LA YER CHAP. 3
I
THEDAT sEC. 3.3 ELEMENTARY DATA L
INK PROTOCOLS
201 I* determines packet size in b The kind field tells whether there .
. . . are any data . h
203
Ytes ,1 the protocols d istmgu1 sh frames contai n· in t e frame beca
pl(T 1024 . . d II mg onl y cont I . , use some of
#define MAX- /* boolean type *I C
ontaining ata as we . The seq and ack r·1e Ids are ro dinformation from those
and acknowled gements, respecti vely· their . use for sequence n b
{false, true} boolean;
~ f enumned int seq_nr;
/* sequence or ack numbers */
[MAX pKT];} packet;/• packet definition */ later. The info field of a data frame .coma· use will be described in
· d ms a single pa k
mor:~ ers,
etai
typedef unsictg {unsigned char data k.,;d. /• frame_kind definition */ control frame ts not use . A more realistic • 1 . c et; the info field of
typedef strv ck nak} trame_ , . fi Id . . . imp ementat10 I a
8 length info 1e , omitting 1t altogether fo r co t I f n wou d use a variable-
.. --..nef enum {data, ' f* frames are transported in th· . • · · . n ro rames.
1y~ v • . IS lay Agatn, 1t 1s 1mport~nt to realize the relationship betw
typedef strvct { /* what kind of a frame ,s it? *I er, The network layer builds a packet by taking een a packet and a frame.
trame_kind kind; /* sequence number *I a message from th
and adding the network layer header to it Thi k . e transport layer
seq~nr seq: /• acknowledgement number */ . l . . h . . s pac et is passed tO th da .
seqJlr ack: I* the network layer packet *I layer for me us1on m t e info fie ld of an outgoing f e ta lmk
. . h d 1· rame. When the fra .
packet info:
at the destmat10n, t e ata rnk layer extracts the pac ket from the fr medamves
the packet to the network layer. Jn this manner th ame an passes
) frame: . h , e network layer can act
. t to happen· return its type in event. *I
though mac hmes can exc ange packets directly. as
/• wait for an even ' A number
void waiLfor_event(evenUype •event); . of procedures
. are. also listed in Fig · 3-9 · These are 11brary
. .
routmes
whose details are 1mplementat10n dependent . and whose inner worki ngs will . not
/• Fetch a packet from the network layer for transmission on the channel. */ concern us ·fu rth erh here. The procedure •~ waumg
wait.for- event sits in a (1.2ht ltJOp ..
.
void from_networlclayer(packet •p); for somethmg to appen, as mentioned earlier. The procedures 1;_nenvork_iayer
/• Deliver information from an inbound frame to the network layer. *I andfromJZetwork_layer are used by the data link layer to pass packets to the net-
void to_network_layer(packet •p); work layer and accept packets from the network layer. respectively. Note that
/• Go get an inbound frame from the physical layer and copy it to r. */ from_physicaLlayer and to_physicaUayer pass frames between the data link lay-
void from_physicaUayer(frame •r); er and physical layer. On the other hand, the procedures to_nerwork_laver and
f rom_network_layer pass packets between the darn link layer and nerwork layer.
/• Pass the frame to the physical layer for transmission . •/ In other words, toJLetwork_layer and Jrom_network_laver deal with the interface
void to_physicaUayer(frame •s); between layers 2 and 3, whereas f rom_physicaUayer ~d to_physicaUayer deal
I• Start the clock running and enable the timeout event. •/ with the interface between layers I and 2.
void starUimer(seq_nr k); In most of the protocols, we assume that the channel is unreliable and loses
/• st0Pth e_clock and disable the timeout event. */ entire frames upon occasion. To be able to recover from such calruruties. the
void stop_llmer(seq_nr k); sending data link layer must start an internal timer or clock whenever it sends a
frame. If no reply has been received within a certain predetennined time interval.
I• Start an auxiliary timer d abl
void starLa,_.,t. ( . an en e the aclLtimeout event •/ the clock times out and the data link layer receives an interrupt signal.
..."- 1mer void); ·
In our protocols this is handled by allowing the procedure wait-for_evenr to
/• Stop the auxiliary timer and d' return event = timeout. The procedures sraruimer and srop_timer tum lhe umer
void stop_ack._timer(void); ,sable the aclUimeout event. •/
on and off, respectively. Ti meou ts are possible only when the ttmer is runnmg. It
/• Allow the network I is explicitly permitted to call staru imer while the timer is running:_such a call
void ayer to cause a tw0
enable_network..Jayer(void)· ne r1Llayeueady event. •/ simply resets the clock to cause the next timeout after a full timer rnterval has
t• Forbid the netw , elapsed (unless it is reset or turned off in the meanwhile ). .. .
void disable ork layer from causin . . control an aux1hary umer
-" 9lwork.Jayer(void)· g a networlLlayeueady event. *I T he procedures start_acLtimer and srop_ack_wner . ·
used to generate acknowledoements under certain condillons.
/• Macro inc is e
#define inc(k) if
Fit11rt 3-9
::~:t~~~):
. ,
~":rement k circularly. *I
- k + 1; else k = Q
the .
b
Th e procedures enab/e_nen1·orLLmer an < 15
I
more sophisticated protoco s. w ere
. . d r able JZerworLlayer are use

h . we no lonoer a~~ume
.b
,•

that the network
bl the network
,n

• · Some defi • . lay I Vv'h he data link laye r ena es


llon1 Ille loca1cd Lil lhe ~111ons needed in the
er a ways has packets to sen<l. en t . 1
·t has a packet to be
1leproroco/.h. protocols to follow. These defi ni- layer, the network layer is then perlllined to interrupt w 1en I ' .
AfALINKLAYER
THEO"
.,, /ayer_ready. When a network laYer
CHAp 3
sec. 3.3 ELEM ENTARY DATA LIN
K PROTocoLS
-
20' . _.,h
- 11en1•or11 -.. f l b t h .
being care u a ou w en It enabl
1 ert'nt -
. 1 1h1~ " h vents. 8kYlayer can prevent th e network la e~ 205
111 dica
\\'r c • e
use sue . provides for data trans . . .
~n\. av m,t 'a " he data 1in , Yer Protocol 1 (utopia) Th . m1ss1on in o .
. u~abled. it tn . .0 t-k layer, l . h ·t has no buf,er space. /* .
e commun,cation cha . ne direction only f
1·1, ner" to1· wh1c I MAX-5EQ · Sender to receiver. nnel 1s ass , rorn
1, ' · · (inclu sive) • ·
nd Ji~blrs · . .· h packers always, .tn the range O toI . f and the receiver 1s assumed to be able to process all thurned to be error 1ree
a ,n i it ",1 I . ~ h • .
from ~ump I! numbers are ·« nt protocols . t is requent y necessa Consequently, t e sender Just srts in a loop pu . e input infinitely quickl
'-1.'.jlli"nce ~ the d111ere -5EQ . f I
is o lowed by 0).
' ry
fast as it can. •/ mp1ng data out onto the line as y.
Frnme ·. SEQ i~ different or 1 circularly (i.e., MAX
wbm ~HX; ~uence 11um~r ~y menting. It has been defined as a macro
the fac to typedef enum {frame_arrival} event_type;
10 3tf\._"( .• perfonns this mere . . al path. As we .will see dlater, fi . r
-n.,, ma,·ro ,m . 'thin the cnt1c #include "protocol.h"
•,... . . u~ed in-ltne w1 re is o,, en . "t protocol processing, so e mmg simple
t,ecausr ,1 is . .. t· h
. · n"twork perfom,an affect the readability o t e code but does· void sender1 (void)
hnuUJI!= < cros does n01 d'f'
ns h~e this as ma . MAX-5EQ will have i 1erent values in dif-
~ oo Also since · · l d {
·mnm,'l' perfom1ance. . : ro it becomes possible to me u e all the pro- frames;
'" r . b ' akmo it a mac . . . . f l f h . I* buffer for an outbound frame *I
ferent protocols. ) m ::_ onflict This ab1hty is use u or t e simulator. packet buffer;
b'narywrthoutc
1 . . I f I* buffer for an outbound packet •!
tocol~ in 1he sam~ Fi 3_9 are part of each of the protoco s to ollow. To
The declarations of_ g. venient reference, they have been extracted and while (true) {
d 10 provide a con •h h trom_network_!ayer( &buffer); I* go get something to send.,
saw ~ce an lly they should be merged wit t e protocols them-
in a special header s.info = buffer; I* copy it into s for transmission ..1
listed together. ~ut con~p~a done by putting the definitions
I l' S In C thrs mergmg is .. f h C to_physicaUayer( &s); I* send it on its way */
se ' . . · // and using the #include facihty o t e preprocessor
file. 111 this case protoco . 1. I* Tomorrow, and tomorrow and tomorrow
to include them in the protocol files. Creeps in this petty pace from day to day
To the last syllable of recorded time.
- Mac0eth, V, v *I
33.1 An Unrestricted Simplex Protocol

As an initial example we will consider a protocol that is as simple as it can be.


void receiver1 (void)
Data are transmitted in one direction only. Both the transmitting and receiving {
network. layers are always ready. Processing time can be ignored. Infinite buffer framer;
space is a\'ailable. And best of all, the communication channel between the data evenLtype event; /• filled in by wait, but nor used here • '
hnk la~ers never damages or loses frames. This thoroughly unrealistic protocol.
which " e will nickname "utopia,'' is shown in Fig. 3-10. while (true) {
The prot~ ol consists of two distinct procedures, a sender and a receiver. The waiUor_event(&event); /• only possibility is frame_arrival ..,
d th
seo er runs ui e data link layer of the source machine, and the receiver kruns 111I from_physicaUayer(&r) ; I* go get the inbound frame .. ,
the data lmk laver 0 f th d st· · No sequence numbers or ac now• •· to_networlLlayer(&r.info) ; /* pass the data to the network layer ·•/
· e e MAXmatron<" machine.
edgemems are u~ed her • }
ble •~ ,.
· 1rame .,·a/ .
(, e, so
th . _,£Q rs not needed. The only event type possi- }
...nrrr l'
Th . . · ·: e amval of an undamaged frame) . 1· as
e i.ender ,~man rnfm·t 1 h·1 .
fast ns it can Th bod · . e w I e loop JUst pumping data out onto the ine ac ket Figure 3-10. An unrestri, te-d simpk\ protocol.
fr0 m the 'always · obi' e .Yot the Joo P consists .
· ol• three actions: h
go fetc a P
' ariable l . and ~ i~~gJ
nd netwo~k layer, construct an outbound frame using the
arriv es. and the procedure wait_jor. _e vent returns.. wi,·th event s'et to ji-ame_arrival
b, tlu~ PTotocol becau ~e on its way. Only the info field of the frame is used 1
(W~ich is ignored anyway). The call co from_phvsicaU aver removes ihe newthy
and there are no.error~~; t; e other fields have to do with error and flow control <llli ved frame from the hardware buffer and puts it· ·m lie I vana ble r· where. ke
The receiver i~equal! ow control restrictions here
onh po ·• h Ys11nple 1 · · . ·
· SSJoi ty being the arr· 1 • nHJaJly. It waits for something to happen.
1hc: rece ·
la IVer Code can get at it. Finall y. the Jata poni~n
back wall
b/ 'l
· ·. assed on to the ne11,1, or
tor t e nex
frame effecuvely
'
iva of an d t· '1n1c Yer, and the data link layer settles to
un amaged frame. Eventually, 1he r,
suspending itself until the frame arrives.
- n1E DA
TA LINK LA YER CHAp_
3 s EC. :U ELEMENTA RY DATA
LI NK PROTOCOLS
2o6 W81't protocol 207
·111plcX Stop
.snd· " protocol 2 (stop-and-wa it) also provide
J \J A S• . use d . / . 1or a one d.
•~ . t'c restriction
t unrea 1is i . d
fi . I
m protocol
I : the b"
. sender to receiver. Th e communica tion schan . - irectional flow of d
·11 ~ ......p the mos ocess incoming ata m imte y quick lya (i,. free , as in protoc~I 1. However, this time , the~el ,s_once again assume~ta from
we w1 k layer to pr I f . fi .
.. g data )ink ayer o an m mite arnou or
uiv
Now .. networ · capacity and a finite processing speed, so the e~i1ver has only a finite b::re error
. f tht recc-1v1ne-0 . the rece1v1n h· t h . nt of
11y o I• the presence in all . coming frames w , e t ey are waitin g th . the sender from flood ing the receiver with d _P loco, must explicitly
atd faster than I
eqm valent )· ·n which to store . in. channel is .
sll·11 assume d to be error f e1r . prevent
, can be handled •/
buffer spscc L The cornrnunica11on ree typedef e.~um {fram~_am val} evenUype;
·~ uve tumsl. ·
!(, pee_ and the data traffic is· still simplex deal
.
with here
.
1s how to prevent the send
#include protocol.h
howe,er. e have to . er
The main problem_w 'th data faster than the latter is able to process them
..--m flooding the receiver w1 . s a time !:l.t to execute from_ph ysical_Ja ver plu . void sender2(void)
f,v . h ce1ver require {
In essence. 1f t e re t transmit at an average rate Iess than one .
frarn s frames;
the
ro.JlerworkJayer. · sender ·cwemus assume that no automatJc . b f" .
u ,ermg and queueing
e packet buffer;
f* buffer for an outbound frame *f
per time M Moreover. 1. , hardware the sender must never transmit a new evenUype event;
I* buffer for an outbound packet •!
/• frame_arnval is the only poss1b1hty •/
are done wi'thin the receiver h· been s fetched by ' Jrom_phys1. l l
ca _ ayer, Iest the new one
frame unul the old one as while (true) {
,erwrite the. old one.. t d trom_networlLlayer( &buffer);
01 circumstances (e.g., sync hronous transm1ss1o · · n and a I• go get something to send •/
ln certliln restnc e . . . . s.info = buffer:
. . da - k la)'er fully dedicated to processmg the one mput hne), 11 might I* copy it into s for transm,ss,on *I
receiving ta 1lD to_physicaUayer( &s) ; I* bye-bye little frame •/
a d~lay into protoco I I to slow II. down
. •
be possible for the sender to simply msert
waiUor_event( &event); /• do not proceed until given the go ahead •/
sufficiently 10 keep from swamping the receiver. Howev~r, more usuall y, each
}
dalll hnk layer will have several lines to attend to, and the time tnterv al between a }
frame aniving and its being processed may vary considerabl y. If the network
designers can calculate the worst-case behavior of the receiver, they can program void receiver2(void)
the sender 10 transmit so slowly that even if every frame suffers the maximum {
delay, there will be no overruns. The trouble with this approach is that it is too framer, s; I* buffers fo r frames •,
conservative. It leads to a bandwidth utilization that is far below the optimum, evenUype event; /• frame_arriva l is the only possibility *'
unless th.e best and worst cases are almost the same (i.e., the variation in the data while (true) {
link layer's reaction time is small). waiUor_event( &event) ; I* only possibility is frame_arnval •
A more general solution to this dilemma is to have the receiver provide feed- from_physicaLlayer( &r) ; I* go get the inbound frame • I
back to the sender. After having passed a packet to its network layer. the receiver to_network_la ye r( &r.info); I* pass the data to the network layer •
sends_8 _little dummy frame back to the sender which, in effect, gives the sender to_physica Uayer( &s) ; I* send a dummy frame to awaken sender •/
}
permission to transmit the next frame. After having sent a frame, the sender is )
required by the protocol to bide its time until the little dummy (i.e., acknow!edge-
:nt) frame arrives. Using feedback from the receiver to let the sender know Figure 3-11. A simplex scop-and-waic protocol.
~ may seod m~e data is an example of the flow control mentioned earlier.
tocols m which the se de
edgement befo . n r sends one frame and then waits for an ac kn Owl- se nd s another frame, theri the recei ver sends another one. dlld ,o on. A half-
e~ample of a ~:: ~eeding are . called stop-and-wait . Figure 3-11 gives an duplex physical channel would suffice here.
Altbougb d p . stop-and·wa11 protocol. As in protocol I, the sender starts out by fetching a packet from r.he network
al.a traffic Ill this e I . .
the recei ver. frames d . xamp e 1s simplex, going only from the sen der to layer, using it to construct a frame and sendin° it on ib wa:,. But now, unlike 10
lion channel between tho travel Ill both directions. Consequently the communica· protocol I, the sender must wai t ~nt il an ackn~w ledgement frame arri ves before
·., . loop·
liuormai1on transfer Hetwodata1·ink layers needs to be capable ' . · al
of bidirecuon t~g back and fetching ·the next packet from the ~network layer. Th e sen d.ln_ccr
fi I Ih . owever thi
irs e sender !>ends a fr • s protocol entails a strict alternation f t1 Ow··
aine. then the receiver sends a frame . then the sender
° d~t_a hnk layer need not even inspec t the incoming frame . there 15 onl) one pm,i-
btltty · Th · · frame is always an acknowle dgemt'nt.
0

e tncomrng
L)NK LA YER CHAP 3
n 1EDATA . .. . . . 5EC. 3.3 ELEM ENTARY DATA LI NK
·eccn'cr2 1s th at after deli vcrin " . PROTocoLs
• 1•I and I t' t, "
,os
~ . t,d weeO 2 . nds an a, cknow ledgement
recc11·c
h rame . back to 4 The du pli·cate f rame also arrives at th d . 209
t,ffcr<•nc~ r,eirer ~e . Because only t e arrival of th e • . . e ata li nk la
Th. ,,n h ' k h ver. r . op agai n. . and is un wittingly passed to the netwo k yer on B perfectly
I
' 11;cne1w11r · '. · the wait 1o ' . contents, the receiver need not Plll a fi le to B, part of the fil e wi ll be dupJi~at ~~r th ere. If A is sending
p:J,k<' t 1,1 bef<,re entenng . ,portant. not its
the ,,·nder h sender i, in . made by B will be incorrect and thee 1.e., th e copy of the fi le
' k at I e . . . IL
frJ111e b,tr . f rn1auon in detec ted ). In other wo rds, the protocol willerror
fail will not have been
1111' particular ,n () N . y Channel
. . I . Protocol for a ois. Clearl y. what is needed is some way for the rece· b
. g fo r the fi rst time from a retra tver.to e abl e tO d'1Slingu1sh
. .
,u
·..
A SirnP ex . . of a communication channel that
I s1tuat10n H a ra f , me that it is seein
nsm1ss1on The 0 b ·
.1der the norma ·damage d or lost complete1y. . owever. we chi eve thi s is to have the sender put a ,equence nu b . · v1ous way
I 11, con~ • h r to. ane it se nds. The n the receiver• can check the sequence m er inbthe header
f of .eac h
Now et · Frame'·' maY Wt 11 detect this fra1
· be e1ld ·e transit,
. the receiver hardware
. . . . f .
frame 10 see 1f 11 1s a new rame or _a duplicate to be discarded.
num er o each amvi
no0
makes erro~.f f me is damage in f 111e is damaged m such a way that the
that , a r,i If the ra · 1 Since a small frame header 1s desirable the questio . . Wh .
;L,~ume· c0 mputes. the checksum.t an un 1I.kely occurrence, this protoco (and all . needed fo r the seq uence· number~ nThe anses. at 1s. the
I 11 •,nimum number of bits b. .
w,en . e,·ertheless correc_· . orrect packet to the network layer). m . . · on Iy [famf 1gmty in
h ·k<um is n . deliver an me Id k thl·s protocol 1s between a frame, m, and lls direct , ucces,or m -'- .
c e, · •01, 1 can fail (1.e.. •ation of protocol 2 wou wor : addi ng . . · • . 1 rame m 1s
()ther p[()t(X . . I em that a van . Id I lost or damaged, the receiver will not acknowledg_e it. so the sender will keep try-
. ._ 1fir<I
1 ~lance it mig it se f me but the recei ver wou on Y send an
. · ·The sender could seod a ra c.orrectly received . If a damaged frame ing 10 send ti. Once 1t has been correctly recei ved. the recei ver will send an
a umer. ·rI the data were acknowledgement to the sender. ft 1s here that the potential trouble crops up.
. knowledgement .frame- would be d.1scarded · After a while the sender
ac d -would
h time
1
anived at the receiver. 1 . Th.. ocess would be repeate unt1 1 t e frame Depending upon whether the acknowledgement frame gets back 10 the sender
ClUI and ·
·end the frame again. is pr correctly or not, the sender may try to send m or m + I.
'
finall y ani"ed intact. fl · it Think about the problem and try to The event that triggers the sender to start sending frame m + 2 is the arrival of
The above scheme has a fata 1 aw id0 _ . f rther an acknowledgement fo r frame m + I . But this implies that m has been correctly
• ht go wrong before rea mg u · .
disco,·er what mig . mber that it is the task of the data lmk layer received. aoo furthermore that its acknow ledgement has also been correctly
T0 hat m1oht go wrong. reme k received by the sender (otherwise. the sender would not have begun with m + 1.
seetowprovide . " error- free, Iran sparent communication between networ. · layer
processes , k machine A gives a series of packets to its data let alone m + 2). As a consequence, the only ambiguity is between a frame and its
rocesses. The net11, or 1ayer 011 . . d 1· d immediate predecessor or successor. not between the predecessor and successor
plink layer whJCh · must ensure that an identical senes of packets . are he 1vere tok themsel ves.
the netwo~k layer on machi ne B by its data link layer. In particular,_t e networ
m
layer on B ha.~ no way of knowing that a packet has been lost d_uphcated , so the A I-bit sequence number (0 or l ) is therefo re sufficient. At each instant of
time, the receiver expects a particular sequence number next. Any arri ving frame
data link layer must guarantee that no combination of transm1ss1on errors , how-
ever unlikely. can cause a duplicate packet to be deli vered to a network layer. containin g the wrong sequence nu mber is rejec ted as a duplicate. When a frame
Consider the following scenario: containing the correct sequence nu mber arri ves. it is accepted and passed to the
network layer. Then the expec ted sequence number 1s incremented modulo 2
I. The network layer on A gives packet I to its data link laye r. The (i.e ., 0 becomes I and I becomes 0).
packet is correctly received at B and passed to the network layer on An example of thi s kind of protocol is shown in Fig. 3-12. Protocols in which
8. B ,end~ an acknowledgement frame back to A. the sender waits for a positive acknowledgeme nt before advan~ing to the n~xt
data item are often called PAR (Positive Acknowledgement with Retransmis-
2. The ackn0\1ledgement frame gets lost completely . It j ust never
sion) or ARQ (Automatic Repeat reQuest ). Like protocol 2. this one also
arri,e, :it all. Life would be a great deal simpler if the channel man-
transmits data onl y in one di rec tion. .
gk<l and lost only data frames and not control frames. but sad to say.
the channel is not very di ,criminating. Protocol 3 differs fro m its predecessors in that both sender and receiver_have a
variable whose value is remembered while the data link layer is in the wait state.
The data link !aver on A II • · · · ·d The sender remembers the sequence number of the next frame to se nd m
.~n .i,·kno,1ledge . · •eventua y lime~ out. Not hav rn g rece1,c..
1o,1()r damaged ment
and .,n d.
(incorrectl y) a~s umes
. . that its data fram
. e I\"' nexr-Jra,11e _ro_send · the recei ver remembe rs the sequence number of_th e next
~ n s the frame contarnrng packet I agam. fram e expected in/rome_expecred
• .· . Each prutOL0. I h·a,. a , hort initiahzauon phase
before enteri ng the infinite loop.
.A UNK LA YER Cl-!Ap Ff.F:. \II ENT AR'/ f>AT.\ I I\K
THEDA 1 s£C 3 1 · PRfJTr,..- ri1 ,;
210 . 211
flow over an unrel iable chan nel • / A he r cran<;m11 t1 ng a fra me the ,ender ,r.i r- rhe '•me· ru
d1rect1onal data , d\ runni ng. 1t wd I be re,et to Jllo'-" mnrher f nnrng If rr wa.\ 11-
must be 1 tor protocol 3 • / 11 11
• protocol 3 lpa rl 811ows unr I• rea -
~hould be c ho<;en to aII ow enou 2 h rime fo he {lmer f
rnrerv::it n.._ , , ic: l1mt n-
MAX. SEO 1 ksurTLerr. timeout) evenUype ,
te r\,d 1 - r r ramc ro •et 1 .__
- ihe rece1\<er to proce,'i 1t m the ""ON a,;e d - o t,,c ;ecene,.
lld6fine
typedef enum
(frame arrival. c
•- tor b k ~ 1n t1,r •~ «:icnow r...1
_ me ro propagate ac 10 the ,ender (J nl·, ,11he rh- ""'tt:DC:ll
tmeiude •protocol.h tra
_ r ~aie to a, , ume I hat ell her the rran\mllted f.., men dt 111ne irner,al ~ e-,,~ '•~--•
vood sen<!er3(VOld)
,, I '" •>r 11, JCknow ed
'-oen los t. and to send a duplicate If the ti meout nt _ eeniem :-i;i,
1• seq number of next outgoing frame •! l"- . e. .11 ., -.er •.oo hort the
\ seq_nr next.JrameJo_send; /• scratch variable • / nder will 1ransm11 unneces;sary frame , While 'he,;e •
,e i:~rra rame, lii1 II no; rtfect
1n1me s /• buffer for an outbound packet • / rhe correctne <;s of the protoco l. they will huri pertnrmance
pecl(el blJlfer: Afte r tran smitting a frame and , tanm11 rhe tuner ·he -- "-·
evenuype event: . . - -..c , iuc. w 1111, for some -
/• initialize outbound sequence numbers •/ ihing exc_,ting to happen . Only th ree po, .,,b,hue, ::~•~t .m iJCkno-.~ement
ne,ct.JrameJo_send = O; /• fetch first packet • / frame arn \'e , und amaged . a damaged Jck.nowleJi1ement t.,..,m_ ..," -
0
trom...netwo111Jayer(&buffer): . . - ·-•-- -~;en Ln. o; tne
timer expires: If a vali d ack.now ledgemen1 come, m. •tie .ender tetc!'l;;, the r~ ,
wftite(true) ( /• construct a frame for transmission •/
s.info =buffer. packet from 11s network la yer and put, 11 m the riutfor n en\r.nn~ nc prCYiOO-,
s.seq = next.Jrame_to_send;
/• insert sequence number in frame •/
/• send it on its way • /
packet. It also advances the ,equence number If a damaged irame ~ \ e, or
00
to_physicl!Uayer(&s):
starU imer(s.seq); /• if answer takes too long, time out • / frame at aJI arri ves. neither the bu ffer nor the -equen~ nurnl:ler ., cb.mreJ 11W '°
/• frame _arrival, cksum_err, timeout •I a dupl icate can be sent. -
wa1U or_8Y8111(&event):
=
It tewnt frame_anival) ( When a va lid frame arri ve~ at the rece,.,,er. us -.equence numoer s ~;ic:c,_aJ to
trorn4'hysica1Jayer(&s); I• get the acknowledgement • / see if it is a dupli cate . If not. 1t I!, accep1ed. pa., -.ec 10 the net ,on. !Jyer. .ind &11
If (s.ack = nexUrame_to_send) { acknow ledgement is generated. Duphcates and damaged trame, .ITe O{.; ~-ed ;0
stop_timer(s.ack); I• turn the timer off •/
the network layer.
from _network..layer(&buffer) ; I• get the nex1 one to send • /
lnc(next_frameJo_send); /• invert nexLframe_to_send • /

) 3.4 SLIDING WINDOW PROTOCOLS


)

\'Old recerver3(void) In the pre viou!, pro tocol,. da1a lrame, \\.ere tr:ubnurtc.-<l n one ~rre~uon onl\
(
In mo~t prac1ical ~itua11on~. there •~ a neeJ tor 1ran,m1mn" JJl:.I n bolh Jm:.:llon,
&eQ...nr trame_expected;
trame r, s; One way of achieving fu ll-duple\ data tran:,nm :,1on 1~ to :l.Jve l\\ o -..:p.intt: L0ffi-
evenLtype 81111!lt munication channels anJ u~e each one tor ,1mple\ L!J!J uJttlL 11n J11terCJ1t duee-
trame..sXl)eCled = 0. tions). If this i:, done. v,e have tV. Ll --cp.irJtt' pn"11:al ~ircu1h . .::11.n ,,ch J ·tor-
wtlilettrueJI ' ward " chan ne l ( for data / anJ J " re\eN: · ..:hannel ,,r J1.~nu"' lcJgemcnt, 1 In
w1t1..1oc even1(&eveot)· both case" the bandw idth oi the re\ er,c , hJnnd " .ilmo, 1 enurel\ \\.1.,tell. In
=
ff (event lrame..amv'a1) I I • possibilities: frame _arrival , cksum_err •/ effect, rhc u.1,er i~ paying for t\\L1..:rrcu1h but u, ing ,,nl\ the ~JflJdt\ ,,t , Hi..:
I• a valid frame has arrived . • /
trom..J)hysicafJa~&r).
A be-Her idea i, to u~e 1he ,a me, irL" uH r,,r J.ira 111 bt_,rh Ju't'\:Uon, \ ttcr all. in
~ (r.seq =a:: fr1me_e~) { /• go get the newly arrived frame •/
I• this Is what we have been waiting tor •/ Protocol._ 2 and 3 11 wa!> alre,llh beinl! u~eJ to tran:,m11 trJme, b.>Lh V.J}:., .i.ml tbe
i~ ~ laver(&r.info); rev en.._. c. h~inncl ha., the , ame L-' ap.1u l\~ J., tht' tL•m JIJ ' h.urn c•I In th,~ model the
·~ ~ -8Xl)eote(j); /• pass the data to the network layer •/
/• next lime expect the other sequence nr ' da1a 1·rarne~ trom· A to B are 111rerm1,L·J 1, 1th rht' Ju,, mrn Ic•Ju =-c·mcnl trnml!.'> trum A
~ad( "' 1 - frll'Tle -8-P6ct8d· to 8 B . J 1 • min " tr.ime the rece1vc:r
1* tell Which frame is being acked •/ • ) 101.1!-. m g al the /..111d l1t'ld 1n tht' hcJ er L' Jll IIH.:ll =- •
~Yllci1Jayer(&1); ,
) 1 can tell \\ ht"tht•r !ht' irunw ,, JJl.l t> r Jd lh1\' k J ~cmenl
* senc1 acknowledgement•/ • ' l1l rhc: ,amc ClfCU II I\ J nr
I Al rh,iugh mterlt',t\ in )! d.1rJ JnJ , unrr. 11 11.1111c,
in1p - ~ ~ct JOlllh<!r 1mprovemen
Ylp n-3, 12 A ro,t'111e111 m er ha\l n" r,1l1 ,t'p.tratc' ph) , ll'J 1 .:ir~ui 1.. - d parare
. ~ 1ove acluowledgcnien1 . . ,, po:,;~iblt-, \\' ht"n u Jt11u~lra111t' JITI\L' ' · 111,teJJ or imm.:Jiarc:l y ,<!n mg J , .:
Wllh re1rans1111:.s10n pro1U<.·ul.
TH E DATA LI NK LA YER
Cll,\ 1, SLI DI NG WINDOW PR
1 5f,C. J.4 OTOCOLS
, . . itself and waits until the network I· ··
21.. . restrains - . ayer . 213
, the receiver
cknow Ie
dgement ,s attac hed to the out go ing d· .. r ,l\1e1
ft. I k at<1 f
Although these protocol ,; give the data I k
. _, in layer m f
1I frJnii.:, in whi ch Jt may senu an d receive frames h ore reedom about th
, 1,nu1 ket The a header) . In e eel, t 1e ac nowledge r<1riie er h . we ave d ti . e ord-
ext pnc . . th frame . n1en1 irern ent that t e pro tocol mu,t deli ver p k. e in1tely not dro d
,, the n , k field ,n e . d ta frame . The techmque of temporaril gets' req u ac ets to the d . . ppe the
1u~1ng che a~he next outpJ1ng athat they can be hooked onto the nex~ delaying . the same orde r th ey were pa~'>ed to the dat 1· k e\t1nat1on network I
free nde on wledgemints so . outgoin, ,n d h . a in layer h ayer
outi!oing ackno as piggybackmg. . . . . , No r have we ., change
. . t e requ irement
. that th e phys1cal
.· coon t e .sendino . c mach·me.
" wire- li ke . th at is. it mu, t deliver all frame, ·1 th mmunication channel i·s
- f-
data ,..,.. . me is known ·
d antage o - fusing piggybackrng
. over having . di stinct ackno111
, •
The seq ue nce nu mbers within the '>e nder·
n e order s
ent.
The principal a v . . of the available channel bandwidth. The k _ · 'i wrndow repre f
is a better m,e . . . . ac held bee n sent or ca n be sent b~t are as _yet not acknowledged. W~ent rame~ that have
,ctgement frames ly a few bits, whereas a sepat ate trame would
r der costs on ., need arri ves from th e network_layer. It J', given the next hiohest' ene ver a new packet
in the frame hea d ent and a checksum . In add1tton , fewer frani a
knowle gem · " es \ent the upper edge of th e winuo w 1, ad\anced hv ~. . equence number, and
11eader, the ac . al" interrupts. and perhaps 1ewer buffers in the re .· . - one vv hen .in a k I
"frame arnv . ce1ver Comes in , the .
lowe r edge I \ auvanced by one I h.
. • n t 1s way th
c now edgement
·d .
means fewer ·h ceiver's software is orgamzed . In the nex t protocol · ously maintains a I 1st of unackno¼ ledaed frame, F e wm ow co ntrnu-
d . 00 bow t e re . . to be
depen mg . b k field costs only I bit m the frame header. It rarely "' . igu re 3-13 ,how, an example.
examined. the piggy ac cos11
more than a few bits. . . . . . Sender
.ooybacking introduces a comphcat10n not pt.esent w1th sep·irat
.11)<,
·(~)'
0

6_0 _1 s_r-;
However. Plec- . ' 1 0
"nts How long should the data hnk layer wa it for a packet ont
acknowIedge m" · ? . . . . o
which to piggyback the acknowledgement. If_the data hnk _!aye, wa11s longer I i
than the sender's timeout period, the frame will be retr~nsm1tted, defeating the
whole purpose of having acknowledgements. If the data hnk layer were an oracle
and could foretell the future, it would know when the next network layer packet
5

4
,

3
2 "
:J ~
4 3
I
2
/~ 2
.l
J 2
was going to come in and could decide either lo wait for it or send a separate ac-
knowledgement immediately, depending on how lo ng the projected wait 11·a1 Receiver
going to be. Of course, the data hnk layer cannot foretell the future, so it mu,1 7 0 0

·(~y
I

reson to some ad hoc scheme. such as waiting a fixed number of mi ll iseconds. II


a new packet arri ves quickly, the acknowledge ment is piggybacked onto it ; other- 6/(TX1 __,
<-\ 6-~1
wise. _if no new packet has arrived by the end of this time period, the data lin~
layer Just sends a separate acknowledgement frame .
5

4
2 5~ x- 2 5
..____/ x_J 2
The next three protocols are bidirectional protocols that belonc,.O to a clasi 3 4 3
called sliding · d . .
ffj
. wm ow protocols. The three differ among themselves rn terms of (a) (b ) (C) (d}
e c1ency, comple ·1 db .
all lid. . xi Y, an uffer requirements as discu ssed later. In these. as 111
s mg wmdow p t I ' br
rani:rin fro ro oco s, each outbound frame contains a seq uence num e· Figure 3- 13. A slid ing winJu"' of , 1ze I "',th J 3-bir ,cquence number.
"~.g m O up to some · · 2" I so the (a) Ini ti a ll y. (b) Afte r the fiN fr:ime has been ,ent. .:1 -\ tier the 11N fr.1JT1e ha,
segue.nee numbe fi · ~axllllum. The maximum is usuall y - . .
protocol uses ~ ts ex~tly 10 an n-bit field . The stop-and-wait sliding w1nd011 bee n recei ved . ( J } After rhe fiN Jckncl\\ kdgement hJ, bet·n recmed.
· ' n - 1• restn · his·
ticated versions · ct~ng the sequence numbers to O and 1, but more sop
Tb can use arbitrary d Since frames curren tl y within the :,e nder·s ¼indo"" may ultimately be lo:,t or
. d e es_sence of all slidin . n. . . . 1e, the b~~:ged in transit. the sende r must keep al l these fr~e~ _in its memory for possi-
seo er maintains a g Wmdow protocols 1s that at any mstant of on ·
led to set of sequ .11 1.5 pernut· b transmission . Thu s. if the ma.\ imum wrndo'-" size ,~ n. the sender needs n
send. These fr · ence numbers corresponding to fram es .
the rece· amesare 'd s mdaf1l, .1uffers to hold the un acknO\\ led oeJ fr::ime ~. If the ,,indo"" ever grows to its max·
it is sv~r also maintain ' s sai_ to fall within the sending window· 1. .,1,n~' mum
llellltitted a recetvi · h t o11r, . size,
· t h e sendin P- data link=- l:ner mu~r torciblj
• · shut Oft· I1ie ne rwork layer
1101 hav h . to accept Th
ct e · e send •
ng wmdow
·
corresponding to t e se 1, 11
, · 1d 0 \
,,J unti l ano h . ;:;,
t er buffer becomes lree.
. .
. .
protocols th same lower and er .s window and the receiver s Wll ,un11 The rec · · . . \\111dow
· , , ds to the trames tt may
a e1v111g data lml-- layers LOrrespon
cou~ of . ey are ftXed in . upper limits or even have the same size. 1n r tli! ccept A . . . d.. . ·ded without comment.
• f
t11ne 45 Stze b 1 · · k 01'( Wh · ny tra me fa lling outs ide th.:- "111dow i~ iscai . .d .
rames arc ' u IIl others they can grow or shrtn en a frame whose se4uence ~
number ,~ .
.:-qua! to the Iower edoe0
of the wm ow
sent and received.
LINK LAYER
THE DATA sec. 3.4 SLIDING WI NDOW PROT
OCOLS
n acknowledgement is gene.
14 k layer. a rated 215
2 d to the netwo~ h sender' s window, the receiver ' s . .
. · assl.! Unlike t e · . • f · Win. . col 4 (sl iding window) is bidirectional. */
~Proto
i~ received. it is_~•rotated b~ ?ne:. Note that a_window s1~e o I means that the
d the window '·. . tits ininal sIZ~- d r but tor larger w indows thi s is not 1
an mains a s 10 or e , d ,o d8 fine MAX_SEQ I* must b
downlwnr re I accepts frame. 'ed data in the proper or er, regardles, f. # d f enum {fram e_a rrival , cksum_err, timeout} e 110r protocol 4 */
. . Iayer on Y.n contrast, is· always 1' •• o type e h" evenLtype·,
data hnk #include "protoco I:
rk layer. I . e . d .. '
'd protocol4 (void)
Toe ne1wo r10k layer,s window s1z .le Wll. h a maximum w111 ow . st ze of I . l ni ti·,11
' y VOi
the data
F ure 3· 13 . shows .an examp the lower
and upper edges ot the sender ' s wind ·
. ow { nr nexUrame_to_send ;
ig are outstanding. so . ation progresses as show n . seq_ t d
no frames . oes 00 , the situ
seq_nr frame_expec e ;
I* 0 or 1 only *I
ual but as time g I* 0 or 1 only */
are eq · tocol framer, s;
I* scratch variables */
B·t Sliding Window Pro packet buffer;
WA~• . . . . . evenLtype event; I* current packet being sent *I
. 1he general case, let us first exam111e a shdmg w111dow. proto. nexUrame_to_send = O;
Before tackling . . f Such a protocol uses stop-and-wan since
. window size o I . d b t· frame_expected = O; I* next frame on the outbound stream •/
col with a maximum d waits for its acknowle gement e ore sending from_networlLlayer( &buffer); I* frame expected next •/
the sender transmits a frame an
=
s.info buffer; I*
1
fetch a packet from the network layer •/
. sueh a protocol . Like the others, it starts ou t .by defi
. ning s.seq = nexLframe_to_send ; * prepare to send the initial frame •/
. one.
the next 3 14 depicts 1
·
Figure·ables 1 end tell s which frame the sender Is try ing to s.ack = 1 - frame_expected ; * insert sequence number into frame •/
Nett-frame_ OJ · · • /• piggybacked ack *I
send. van
some ·
· frame_expec
Similarl·y. ted tells . . . frame the receiver 1s expecting. In
. . which to_physicaUayer( &s) ;
I• transmit the frame •/
bo1h .. 0 and I are the only poss1b1h11es. . . starUimer(s.seq) ;
/• start the timer running •/
ca.~es. norma1 mcum
Under • stances , one of the two data hnk layers
. goes fr rst and while ftrue) {
· the fi1rst frame. t11 other words· only one. of the data lmk layer
transmits . program
.. ! waiLfor_event( &event);
if (event== frame_arrival) { I* frame_arrivaJ. cksum_err, or timeout •/
should contain the to_physicaU ayer and start_t1111er pr~c~dure call s outside the I* a frame has arrived undamaged. •/
main loop. In the event that both data link layers start oft _s1multaneously :. a pecu- from_physicaUayer(&r) ; I• go get it •/
liar situation arises. as discussed later. The starting machme fetches the ti rst pac- if (r.seq ==frame_expected) {
/• handle inbound frame stream. •/
ket from its network layer, builds a frame from it, and sends it. When this {or to_network_layer(&r.info); /• pass packet to network layer •/
any) frame arrives, the receiving data link layer checks to see if it is a dupl icate, inc(frame_expected); I* invert seq number expected next •!
just as in protocol 3. If the frame is the one expected , it is passed to the network
layer and the recei ver's window is slid up. .
if (r.ack ==
nexLframe~to_send) { /• handle outbound frame stream. •!
The acknowledgement field contains the number of the last frame rece ived stop_timer(r.ack) ; /• turn the timer off *I
without error. If this number agrees with the sequence number of the frame the from_networlclayer(&buffer); /• fetch new pkt from network layer•/
sender is trying to send, the sender knows it is done wi th the fram e stored 111 inc(next_frame_to_send); /• invert sender' s sequence number •/
ln,ffer and can fetch the next packet from its network layer. If the sequence
numbe~ disagrees. it must continue trying to send the same fram e. Whenever a }
frame is received, a frame is also sent back. s.info = butter; /• construct outbound frame •/
.
Now let us examine p t 1 4
scenanos . . Assum h· ro oco
. .. . .
· see how resi lient 1t 1s to pat 0
to
h logical
B
=
s.seq next_frame_to_send; /• insert sequence number into it •/
and that 8. .1 . e t at computer A is trying lo send its frame O to computer s.ack = 1 - frame_expected; seq number of last received frame •/
, ..
~ trving to send 1 -ts f · to B to_physicaUayer( &s); /• transmit a frame •/
~
but A' ·s t'inieout•.interval i~ a r .I r.une Oto A. Suppose
that A se nds a trame e·1t··
starLtimer(s.seq); I* start the timer running •/
edly. ,ending a ~erie f .·d Ht e 100 short. Consequently, A m ay time out rep ' }
' o , en1tcat fra . II . I }
When the ti r,t ,. 1.d f mes. a With seq = 0 and ack = . d
a I ramc · . I ·111
frmne_n 1>eu,.,c1 will be arnves at computer B, it will be acceptet ' ,J
bee·uu,e n·" now expe • ~et . to I · Al l tiie sub sequent frame s w I·11 be i·eJ~cte Figu re 3-14. A I-bi t slid ing window protocol.
Cling tra . · . ore.
me~ With sequence number I . not 0. Furibenn
A L(NK LA YER CHl\p_ l
rHE DA T
d 8 is still waiting for an ack now i 5EC. J.4 SLID ING WINDOW PROTOCOLS
216 have ack "' I ant_ m it s network layer. edge. 217
JicateS • acket ro · . n these situ ation, the long round-trip time c h .
11 thC dur · ~ tch a new P . •n B sends A a tram e co ntaining , false . I f th b· d . . . an ave rmpona t .
qn,·e a_ ficien cy o 1· .
B ,·ill not e I' ate conics t .
nrnt ol O. , ' ·ectcd dup JC hese arrives correct Iy at A ' causing .· Wq ::: [) f rt he e f . e an width utili zation . A•, an ex.a mple c n.dim p 1-cat1on5
,1 to be ,· o ellite chann e l wJth a 500-m5ec round- trip propagatio n de!~ on51 er a :i0-kbp5
, Aller c,·e1j rt;J tunllY• one oft b' tio11 of lost frames or premature ti111 gin sat _ to use protoco l 4 to ,e nd I 000-bJt frames via th
0 En:n N com
anJ a,·l ~ . ·t packet. o d ina .h
Jicate packets to e1t er network laye r, toeou1, 1ry1ng . Y-_ Let U5 imagrne
!llling tht ncx sk . starts send111 g the fi1r~t fram e. At t = 20 m,;e, the \alellite At 1 _ 0 th
110 deli ver up . ip sen de r - - " e
f
rame
·
has b
- e
st the protoeo . _ · ly sent. Not until t = 270 msec ha<; the fra me fully
can cau.<e deadlock- . . s if p1ete . 520 d een com-
l;et or w . ·tuatwn anse. both sides sunultane ou sly send .1 . . ot until t = msec ha<, the acknov.,led .
gement arnvarnve at
d b k the receiver
apac • . a pei:uhar s1_ . difficulty is illustrate d b y F.1g. 3-15 . In , n in1 . an d n . e ac at the \ende ,
Howe1er. ch 1za11on part ( r the best of circumsta, n ce5 ( no v., altmg
.. .
m the receive d
. k I This syn ron I is shown. In (b) the pec u ianty
1· . . . a),
is illustrat d
d
un e .
ent frame ). Thi » mean <. that the <,ender - r an a ~ hon acknowlr,
ual P3' e . . f the protoco edgem wa, blocked d
unng :, 00/520 or 96-
1
· . h . ~
al 0 perauon o b f re sendino one o its own, t e sequence is e. .
ihc norm . first frame e o "' . ·1· A d B . pe rc ent of the ttm e. In other . .word ,. on ly -+ percent of the ava·ilahl e ban dw1 <l t h was
If B waits for As I
d every
f I accepted. However. I
·s an s1_multaneous"'h· sed. Clearly. the co mb111at1 on of a long tran<;it time. high bandwidth d h
rame
chown in (a). an . th . first frame s cross. an d the d ata · 1111
· k Iayers then ' u . d' .
- get frame length 1s 1sastrous 111 terms o f e ffi1c1ency.
. . an s ort
iniuaie commu 01·canon• elf·h frame arrival brmgs ·
a new pac k et "1or the network The problem desc nbed above can be viewed as a con~equence of the rule
inio situation (b). In (ali) eat\ In (b} half of the frames contain duplicates even
........ are no dup ca e . . . . . requiring a sender to wait for an ack nowledge ment before sending another frame
layer: u~~ •ssion errors. Similar s1tuat1ons '
h can occur as a result of If we relax that restn ~t1on. muc h better effi ciency can be ach1eved. Basicallv. the
thoug there. are no rransm1.when one side clearly starts f irst. ' In f act, ..
1f multiple solution lies in allow111g the sender to transmit up to 1~ frame<; before bl~kirn1:.
ture umeouts. even .
prema . cur
premature umeouts oc • frames mav• be sent three or more times. instead of just I. With an appropriate choice of 1-\ the ,ender -,., ll be able to

:;L
1 co;.
tinuously transmit frames fo r a time equal to the ro und-tnp transit time without
Asenos (0. 1. AO)---- A sends (0 , 1, AO)? ; B sends (0, 1, BO)
--._ B gets (0, 1. AOr B gets (0 , 1, AO)"
filling up the. window. In the ex ample above. ~v ~hould be at least 26. The <,ender
B sends (0. O. BO) B sends (0, 0, BO) begins sending frame O as before. By the time it ha~ fini<,hed sending 26 frame~.
Agets (0. 0. BO)" --------- A gets (0 , 1, BO)'
at t =520, the acknowle dge ment fo r frame O will have just armed. Thereafter.
Asends(1 , 0, A 1 ) - - B gets (l, O, Alr A sends (0 , 0, AO) acknowle dgements arrive every 20 msec. so the sender aJv.,a:,,'i gets perrmsswn
to
- - B sends (1 . 1, B1 l 0 continue just when it needs it. At all times. 25 or 26 unackno-,.,led2ed frames
Agets (1 . 1. B1)" : ; !~sdi (·t o~~t) are
outstanding. Put in other terms, the sender' s maximum window ,1z; i!> 26.
Asends (O, l A2)- - - B gets (0, 1, A2r ~ ;!~~~ 0
i1~l~1~
The need for a large window on the sending side occurs whene\er the product
Agets (O. o, • - - B sends (0, 0, B2)
Asends (1 . 821
B gets (1, 0, A1)'
0
A3) B sends (1, 1, 81 ) of bandwidth x round-l!ip -delay is large If the bandwidth I\ high. e\en
for a
- - - - Bgets(1 , 0, A3)" A gets (1 , 0, B1)" moderate delay, the sender will exhaust its v. indow quick.1 unk,~ it ha, a
Bsends(1, 1, B3) 1 large
A sends (1, 1, A 1 ) ~ B gets (1. 1,A1 ) window. If the delay is high (e.g .. on a geostatJ onary , atellne channel 1. the ,ender
B sends (0, 1, 82) will exhaust its window even for a moderate bandv. idth. The produ.:t of the,e
t\\O
fa~t?rs basically tell s what th e capac ity of the pipe i,. and the sender need<,
the
abiltty ~o fill it without stopp ing in order to operate at peak effic1enc)
(2) Time
(b) This technique is kn own as pipelining . If the ,·hannel c:.1pac1t~ b h b1h/,ec.
r~ure 3-15, 1'11 .. \(' t ll.lr f th e frame size I bits. and
1 the round-trip propagation ume R ,ec. the nme required
•N Thl' 11 ,, "' or protocol 4. (al Norm al case. (bJ Abnormal
1 11 to transmit a single frame is lib ~c'C . .-\ fter the la:-t bit L'f J J:.ita frame ha~
""""rl.1,,,l'r : /'n ' ' '·s:y, ark. packet number). An asteri sk indicates where a been
. ,tp 1' a PJ,ket. sent, there is a delay of R I?. be fo re that bit an-i, e:- at the recmer and another
14.2 A Pr t delay of at least R 12 for the ackn owkd\!e men1 to come bad.. tor •1 total Jel.i:
of
o ocol Using Go Back N R. In st op-and-w ait the line is bu~y for ///, :i.nJ idk for R. gt\ ing
l.':,1 i1 ~\)\\ \\ . line utili ,a tion = / 11/
re JU , ., ' ha I e n . d -r hR)
, ir," I ,r J 'r· la e the ta ·
le,,, . 4m, ro arn 1 ,
l. 11 •;1 en assumption that the transmi.ss ion · 1iine
. lf I< bR , t he efficienc - pt' rl·t' nt. s ·· there i, .1!11J1:. 3
~,•-~•"Ill t,, ' at the rece · . f · 1he ac · y ,, ill be" le:s:, th.111 :,Ll llll l · .·
l"Jne b:ick i . . iver plus the transmiss ion time nonzero d I
or
. this assumptio- n 1·5 clean1·, . . e ay for the acknO\\ leJgelllc' ll l to ~m ip.ig:i.tt' t, ,lL·k· pipel 1111 no can. in
e. sornet11nes
~ neghg1bJ
1 .
Pnnc1pl b .• · ."' .
s
111
e. e used to keep the line - hth\ dunn . h
g t 1' inten a.l · bu t 11 the 111 tef\-J is
all • the a ctct·111onal
· co mplexity is not \\O. ri h th..: 11·L'U t,I t.•
• •s
.h
n 1E PI\
TA LINK LA YER

l'rth"'"~ ff\\ ,hat happens if . eeding fram es will a rri ve at the . darn.
F,~. " . he-fS of ~ucc . ~ . .
,i1r.- ,-.<11C'.S- ., u r~r oun1 • that anything ,s wrong .
- -~ (\! I<'-' ' .an <'vcn finds out
Wh
C
HAr 1
liuble coimnunic~ti o n c ha nne l rai ses so me .
. nll'-~ orer an unre a frame in lhe middle of a lo ng stream is ,eri.

rece1,
en a c..l arn aged f , er
1 should be discarded , but w hat sho Irun1e
sf.C - J.4

kJ1
c~w~
.
10
0wle g
SLID ING W INDO W PROTOCOL')

empty. E ~e ntu ally, the_ ,e nde r will time out and


i,cgin d ed frame~ m o rde r, starting with the damaged
-d h •r h
te a Jo t o f b a ndw1 t I t e error rate 1, high
n Fig. 3- 16( a) we see go b ac k n for the case in which the
or lost one Th
·
219
ret r.in, mn all unac-
1s approach

.
~,v ...., ..rn.,.r . obvious y . . ? R b
r Frame s O a nd I a re correctly received and k recei ve r " window
u d th . 1arge. ac Mw ledged F
i,r<,,rr "" rrceivr r, 11 f ~s following 11. emem e r tha t the re . e 15 r is damaged or lost. The ,ender unaware of th
31 tilt' _ rrect rarn k . ceiv n weve , · . · · rame 2.
8!Tl"'5 ,th all the co h d packets IO the networ 1aye r in sequen 1 g hond fame s until lhe time r fo r fr ame 2 expire<; Then . 1b·c; problem k· · continue., to
,-er d,1 \\ I ted to an W . ce. In se r J over with . 1t.. sen d .m g 2 . 3 . 4 . etc ' 1
ac > up to frame 1 d
JT'l."t'J ,. ,·er 1~ ob 1g~ _ ·pelining on error recove ry . e w ll] now all o ver again ~ an
~rn 1;11~ 1a. the efteclS ol pt exam. startS ale other
;.tt> "''(' !'OC genera l s tra tegy f o r handling errors~ when f . _
t:·
' t~ C'm e detail.
Th Wh . . rame, are pipe li ned '"
,nr11in ' -j called selective repe~t - e n It is used. _a bad frame that i, received ,.., d1,;card d

\\l\t\~D\\L!l\~~\Z}ft
ood frames recei ved afte r 1t are bu tfered . When the "·nd e
out g . . "' er times out. only·
est unacknowledged frame 1s retransmitted. If that frame
the Old . . am ves correctly.
the receiver can . deliver to . the ne twork _layer. in s;equence all the frames; it ha<;
buffered. Selective repea t 1s o ften combmed with having the receiver s,end a neo.
ative acknowledgement (NAK ) when it detects an error fo r ex.ample. when r;-
11
1;J')j ' 0 0 0 0 0 0 [a] 0 [iJ
ceives a checksum error or a frame out of sequence. ~AK., ,ti mu late retran\mi,;-
sion before the corresponding timer expi res and thus improve performance.
In fig . 3-16(b), frames O and L are again correctl y received and acknowledeed
Erro( Frames discarded by data link layer
and frame 2 is los!. When frame 3 arrives at the recei ver. the data link ]aver th~re
Time--- notices that is has missed a fr ame. so it sends back a '.'iAK fo r : but buf~er; 3.
When frames 4 and 5 arrive, the y, too. are buffered by the data mk layer m,tead
(a)
of being passed to the network layer. Eventually. the ~ .\K 2 gets back to the
sender, which immediately resend s frame 2. When that arm e~. the Jata li nk !aver
now has 2, 3, 4, and 5 and can pass a ll of them to the network layer in the corr'ect

~\~!~ •~~~ '~'~ w


#;~™:/;<~:'*,W:X~:*~i
3 4

... - ~ ~,~ -~
li:'if./'xi;<&3/-}!)X/:{ ~
5 order. It can also acknowledge all frames up to and including 5. as ... hown m the
figure. If the NAK should get lo st, e ve ntually the sender ..... ill ume ou1 fo r frame 2

~~\'f'\~,
I~ I~ I~ / and send it (and only it) of its own accord. but that may be a qmte J. whil e later.
,~~
, 1\.: ~ ~ ~ "<'~ "<'~ In effect, the NAK speeds up the retransmission of one ..,pec1fic fnme

' / ; : ; ,· ; ; ~~ [ioJ ~~ [fiJ ~


• I , V V I
I I I I I I I I ,'\I I I I
Selective repeat correspond s to a receiver windov, larger than I .\ny frame
within the window may be acc epted and buffered until all the preceding one~ ha\ e
been passed to the network laye r. T his approach can reqmre large J.mounh of
Error Frames buttered by data link layer
data link layer memory if the wi ndow is large.
(b) . These two alternative approac hes are trade-offs between bd!ldv, 1dth and data
lmk layer buffer space . Depending on which re~ource is -,career. one or the other
J'"1prt 3-1,. Pipelining and
(a) receiver's wind . . error recovery . Effect of an error when c_an be used. Figure 3-17' shows a pipe lining protocol in whKh the recet\ mg Jata
ow size 15 1 and (b) receiver's window size is large. hnk layer only accepts frames in o rder: frames follov, ing an error are J,~carded.
Tv.-o t>as· In this protocol, for the firs t time we ha,.e droppc'J the .b-'>Umption that th e" net-
lllJICUrun ic approaches are a .I b . f work layer always has an infin ite supplv of packet:- to send. When th e ne twork
·uh...... ..g Ooe way c lied vai a le for dealing with errors in the presence 0
x'"""'"fUC1Jl [ ' a go back · c1 · d all layer has a packet it wan ts to se nd. it c;n cau:-.e J 11r.'f\l c•rL/cn er _read, event to
r«mes, send· n, is or the receiver simpl y to d1 scar .
~ eor-....._ mg no acknowled This happen. However, to enforce the fl ow cL,n trol ruk of no more th an ,WA.'C.5EQ
I~ --·""jlU!lds to a rec · . gements for the discarded fram es. . k
la~ ~ lo accept anv f e1ve Window of size 1. In other words , the data hn . unacknowledged frames outs tand ino at any time. the Jaca link layer m~~I be able
• rame except th to kee th O
the '>end . 1t ..... 1th mort work · The hbral) pro-
.
er ~ window fill h e1work p e network la yer from bo the ring · ,
e next one it must give IO t e n .11
J s up before the timer runs out , the pi peline w1
Cedurcs bl .
ena e_network_laye r and d1si1blt' ll<'f\ t1r " 1 . /. . / 1 a Jo th,~ Job.

C
r THE DATA LI NKLAYER

outstanding frames . The sender ll1


.
1
ck n) allows mu,ltrp for an ack. In addition , unlike in th e
pron,col 5 (go blmes without wartrng urned to have a new packet all th e I evious ·
•10 MAx- sea tra ~,ork layer is not kasslayeueady even w en ere 1s a Pa k · Ins1,;.
protot\115· the ne causes a networ -
the networl< tayer
t h th

I* should be 2 ' n - 1 */
. ime
CHAP. 3

iy
trans~.

c et tos,-,
.,_
SEC. 3.4

whil e (true) {
waiL fo r _eve nt(&event) ;

switc h(event) {
SLfDf NG WINDOW PROTOCOLS

case network_ layer _ready :


/k four poss·bl .

f* the network
' r ,ties: see evenLtype above •!

1
I* Accept, save , and transmit a new frame .,,1 ayer has a packet to send•/
221

trom_ network_laye r( &buffer(next _frame _t~_sendl)· 1..


~tAX-,SEO 7 . k m err timeout , network_layer_ ready} event 1
~'ine: {trame_amval. c su - ' - 1YPe, nbuffered = nbuffered + 1; /* expand the se d. r' etch new packet •!
iypede1enum • n e s Nrndow . ,
send_data ( next_ f ram e _to_send , frame_expected cutter . ..
t:tie1ude"l'ro:ocol.h , .. advance send~rs )',/ transmit the frame ~,
inc(nexL fra m e_to _se nd);
eq nr b, seq_nr c) break ; upper Ntndow edge •
tietween(seq_nr a, s -
SIBbC t)Ol. lean
{ . dl < c circularly; false otherwise . *I case frame _arrival :
•• Retumtrue rf a - )) 11 ((c < a) && (a<= b)) II ((b < c) && (c < a))) I• a data or control frame has amved •1
ff (\(a<=- b) && (b < c from _physicaU ay e r( & r);
/ • get incoming 'rame 'rom ohysicat ayer •
retum(true):
else if (r.seq == frame _expected) {
re.tum/false): I* Frames are accepted only in order. *I
to_network_laye r(&r.info); / • pass packet to netwcrl< layer~
inc(frame _expected); /• advance lower edge of receiver's wmaow *I
s:s.ncVOJd send_data(seq_nr frame_nr, seq _nr frame _expected , p acket buffer[ ])
{
• Construct and send a data frame. •/ I* Ack n implies n - 1, n - 2. etc . Check for thrs ...
frames; I* scratch variable *I while (between (ack_e xpected, r.ack, nexUrame_'.o_ser d )
I* Handle piggybacked ack. *f
s.mto = bufte~frame_nr]; I* insert packet into frame *I
nbuffered = nbuffered - 1; /• one frame fewer buffered •
s.seq = lrame_nr: f* insert sequence number into frame •/ stop_timer(ack_ e xpected); f* frame arrived ntact; stop nmer ,.
sack = (frame _expected + MA>CSEQ) % (MA)LSEQ + 1)·/* piggyback ack •/ inc(ack_expecte d); /• contract senders w ndow •
~ ~ tlayer(&sr f* transmit the fra;,,e * I }
· rame _nr ' f* start the timer running *I break;

vo:o p-:otocc'5(vo1dJ case cksum_err: break ; / • Just ignore bad frames ,.


{

5eq_nr next__frame Jo_send· case timeout: 1- troubl e; retransmit all ourstanamg frames • 1
S€(;J1r aeicexpecied· , I• MAX_SEQ > 1; used for outbound st ream· nexLframe_to_s end = ack_expected ; * start retransmitting here •
5eq_r.r l:arne _expect , d· f* oldest frame as yet unacknowledged• , • for (i = 1 ; i <= nbuff e red ; i++ ) {
frame r: e,
I• next frame expected on inbound strearn send_data(next_ frame_to_send, frame_expectea, buffer),, .. resend frame ..,
Dael.et outte~MAX 1
!'.eQ..ru nbuftered· SEQ ➔ 1]; I• scratch variable •/ inc(next_frame_ to_send); I- prepare to send the next one •
~ nr, , /• buffers for the outbound stream •/
'='t!nt t~ I• # output buffers currently in use •/
· - ,..., ev1:nt;
1* used to index into the buffer array •1
eri2b!c r etwor1,
ac~ e ~e . _ Jayf:r( J. if (nbuttere d <: MAX_SEQ )
ne~ f o. O·
fram1; 7irne
ex
10 ,.
aenrj " 0 ~: allow network_layer _ ready events •/ enable_ n e twork_ laye r() ;
else
ribvtt Pee1ea ·" o · next ack expected inbound *1
t rea " 0. ,
I• next frame going out *I d ,f ) d is a b le_ n e two rk_la ye r() ;
1
" nu mber of frame expected inboun )
/• initially no packets are buffered •/

Flgurt" J . t 7. f\ ,liJm~ w 111,k"~ promc0I u,mg go buck n.


,rt: DATA LINK LAYER CHAp
Tn~ ·3
2ll AX.-5£Q frames and not MAX-5EQ + 1 fra SEC. 3.4 SLIDI NG WINDOW PROT
ATiJllUDl of M
·"•t a 01..... • tant ev
en though there are MAX-5EQ + ct· ll'tes
1 •st n
ocou;
.
Note ~ng at any ins · MAX-SEQ. To see why thi s restriction is1 ct 223
may be OU mt,ets: 0, I, 2, . . .. ·o with MAX-SEQ= 7. te- Real
seqi,enct n~ following scenan / time
_,;-i consider the
11111•~- d frames Othrough 7.
~sen s
'I. The . ledgement for frame 7 eventually comes back
! . Apiw--
.ft...mackoo ack:now
tothe ~ · · 'th
th r eight frames, agam w1 sequence numbers
L r~ •11~ 2

3. The sender sends ano e


Pointer to next timeout
Frame being timed
omrough 7.
Ticks to go
. backed acknowledgement for frame 7 comes in.
4. Now another piggy (a)
lb)
. . .. Did all eight frames belonging to the second batch arrive sue-
-. mlKhon 1s this. · d' d ' II ·
CtAfully ordi'dall e1g
, .. ."t-"' · ht get lost (countmg 1scar s 10 owmg h an error as Jost)? Figure 3-18. Simulation of mu ltiple timers in software

In both cases ' the rece ·


,ver would be sending
. frame 7 as t · e acknowledgement ·
~ ader has no way of telling. For this reason the maximum number of out- and 10:00:01.9. Every time the hardware clock ricks, the real time is updated and
5Wlding ~s must be restricte.d to MAX~EQ. . . . the tick counter at the head of the list is decremented. When the tick counter be-
Although protocol 5 does not buffer the frames ~vmg after an error, 1t does comes zero, a timeout is caused and the node is removed from the list. as shown
ID escape the problem of buffering altogether. Smee a sender may have to in Fig. 3-l 8(b ). Although this organization requires the list to be scanned when
l'dl1mmit all the unacknowledged frames at a future time, it must hang on to all start_Jimer or stop_timer is called. it does not require much work per tick. In pro-
trammittcd frames until it knows for sure that they have been accepted by the tocol 5, both of these routines have been given a parameter. indicating which
receiver. When an acknowledgement comes in for frame n , frames n - 1, n - 2, frame is to be timed.
and so on are also automatically acknowledged. This property is especi ally im-
pMant when some of the previous acknowledgement-bearing frames were lost or 3.4.3 A Protocol Using Selective Repeat
~ - Whenever any acknowledgement comes in, the data link layer checks 1_0
see if any buffers can now be released. If buffers can be released (i.e., there 15 Protocol 5 works well if errors are rare, but if the line i~ poor. it wastes a lot
of bandwidth on retransmitted frames. An alternative scrategy for handling errors
S<llle room available in the window), a previously blocked network layer can now
be allowed to cause m k . to allow the receiver to accept and buuer
1s a th e frame s followmoO a dama. 0 fred or
0

F . ore networ -1ayerJeady events. . d fr ames merely because an ear1ier . ame


or this l)rOlocol w . · h·ch to lost one. Such a protocol does not discar
piggyback ' e assume that there 1s always reverse traffic on w 1
Protooo14 ~~wlcdgeme~ts. If there is not, no acknowledgements can be s~nt. was damaged or lost. . . ·ndo·" of acceptable
· uun not Deed this ass · since
· 1t · sends back one frame every ume
.
In this protocol, both sender and recei.ver ma.mtarn a tw1 and..orows to some
tt ·~ - a~-_
- Y Q <ICIIIIC even 'f . '--- .
umpt1on O
1 t co sequence numbers. The sender's window SJZe 5.~i:~;;, in con;ast, is always
we will sol~ the ~L • it ,ldli Just already sent that frame. In the next pro 0 1
;~f predefined maximum, MA)CSEQ. The receiver _s h· a buffer reserved for each

= ~ause Protoeot one~way traffic in an elegant way.


lunen, one per OUlstand~ultiple outstanding frames, it logically needs m~ all
• ~ ncs. All of the in~ frame. Each frame times out independently ? a
0
!ti· fixed in size and equal to MAX-5EQ. The receiver_ asd with each buffer is a bit
sequence number within its . fixe d w~n• d?w· Associate Whenever a frame . .
~ ves,
(arrived) telling whether the buffer is tu ll or empty. . to see if it falls within the
1111a1t hard se tuners . . using • · 0 between
rorni alinked "'art clock Iha can easily be simulated m software, Its sequence number is checked by the f uncuo . d it is accepted and sto red·
.st t cause · . t'Imeou15 Window. If so and if it has not already been receive! it con1ains the next pac~et
the ,i...... h , With each nnA.s interrupts periodically. The pending ntil
... ,11:r cxpi s 'oUUC of th Ii k t' cks u
. re ..the r~--
As an illUSlrati "-'
•"'ut: ~ng ti ed e st telling the number of cloc 1 uus action is taken without regard to whether
'l'L:
. or stnobe kept w1thu
• · 1 the data link
0
pie of Fig. 3-l&(a n of how the ti: • and a ~inter to the next n~de. e exaf!l• expected by the network layer. Or· cour:;,e· 1t t'lnrnall the \ower-num bere ct frames
t
1 I
ayer and not passed to the networ k layer un · the correct order. A pro oco1
lhc reai time is tci.' ~ &utnc that the: could.be implemented, consider thinitiallY• ha~e already been delivered to t~e network layer IO
.00.00.0; three ti rn lock ticks once every I 00 msec. ·00:0 t .3, using this algorithm is given in Fig. 3· 19 ·
eouts are pending, at 10:00:00.5, 1O.

You might also like