[SOLVED] where is calculated the TCP checksum of incoming segments?
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
where is calculated the TCP checksum of incoming segments?
I am doing a modification to the TCP protocol that handles incoming segments with errors. I found some places where the checksum is calculated: in tcp_rcv_established() in /net/ipv4/tcp_input.c. Also I found it in tcp_v4_do_rcv() in /net/ipv4/tcp_ipv4.c. I would like to know exactly where the checksum is calculated before it is discarded so i can create a function that uses the information in the segment .
I am working with a 2.6.32 kernel in Ubuntu.
I hope that someone could help me with this, please.
I saw a TCP mod proposal for wireless network that sends a negative ack to inform the sender that the segment was lost due to an error and not by congestion in the network. I created a new flag in the TCP header using one bit of the reserved field. To send the negative ack I was thinking to modify the function send_tcp_ack() in tcp_output.c to send my flag instead of the normal ack flag, something like this:
if (buff == NULL) { /* I don't know exactly what this does */
inet_csk_schedule_ack(sk);
inet_csk(sk)->icsk_ack.ato = TCP_ATO_MIN;
inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
TCP_DELACK_MAX, TCP_RTO_MAX);
return;
}
skb_reserve(buff, MAX_TCP_HEADER);
tcp_init_nondata_skb(buff, tcp_acceptable_seq(sk), TCPCB_FLAG_NACK); /* here I use the new flag. */
the problem is that I don't really know if this would work, and I can't test it because I don't know exactly were I should put this function, the only thing I know is that it has to be just after the checksum says that the packet has error.
If both sender and receiver are under your code control, your concept is fine. Maybe for the case, recovery can be speeded up. For normal case, it didn't work because sender don't understand your flag.
I've been reading books about tcp implementation in linux, from there I understand that an incoming packet is managed by tcp_v4_rcv() that calls tcp_v4_do_rcv() that calls tcp_rcv_established(), but the checksum calculation is barely mentioned so I saw the source code and the functions that verify the checksum are different: skb_csum_unnecessary(skb) && tcp_v4_checksum_init(skb) in tcp_v4_rcv(), tcp_checksum_complete(skb) in tcp_v4_do_rcv() and tcp_checksum_complete_user in tcp_rcv_established.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.