Transmission Control Protocol TCP Reading Chapter 24 Fall
- Slides: 16
Transmission Control Protocol (TCP) Reading: Chapter 24 Fall 2004 FSU CIS 5930 Internet Protocols 1
TCP • A reliable, byte-oriented, connection-oriented transport protocol • Requirements – – – Fall 2004 Reliable transmission of byte streams In-order delivery (to application layer) No duplicate delivery (to AL) Transport data of arbitrary length Synchronization between sender and receiver Flow control FSU CIS 5930 Internet Protocols 2
View of TCP from applications • • Connection-oriented Peer-to-peer communication Complete reliability Full-duplex communication Byte-stream interface Reliable connection startup Graceful connection shutdown Fall 2004 FSU CIS 5930 Internet Protocols 3
TCP header Source Port Destination Port Sequence Number Acknowledgement Number Length reserved Control Flags Checksum Window Size Urgent Pointer Options (optional) Data (optional) Fall 2004 FSU CIS 5930 Internet Protocols 4
struct tcphdr { struct tcphdr __u 16 source; __u 16 dest; __u 32 seq; __u 32 ack_seq; #if defined(__LITTLE_ENDIAN_BITFIELD) __u 16 res 1: 4, doff: 4, fin: 1, syn: 1, rst: 1, psh: 1, ack: 1, urg: 1, ece: 1, cwr: 1; #elif defined(__BIG_ENDIAN_BITFIELD) __u 16 doff: 4, res 1: 4, cwr: 1, ece: 1, urg: 1, ack: 1, psh: 1, rst: 1, syn: 1, fin: 1; #else #error "Adjust your <asm/byteorder. h> defines" #endif __u 16 window; __u 16 check; __u 16 urg_ptr; }; Fall 2004 FSU CIS 5930 Internet Protocols 5
Implementation of TCP send TCP Fast Path sk->data_ready tcp_data _queue tcp_data_ snd_check Slow Path Section 24. 3 tcp_rcv_ state_process tcp_rcv_ established tcp_ack_ snd_check Pure ACK tcp_send_ (delayed)_ack tcp_sendmsg Retrans. Timer tcp_send_skb tcp_write_ timer tcp_ack tcp_re transmit_skb TCP_ESTABLISHED tcp_v 4_do_rcv tcp_write_ xmit __tcp_v 4_lookup() tcp_v 4_rcv ip_input. c ip_local_deliver Fall 2004 tcp_transmit_skb ip_output. c ip_queue_xmit FSU CIS 5930 Internet Protocols 6
Handling incoming TCP segments • Ip dispatches packets based on protocol • tcp_v 4_rcv() – Some sanity check, drop packet if necessary – Looking for proper sock (tcp_v 4_lookup()) – If found, continue with tcp_v 4_do_rcv() – Else, send RESET segment (tcp_send_reset()) Fall 2004 FSU CIS 5930 Internet Protocols 7
tcp_v 4_do_rcv() • Processing segment depending on socket state (connection state) – TCP_ESTABLISHED (tcp_rcv_established()) – Other states (tcp_rcv_state_process()) • tcp_rcv_established() – To speed up segment processing • Fast path vs. Slow path Fall 2004 FSU CIS 5930 Internet Protocols 8
Fast path vs. Slow path • FP for “normal” TCP segments – A pure ACK segment – The expected packet (next packet in stream) • SP for other segments – – – Fall 2004 Unexpected TCP flags Not a packet expected (out-of-order) Both parties exchange data Window size is zero Unexpected TCP options FSU CIS 5930 Internet Protocols 9
Fast path • Some sanity check • If ACK segment – Processing with tcp_ack() – Releasing socket buffer – Checking if local data can be sent (tcp_data_snd_check()) • If data segment – If can be copied to user process, • copy payload • Update expected packet Fall 2004 FSU CIS 5930 Internet Protocols 10
Fast path (cont’d) • Otherwise (cannot copied to user process) – Inserting into sock queue – Updating expected packet • Some management processing (tcp_event_data_rcv()) • Checking if acknowledgement has to sent – Delayed ACK vs. Quick ACK Fall 2004 FSU CIS 5930 Internet Protocols 11
Slow path • Many many different processing conditions – Checking code • Some functions for handling incoming packets – tcp_ack() – tcp_event_data_recv() – tcp_data_snd_check() – tcp_rcv_state_process() Fall 2004 FSU CIS 5930 Internet Protocols 12
Sending TCP segments • tcp_sendmsg() – Copying data from user space to kernel – Checking if connection established • If not, wait_for_tcp_connect() – Checking if data can be sent • tcp_send_skb() – Sending data • __tcp_push_pending_frame() Fall 2004 FSU CIS 5930 Internet Protocols 13
tcp_send_skb() • Adding data into transmit queue – sk->write_queue • Testing if data can be sent – tcp_snd_test() • If positive, send data – tcp_transmit_skb() • Starting retransmission timer – tcp_reset_xmit_timer() Fall 2004 FSU CIS 5930 Internet Protocols 14
tcp_transmit_skb() • Some processing depending on if ACK set • Passing packet to. IP – tp->af_specific->queue_xmit() • tp_queue_xmit() • Adjusting slow-start threshold Fall 2004 FSU CIS 5930 Internet Protocols 15
tcp_push_pending_frame() • Checking if we can send data – tcp_snd_test() • Sending data – tcp_write_xmit() • Checking sending conditions (slow-start, congestion windows etc) • Fragment data if necessary • Sending data (tcp_transmit_skb()) Fall 2004 FSU CIS 5930 Internet Protocols 16
- Tcp (transmission control protocol) to protokół
- 4-way handshake
- Transmission control protocol
- While reading activities
- Rfc tcp/ip
- Arp protocol in tcp/ip
- Tcp rst rfc
- Error control in tcp
- In2140
- Tcp congestion control
- Tcp flow control
- Tcp flow control
- Tcp congestion control
- Tcp connection management finite state machine
- Tcp
- Tcp flow control diagram
- Error control in tcp