how much faster si udp
I've sometimes wondered how much faster than TCP is UDP, and go about what percentage it lost.
You can't really compare them like that.
UDP is a very very basic protocol that enforces nothing but intact packets. TCP in comparison is a beast of a protocol. It implements a lot of integrity rules that you may not need for the situation at hand.
Use UDP if you need low latency, TCP if you need steady throughput.
UDP is a very very basic protocol that enforces nothing but intact packets. TCP in comparison is a beast of a protocol. It implements a lot of integrity rules that you may not need for the situation at hand.
Use UDP if you need low latency, TCP if you need steady throughput.
Also remember there is no guarantee a UDP packet arrives at the other end at all, or in any specific order.
TCP will automatically resend packages if needed, and make sure they are delivered in order to the application
So you must make sure the protocol you implement on top of it has no problem with lost packages and doesn't care about package order.
TCP will automatically resend packages if needed, and make sure they are delivered in order to the application
So you must make sure the protocol you implement on top of it has no problem with lost packages and doesn't care about package order.
When you have a good connection through the Internet their performance will be essentially equal; packets will arrive in order and on time, and both protocols have minimal overhead.
That describes almost all the time on the Internet. It is mostly very stable. In the general case of uncongested lines and stable hardware there will be no significant difference in performance.
The rare problems come when there is congestion, routing changes, or hardware failures along the line (which are not very often). In that case you need to handle the situation correctly; TCP handles all that for you in a very robust way. UDP assumes you know what you are doing and will handle it correctly by yourself. Can you handle it yourself, with performance better than TCP? That is a harder question.
That describes almost all the time on the Internet. It is mostly very stable. In the general case of uncongested lines and stable hardware there will be no significant difference in performance.
The rare problems come when there is congestion, routing changes, or hardware failures along the line (which are not very often). In that case you need to handle the situation correctly; TCP handles all that for you in a very robust way. UDP assumes you know what you are doing and will handle it correctly by yourself. Can you handle it yourself, with performance better than TCP? That is a harder question.
That describes almost all the time on the Internet. It is mostly very stable.
Really?
Granted I don't have a lot of networking experience, and most of it a 7-8 years ago, my experience is the opposite.
Specially if you mix some wireless into it, which is pretty much the normal case nowadays.
One of the "bottlenecks" of TCP is the window size, it will only send a certain amount of packages before making sure the first one has arrived.
This will limit the speed when you have high latency.
Also, it eats some of the bandwidth in the "other direction", sending ACK packages, this could be nice to avoid if you have to handle a lot of traffic.
UDP is great if your protocol has no need of packages being in perfect order or lost, if you do need that, TCP is the better choice.
[quote name='frob' timestamp='1332858645' post='4925673']
That describes almost all the time on the Internet. It is mostly very stable.
Really?
Granted I don't have a lot of networking experience, and most of it a 7-8 years ago, my experience is the opposite.
Specially if you mix some wireless into it, which is pretty much the normal case nowadays.
[/quote]
Congestion and saturation are the major causes of lost packets. If you saturate your line you are more likely to lose packets. If you are flooding your line it doesn't matter if you are on wired or wireless connections, once it gets saturated it won't take any more.
One of the "bottlenecks" of TCP is the window size, it will only send a certain amount of packages before making sure the first one has arrived.
This will limit the speed when you have high latency.
[/quote]
Window sizes are negotiated at protocol start and are dynamically resized up to 1GB windows; that is part of the protocol. In practice this is rarely an issue.
Also, it eats some of the bandwidth in the "other direction", sending ACK packages, this could be nice to avoid if you have to handle a lot of traffic.
[/quote]
Traffic needs are asymmetric, and ack commands are very small. If you implement your own control system with UDP you will still need to implement something similar.
UDP is great if your protocol has no need of packages being in perfect order or lost, if you do need that, TCP is the better choice.
[/quote]
Some people have other needs. Many networking packages for games implement their own TCP-style layer on top of UDP where they can mix reliable information (such as game state) with unreliable information (such as delta-updates). If you have the means to do such a thing you can get slightly better performance than raw TCP in the general case along with all its benefits.
That type of solution is generally outside the reach of most beginners.
I've sometimes wondered how much faster than TCP is UDP, and go about what percentage it lost.
If there is no packet loss, then TCP and UDP are exactly the same speed.
If there is packet loss, then UDP gives you nothing (so, infinitely slow) whereas TCP will delay and retry until the data gets through (so, slower than immediate.)
You use UDP when you'd rather have no data than slow data. You use TCP when you'd rather have all the data, in order.
If there is no packet loss, then TCP and UDP are exactly the same speed.
Even if there's no packet loss, TCP requires the receiver to send acknowledgements of received data.
[quote name='hplus0603' timestamp='1332865082' post='4925722']
If there is no packet loss, then TCP and UDP are exactly the same speed.
Even if there's no packet loss, TCP requires the receiver to send acknowledgements of received data.
[/quote]
That does not affect the speed of data transfer. In the distance past, long-distance transfers would slow down because of window exhaustion, but with window scaling that hasn't been a problem for a long time.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement