1 / 76

Chapter 4 Transport Layer

Chapter 4 Transport Layer. Note. This presentation is not in the order of the book or online curriculum. This presentation also contains information beyond the curriculum. Transport Layer Overview. Transport Layer. TCP UDP.

Télécharger la présentation

Chapter 4 Transport Layer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4Transport Layer

  2. Note • This presentation is not in the order of the book or online curriculum. • This presentation also contains information beyond the curriculum.

  3. Transport Layer Overview

  4. Transport Layer TCP UDP • The Layer 4 data stream is a logical connection between the endpoints of a network, and provides transport services from a host to a destination. • This service is sometimes referred to as end-to-end service. • The transport layer also provides two protocols • TCP – Transmission Control Protocol • UDP – User Datagram Protocol

  5. TCP Header UDP Header or Application Header + data

  6. UDP TCP/UDP TCP/UDP TCP

  7. Reminder of encapsulation/decapsulation Data Link Trailer Data Link Header IP Header TCP Header HTTP Header Data Data Link Trailer Data Link Trailer Data Link Header Data Link Header IP Packet IP Packet Data Link Trailer Data Link Trailer Data Link Header Data Link Header IP Packet IP Packet Data Link Trailer Data Link Trailer Data Link Header Data Link Header IP Packet IP Packet Data Link Trailer Data Link Header IP Header TCP Header HTTP Header Data

  8. Focus on Transport Layer TCP TCP

  9. Transport Layer • The Transport layer provides for the segmentation of data and the control necessary to reassemble segments. • Primary responsibilities: • Tracking the individual communication between applications on the source and destination hosts • Segmenting data • Managing each segment • Reassembling the segments into streams of application data • Identifying the different applications

  10. segment segment Transport Layer • Protocols: • TCP • UDP • Transport layer referred to as a segment • IP is a best-effort delivery service • No guarantees • Best-effort service • “Unreliable service” • TCP/UDP is responsible for extending IP’s delivery service between two end systems to a delivery service between two process running on the end systems. • Known as transport layer multiplexing and demultiplexing.

  11. TCP vs. UDP • UDP provides: • Unreliable delivery • No error checking • No flow control • No congestion control • No ordered delivery • (No connectionestablishment) • Applications • DNS (usually) • SMTP • RTP (Real-Time Protocol) • VoIP • TCP provides: • Reliable delivery • Error checking • Flow control • Congestion control • Ordered delivery • (Connection establishment) • Applications: • HTTP • FTP • Telnet • MSN messenger

  12. HTTP HTTP SMTP FTP Cabrillo Web Server TCP TCP TCP ISP’s Email and FTP Server TCP TCP • A single client may have multiple transport connections with multiple servers. • Notice that TCP is a connection-oriented service (two-way arrow) between the hosts, whereas UDP is a connectionless service (one-way arrow) . (later) UDP TCP UDP

  13. Port Numbers: TCP and UDP

  14. UDP Header TCP Header • Both TCP and UDP use ports (or sockets) numbers to pass information to the upper layers. HTTP is Port 80

  15. Application Header + data Port numbers are used to know which application the receiving host should send the “Data”. Application Header + data Port numbers are used to know which application the receiving host should send the “Data”.

  16. http://www.iana.org/assignments/port-numbers • The Internet Assigned Numbers Authority (IANA) assigns port numbers.

  17. Well Known Ports (Numbers 0 to 1023) • Reserved for common services and applications. • HTTP (web server) POP3/SMTP (e-mail server) and Telnet. • Client: TCP destination port • Client applications can be programmed to request a connection to that specific port and its associated service.

  18. Registered Ports (Numbers 1024 to 49151) • Assigned to user processes or applications. • Primarily individual applications that a user has chosen to install rather than common applications that would receive a Well Known Port. • When not used for a server resource, these ports may also be used dynamically selected by a client as its source port.

  19. Dynamic or Private Ports (Numbers 49152 to 65535) • Also known as Ephemeral Ports • Usually assigned dynamically to client applications when initiating a connection. • Client: TCP source port • It is not very common for a client to connect to a service using a Dynamic or Private destination port (although some peer-to-peer file sharing programs do). • May also include the range of Registered Ports (Numbers 1024 to 49151)

  20. Client Server Telnet

  21. Client TCP Header 1028 23 Data for Telnet Client Server • Client sends TCP segment with: • Destination Port: 23 (Well known port number) • Source Port: 1028 (Dynamic Port assigned by client)

  22. Server TCP Header 23 1028 Data for Telnet Client Server • Server responds with TCP segment with: • Destination Port: 1028 (Dynamic Port assigned by client) • Source Port: 23 (Well known port number)

  23. Client Server Notice the difference in how source and destination port numbers are used with clients and servers: Client (initiating Telnet service): • Destination Port = 23 (telnet) • Source Port = 1028 (dynamically assigned) Server (responding to Telnet service): • Destination Port = 1028 (source port of client) • Source Port = 23 (telnet)

  24. 49888 49890 • Same client to same server - Two different HTTP sessions • Client: Same destination port • Client: Different source ports to uniquely identify this web session.

  25. 49888 49890 C:\Users\rigrazia>netstat -n Active Connections Proto Local Address Foreign Address State TCP 192.168.1.101:49888 198.133.219.25:80 TIME_WAIT TCP 192.168.1.101:49890 198.133.219.25:80 TIME_WAIT C:\Users\rigrazia> Destination Port Connection State Source Port TCP or UDP Source IP Destination IP

  26. 192.168.1.101 Destination Port Source Port 198.133.219.25 49888 80 49890 80 80 172.16.5.5 Source Port www.cisco.com What makes each connection unique? • Connection defined by the pair of numbers: • Source IP address, Source port • Destination IP address, Destination port • Different connections can use the same destination port on server host as long as the source ports or source IPs are different. 49888

  27. TCP or UDP Source IP Destination IP Connection State Source Port Destination Port • Note: When downloading a web document and its objects it is common that there will be several TCP sessions created. netstat –n www.google.com www.cisco.com

  28. Connectionless Transport: UDP

  29. UDP • No frills, barebones transport protocol. • Destination and Source Ports • Length and Checksum (used for error checking) • RFC 768 • Connectionless transport • No “handshaking” (no connection establishment) as with TCP (coming) • Unreliable delivery • No error checking • No flow control • No congestion control • No ordered delivery

  30. UDP • source port -- the number of the calling port • destination port -- the number of the called port • UDP length -- the length of the UDP header • checksum -- the calculated checksum of the header and data fields • data -- upper-layer protocol data

  31. UDP Why would an application developer choose UDP rather than TCP? • Finer application-layer control • TCP will continue to resend segments that are not acknowledged. • Applications that use UDP can tolerate some data loss: • Streaming video • VoIP (Voice over IP) • Application decides whether or not to resend entire file: TFTP

  32. UDP Client Server UDP segment Time UDP segment UDP segment UDP segment • No connection establishment • TCP uses a three-way handshake to establish a connection (coming) • UDP does not – it just blasts away the data to the sender. • No delay to establish connection.

  33. UDP Client Server UDP segment Time UDP segment UDP segment UDP segment • No connection state • UDP does not maintain connection state as does TCP (coming) • Connection state is used for reliability and flow control. • Server can support more active clients when not maintaining state information • Small packet header overhead • TCP header has 20 bytes of overhead. • UDP header has only 8 bytes of overhead

  34. UDP • Note: Multimedia Applications and UDP • There is an issue (controversy) with multimedia applications over UDP. • UDP offers no congestion control (as we will see with TCP) • Congestion control is needed to prevent the network from entering and staying in a congested state. • If all applications were using UDP, because of congestion, very few UDP packets would be delivered and this would also cause TCP traffic rates to dramatically decrease. • Many applications give you a choice of TCP or UDP.

  35. UDP Checksum (FYI) Client Server UDP segment Time UDP segment UDP segment Cumulative Sum: 1100101011001010 UDP segment 1s complement: 0011010100110101 Final Checksum Total: 1111111111111111 • UDP checksum provides error detection, any changed bits or missing segments. • Simplified explanation (see RFC 1071 for more details): • Sender • UDP adds 16 bit ‘words’ keeping a cumulative sum. • Performs one's complement of the sum of all the 16-bit words in the segment. • Convert 0’s to 1’s and 1’s to 0’s • This result is put in the checksum field of the UDP segment. • Receiver • UDP adds 16 bit ‘words’ keeping a cumulative sum • Adds 1’s (ones) complement • If no errors are introduced into the segment, then the Total at the receiver will be 1111111111111111.

  36. UDP Checksum (FYI) Client Server UDP segment Time UDP segment UDP segment Cumulative Sum: 1100101011001010 UDP segment 1s complement: 0011000100110101 Final Checksum Total: 1111101111111111 What if there is an error? • UDP does nothing to recover the error. • It is up to the application layer protocol (example TFTP) to decide what to do, such as prompt the user to download/upload the entire file again.

  37. Connection-oriented Transport: TCP

  38. TCP • TCP provides reliable delivery on top of unreliable IP • TCP provides: • Reliable delivery • Error checking • Flow control • Congestion control • Ordered delivery • Connection establishment

  39. TCP • source port -- the number of the calling port • destination port -- the number of the called port • sequence number -- the number used to ensure correct sequencing of the arriving data • acknowledgment number -- the next expected TCP octet • HLEN -- the number of 32-bit words in the header • reserved -- set to 0 • code bits -- the control functions (e.g. setup and termination of a session) • window -- the number of octets that the sender is willing to accept • checksum -- the calculated checksum of the header and data fields • urgent pointer -- indicates the end of the urgent data • option -- one currently defined: maximum TCP segment size • data -- upper-layer protocol data

  40. TCP: Connection Establishment • For a connection to be established, the two end stations must synchronize on each other's TCP initial sequence numbers (ISNs). • Sequence numbers : • Track the order of packets • Ensure that no packets are lost in transmission. • The initial sequence number is the starting number used when a TCP connection is established. • Exchanging beginning sequence numbers during the connection sequence ensures that lost data can be recovered.

  41. Three-way Handshake Web Server Client SYN, SEQ=8563 SYN Received Note: ISNs do not start a 0 or 1. There are several reasons for this including segments that may still be in buffers and also security issues. (Beyond the scope of this presentation.) Step 1: • The three-way handshake happens before any data, HTTP Request (GET), is sent by the client. • A TCP clientbegins the three-way handshake by sending a segment with the SYN (Synchronize Sequence Number) control flag set, indicating an initial value in the sequence number field in the header. • The sequence number is the Initial Sequence Number (ISN), is randomly chosen and is used to begin tracking the flow of data from the client to the server for this session.

  42. Three-way Handshake Web Server Client SYN, SEQ=8563 SYN Received SYN, ACK, SEQ=1678ACK=8564 SYN, ACK Received Step 2: • The TCP server needs to acknowledge the receipt of the SYN segment. • Server sends a segment back to the client with: • ACK flag set indicating that the Acknowledgment number is significant. • The value of the acknowledgment number field is equal to the client initial sequence number plus 1. • This is called an expectational acknowledgement – the next byte this host expects to receive (more soon). • SYN flag is set with its own random ISN for the Sequence number

  43. Three-way Handshake Web Server Client SYN, SEQ=8563 SYN Received SYN, ACK, SEQ=1678 ACK=8564 SYN, ACK Received ACK, SEQ=8564 ACK=1679 ACK Received HTTP Request (GET) Step 3: • TCP client responds with a segment containing an ACK that is the response to the TCP SYN sent by the server. • The value in the acknowledgment number field contains one more than the initial sequence number received from the server. • The client can now send application data encapsulated in TCP segment. • HTTP Request (GET)

  44. Step 1: Client sends ISN, SEQ=8563 (last four digits)

  45. Step 2: Server responds with ACK=8564, own ISN, SEQ=1678

  46. Step 3: Client sends ACK=1679

  47. Client now sends HTTP Request (GET) to Web Server

  48. TCP: Connection Termination 1. When the client has no more data to send in the stream, it sends a segment with the FIN flag set. 2. The server sends an ACK to acknowledge the receipt of the FIN to terminate the session from client to server. 3. The server sends a FIN to the client, to terminate the server to client session. 4. The client responds with an ACK to acknowledge the FIN from the server.

More Related