News for hackers. Stuff that matters.
Re:Game servers: UDP vs TCP by zurn on Tuesday April 01, 2014 @09:32AM (#7507969)
Impressive that he managed to say so much without mentioning head-of-line blocking, which is the main TCP problem with realtime apps.

This is not due to congestion control, but because of the ordered byte stream semantics of TCP. You can't deliver a packet until the retransmission dance is done for any previous lost packets.

As an aside, these days it's worth noting that a 3G, WLAN or 4G link layer will try very hard not to drop any packets. So when you're doing UDP, watch out for those 40000 millisecond old packets that will burst to your lap once the rain cloud moves away from the cell tower or your co-worker's cocoa blings in the microwave.

Re:Game servers: UDP vs TCP by rdtsc on Tuesday April 01, 2014 @10:02AM (#7508214)
SCTP is sometimes promoted as an alternative to solve that problem. You can have multiple stream per connection so if one blocks the other ones can keep going.
Re:Game servers: UDP vs TCP by _mhp_ on Wednesday April 02, 2014 @02:17AM (#7513886)
Another alternative is minion[0]. The format is TCP on the wire which avoids the NAT problems that SCTP has, but it is able to deliver some really interesting features, including multiple message streams like SCTP.

[0] https://datatracker.ietf.org/doc/search/?name=minion&actived...

Re:Game servers: UDP vs TCP by tankenmate on Wednesday April 02, 2014 @10:59AM (#7515963)
Or if SCTP firewall issues are the only thing holding you back you can use RFC 6951; SCTP over UDP.

http://tools.ietf.org/html/rfc6951

Re:Game servers: UDP vs TCP by lallysingh on Tuesday April 01, 2014 @11:17AM (#7508866)
My thoughts exactly. Also, you can send some data reliably (e.g., a new character model) and other data unreliably on the the same SCTP association.
Re:Game servers: UDP vs TCP by scott_karana on Tuesday April 01, 2014 @12:41PM (#7509591)
SCTP has always looked intriguing to me, but would most backbones and ISPs pass it natively?

It sounds like it would be a waste to tunnel it in UDP, which is the alternative...

Re:Game servers: UDP vs TCP by derefr on Tuesday April 01, 2014 @01:09PM (#7509841)
WebRTC Data Channels are, in fact, SCTP tunnelled over UDP (or rather, over DTLS over UDP.) They work pretty well.

(I'm not sure how much of the redundancy is shaved off--does anyone know if WebRTC's tries to encapsulate "normative" SCTP, or whether it uses SCTP without checksum/port information?)

Re:Game servers: UDP vs TCP by rdtsc on Tuesday April 01, 2014 @01:52PM (#7510247)
Yeah not sure either, good question.

There is also QUIC protocol also by Google, which is yet another crack at solving the problem. Wonder if those 2 groups sat down and discussed merging or re-using code.

Re:Game servers: UDP vs TCP by _delirium on Tuesday April 01, 2014 @12:47PM (#7509650)
The poor prospects for getting widespread SCTP support was one (though not the only) justification the SPDY people cited for doing some similar things at the application-protocol level: http://www.chromium.org/spdy/spdy-whitepaper
Re:Game servers: UDP vs TCP by noselasd on Tuesday April 01, 2014 @03:36PM (#7511077)
Yes they would. The real problem is your home router/gateway/modem will not - and you're normally behind a NAT, which in all likelyhood does not know anything about SCTP (SCTP also isn't very NAT friendly).
Re:Game servers: UDP vs TCP by fulafel on Tuesday April 01, 2014 @04:18PM (#7511370)
Sctp only breaks if the ISP or user has turned on NAT. A router wouldn't break it. NAT does bad things to IP (breaks the fundamental guarantees).
Re:Game servers: UDP vs TCP by hueving on Tuesday April 01, 2014 @09:38PM (#7513026)
>Sctp only breaks if the ISP or user has turned on NAT.

This describes 95%+ of home users. NAT may do bad things to IP, but if you are an app developer that depends on no NAT, you're product is going to have a very limited market of people that can use it.

Re:Game servers: UDP vs TCP by fulafel on Wednesday April 02, 2014 @01:32AM (#7513746)
IPv6!
Re:Game servers: UDP vs TCP by mfukar on Wednesday April 02, 2014 @02:07AM (#7513853)
NAT isn't going away with IPv6.
Re:Game servers: UDP vs TCP by fulafel on Wednesday April 02, 2014 @04:43AM (#7514285)
IPv4 NAT is not, but you can sidestep it by using IPv6. Look at eg how XBox One is doing it.

Or are you predicting the rise of IPv6 NAT?

Re:Game servers: UDP vs TCP by piranha on Wednesday April 02, 2014 @05:47AM (#7514441)
What is Xbox One doing?
Re:Game servers: UDP vs TCP by fulafel on Wednesday April 02, 2014 @06:23AM (#7514584)
They are tunneling IPv6 over Teredo if native IPv6 is unavailable. They provide their own relay servers for people who have NAT traversal incapable connectivity.

Teredo is a Microsoft-developed (but IETF-standadized) NAT-traversing IPv6-over-IPv4 tunneling method.

http://www.internetsociety.org/deploy360/blog/2013/10/micros...

http://www.ietf.org/proceedings/88/slides/slides-88-v6ops-0....

Re:Game servers: UDP vs TCP by drdaeman on Wednesday April 02, 2014 @09:20AM (#7515268)
An ISP employee here. We did nothing particular to support SCTP, so I got curious whenever it works. Just ran a pair of socat's (sctp-listen:12345 and sctp:example.org:12345) and it worked perfectly.

In our setup, NAT's done on a GNU/Linux machines in a simplest possible way, almost like `iptables -t nat -A POSTROUTING -s 10.0.0.0/8 -o eth1 -j MASQUERADE` (we offer dynamic globally-routeable IPv4 addresses first, but when our pools are drained, we have no choice but do NAT for v4). So, it seems, almost every ISP who uses software routers (they're stable, performant and cheap) should be SCTP-friendly.

No idea about Ciscos and alikes, though. None we have does NAT, and given I'm not a Cisco guy I'm not going to reconfigure one just to test things.

Re:Game servers: UDP vs TCP by drdaeman on Wednesday April 02, 2014 @08:44AM (#7515058)
Most cheap home routers are Linux-based, so the adoption plan seems trivial.

Linus should just make STCP NAT support the default with a comment "router manufacturers - please don't disable", so the next time router vendors update their kernels, it gets built into.

Then just wait for 3-4 years.

Re:Game servers: UDP vs TCP by zurn on Thursday April 03, 2014 @01:03AM (#7521055)
Look how long it's taking IPv6 support in consumer NAT boxes, and that's something that's hyped and all vendors are officialy drumming for it, and has been finished spec-wise since the 90s.

SCTP has had 14+ years - SCTP made standards track in 2000 (rfc2960) and was in use before that. Chicken and egg.

This is why NAT is bad. It's has introduced a systemic freeze in the Internet, breaking the inert router/smart host model that used to enable deployment of new protocols.

Re:Game servers: UDP vs TCP by drdaeman on Thursday April 03, 2014 @05:12PM (#7526743)
IPv6 is complicated matter. Even if kernel has ipv6 module/support built in, it's still a very tiny first step for router to support IPv6.

On the other hand, STCP NAT support is just one kernel config option away and no further configuration's needed. A complete no-brainer - just persuade those building routers' firmware to not tick it off.

Re:Game servers: UDP vs TCP by MichaelGG on Tuesday April 01, 2014 @02:56PM (#7510786)
Backbones and most ISPs are gonna route IP packets regardless of content. Until you hit a NAT or firewall and everything that's not UDP or TCP gets dropped.
Re:Game servers: UDP vs TCP by stplsd on Tuesday April 01, 2014 @06:11PM (#7512101)
Or just open multiple TCP streams (that means of course multiple TCP connections) and waste resources on additional TCP state tracking and additional recieve/send buffer allocations, etc.
Re:Game servers: UDP vs TCP by yvdriess on Tuesday April 01, 2014 @09:59AM (#7508195)
I was under the impression that packets behind the blocked TCP packet still sent through the network, relying on the client-side or last-hop to maintain the sequential stream illusion and thus reducing the delay of the subsequent frames to the delay blocked/resent frame. Could with a deeper knowledge confirm or deny this?
Re:Game servers: UDP vs TCP by eggnet on Tuesday April 01, 2014 @11:53AM (#7509194)
Yes that is true but maintaining the illusion means that the application can't read the data after the lost packet until the packet is retransmitted and received.

So yes, selective acks preserve network bandwidth but don't solve the real time problems. With UDP the client application can receive all packets when they arrive even if there are some missing.

Re:Game servers: UDP vs TCP by ForHackernews on Tuesday April 01, 2014 @12:06PM (#7509314)
> With UDP the client application can receive all packets when they arrive even if there are some missing.

Isn't that a good thing?

Re:Game servers: UDP vs TCP by lotharbot on Tuesday April 01, 2014 @12:34PM (#7509535)
Depends on the game.

I still play a game that's almost 20 years old (the original Descent), which has a small but active multiplayer community [0]. I regularly play against players in my own house as well as players from as far away as Brazil, Qatar, and Australia -- so I have to deal with various connection consistency issues. Given the game physics, I would much rather have out-of-order packets (resulting in an opposing ship briefly flashing in a wrong location and firing a shot from there) than having a delay on in-order packets (resulting in an opposing ship completely freezing, and then completing several seconds of movement and several seconds of shots in a fraction of a second).

There are other games that behave differently, where TCP would be preferable.

[0] descentrangers.com for anarchy, cooperative, and team games; descentchampions.org for competitive 1v1s.

Re:Game servers: UDP vs TCP by Nacraile on Tuesday April 01, 2014 @02:16PM (#7510464)
Yes. It gives you the flexibility to make your own decision in the trade off between: increased latency vs. bandwidth overhead vs. loss of data. With TCP, you get increased latency.

If your protocol is stateless, you might choose to lose the data, because you know that the loss doesn't matter as soon as you get a new update. This might be applicable in a games, if the state you need to synchronize (say, position) is quite small.

Even if you need your protocol to be stateful: you might choose to design your protocol such that loss results in a temporary degradation in the client view of state, but which will converge back on the correct state as it receives new data. This is a very common pattern; the quake net protocol referenced in OP is an example, as are most streaming A/V codecs.

If you absolutely cannot tolerate the loss of any data, and are also latency sensitive, you can also choose to add redundant data so you can recover the lost data without retransmitting.

And you can make intermediate trade-offs: A little bit of extra overhead for error-correction, and in the now-rare cases where error rate overwhelms your correction ability, you accept a degradation / retransmit round-trip. Or you accept a certain amount of degradation before you need retransmission to recover. Etc.

Re:Game servers: UDP vs TCP by mikeash on Tuesday April 01, 2014 @10:07AM (#7508246)
That's true, but the delay from waiting for the lost packet to be retransmitted is the problem, not a delay for subsequent data after retransmitting the lost packet. Retransmission can take a substantial amount of time.
Re:Game servers: UDP vs TCP by lucb1e on Tuesday April 01, 2014 @09:50AM (#7508130)
He didn't mention the term head-of-line blocking, but the issue was apparent to me as I read it. Perhaps because I have a bit of previous experience with tcp vs udp, but still.