TCP packet entry (Linux Kernel)
This post should have preceeded the earlier post about the SYN and SYN-ACK's. But this is what happens when I dont keep my papers in order =). Anyways here it is. Once again I am not mentioning a few details which I dont think are neccessary. So here goes the entry of a TCP packet into the TCP layer of the Linux Network Stack.
As it happens, tcp_v4_rcv() is the function that is the entry point for a TCP packet into the TCP layer. This fuction first pulls out the TCP header from the packet and populates the 'th' variable in sk_buff. It then checks if there is a socket associated with the flow. It can either be the server socket or the client socket. If it fails to find such a socket, the packet is dropped. Otherwise the function populates other bookkeeping vaiables for the flow and finally calls tcp_v4_do_rcv(). tcp_v4_do_rcv() first checks to see if the socket is in the established state. If so, tcp_rcv_established() is called. What this means is that there was a SYN packet earlier to this packet and that the flow has gone beyond the 3-way handshake. Any other state the flow is in is handled by tcp_rcv_state_process().
Some of the important functions in tcp_rcv_established() are listed below.
tcp_ack(): This function deals with incoming acks only.
tcp_data_snd_check(): This function deals with data packets.
tcp_event_data_recv(): This function schedules ack's. The rest of the function deals with the data.
tcp_ack_scheduled(): This function returns the value of tp->ack.pending
tcp_send_ack(): This function prepares an outgoing ACK packet.
tcp_send_delayed_ack(): This function deals with delayed ACK's. Eventually it calls tcp_send_ack() to send out the packet.
__tcp_ack_snd_check(): This function checks to see if the kernel needs to send an ACK.
Well this is what I have at the moment. I thought I had more stuff to write but it turns out I dont.
As it happens, tcp_v4_rcv() is the function that is the entry point for a TCP packet into the TCP layer. This fuction first pulls out the TCP header from the packet and populates the 'th' variable in sk_buff. It then checks if there is a socket associated with the flow. It can either be the server socket or the client socket. If it fails to find such a socket, the packet is dropped. Otherwise the function populates other bookkeeping vaiables for the flow and finally calls tcp_v4_do_rcv(). tcp_v4_do_rcv() first checks to see if the socket is in the established state. If so, tcp_rcv_established() is called. What this means is that there was a SYN packet earlier to this packet and that the flow has gone beyond the 3-way handshake. Any other state the flow is in is handled by tcp_rcv_state_process().
Some of the important functions in tcp_rcv_established() are listed below.
tcp_ack(): This function deals with incoming acks only.
tcp_data_snd_check(): This function deals with data packets.
tcp_event_data_recv(): This function schedules ack's. The rest of the function deals with the data.
tcp_ack_scheduled(): This function returns the value of tp->ack.pending
tcp_send_ack(): This function prepares an outgoing ACK packet.
tcp_send_delayed_ack(): This function deals with delayed ACK's. Eventually it calls tcp_send_ack() to send out the packet.
__tcp_ack_snd_check(): This function checks to see if the kernel needs to send an ACK.
Well this is what I have at the moment. I thought I had more stuff to write but it turns out I dont.
0 Comments:
Post a Comment
<< Home