Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is UDP + a software reliable ordering system faster than TCP?

Some games today use a network system that transmits messages over UDP, and ensures that the messages are reliable and ordered.

For example, RakNet is a popular game network engine. It uses only UDP for its connections, and has a whole system to ensure that packets can be reliable and ordered if you so choose.

My basic question is, what's up with that? Isn't TCP the same thing as ordered, reliable UDP? What makes it so much slower that people have to basically reinvent the wheel?

like image 340
Ricket Avatar asked Jul 29 '09 14:07

Ricket


Video Answer


2 Answers

General/Specialisation

  1. TCP is a general purpose reliable system
  2. UDP +whatever is a special purpose reliable system.

Specialized things are usually better than general purpose things for the thing they are specialized.

Stream / Message

  1. TCP is stream-based
  2. UDP is message-based

Sending discrete gaming information maps usually better to a message-based paradigm. Sending it through a stream is possible but horribly ineffective. If you want to reliably send a huge amount of data (File transfer), TCP is quite effective. That's why Bit-torrent use UDP for control messages and TCP for data sending.

like image 132
Steve Schnepp Avatar answered Sep 23 '22 22:09

Steve Schnepp


There's much more of a difference between UDP and TCP than just reliability and sequencing:

At the heart of the matter is the fact that UDP is connectionless while TCP is connected. This simple difference leads to a host of other differences that I'm not going to be able to reasonbly summarize here. You can read the analysis below for much more detail.

TCP - UDP Comparative Analysis

like image 28
Justin Niessner Avatar answered Sep 22 '22 22:09

Justin Niessner