Faculy of rs and Science Universiy of Torono CSC 358 - Inroducion o Compuer Neworks, Winer 218 Soluions for ssignmen 2 Quesion 1 (2 Poins): Go-ack n RQ In his quesion, we review how Go-ack n RQ can be used o ensure a reliable daa ransfer. Use n = 3 for Quesion (a)-(c). Use he convenion ha when has o reransmi packes i sars wih he SN a he beginning of he window and reransmis packes in order of heir sequence number. (a) (Error in Transmission from o ) Fill in he values for SN and RN, indicae he window size, as well as he packes delivered o he nex higher layer. Window Size[,2] [1,3] [2,4] [3,5] [4,6] SN 1 2 1 2 3 4 5 3 4 5 6 RN 1 2 2 2 2 3 3 3 3 4 5 1 2 3 4 (b) (Error in Transmission from o ): Repea (a). 1
Window Size SN [,2] 1 2 [1,3] [2,4] [3,5] [5,7][6,8] 1 2 3 4 5 3 4 5 RN 1 1 2 3 3 1 2 3 3 3 5 6 6 6 3 4 5 (c) Repea (a). 2
Window Size SN [4,6] [,2] [1,3] [3,5] [5,7] [6,8] 1 2 1 2 3 1 3 4 5 3 4 5 6 7 5 3 RN 1 1 1 1 2 3 4 4 4 5 5 5 5 6 7 8 1 2 3 4 5 6 7
Quesion 2 (2 Poins): Selecive Repea RQ In his quesion, we review how Selecive Repea RQ can be used o ensure a reliable daa ransfer. Use n = 5 for Quesion (a)-(c). Use he convenion ha always acknowledges he las error-free packe from, and when has o reransmi packes i sars wih he SN a he beginning of he window and reransmis packes ha have no ye been acknowledge by in order of heir sequence number. (a) (Error in Transmission from o ) Fill in he values for SN and RN, indicae he window size a and, as well as he packes delivered o he nex higher layer. CK s in uffer Window Size [,4] [1,5] [2,6] SN 1 2 3 4 5 4 6 7 5 6 2 4 6 2 4 2 [7,1 RN 1 2 4 4 4 6 7 7 5 7 3 Window Size Packes in uffer [,4] [1,5] [2,6] 3 5 6 4 [7,11] 1 2,3,4,5,6 (b) (Error in Transmission from o ): Repea (a). CK s in uffer Window Size [,4] [1,5] SN 1 2 3 4 3 5 1 4 6 4 5 1 4 1 5 RN 1 1 2 3 3 4 5 6 Window Size Packes in uffer [,4] [1,5] [2,6] [3,7] [4,8] [5,9] [6,1] 5 6 6 5 [6,9] 1 2 3 4 5 5 4
(c) Repea (a). CK s in uffer 3 4 5 Window Size [,4] [1,5] [5,9] [6,1] [7,11] [8,12 SN 1 2 3 4 5 1 5 1 5 1 5 6 7 8 9 1 5 RN [,4] [1,5] Window Size Packes in uffer 1 3 4 4 5 5 2 2 [5,9] 2 6 6 6 7 8 9 1 [6,1] [7,11][8,12][9,13] [1,14] 2 3 4 1,2,3,4 5 5 5 5 5
Quesion 3 (2 Poins): Sop-and-Wai RQ This quesion regards Sop-and-Wai RQ. In he following, we give several varians of Sop-and-Wai RQ proocols, and we consider hem in a few differen communicaion channel models. For each combinaion of proocol and channel pairs (see proocol and channel descripions below), answer wheher he proocol works correcly for ha channel model; if no, give a couner-example. Use he following assumpions for his quesion, Packes (daa packes and CK-packes) may be corruped during ransmission; ll packes wih error are deeced; Packes ha arrive are in he same order as ransmied. lgorihm : Sender: 1. ccep a packe from he nex higher layer; if no packe is available, wai unil i is; 2. Transmi he packe; 3. If an CK is received from he receiver, go o Sep 1; if a NK is received from he receiver, go o Sep 2. Receiver: 1. Whenever an error-free packe is received, release he packe o he higher layer and send an CK o he sender; 2. Whenever a packe is received wih an error, send a NK o he sender. Noe: for his algorihm only, assume CK s and NK s are always received error-free. 6
lgorihm : Sender: 1. Se he ineger variable SN o ; 2. ccep a packe from he nex higher layer; if no packe is available, wai unil i is; assign number SN o he new packe; 3. Transmi he packe wih SN in he sequence number field; 4. If an CK is received from he receiver, incremen SN and go o Sep 2; if no acknowledgmen is received wihin T ou, go o Sep 3, where T ou is a finie amoun of ime, which is larger han he maximum round-rip ime if he maximum delay is known. Receiver: 1. Whenever an error-free packe is received, use a local variable o rack he sequence number of he received packes. If i is he firs ime ha an error-free packe wih his paricular sequence number has been received, release he packe o he higher layer, and send an CK o he sender; 2. Whenever a packe is received wih an error, simply ignore i. Communicaion Channels: We consider he following communicaion channels beween he Sender and he Receiver. Channel I The maximum delay is known, and packes and CK s never ge los during ransmissions; Channel II The maximum delay is known, and packes and CK s may be los during ransmissions; Channel III Packes can have an arbirary and variable delay, and packes and CK s never ge los during ransmissions; Soluion: lgorihm lgorihm Channel I Channel II Channel III (a) (b) 7
Noes: (a) deadlock if an CK is los: S R CK (b) deadlock if an CK is los: S T ou T ou R CK 8
Quesion 4 (1 Poins): Modulus m For Go-ack n RQ and Selecive Repea RQ we have o be careful how we apply a modulus m o he sequence number. In his quesion, we illusrae his issue. (a) Give an example where Go-ack n wih modulus m fails if m = n. Use n = 5 for your example. The simples example is for node o send packe hrough n 1. In case of delayed acknowledgmens (i.e. no reurn packes in he inerim), node goes back andreransmispacke(seefigure6). Ifheohernodehasreceivedallhepackes, i is waiing for packe n, and if he modulus m equals o n, his repea of packe is inerpreed as packe n. Window Size SN...... 1 n-2 n-1 1 RN 1 2 n-2 n-1 n Figure 1: Examples where go back n RQ fails when he modulus m is equal o n (b) Give an example where Selecive Repea wih modulus m fails if m = 2n 1. Use n = 5 for your example. CK s in uffer [,3] Window Size SN 1 2 3 RN Window Size [,3] Packes in uffer 1 2 3 4 [2,5] [4,] [1,4] [3,6] 1 2 3 Figure 2: Noe ha in he above example all CK s are los. s a resul, reransmis packe (afer a ime-ou), bu he receiver inerpres as an ou-of-order packes and sores i in he buffer. 9
Quesion 5 (1 Poins): Sop-and-Wai RQ In class, we discussed ha we can employ he RQ proocol a any layer - for example, we could implemen RQ a he ranspor layer (end-o-end RQ) or a he link layer (hopby-hop RQ). In his quesion, we sudy how he decision where we use RQ impacs he nework performance (in erms of average packe delay). Consider a Sop-and-Wai proocol beween wo peer processes X (sender) and Y (receiver) where Y sends immediaely an CK (wih he corresponding RN number) o X whenever i receives an error-free a packe from X. ssumeahoswansosendpackesoa(disan)hos. Inorderocommunicaewih hos, hos has o send is packes firs o a swich C, where packes ge forwarded o hos. llpackeshavehesamesizeofn bis. SwichC mushavereceivedhecomplee packe before i can be forwarded o (why?). During he ransmission of a packe from hos o swich C, bis are corruped independenly wih a bi error probabiliy P bi, < P bi < 1. Similar, during he ransmission of a packe from swich C o hos, bis are corruped independenly wih he same bi error probabiliy P bi. The ransmission rae of he link beween hos and swich C is R bis per second - he ransmission rae of he link beween swich C and hos is also R bis per second. For he quesions below, provide all relevan derivaions. (a) Wha is he probabiliy P packe ha a packe from hos arrives error-free a swich C? P packe = (1 P bi ) N (b) ssume ha hos and swich C implemen he above Sop-and-Wai RQ. In addiion, make he following assumpion regarding he channel beween and C: CK s from swich C always arrive error-free a and no packes or CK s are dropped. ssuming ha hos never exceeds he ime-ou (when waiing for an CK), wha is he probabiliy P k, k = 1,2,..., ha has o ransmi a packe k imes o ge i acceped a swich C? P k = (1 P packe ) k 1 P packe = [ 1 (1 P bi ) N ] k 1(1 Pbi ) N. (c) (Hop-by-Hop RQ) ssume ha swich C and hos also implemen he above Sop-and-Wai RQ o send packes from C o, and ha he same assumpion ha we made in (b) for he channel beween and C also hold for he channel beween C and. Wha is he average delay of a packe, i.e. he average lengh of he inerval beween he ime ha hos sars sending a packe for he firs ime and he ime ha hos passes he packe o he nex higher layer? Ignore queueing and processing delays, as well as ransmission delays of CK s (bu no of packes), and assume ha hos and swich C never exceed he ime-ou (waiing for a CK). Le E[T C ] be he oal delay for one hop from o C, and le k be he even ha 1
has o send he packe k imes o ge i acceped. Then we have E[T C ] = E[T k]p k k=1 = k N k=1 R P k = k N k=1 R (1 P packe) k 1 P packe = L 1 = N 1 RP packe R (1 P bi ) N Le E[T C ] be he oal delay for he hop from C o. Noe ha nd he oal delay E[T] is equal o E[T C ] = E[T C ] E[T] = E[T C ]+E[T C ] = 2 N R 1 = 2 N 1 P packe R (1 P bi ) N. (d) (End-o End RQ) Suppose ha swich C does no check packes for errors, bu forwards each packe from immediaely o hos (wihou sending an CK o hos ). However, hos and hos use he above Sop-and-Wai RQ o ensure a reliable daa ransfer. ssume ha CK s from hos always arrive error-free a hos and ha no CK s are dropped. For his case, wha is he average delay of a packe? gain, ignore queueing and processing delays, as well as ransmission delays of CK s, and assume ha hos never exceeds he imes-ou (waiing for a CK). The probabiliy P packe ha a packe from arrives error free a is given by P packe = (1 P bi ) N (1 P bi ) N = (1 P bi ) 2N. nd he oal delay E[T ] is given by E[T ] = 2N R 1 P packe = 2N R 1 (1 P bi ) 2N. (e) Evaluae he answers for (c) and (d) for P packe =.99,.1,.1. For P packe =.99 For P packe =.1 For P packe =.1 E[T] = 2.2 N R E[T] = 2 N R E[T] = 2 N R ande[t ] = 2.4 N R, and E[T ] = 2 N R, and E[T ] = 2 1 6N R, 11
(f) Using he resul of (e), in wha siuaion would you use Hop-by-Hop RQ (End-o- End RQ)? IfhebierrorprobabiliyP bi isquiehigh(suchasforawirelesschannel),henusing Hop-by-Hop RQ significanly reduces he exepced delay. If he bi error probabiliy P bi is very low (such as for an opical channel), hen using End-o-End RQ does no significanly increase exepced delay and is less expensive o implemen. 12