Altera_Forum
Honored Contributor
15 years agoDelay of TCP transmission
I use uC RTOS and Nichestack and I have a strange delay in the trasmission of TCP data. I can't understand if this is normal.
I establish a connection where my pc is the client and the Nios is the server. The transaction is this: 1- pc sends 6 byte of tcp data 2- nios answers 6 bytes of tcp data 3- after a short time (<5ms), Nios sends 7 more bytes of data. This small delay is normal because Nios waits for data coming from an upper layer. The problem is: steps 1 to 3 executes in the expected time: it takes a few ms from when pc application sends data to its tcp stack to when nios sends to the Nichestack tx function the 7 bytes. But the Ethernet frame is actually transmitted a long time after, usually 100 to 200ms later. I monitored this delay with oscilloscope through PIOs driven by Nios and probing the rx/tx signals on Ethernet PHY, so I'm pretty sure the delay is introduced by Nichestack or MAC. I tried to disable the Nagle algorithm with TCP_NODELAY option but nothing changes. The strange thing is that if I force step 3 from Nios (without any request from the client) the frame trasmission is nearly immediate!!! I also captured the TCP packets with Wireshark. time 0.000000 PC sends 6 bytes time 0.000378 Nios ack the 6 bytes time 0.002695 Nios send its 6 bytes time 0.109926 PC ack the 6 bytes time 0.110407 Nios sends the remaining 7 bytes time 0.310343 PC ack the 7 bytes Note that the delayed 7 bytes are transmitted just after the ack of the previous ones. Could it be that Nichestack delays because it waits the ack of the first 6 bytes before sending the other 7 ? Thank you in advance for any advice. Cris