© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. © The McGraw-Hill Companies, Inc. Transport Layer Protocols – UDP and TCP Asst. Prof. Chaiporn Jaikaeo, Ph.D. Computer Engineering Department Kasetsart University, Bangkok, Thailand Adapted from the notes by Lami Kaya and lecture slides from Anan Phonphoem
2 Outline Transport Layer User Datagram Protocol (UDP) Transmission Control Protocol (TCP)
3 Application Transport Network TCP/IP protocol Suite Application Transport Network Data Link Physical Data Phy Data Phy Physical Data Link
4 Issues in Network Layer No/Little error detection No attempt to correct Retransmission Point-to-point (connectionless) No handshaking No verification No flow control
5 Transport Protocol Set of rules for exchange control message / data End-to-End Application may by-pass Transport Layer build functions on top of IP reduce overhead application run on switch/router that has no Transport Layer
6 Transport Protocols User Datagram Protocol (UDP) Transmission Control Protocol (TCP) Stream Control Transmission Protocol (SCTP) Real-Time Transport Protocol (RTP)
7 Ports and Addresses IP address is the end point of identifier source / destination On same machine (same IP) needs identifier for each application multiple applications (e.g. 3 ftp sessions) “Port” 16-bit number (65,356 ports) for each IP
8 Ports and Addresses IP address: Unique connection identifier [source IP] + [source port] + [dest. IP] + [dest. port] Web #1 [Src :3213, Dst :80] Web #2 [Src :4121, Dst :80] Ftp [Src :9785, Dst :21]
9 Ports and Addresses Known destination IP Concern Issues destination port ? listen port ? IANA * divides ports into three ranges well-known ports registered ports dynamic / private ports *IANA – The Internet Assigned Numbers Authority
10 Well-known ports 0 – 1023 Used by server applications Use with restricted privileges (root)
11 Registered Ports 1024 – 49,151 Assigned by IANA Used for server applications Allow client to make contact Can be used by ordinary users
12 Dynamic / Private ports 49,152 – 65,535 Ephemeral (temporary) ports as-needed basis freed up when done Assigned by local machines Cannot be registered with IANA
13 Connection-Oriented Transport Advantages easy to communicate (if receiver is there!) verify the real receiver agree on some protocols error correction Disadvantages heavier-weight protocol sophisticated implementation (keep state) consume high bandwidth for management TCP – Transmission Control Protocol establish connection transfer data tear down connection
14 Connectionless Transport Datagram approach Advantages rapid data transfer no connection setup no need for connection maintenances Disadvantages not reliable (losses are expected) out of order packets application more complex (takes precautions) UDP – User Datagram Protocol transfer data
15 Outline Transport Layer User Datagram Protocol (UDP) Transmission Control Protocol (TCP)
16 User Datagram Protocol (UDP) Characteristics No error detection/recovery No flow control No checking for existing of destination Simple services Very useful protocol
17 UDP Basic Functions Provides basic functions above raw IP Port addressing – to specific application Data integrity verification – checksum
18 UDP Message Format Total length = UDP header+ Payload ≤ 2 16 bytes
19 UDP Message Fragmentation UDP HeaderData IP Header Data IP Header UDP Header PayloadData Transport Layer IP Layer
20 Protocols that use UDP TFTP (trivial FTP) BOOTP (for diskless station) Network Time Protocol (NTP) need basic delivery and checksum Network File System (NFS) need low overhead Many multimedia applications need low latency losses are acceptable
21 Outline Transport Layer User Datagram Protocol (UDP) Transmission Control Protocol (TCP)
22 Transmission Control Protocol (TCP) Most popular/important in Internet Reliable transport protocol Connection-oriented need connection establishment [IP+source port] [IP+destination port] guarantee error-free / in-order delivery
23 TCP Messages (Segment)
24 Making connection Application on server passive receive mode listening by issue Listen request to socket locally Application on Client request to socket API locally with destination IP destination port (source port: if not specify, TCP assigns private port) Server Client
25 TCP Connection Establishment Application TCP stack Application Server Client Internet Passive Open Active Open Synchronize Ack and Synchronize Ack Open Req Open Ready 3-way Handshake
26 TCP Segments Segment size at source node = MTU local link fit in IP packet may be fragmented along the way IP Header PayloadData TCP HeaderData Transport Layer IP Layer
27 Data Transmission (I) Server Client Internet Send Req bytes Seq. 1 ; length 1000 Rec bytes Seq ; length 500 Push Ack 1001 Ack 1501 Application TCP stack Application Rec. 500 bytes
28 Flow Control A process of managing rate of data transmission between two devices Make sure fast sender does not overwhelm slow receiver TCP uses Windowing Flow Control I'm running out of buffer! Take this :
29 TCP Window Control Send BufferRecv. Buffer Win
30 Closing Connection (By either end) Server Client Internet Data Last Data Segment Data Fin Flag; Ack = n+2; Seq.= m + 1 Ack (Empty Data) Fin Flag ; Seq.= n + 1 Application TCP stack Application Close Close req Close Ack = m + 2 Close Resp 3-way Handshake 1 byte
31 Protocols that use TCP File Transfer Protocol (FTP) Hypertext Transfer Protocol (HTTP) Simple Mail Transfer Protocol (SMTP) Post Office Protocol (POP3) Telnet
32 Choosing between TCP and UDP TCP reliable transport services UDP non-reliable transport services only delivery data to specific port
33 Summary Transport Layer port & IP address User Datagram Protocol (UDP) packet format (8-byte header) functions Transmission Control Protocol (TCP) packet format ( 20-byte header) connection establishment / tear down window control