When is udp preferred over tcp




















UDP provides no guarantee for delivery and no protection from duplication, but the simplicity of UDP reduces overhead from the protocol and can be adequate for some applications. A computer may send UDP packets without first establishing a connection to a recipient. The computer completes the appropriate fields in the UDP header PCI and forwards the data together with the header for transmission by the IP network layer.

Typically, use UDP in applications where speed is more critical than reliability. The web just wouldn't function without TCP. And while TCP is slower because of the way it establishes connections, and due to the checks for missing packets, it can still be blazing fast. TCP also allows for buffering, so your browser can request and load more data as you watch, allowing for smooth playback and for you to skip ahead to other parts of the video.

UDP is the better choice for live video and audio or online games where speed is more important than potential data loss.

If you play video games, you might think that the way TCP ensures all data packets arrive at the other device would make it the ideal choice. But in reality, all the checking and resending data that TCP does just adds latency. Game developers have found other clever ways to ensure that player input and state are as accurate as possible. If you're interested in reading more about why UDP is preferred for online gaming, check out this article.

And if someone asks which is faster, tell 'em what you read here: "UDP is faster, but And if you like what you read, let me know over on Twitter. If you read this far, tweet to the author to show them you care. Tweet a thanks. Learn to code for free. Get started. Forum Donate. Network engineers don't chose protocols.

Application developers do. A similar question was asked and answered here. Add a comment. Active Oldest Votes. Improve this answer. JFL 18k 1 1 gold badge 30 30 silver badges 62 62 bronze badges. Joey Miller Joey Miller 1 1 silver badge 4 4 bronze badges.

The answer is as simple as it can get: speed TCP , due to its connection establishing and error checking mechanism is considered a slow protocol although reliable.

Kobayashi Kobayashi 2 2 silver badges 9 9 bronze badges. TCPs reliability comes at a price in several areas. Startup time: A UDP protocol can send a request and get a response in one round trip. Head of line blocking: If a TCP packet is lost all subsequent packets will be held in the network stack and unavailable to the application until the lost packet is resent. Server resource use, all that buffering and connection state tracking takes memory and CPU.

Extra network chatter, UDP can deliver a small request and response in two packets. TCP is likely to send substantially more. Peter Green Peter Green In addition to operating system permission issues wrapping your new protocol in UDP also helps it go through NATs and similar. By continuing to use Wowza websites without changing your browser settings, you are agreeing to our use of cookies. I agree Learn more about our cookies policy. Performs basic error checking and discards erroneous packets without attempting error recovery.

TCP is heavy. It needs three packets to set up a socket connection before data can be sent. UDP is lightweight.



0コメント

  • 1000 / 1000