Page 1 of 1

TCP Packet Size Limitations

Posted: Fri Jan 30, 2015 3:06 am
by kemosparc
Hi,
I have a problem with sending TCP packets out.

What I have is basically a very simple hard wired TCP stack that I have developed to test and understand the TCP communication. I already developed a hard wired server side ARP to respond to ARP resolution echo requests.

What I have right now is a very small HTTP server that receives an HTTP request and respond to it with a hard wired message. I use the e1000 virtual nic on qemu.

The following is a summary of the TCP communication sequence I have after ARP resolution:

Code: Select all

Client:		SYN			Payload=0 	Seq=f8 4d 26 1b		Ack=00 00 00 00		Seq = Rand	
Server:		SYN,ACK		Payload=0		Seq=ed 2c cf 7b		Ack=f8 4d 26 1c		Seq = Rand 	Ack=Prev. Seq +1
Client:		ACK			Payload=0		Seq=f8 4d 26 1c		Ack=ed 2c cf 7c		Seq = Prev Ack	Ack = Prev. Seq +1
Client:		PSH,ACK		Payload=87		Seq=f8 4d 26 1c		Ack=ed 2c cf 7c		Copy Prev Seq and Ack      (HTTP REQUEST)
Server:		Ack			Payload=0		Seq=ed 2c cf 7c		Ack=f8 4d 26 73		Seq = Prev Ack	Ack = Prev. Seq + Prev.Payload
Server:		PSH,ACK		Payload=251	Seq=ed 2c cf 7c		Ack=f8 4d 26 73		Copy Prev Seq and Ack     (HTTP REPLY - HERE IS THE PROBLEM WHEN > 164 bytes)
Client:		Ack			Payload=0		Seq=f8 4d 26 73		Ack=ed 2c d0 77		Seq = Prev Ack	Ack = Prev. Seq + Prev.Payload		
Client:		FIN,ACK		Payload=0		Seq=f8 4d 26 73		Ack=ed 2c d0 77		Copy Prev Seq and Ack
Server:		FIN,ACK		Payload=0		Seq=ed 2c d0 77		Ack=f8 4d 26 74		Seq = Prev Ack	Ack = Prev. Seq +1
Client:		FIN,ACK		Payload=0		Seq=f8 4d 26 74		Ack=ed 2c d0 78		Seq = Prev Ack	Ack = Prev. Seq +1
My kernel is the server, and the client is the command line CURL program I use to initiate requests (I also tried firefox)

The above works perfectly as long as the HTTP reply packet is less than or equal to 164 bytes in total (Eth Header+IP Header+TCP header and options+ payload)., and when I change the payload for larger sizes it fails.

I expect that I calculate the checksums correctly (IP and TCP) since packets less than 165 byte go through and are accepted.

I have been trying to fix this for three days now and I cannot. My problem is that when the packet size exceeds the 164 bytes the packet does not appear on Wireshark which makes me think that it did not leave the NIC in the first place.

If anyone can think about the cause or what can be the reason behind it, it will be of great help.


Thanks,
Karim.

Re: TCP Packet Size Limitations

Posted: Fri Jan 30, 2015 4:11 am
by Shaun
My problem is that when the packet size exceeds the 164 bytes the packet does not appear on Wireshark which makes me think that it did not leave the NIC in the first place.
From my point of view, the most possibility is that nic driver drop the packet. Due to the lack of nic driver source code, i guess:
1,check out the e1000 ringbuffer size, mtu . these were initialized by driver.
2,disable the e1000 checksum offloading property. if enabled, nic will calculate the checksum and drop packet if the value is invalid.

Re: TCP Packet Size Limitations

Posted: Fri Jan 30, 2015 9:52 am
by kemosparc
Hi,

I am very sorry for posting this problem.

It turned out the I was passing the length of the received packet instead of the packet I need to send.

That what happens when you write code in the middle of the night.

Sorry again and thanks for the help.

Regard,
Karim.