1 / 17

CS 498 Lecture 17 TCP Implementation in Linux

CS 498 Lecture 17 TCP Implementation in Linux. Jennifer Hou Department of Computer Science University of Illinois at Urbana-Champaign Reading: Chapter 24, The Linux Networking Architecture: Design and Implementation of Network Protocols in the Linux Kernel. Outline.

valin
Télécharger la présentation

CS 498 Lecture 17 TCP Implementation in Linux

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. CS 498 Lecture 17 TCP Implementation in Linux Jennifer Hou Department of Computer Science University of Illinois at Urbana-Champaign Reading: Chapter 24, The Linux Networking Architecture: Design and Implementation of Network Protocols in the Linux Kernel

  2. Outline • Paths of Incoming and outgoing segments • Connection management (this lecture) • Flow control and congestion control

  3. tcp_rcv_established TCP_ESTABLISHED TCP Implementation in Linux 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_re -transmit_skb 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

  4. Initial State CLOSED Application.: passive opening send: --- timeoutsend: RST Application.: active openingsend: SYN LISTEN Receives: SYN; send: SYN, ACK Application.: send datasend: SYN Passive Opening Receive RST Receive: SYN send: SYN, ACK Simultaneous opening SYN_RECV SYN_SENT Application: close or timeout Receive: SYN, ACKsend: ACK Receive ACKsend: --- Application: closesen: FIN Passive Close ESTABLISHED Receive FINsend: ACK Data Transmission Application: closesend: FIN CLOSE_WAIT Simultaneous close Receive FINsend ACK Application: c;pse send: FIN FIN_WAIT_1 CLOSING Receive: ACKsend: --- Receive: ACKsend: --- Receive ACKsend: --- LAST_ACK Receive: FIN, ACKsend: ACK FIN_WAIT_2 TIME_WAIT Receive: FINsend: ACK MSL: max. segment life Aktive close 2 MSL timeout

  5. tcp_rcv_state_process() • Handles mainly state transitions and connection management. • For example, if the packet received contains an ACK flag, • If state=SYN_RECV, then stateESTABLISHED, and the acknowledgement is processed. • If state=FIN_WAIT_1, then state FIN-WAIT2 and the TIMEWAIT timer is set. • If state=CLOSING, then state TIMEWAIT • If state=LAST_ACK, stateCLOSED and the socket is reset.

  6. Transition CLOSED SYN_SENT • connect()  tcp_v4_connect() tcp_connect() • tcp_connect() changes the state to SYN_SENT by invoking tcp_set_state(sk, TCP_SYN_SENT).

  7. Transition LISTENSYN_RECV • The LISTEN state is set when the server application invokes listen(). • When a SYN is received, • tcp_rcv_state_process()tcp_v4_hnd_req() tcp_check_req() tcp_v4_syn_recv_sock() tcp_create_openreq_child(). • In tcp_create_openreq_child(), the state is set to TCP_SYN_RECV. • tcpaf_specificconn_request() (pointed to tcp_v4_conn_request()) is invoked to specify the initial SN. • tcp_v4_send_synack() sends a reply with the ACK and SYN flags set.

  8. Transition SYN_SENT ESTABLISHED • tcp_rcv_state_process() tcp_rcv_synsent_state_process() • if (thack) { …… if (!thsyn) goto discard; ……. tcp_set_state(sk, TCP_ESTABLISHED); ……. tcp_schedule_ack(tp); ……. }

  9. Transition SYN_SENT SYN_RECEIVED • This takes place in the case of simultaneous opening. • tcp_rcv_state_process() tcp_rcv_synsent_state_process() • if (thsyn) { tcp_set_state(sk, TCP_SYN_RECV); …… tcp_set_synack(sk); …… }

  10. Transition SYN_RECV ESTABLISHED • tcp_rcv_state_process() processes this case. • If (thack) { switch(skstate) { case TCP_SYN_RECV: …. tcp_set_state(sk, TCP_ESTALISHED); } } Now the connection is established and the two peers can exchange data

  11. Initial State CLOSED Application.: passive opening send: --- timeoutsend: RST Application.: active openingsend: SYN LISTEN Receives: SYN; send: SYN, ACK Application.: send datasend: SYN Passive Opening Receive RST Receive: SYN send: SYN, ACK Simultaneous opening SYN_RECV SYN_SENT Application: close or timeout Receive: SYN, ACKsend: ACK Receive ACKsend: --- Application: closesen: FIN Passive Close ESTABLISHED Receive FINsend: ACK Data Transmission Application: closesend: FIN CLOSE_WAIT Simultaneous close Receive FINsend ACK Application: c;pse send: FIN FIN_WAIT_1 CLOSING Receive: ACKsend: --- Receive: ACKsend: --- Receive ACKsend: --- LAST_ACK Receive: FIN, ACKsend: ACK FIN_WAIT_2 TIME_WAIT Receive: FINsend: ACK MSL: max. segment life Aktive close 2 MSL timeout

  12. Transition ESTABLISHED FIN_WAIT_1 • close() tcp_close() tcp_close_state(). • In tcp_close_state(), the state is changed from ESTABLISHED to FIN_WAIT_1.

  13. Transition FIN_WAIT_1 FIN_WAIT_2 • In tcp_rcv_state_process() • if (thack) { switch(skstate) { …… case TCP_FIN_WAIT1: ………………… tcp_set_state(sk,TCP_FIN_WAIT2); …… } }

  14. Transition FIN_WAIT2TIME_WAIT • In tcp_fin(), switch(skstate) { ….. case TCP_FIN_WAIT2: tcp_send_ack(sk); tcp_time_wait(sk, TCP_TIME_WAIT, 0); break; ….. } tcp_v4_do_rcv() tcp_rcv_state_process() tcp_data_queue() tcp_fin()

  15. Transition ESTABLISHED CLOSE_WAIT tcp_v4_do_rcv() tcp_rcv_established() tcp_data() tcp_ack_snd_check() tcp_data_queue() tcp_fin()

  16. Transition ESTABLISHED CLOSE_WAIT • In tcp_fin(), switch(skstate) { case TCP_SYN_RECV: case TCP_ESTABLISHED: tcp_set_state(sk,TCP_CLOSE_WAIT); if (thrst) skshutdown= SHUTDOWN_MASK; break; • In tcp_ack_snd_check(), a packet is sent with the ACK flag set.

  17. Transition CLOSE_WAIT LAST_ACK • TCP on the other hand has closed the connection. Now we are waiting for our TCP instance to close the connection. • tcp_close() tcp_close_state() • In tcp_close_state(), tcp_set_state(sk, LAST_ACK) is invoked.

More Related