Download presentation
Presentation is loading. Please wait.
1
Transmission Control Protocol (TCP)
Reading: Chapter 24 Fall 2004 FSU CIS 5930 Internet Protocols
2
FSU CIS 5930 Internet Protocols
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 Fall 2004 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 Fall 2004 FSU CIS 5930 Internet Protocols
4
TCP header Fall 2004 FSU CIS 5930 Internet Protocols Data (optional)
Options (optional) Destination Port Length Control Flags Source Port Sequence Number Acknowledgement Number reserved Window Size Checksum Urgent Pointer Fall 2004 FSU CIS 5930 Internet Protocols
5
FSU CIS 5930 Internet Protocols
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, fin:1; #else #error "Adjust your <asm/byteorder.h> defines" #endif __u16 window; __u16 check; __u16 urg_ptr; }; Fall 2004 FSU CIS 5930 Internet Protocols
6
Implementation of TCP Fall 2004 FSU CIS 5930 Internet Protocols TCP
ip_input.c ip_local_deliver ip_output.c ip_queue_xmit tcp_v4_rcv tcp_v4_do_rcv __tcp_v4_lookup() tcp_rcv_ established TCP_ESTABLISHED tcp_rcv_ state_process tcp_sendmsg tcp_send_skb tcp_transmit_skb tcp_ack_ snd_check tcp_data_ snd_check tcp_write_ xmit tcp_write_ timer tcp_re - transmit_skb tcp_send_ (delayed)_ack tcp_ack tcp_data tcp_data _queue sk->data_ready Fast Path Slow Path send Pure ACK Retrans. Timer TCP Section 24.3 Fall 2004 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()) Fall 2004 FSU CIS 5930 Internet Protocols
8
FSU CIS 5930 Internet Protocols
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 Fall 2004 FSU CIS 5930 Internet Protocols
9
FSU CIS 5930 Internet Protocols
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 Fall 2004 FSU CIS 5930 Internet Protocols
10
FSU CIS 5930 Internet Protocols
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
11
FSU CIS 5930 Internet Protocols
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
12
FSU CIS 5930 Internet Protocols
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
13
FSU CIS 5930 Internet Protocols
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
14
FSU CIS 5930 Internet Protocols
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
15
FSU CIS 5930 Internet Protocols
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 Fall 2004 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()) Fall 2004 FSU CIS 5930 Internet Protocols
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.