1 / 25

Transport Layer TCP and UDP

Transport Layer TCP and UDP. IS250 Spring 2010 chuang@ischool.berkeley.edu. HTTP, FTP, NNTP, SMTP,. telnet,. TCP, UDP. IP. Wi-Fi. Ethernet. FDDI, SONET. coax, twisted pair, fiber,. wireless,. Network Layers. Application (layer 7): specific to application need

Download Presentation

Transport Layer TCP and UDP

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. Transport LayerTCP and UDP IS250 Spring 2010 chuang@ischool.berkeley.edu

  2. HTTP, FTP, NNTP, SMTP, telnet, ... TCP, UDP IP Wi-Fi Ethernet FDDI, SONET coax, twisted pair, fiber, wireless, ... Network Layers • Application (layer 7): specific to application need • Transport (layer 4): end-to-end delivery, congestion and flow control • Network (layer 3):addressing, routing • Data Link (layer 2): framing, error detection • Physical (layer 1): bits (0/1), voltages, frequencies, wires, pins, … John Chuang

  3. end-to-end Appl Appl end-to-end Trans port Trans port point-to-point Net work Net work Net work Net work point-to-point Link Link Link Link Host A Router 1 Router 2 Host B TCP/IP Model John Chuang

  4. Transport Layer • Functions • Addressing (ports) • Data integrity (error detection) • Reliable data transport • Flow control • Congestion control • Protocols • Transmission Control Protocol (TCP) • Reliable data transport (1, 2, 3, 4, and 5) • User Datagram Protocol (UDP) • Unreliable data transport (1 and 2 only) John Chuang

  5. TCP Segment Format Bit 0 Bit 31 Source Port # (16) Destination Port # (16) • Like the IPv4 header, TCP header is also 20 bytes long without options Sequence Number (32 bits) Acknowledgement Number (32 bits) Hdr Len (4) Reserved (6) Flags (6) Window Size (16) Data Header TCP Checksum (16) Urgent Pointer (16) Options (if any) PAD Data (variable length) John Chuang

  6. UDP Datagram Format 0 16 31 • UDP is considered light-weight : • low overhead; no connection setup • used for real-time applications (don’t need retransmission) Source Port Number (16) Destination Port Number (16) UDP Header Message Length (16) UDP Checksum (16) Data John Chuang

  7. TCP Maximum Segment Size • Note that TCP segment header does not include segment size field • Instead, Sequence Number field is used to identify location of segment in the TCP byte stream (more on SEQ later) • Sender constructs segments so that they do not need to be fragmented at the network layerMSS = MTU - IP header length - TCP header length 20 bytes without Options 20 bytes without Options Maximum Segment Size Maximum Transmission Unit John Chuang

  8. Transport Layer Functions • Addressing (ports) • Data integrity (error detection) • Reliable data transport • Flow control • Congestion control John Chuang

  9. Bit 0 Bit 31 Source Port # (16) Destination Port # (16) Sequence Number (32 bits) Acknowledgement Number (32 bits) TCP Header Hdr Len (4) Reserved (6) Flags (6) Window Size (16) TCP Checksum (16) Urgent Pointer (16) Options (if any) PAD L4 Addressing • TCP/UDP ports identify processes on a host 0 16 31 UDP Header Source Port Number (16) Destination Port Number (16) Message Length (16) UDP Checksum (16) John Chuang

  10. Ports • Multiple processes can run on a single host • all processes share a single IP address • each process talks/listens via a different port 128.2.14.60; port 50001 128.32.226.87; port 21 ftp client ftp server http client http server 128.2.14.60; port 50002 128.32.226.87; port 80 Note: IP cannot distinguish ftp packets from http packets (they have the same source and destination IP addresses) John Chuang

  11. Ports • The port numbers are divided into three ranges: • Well known ports (0-1023) • Registered ports (1024-49151) • Dynamic and/or private ports (49152 – 65535) • Some “well known ports” • ftp (21); ssh (22); telnet (23); smtp (25); finger (79); http (80) • Assigned by Internet Assigned Numbers Authority (http://www.iana.org/numbers.html) John Chuang

  12. Transport Layer Functions • Addressing (ports) • Data integrity (error detection) • Reliable data transport • Flow control • Congestion control John Chuang

  13. Data Integrity • TCP/UDP checksums cover entire segment/datagram Bit 0 Bit 31 Source Port # (16) Destination Port # (16) Sequence Number (32 bits) Acknowledgement Number (32 bits) TCP Header Hdr Len (4) Reserved (6) Flags (6) Window Size (16) TCP Checksum (16) Urgent Pointer (16) Options (if any) PAD 0 16 31 UDP Header Source Port Number (16) Destination Port Number (16) Message Length (16) UDP Checksum (16) John Chuang

  14. Transport Layer Functions • Addressing (ports) • Data integrity (error detection) • Reliable data transport • Flow control • Congestion control John Chuang

  15. Reliable Data Transport • Connection (or Session) Management • Agreement on start and end of connection/session • Error Control • Data delivered without deletions, insertions, duplications, reordering John Chuang

  16. Connection Management • TCP establishes a session with ordered and bi-directional reliable delivery of bytes • Establishment: • Informs receiving port of connection • Initializes packet sequence number (to a random number) • Sets congestion and flow control state • Teardown: • By either peer • Frees state and resources John Chuang

  17. A TCP Session Process A Process B SYN SYN + ACK 3-Way handshake to establish TCP session ACK Data Can be merged into one Data + ACK Data + ACK Conversation Data + ACK FIN FIN + ACK Teardown ACK John Chuang time

  18. TCP Header Flags • Flags: URG, ACK, PSH, RST, SYN, FIN Bit 0 Bit 31 Source Port # (16) Destination Port # (16) Sequence Number (32 bits) Acknowledgement Number (32 bits) Hdr Len (4) Reserved (6) Flags (6) Window Size (16) TCP Checksum (16) Urgent Pointer (16) Options (if any) PAD John Chuang

  19. Error Control • Original data stream: “I am here” • Can data be deleted? “I here” • Can data be reordered? “here I am” • Can data be duplicated? “I am am here” • Can non-data be inserted? “I am not here” John Chuang

  20. Reliable Delivery • Positive Acknowledgment with retransmission • Sequence and acknowledgement numbers 0 16 31 Source Port Number (16) Destination Port Number (16) Sequence Number (32) Acknowledgement Number (32) TCP Header Hdr Len (4) Reserved (6) Flags (6) Window Size (16) TCP Checksum (16) Urgent Pointer (16) Options (if any) Padding Data John Chuang

  21. Reliable Delivery • Each packet has a sequence number (SEQ) • SEQ represents byte offset with respect to initial SEQ • Duplicate packets can be detected and discarded • Out of order packets can be re-ordered • Each packet carries acknowledgment of received packet • ACK = sequence number of next byte expected by the receiver • Lost packet can be detected by missing ACK • Lost packet can be retransmitted after a timeout period John Chuang

  22. A TCP Session Process A Process B SYN (Seq=x) SYN (Seq=y; Ack=x+1) 3-Way handshake to establish TCP session Data (Seq=x+1; Ack=y+1) Data (Seq=y+1; Ack=x+2) Data (Seq=x+2; Ack=y+2) Conversation Data (Seq=y+2; Ack=x+3) FIN (Seq=x+3; Ack=y+3) FIN (Seq=y+3; Ack=x+4) Teardown ACK (Ack=y+4) • Notes: • Processes pick random initial values for x and y • SEQ incremented by one for illustrative purposes only (in practice, SEQ incremented by MSS) time John Chuang

  23. ACK and Packet Retransmission Process A Process B Data (Seq=x+1) Data (Seq=y+1; Ack=x+2) Data (Seq=x+2; Ack=y+2) IP loses packet Timeout Data (Seq=x+2; Ack=y+2) TCP resends packet ACK (Ack=x+3) John Chuang time

  24. ACK and Packet Retransmission Process A Process B Data (Seq=x+1) Data (Ack=x+2) Data (Seq=x+2) IP loses ACK Data (Ack=x+3) Timeout TCP resends packet TCP resends ACK; drops duplicate Data (Seq=x+2) ACK (Ack=x+3) John Chuang time

  25. Adaptive Retransmission (Timeout) • Round trip time (RTT): elapsed time between sending of a TCP segment and the receipt of the corresponding ACK EstRTT = (a*EstRTT) + ((1- a)*SampleRTT) Timeout = b * EstRTT • In the original spec, suggested values for a and b are 0.9 and 2. In Jacobson/Karels algorithm, timeout is set adaptively to avoid spurious retransmissions John Chuang

More Related