0

Lets say the device tx ring is full and you do a normal C non blocking write(fd, buff) to enqueue data in the TCP SND buffer.

What happens when this fails? In UDP - the packet would be dropped but what happens in TCP?

Here is the context:

I have a tester which sends data to a bunch of TCP sockets sequentially in non blocking. It sends enough data to fill the SND BUFF.

The condition I am testing for is one where after filling the SND BUFF; I will not receive a OPS_WRITE event from the non blocking poll for several seconds for a handful out of 500 connections. It happens, sometimes up to 2-3 seconds I will get nada from poll.

I increased my TX RING from 512 to 2048 and now it never happens unless the nic is at capacity for 10 seconds or more.

1
  • The two days I spent on this seems to make me think a ring failure is just like a UDP failure - the TCP retransmit timer takes control which seems to jive with my 3s timings. I would like some input from someone who understands how these things actually work. Apr 15 '15 at 15:17
0

From write(2),

Errors

      ⋮

EAGAIN or EWOULDBLOCK

    The file descriptor fd refers to a socket and has been marked nonblocking (O_NONBLOCK), and the write would block.  POSIX.1-2001 allows either error to be returned for this case, and does not require these constants to have the same value, so a portable application should check for both possibilities.

In other words, the write will return -1, with errno set to either EAGAIN or EWOULDBLOCK.  (And, of course, the data in the buffer are not sent.)

2
  • I am referring to the device tx ring. If TCP fails to add packet X to tx ring then what happens? Apr 15 '15 at 7:47
  • It does exactly what he says, apparently. I stumbled across this issue myself, when the device ring is full linux just refuses to add the packet to the buffer (or the driver refuses), throwing an EAGAIN error. If you try and write the packet, it doesn't get added.
    – Allison
    Jan 2 '18 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.