LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-21-2012, 06:40 AM   #1
$ubbu
LQ Newbie
 
Registered: Sep 2011
Posts: 8

Rep: Reputation: Disabled
Unexpected TCP Retransmission.


Hi

I am writing a KERNEL module which modifies the received SKB(from protocol stack) according to my need and transmits the new SKB. While doing this I face a problem as described below.

A web client (where my kernel module is loaded) requests for a HTML page (30KB) from web server. I have disabled compression in the web server. So the entire html page is supposed to be sent by the server in multiple TCP segments.

But when I capture the packets through Wireshark, I see the web server after sending 3 segments, instead of sending 4th segment it starts retransmitting the first segment again despite all 3 segments are acknowledged (Delayed ACK) by the client before the retransmission occurs. So my question is why does the server retransmits the first segment even after receiving the ACK for it?

fyi,

Just to make sure the way I form the SKB is not the culprit, I called the function which forms a new SKB but still while transmission I freed the new SKB and sent ONLY the SKB which I received from protocol stack . But still I see the same problem as described above.

Please let me know if I am not clear.

Thanks,
$ubbu.
 
Old 05-22-2012, 02:19 AM   #2
$ubbu
LQ Newbie
 
Registered: Sep 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
Any reply please?
 
Old 05-23-2012, 02:24 PM   #3
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,686

Rep: Reputation: 143Reputation: 143
Is ACK sequence number correct you response to server?
 
Old 05-23-2012, 10:56 PM   #4
$ubbu
LQ Newbie
 
Registered: Sep 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
Yes I do adjust the ACK and seq no accordingly. So as expected the ACK sent by the web client (after adjusting the seq no) is getting dropped by web server. Hence retransmission happens from the server side.

The reason for drop is the checksum calculation for outgoing ACK is wrong. But I use the same checksum calculation for the HTTP GET Request which gets passed. So I am unable to figure out why the checksum for outgoing ACK is wrong while the checksum for HTTP GET request is correct?

Any thoughts? Thanks for your reply..
 
Old 05-24-2012, 02:22 PM   #5
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,686

Rep: Reputation: 143Reputation: 143
How do you know the checksum is wrong? There are two seq number in ACK packet. Are you sure both is correct?
 
Old 05-25-2012, 10:41 AM   #6
$ubbu
LQ Newbie
 
Registered: Sep 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
2 seq no, whats that? Wireshark shows incorrect checksum for outgoing ACK's by webclient.
 
Old 05-29-2012, 02:17 PM   #7
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,686

Rep: Reputation: 143Reputation: 143
There are two sequence number, Sequence Number and Acknowledgment Number. If Wireshark shows incorrect checksum for outgoing ACK, that means your program is worng even if HTTP GET is correct.
 
Old 05-31-2012, 03:43 AM   #8
$ubbu
LQ Newbie
 
Registered: Sep 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
As I said earlier both the ack no and seq no are adjusted correctly. Neways I got it to resolve the checksum error but couldnt understand the reason behind it.

Case 1: When I dont see the checksum error I do the following.

1. I dont compute TCP checksum in xmit_hook after adjusting the sequence number.
2. I do compute TCP checksum in recv_hook after adjusting the acknowledgement number.
3. The TCP checksum offload is disabled by the following command (#ethtool --offload eth0 rx off tx off)

Case 2: When I see the checksum error I do the following.

1. I do compute TCP checksum in xmit_hook after adjusting the sequence number.
2. I do compute TCP checksum in recv_hook after adjusting the acknowledgement number.
3. The TCP checksum offload is disabled by the following command (#ethtool --offload eth0 rx off tx off)


As per my understanding Case 1 should fail while Case 2 should pass but its behaving exactly opposite to what I think What am I missing here?

In Case 1 When I dont explicitly calculate the checksum and when I turn off the Checksum offload calculation I expect the HTTP communication failure but instead I see HTTP communication happening correctly and checksum is also calculated correctly (by the hardware?). But why does this happen when I have turned off? And why does case 2 fails?

Any thoughts please!!!

Last edited by $ubbu; 05-31-2012 at 03:48 AM.
 
Old 05-31-2012, 02:40 PM   #9
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,686

Rep: Reputation: 143Reputation: 143
It look like your code doesn't pass TCP/IP stack completely, only working on SKB. I don't know where is your hook position.
 
Old 05-31-2012, 11:55 PM   #10
$ubbu
LQ Newbie
 
Registered: Sep 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
Yup it doesnt pass TCP/IP stack completely. In xmit_hook I steal the packets (only if needed) while in recv_hook I just recompute checksum and accept all the packets.

My hook positions for

xmit_hook is NF_INET_POST_ROUTING chain and recv_hook is NF_INET_LOCAL_IN.

Let me know if you need any other info. Thanks!!
 
Old 06-01-2012, 02:09 PM   #11
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,686

Rep: Reputation: 143Reputation: 143
If so, your case 1 make sense. For sending side, the TCP/IP stack will recalculate checksum before sending to meduim. For receiving side, TCP socket will check checksum.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] tcp\ip ack timeout and packet retransmission - Solved Fabio Paolini Linux - Networking 7 12-08-2011 08:04 AM
ssh hangs upon tcp errors or retransmission wastingtime Linux - Software 1 03-10-2009 08:13 PM
TCP Retransmission in Information tab of Ethereal Linuxfan0001 Linux - Networking 1 06-18-2008 03:28 PM
TCP Retransmission & lost segments problem under Linux but not under XP debuser123 Linux - Networking 22 12-16-2007 04:34 PM
TCP retransmission and duplicated ack enjoyzj Linux - Networking 0 06-05-2004 06:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:26 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration