News for hackers. Stuff that matters.
Re:It's Always TCP_nodelay by immibis on Monday December 22, 2025 @07:30PM (#46360988)
Nagle is quite sensible when your application isn't taking any care to create sensibly-sized packets, and isn't so sensitive to latency. It avoids creating stupidly small packets unless your network is fast enough to handle them.
Re:It's Always TCP_nodelay by silisili on Monday December 22, 2025 @08:28PM (#46361366)
At this point, this is an application level problem and not something the kernel should be silently doing for you IMO. An option for legacy systems or known problematic hosts fine, but off by default and probably not a per SOCKOPT.

Every modern language has buffers in their stdlib. Anyone writing character at a time to the wire lazily or unintentionally should fix their application.

Re:It's Always TCP_nodelay by AnthonyMouse on Monday December 22, 2025 @11:14PM (#46362365)
The programs that need it are mostly the ones nobody is maintaining.

TCP_NODELAY can also make fingerprinting easier in various ways which is a reason to make it something you have to ask for.

Re:It's Always TCP_nodelay by silisili on Tuesday December 23, 2025 @01:51AM (#46363051)
> The programs that need it are mostly the ones nobody is maintaining

Yes, as I mentioned, it should be kept around for this but off by default. Make it a sysctl param, done.

> TCP_NODELAY can also make fingerprinting easier in various ways which is a reason to make it something you have to ask for

Only because it's on by default for no real reason. I'm saying the default should be off.

Re:It's Always TCP_nodelay by mort96 on Tuesday December 23, 2025 @04:28AM (#46363802)
>> TCP_NODELAY can also make fingerprinting easier in various ways which is a reason to make it something you have to ask for

> Only because it's on by default for no real reason. I'm saying the default should be off.

This is wrong.

I'm assuming here that you mean that Nagle's algorithm is on by default, i.e TCP_NODELAY is off by default. It seems you think the only extra fingerprinting info TCP_NODELAY gives you is the single bit "TCP_NODELAY is on vs off". But it's more than that.

In a world where every application's traffic goes through Nagle's algorithm, lots of applications will just be seen to transmit a packet every 300ms or whatever as their transmissions are buffered up by the kernel to be sent in large packets. In a world where Nagle's algorithm is off by default, those applications could have very different packet sizes and timings.

With something like Telnet or SSH, you might even be able to detect who exactly is typing at the keyboard by analyzing their key press rhythm!

To be clear, this is not an argument in favor of Nagle's algorithm being on by default. I'm relatively neutral on that matter.

Re:It's Always TCP_nodelay by BenjiWiebe on Tuesday December 23, 2025 @10:52AM (#46366291)
As of recently, OpenSSH prevents keystroke timing analysis on it's own.
Re:It's Always TCP_nodelay by silisili on Tuesday December 23, 2025 @11:06AM (#46366423)
> I'm assuming here that you mean that Nagle's algorithm is on by default, i.e TCP_NODELAY is off by default.

Correct, I wrote that backwards, good callout.

RE: fingerprinting, I'd concede the point in a sufficiently lazy implementation. I'd fully expect the application layer to handle this, especially in cases where this matters.

Re:It's Always TCP_nodelay by withinboredom on Tuesday December 23, 2025 @05:41AM (#46364204)
Nagles algorithm does really well when you're on shitty wifi.

Applications also don't know the MTU (the size of packets) on the interface they're using. Hell, they probably don't even know which interface they're using! This is all abstracted away. So, if you're on a network with a 14xx MTU (such as a VPN), assuming an MTU of 1500 means you'll send one full packet and then a tiny little packet after that. For every one packet you think you're sending!

Nagle's algorithm lets you just send data; no problem. Let the kernel batch up packets. If you control the protocol, just use a design that prevents Delayed ACK from causing the latency. IE, the "OK" from Redis.

Re:It's Always TCP_nodelay by FridgeSeal on Tuesday December 23, 2025 @02:52AM (#46363333)
If nobody is maintaining them, do we really need them? In which case, does it really matter?

If we need them, and they’re not being maintained, then maybe that’s the kind of “scream test” wake up we need for them to either be properly deprecated, or updated.

Re:It's Always TCP_nodelay by josefx on Tuesday December 23, 2025 @04:26AM (#46363788)
> If nobody is maintaining them, do we really need them?

Given how often issues can be traced back to open source projects barely scraping along? Yes and they are probably doing something important. Hell, if you create enough pointless busywork you can probably get a few more "helpfull" hackers into projects like xz.

Re:It's Always TCP_nodelay by mort96 on Tuesday December 23, 2025 @04:30AM (#46363812)
How much ongoing development effort do you think goes into, say, something like a gzip encoder?
Re:It's Always TCP_nodelay by yxhuvud on Tuesday December 23, 2025 @04:48PM (#46369866)
A gzip encoder has no business deciding whether a socket should wait to fill up packets, however. The list of relevant applications and libraries gets a lot shorter with that restriction.
Re:It's Always TCP_nodelay by mort96 on Wednesday December 24, 2025 @08:12AM (#46375270)
It was a response to the sentiment expressed in:

> If nobody is maintaining them, do we really need them?

Software can have value even when not maintained.

Re:It's Always TCP_nodelay by hinkley on Tuesday December 23, 2025 @05:02AM (#46363983)
I think you’re forgetting how terminals work.
Re:It's Always TCP_nodelay by immibis on Tuesday December 23, 2025 @06:39AM (#46364493)
So to be clear, you believe every program that outputs a bulk stream to stdout should be written to check if stdout is a socket and enable Nagle's algorithm if so? That's not just busywork - it's also an abstraction violation. By explicitly turning off Nagle's, you specify that you understand TCP performance and don't need the abstraction, and this is a reasonable way to do things. Imagine if the kernel pinned threads to cores by default and you had to ask to unpin them...
Re:It's Always TCP_nodelay by rocqua on Tuesday December 23, 2025 @08:14AM (#46365083)
No, the program should take care to enable TCP_NODELAY when creating the socket. If the program gets passed a FD from outside it's on the outside program to ensure this. If somehow the program very often gets outside FDs from an oblivious source that could be a TCP socket, then it might indeed have to manually check if it really wants Nagle's algorithm.
Re:It's Always TCP_nodelay by mort96 on Wednesday December 24, 2025 @08:13AM (#46375281)
> That's not just busywork - it's also an abstraction violation.

You used AI to write this didn't you? Your sentence structure is not just tedious - it's a dead give-away.

Re:It's Always TCP_nodelay by immibis on Wednesday December 24, 2025 @10:26PM (#46381806)
No, I did not. Am I now forbidden from using sentence structures that AI has also used? That's not just stupid - it's insane. You know that's not even an em-dash, right?
Re:It's Always TCP_nodelay by CamperBob2 on Monday December 22, 2025 @10:28PM (#46362117)
If by "latency" you mean a hundred milliseconds or so, that's one thing, but I've seen Nagle delay packets by several seconds. Which is just goofy, and should never have been enabled by default, given the lack of an explicit flush function.

A smarter implementation would have been to call it TCP_MAX_DELAY_MS, and have it take an integer value with a well-documented (and reasonably low) default.

Re:It's Always TCP_nodelay by Gibbon1 on Tuesday December 23, 2025 @02:36AM (#46363250)
Reminds me of trying to do IoT stuff in hospitals before IoT was a thing.

Send exactly one 205 byte packet. How do you really know? I can see it go out on a scope. And the other end receives a packet with bytes 0-56. Then another packet with bytes 142-204. Finally a packet a 200ms later with bytes 57-141.

FfffFFFFffff You!

Re:It's Always TCP_nodelay by taherm789 on Tuesday December 23, 2025 @03:49AM (#46363610)
Things like these make me cry
Re:It's Always TCP_nodelay by readmodifywrite on Tuesday December 23, 2025 @10:35AM (#46366138)
If you were using TCP, then this is absolutely normal and expected behavior. It is a stream protocol, not packet/message based.
Re:It's Always TCP_nodelay by josefx on Tuesday December 23, 2025 @11:25AM (#46366604)
At the application layer you would not see the reordered bytes. However on the network you have IP beneath both UDP and TCP and network hardware is normally free to slice and reorder those IP packages however it wants.
Re:It's Always TCP_nodelay by immibis on Tuesday December 23, 2025 @02:48PM (#46368694)
It's not. Routers are expected to be allowed to slice IPv4 packets above 576 bytes. They can't slice IPv6 and they can't slice TCP.

However, malicious middleboxes insert themselves into your TCP connections, terminating a separate TCP connection on each side of the spyware and therefore completely rewriting TCP segment boundaries.

In less common scenarios, the same may be done by non malicious middleboxes - but it's almost always malicious ones. The party that attacked xmpp.is/jabber.ru terminated not only TCP but also TLS and issued itself a Let's Encrypt certificate.

Re:It's Always TCP_nodelay by sundbry on Tuesday December 23, 2025 @12:06PM (#46366970)
If only there was some sort of User Datagram Protocol where you could send specifically tuned packets like this.
Re:It's Always TCP_nodelay by CamperBob2 on Tuesday December 23, 2025 @01:41PM (#46367951)
Those who do not understand TCP are doomed to reimplement it with UDP.

The same is true of those who do understand it.

Re:It's Always TCP_nodelay by nomel on Tuesday December 23, 2025 @03:12PM (#46368960)
That first time you do sure is fun though.
Re:It's Always TCP_nodelay by littlecranky67 on Tuesday December 23, 2025 @03:25AM (#46363501)
It delays one RTT, so if you have seen seconds of delays that means your TCP ACK packages were received seconds later for whatever reason (high load?). Decreasing latency in that situation would WORSEN the situation.
Re:It's Always TCP_nodelay by CamperBob2 on Tuesday December 23, 2025 @01:44PM (#46367980)
Maybe, maybe not, whatever.

I was testing some low-bandwidth voice chat code using two unloaded PCs sitting on the same desk. I nearly jumped out of my skin when "HELLO, HELLO?" came through a few seconds late, at high volume, after I had already concluded it wasn't working. After ruling out latency on the audio side, TCP_NODELAY solved the problem.

All respect to Animats, but whoever thought this should be the default behavior of TCP/IP had rocks in their head, and/or were solving a problem that had a better solution that they just didn't think of at the time.

Re:It's Always TCP_nodelay by littlecranky67 on Wednesday December 24, 2025 @12:51PM (#46377625)
Whatever your issue in that setup was, NODELAY had nothing to do with it
Re:It's Always TCP_nodelay by CamperBob2 on Saturday December 27, 2025 @12:47PM (#46403602)
Then why did it stop happening when NODELAY was used?
Re:It's Always TCP_nodelay by littlecranky67 on Monday December 29, 2025 @02:49AM (#46418393)
Hard to say without looking at the complete setup - and probably just a side-effect of the underlying issue. The question is, why did you have such high RTTs? That already points to a different cause.

I would even argue that NODELAY for a VoIP solution makes no sense - why are you even using TCP instead of UDP in the first place?