Page 1 of 1
TCP Multiple Packet Acknowledgment
Posted: Thu Jul 09, 2015 6:44 am
by kemosparc
Hi,
I am working on my TCP stack within my small hobby OS.
I managed to have a built-in small web server into my kernel.
It is functional and working good but it has some performance problems.
I compared it with apache on linux and using curl command line as a client.
I found that curl sends one ack every a number of packets to the server acknowledging all what preceded. Mine does not and I think this is why it is slower, as it has to acknowledge every packet.
As per the wireshark screen shots, apache and my OS, you will fond that the first marked ACK packet sent by curl in the case of apache acknowledges all what preceeded it, while in my case the first ACK packet acknowledges the first payload packet I sent.
My question is how to force the client to acknowledge bulk packets with one acknowledgement packet.
Thanks,
Karim.
Re: TCP Multiple Packet Acknowledgment
Posted: Thu Jul 09, 2015 8:31 am
by iansjack
I wonder if you are getting cause and effect the wrong way round. Could it be that the reason that every packet is being acknowledged is because transmission is slower?
Just a thought.
Re: TCP Multiple Packet Acknowledgment
Posted: Thu Jul 09, 2015 8:42 am
by kemosparc
If you look at the timestamps we will find them very close.
Its lows down afterwards when I start getting the acks, but in the first batch they are almost the same if I am not faster than apache.
Karim.
Re: TCP Multiple Packet Acknowledgment
Posted: Thu Jul 09, 2015 10:02 am
by dschatz
You seem to be passing options on the ACK of the GET request - Why are you doing this? Could this be causing Linux to send early ACKs to deal with window size recalculations?
Re: TCP Multiple Packet Acknowledgment
Posted: Thu Jul 09, 2015 10:06 am
by kemosparc
Please elaborate.
Do you mean the MSS and SACK_PERM ?
Karim.
Re: TCP Multiple Packet Acknowledgment
Posted: Fri Jul 10, 2015 8:00 am
by kemosparc
Nope,
I have adjusted the code to remove the options and still the same symptom !
I have been searching for this over the internet for the past week and the only thing that I found and was not very well documented is that acknowledging multiple packets with on ACK need sending full sized packets, and this is what I do.
I even compared the packets of my web server and the apache and they are identical except for the time stamps !! they even send the same data stream.
Any ideas ?
Thanks,
Karim.
Re: TCP Multiple Packet Acknowledgment
Posted: Fri Jul 10, 2015 8:06 am
by iansjack
If the packets are identical except for the timestamps (and checksums) then there is only one logical conclusion.
Re: TCP Multiple Packet Acknowledgment
Posted: Fri Jul 10, 2015 8:20 am
by kemosparc
And what is that ??
Re: TCP Multiple Packet Acknowledgment
Posted: Fri Jul 10, 2015 8:54 am
by iansjack
You say there is only one variable, so that has to be the answer.
When you have eliminated the impossible, whatever remains, however improbable, must be the truth.
But are the packets really identical - sequence numbers, acknowledgement numbers, etc.? You said identical apart from timestamps but clearly that is not the case; at the very least the checksums have to differ, so what else differs?
Re: TCP Multiple Packet Acknowledgment
Posted: Sat Jul 11, 2015 9:27 am
by iansjack
One other thing that I notice, which may well have a bearing. In the two screenshots the Win values are very different between Apache and your server in the first packet after the "GET" request. The value for your server of 3706880 seems to be quite large and may well have a bearing on things.
Re: TCP Multiple Packet Acknowledgment
Posted: Sat Jul 11, 2015 9:34 am
by kemosparc
Hi,
I figured out the problem.
I was concentrating on comparing TCP headers while the problem was with the IP header.
In the IP header there is a field called id. This field needs to be incremented on every payload packet and this will make the IP layer group some packets while they are going out of the sender stack. On the other side the packets are received as one large packet which is larger then the MTU.
I was able to detect that by having wireshark started on both sides so every number of packets sent out from the server are realized by the client stack as a one big packet, usually in the order of 7-10 K rather than the 1500 Bytes MTU size.
Now, both apache and my OS are behaving the same
Thanks a lot anyways for your replies.
Karim.