Presentation is loading. Please wait.

Presentation is loading. Please wait.

Transport Layer TCP and UDP IS250 Spring 2010

Similar presentations


Presentation on theme: "Transport Layer TCP and UDP IS250 Spring 2010"— Presentation transcript:

1 Transport Layer TCP and UDP IS250 Spring 2010 chuang@ischool.berkeley.edu

2 John Chuang2 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, … IP TCP, UDP HTTP, FTP, NNTP, SMTP, telnet,... coax, twisted pair, fiber, wireless,... Ethernet FDDI, SONET Wi-Fi

3 John Chuang3 TCP/IP Model Appl Trans port Net work Link Net work Link Net work Link Appl Trans port Net work Link Host AHost BRouter 1Router 2 end-to-end point-to-point end-to-end

4 John Chuang4 Transport Layer  Functions 1.Addressing (ports) 2.Data integrity (error detection) 3.Reliable data transport 4.Flow control 5.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)

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

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

7 John Chuang7 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 layer MSS = MTU - IP header length - TCP header length Maximum Segment Size Maximum Transmission Unit 20 bytes without Options

8 John Chuang8 Transport Layer Functions 1.Addressing (ports) 2.Data integrity (error detection) 3.Reliable data transport 4.Flow control 5.Congestion control

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

10 John Chuang10 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.32.226.87; port 21 128.2.14.60; port 50001 128.32.226.87; port 80 128.2.14.60; port 50002 ftp client http client ftp server http server Note: IP cannot distinguish ftp packets from http packets (they have the same source and destination IP addresses)

11 John Chuang11 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)

12 John Chuang12 Transport Layer Functions 1.Addressing (ports) 2.Data integrity (error detection) 3.Reliable data transport 4.Flow control 5.Congestion control

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

14 John Chuang14 Transport Layer Functions 1.Addressing (ports) 2.Data integrity (error detection) 3.Reliable data transport 4.Flow control 5.Congestion control

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

16 John Chuang16 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

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

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

19 John Chuang19 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”

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

21 John Chuang21 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

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

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

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

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


Download ppt "Transport Layer TCP and UDP IS250 Spring 2010"

Similar presentations


Ads by Google