1 / 16

Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP). Reading: Chapter 24. TCP. A reliable, byte-oriented, connection-oriented transport protocol Requirements Reliable transmission of byte streams In-order delivery (to application layer) No duplicate delivery (to AL) Transport data of arbitrary length

kimi
Download Presentation

Transmission Control Protocol (TCP)

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. Transmission Control Protocol (TCP) Reading: Chapter 24 FSU CIS 5930 Internet Protocols

  2. TCP • A reliable, byte-oriented, connection-oriented transport protocol • Requirements • 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

  3. 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 FSU CIS 5930 Internet Protocols

  4. Source Port Destination Port Sequence Number Acknowledgement Number Length reserved Control Flags Window Size Checksum Urgent Pointer Options (optional) Data (optional) TCP header FSU CIS 5930 Internet Protocols

  5. struct tcphdr struct tcphdr { __u16 source; __u16 dest; __u32 seq; __u32 ack_seq; #if defined(__LITTLE_ENDIAN_BITFIELD) __u16 res1:4, doff:4, fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1; #elif defined(__BIG_ENDIAN_BITFIELD) __u16 doff:4, res1: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 __u16 window; __u16 check; __u16 urg_ptr; }; FSU CIS 5930 Internet Protocols

  6. sk->data_ready send TCP tcp_ack_snd_check tcp_data _queue tcp_sendmsg Fast Path Retrans.Timer tcp_send_(delayed)_ack tcp_send_skb tcp_data tcp_data_snd_check Section 24.3 SlowPath tcp_write_timer PureACK tcp_rcv_state_process tcp_ack tcp_rcv_established tcp_re -transmit_skb TCP_ESTABLISHED tcp_v4_do_rcv tcp_write_xmit __tcp_v4_lookup() tcp_transmit_skb tcp_v4_rcv ip_input.c ip_output.c ip_local_deliver ip_queue_xmit Implementation of TCP FSU CIS 5930 Internet Protocols

  7. Handling incoming TCP segments • Ip dispatches packets based on protocol • tcp_v4_rcv() • Some sanity check, drop packet if necessary • Looking for proper sock (tcp_v4_lookup()) • If found, continue with tcp_v4_do_rcv() • Else, send RESET segment (tcp_send_reset()) FSU CIS 5930 Internet Protocols

  8. tcp_v4_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 FSU CIS 5930 Internet Protocols

  9. 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 • 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

  10. 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 FSU CIS 5930 Internet Protocols

  11. 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 FSU CIS 5930 Internet Protocols

  12. 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() FSU CIS 5930 Internet Protocols

  13. 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() FSU CIS 5930 Internet Protocols

  14. 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() FSU CIS 5930 Internet Protocols

  15. tcp_transmit_skb() • Some processing depending on if ACK set • Passing packet toIP • tp->af_specific->queue_xmit() • tp_queue_xmit() • Adjusting slow-start threshold FSU CIS 5930 Internet Protocols

  16. 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()) FSU CIS 5930 Internet Protocols

More Related