ST 220: Ch3-Trns Lyer Abdullh Konk School of nformtion Sciences nd Technology Penn Stte Berks Lerning Objectives. Understnd position of trns lyer in nternet model. Understnd rtionle for extence of trns lyer. Understnd concept of ppliction- -ppliction delivery. Understnd duties of trns lyer: pcketizing, ddressing, connection cretion, nd relible delivery. Dtinguh between two trns-lyer procols used in nternet: UDP nd TCP. Know which ppliction lyer progrm cn use UDP nd which cn use TCP. ST 220/Ch3: Trns Lyer 2 1
Trns Lyer Appliction--Appliction Delivery (Process--Process Delivery) Appliction: Web Trns Client Appliction: Web browser The The trns trns lyer lyer provides provides nd nd mnges mnges ppliction-ppliction ppliction-ppliction delivery delivery in in nternet. nternet. ST 220/Ch3: Trns Lyer 3 Functions of Trns Lyer Pcketizing Addressing for pplictions Creting connections Appliction--ppliction relible delivery Dmge, Loss, Order, Duplicte Terminting Connections ST 220/Ch3: Trns Lyer 4 2
Pcketizing The trns lyer divides long messge in smller ones, clled pckets. A heder dded ech pcket. Originl Messge One One of of fields fields in in heder heder 32-bit 32-bit sequence number. ST 220/Ch3: Trns Lyer 5 Connection Estblhment Three wy hndshke Client cknowledge. cknowledge. Thnk Thnk you you dude! dude! owe owe you. you. The The sequence sequence number number of of first first pcket pcket ttched. ttched. Plese Plese tke tke good good cre cre of of pckets. pckets. 1 3 request request connection. connection. Cn Cn we we synchronize synchronize dude? dude? SYN=synchronize ACK=cknowledge SYN SYN / ACK ACK 2 Oky! Oky! m m not not busy busy now now nywy. nywy. We We cn cn crete crete connection connection (synchronize). (synchronize). Plese, Plese, cknowledge cknowledge ST 220/Ch3: Trns your your request. Lyer request. 6 3
Addressing: Numbers The ddresses of client nd server progrms re clled numbers. The numbers rnge from 0 65535 nd re divided in three rnges: Well-known s: 0 1023 Regtered s: 1,024 49,151 Temporry s: 49,152 66,535 These ddresses re locl computer running progrms. The ddresses must be unique loclly but not universlly. A client uses temporry number; server uses well-known number. ST 220/Ch3: Trns Lyer 7 From Client Appliction Appliction Client s Appliction Lyer s Appliction Lyer Client 1 Client 2 HTTP Client FTP SMTP HTTP #1 #2 #3 20 21 23 25 80 Client s Trns Lyer s Trns Lyer Pcket Heder #1 23 Client Client pplictions pplictions re re ssigned ssigned rndom rndom temporry temporry numbers. numbers. A A client client ppliction ppliction uses uses sme sme number number until until it it spped. spped. pplictions pplictions use use wellknown wellknown s s Source Source Destintion Destintion ST 220/Ch3: Trns Lyer 8 4
From Appliction Client Appliction Client s Appliction Lyer s Appliction Lyer Client 1 Client 2 HTTP Client FTP SMTP HTTP #1 #2 #3 20 21 23 25 80 Client s Trns Lyer s Trns Lyer Notice Notice tht tht source source nd nd destintion destintion s s re re swpped swpped in in pcket pcket heder heder from from server server client. client. Pcket Heder 23 #1 Destintion Destintion Source Source ST 220/Ch3: Trns Lyer 9 Appliction Addresses with Numbers: How does it work? (2) (2) My My user user strted strted new new session. session. better better ssign ssign number number th th new new telnet telnet session. session. Hmm! Hmm! 1030 1030 currently currently not not used used by by ny ny or or ppliction. ppliction. (1) (1) B. B. A DP: Destintion SP: Source (5) (5) got got pcket pcket for for destintion destintion 1030. 1030. Currently, Currently, ppliction ppliction using using th th.. better better hnd hnd it it over over ppliction ppliction t t 1030. 1030. SP DP 1030 23... SP DP 23 1030... (3) (3) Hoops! Hoops! got got pcket pcket for for 23. 23. better better send send th th pcket pcket ppliction. ppliction. (4) (4) Oky. Oky. My My telnet telnet server server ppliction B ppliction hs hs processed processed request. request. t t would would be be nice nice respond respond bck. bck. ST 220/Ch3: Trns Lyer 10 5
mnt Numbers TCP 20 FTP dt trnsfer TCP 21 FTP control TCP 23 TCP 25 SMTP TCP 80 HTTP Web services TCP & UDP 53 DNS TCP & UDP 123 Network Time Procol (NTP) TCP 110 Post Office Procol version 3 (POP3) TCP 119 Network News Trns Procol (NNTP) UDP 69 TFTP UDP 161 SNMP Lern se bold ones ( first five). ST 220/Ch3: Trns Lyer 11 Relible Delivery Relible Relible Delivery Delivery Service Service Order Order Duplicte Duplicte Loss Loss Dmge Dmge Sequence Numbers Sequence Numbers Acknowledgment Retrnsmsion Checksums (Error Detection) Acknowledgment Retrnsmsion ST 220/Ch3: Trns Lyer 12 6
Acknowledgment TCP uses cknowledgement (ACK) mke sure relible delivery. The receiver cknowledge with next expected pcket number. The number of pckets sent without receiving n cknowledgment clled window size. sender receiver sender receiver Window size of 1 Window size of 3 send 1 receive 1 send 1 ACK 2 send 2 send 2 receive 2 send 3 ACK 3 ACK 4 send 3 send 4 ST 220/Ch3: Trns Lyer 13 Exmple 1: Acknowledgment with Retrnsmsion Sender Positive Acknowledgment with Retrnsmsion with window size of 3 send 1 send 2 Receiver 1 send 3 2 3 4 5 6 ACK 4 1 2 3 4 5 6 send 4 send 5 LOST! send 6 send 5 ACK 5 ACK 7 ST 220/Ch3: Trns Lyer 14 7
1 Exmple 2: Acknowledgment with Retrnsmsion Sender Positive Acknowledgment with Retrnsmsion with window size of 4 send 1 LOST! send 2 Receiver 2 3 4 5 6 1 2 3 send 4 send 1 LOST! ACK 1 4 send 2 send 3 send 4 DAMAGED! ACK 5 send 5,6,7,8 ST 220/Ch3: Trns Lyer 15 Dmge : Error Detection with Checksums (16- bit) 1. All dt strem divided in 16-bit groups. 2. For ech group, n integer vlue clculted. 3. The se number re dded ger give checksum. 4. The checksum divided by 2 16 find reminder. 5. An extr 16 bits representing reminder dded heder. 6. The receiving device performs sme clcultions, nd n it compres result with one sred 16 bits in heder. 7. f sme result obtined, messge not dmged. ST 220/Ch3: Trns Lyer 16 8
Checksums t Sender 111101010101010101010101010101010100111010101 1111010101010101 0101010101010101 0100111010101 1 62805 21845 2517 2 sum=87167 3 87167 mod 2 16 =21631 21631 =101010001111111 4 5 111101010101010101010101010101010100111010101 101010001111111 Checksum ST 220/Ch3: Trns Lyer 17 Checksums t Receiver 111101010101010101010101010101000100111010101 101010001111111 1111010101010101 0101010101010100 0100111010101 62805 21844 2517 sum=87166 87167 mod 2 16 =21630 21631 =101010001111110 Not equl checksum! The messge hs been corrupted on wy. Request retrnsmsion. ST 220/Ch3: Trns Lyer 18 9
Connection Termintion ST 220/Ch3: Trns Lyer 19 Trns Lyer Procols The The nternet Model Model Trns Lyer Lyer Procols TCP TCP (Trnsmsion procol) Connection oriented relible delivery. Connection estblhment nd termintion. Order, loss, dmge, nd duplicte control. Acknowledgment. UDP UDP (User (User Dtgrm Procol) connectionless unrelible delivery. NO connection estblhment nd termintion. NO order, loss, nd duplicte control. NO cknowledgment. Only error detection without retrnsmsion. ST 220/Ch3: Trns Lyer 20 10
TCP vs UDP Most TCP/P pplictions use TCP for trns lyer TCP provides connection (logicl ssocition) between two entities regulte flow nd check errors. UDP (User Dtgrm Procol) does not mintin connection; nd refore it does not gurntee delivery, preserve sequences, or protect ginst dupliction. However, UDP hs less overhed. ST 220/Ch3: Trns Lyer 21 UDP Heder Dt UDP Heder Source Number Pcket Pcket Length (size) (size) Destintion Number Checksum ST 220/Ch3: Trns Lyer 22 11
TCP Heder Dt TCP Heder Source Number (16 bits) Destintion Number Sequence Number (32 (32 bits) bits) Acknowledgment Number (32 (32 bits) bits) HLEN Reserved (4 bits) (6 bits) (6 bits) Window Size Size Urgent Urgent Pointer Checksum ST 220/Ch3: Trns Lyer 23 TCP nd UDP Trns Lyer Lyer Procols Applictions TCP TCP (Trnsmsion procol) UDP UDP (User (User Dtgrm Procol) FTP TELNET HTTP HTTPS SSH... Streming Video Voice Over P Rel-time online multi plyer gmes TFTP Domin Nme System (DNS) Dynmic Host Configurtion Procol (DHCP) ST 220/Ch3: Trns Lyer 24 12