LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 03-16-2011, 06:29 PM   #1
NANNOB1
LQ Newbie
 
Registered: Feb 2011
Posts: 8

Rep: Reputation: 0
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.

Last edited by NANNOB1; 03-16-2011 at 06:30 PM.
 
Old 03-18-2011, 02:18 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,854

Rep: Reputation: 161Reputation: 161
What's your point? Both function can validate checksum if necessary because it is in different path.
 
Old 03-18-2011, 05:02 PM   #3
NANNOB1
LQ Newbie
 
Registered: Feb 2011
Posts: 8

Original Poster
Rep: Reputation: 0
thanks for the reply. What I want to do is to inform the sender that a packet was received with error, like a negative acknowledge:


csum_error:
tcp_send_ack_err(sk); /*this is the function I am creating */
TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_INERRS);

discard:
__kfree_skb(skb);

I would like to know is if my function is located in the right place, after that a segment with bad checksum was detected.
 
Old 03-21-2011, 02:29 PM   #4
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,854

Rep: Reputation: 161Reputation: 161
Why do you want to send a error ACK to sender? How do you do it?
 
Old 03-23-2011, 10:36 AM   #5
NANNOB1
LQ Newbie
 
Registered: Feb 2011
Posts: 8

Original Poster
Rep: Reputation: 0
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:

void tcp_send_ack_err(struct sock *sk)
{
struct sk_buff *buff;


buff = alloc_skb(MAX_TCP_HEADER, GFP_ATOMIC);


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. */


TCP_SKB_CB(buff)->when = tcp_time_stamp;
tcp_transmit_skb(sk, buff, 0, GFP_ATOMIC);
}



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.
 
Old 03-23-2011, 02:11 PM   #6
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,854

Rep: Reputation: 161Reputation: 161
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.
 
Old 05-18-2011, 01:31 PM   #7
NANNOB1
LQ Newbie
 
Registered: Feb 2011
Posts: 8

Original Poster
Rep: Reputation: 0
Question

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.

What is the diference? How they work?
 
Old 05-23-2011, 02:42 PM   #8
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,854

Rep: Reputation: 161Reputation: 161
Learn checksum offloading and then you can understand more.
 
Old 06-05-2011, 11:17 AM   #9
NANNOB1
LQ Newbie
 
Registered: Feb 2011
Posts: 8

Original Poster
Rep: Reputation: 0
I disabled the checksum offload calculation, put the function in tcp_rcv_established() and now everything works. Thanks!

Last edited by NANNOB1; 06-05-2011 at 11:18 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Increasing TCP initial window to 3 segments (rfc 2414 or 3390) nenderle Linux - Networking 1 06-08-2009 04:16 AM
TCP Retransmission & lost segments problem under Linux but not under XP debuser123 Linux - Networking 22 12-16-2007 04:34 PM
TCP header checksum live_dont_exist Programming 16 04-13-2005 12:45 PM
anyone can help me with the TCP checksum? vaaub Programming 1 02-10-2004 01:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 12:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration