The "unreliability" of UDP is a formalism. Transmission isn't absolutely guaranteed. As a practical matter, they almost always get through. They just aren't acknowledged and retried after a timeout. Really huge. There is no appreciable UDP overhead. Most importantly, you can easily supplement UDP with some reliable delivery hand-shaking that's less overhead than TCP. UDP is useful for broadcasting information in a publish-subscribe kind of application. Any other kind of one-way "significant event" or "logging" activity can be handled nicely with UDP packets.
You want to send notification without constructing an entire socket. You don't expect any response from the various listeners. System "heartbeat" or "I'm alive" messages are a good choice, also. Missing one isn't a crisis. Missing half a dozen in a row is. The product is a database server, so reliability is critical.
We have to handle all of the issues imposed by UDP packet loss, packet doubling, packet order, etc. There are rarely any problems, but they do sometimes occur and so must be handled. The benefit to supporting UDP is that we are able to customize it a bit to our own usage and tweak a bit more performance out of it. Every network is going to be different, but the UDP communication protocol is generally a little bit faster for us.
The skeptical reader will rightly question whether we implemented everything correctly. Plus, what can you expect from a guy with a 2 digit rep? Nonetheless, I just now ran a test out of curiosity. I set the number of records to return with each individual client request to be 1, 10, and then three test runs with each protocol. The server was only two hops away over a Mbit LAN.
The total times in milliseconds were as follows for this particular test:. There are already many good answers here, but I would like to add one very important factor as well as a summary.
UDP can achieve a much higher throughput with the correct tuning because it does not employ congestion control. Congestion control in TCP is very very important. It controls the rate and throughput of the connection in order to minimize network congestion by trying to estimate the current capacity of the connection. Even when packets are sent over very reliable links, such as in the core network, routers have limited size buffers. These buffers fill up to their capacity and packets are then dropped, and TCP notices this drop through the lack of a received acknowledgement, thereby throttling the speed of the connection to the estimation of the capacity.
TCP also employs something called slow start , but the throughput actually the congestion window is slowly increased until packets are dropped, and is then lowered and slowly increased again until packets are dropped etc. This causes the TCP throughput to fluctuate. You can see this clearly when you download a large file. Because UDP is not using congestion control it can be both faster and experience less delay because it will not seek to maximize the buffers up to the dropping point, i.
UDP packets are spending less time in buffers and get there faster with less delay. UDP is still vulnerable to congestion and packet drops though, so your application has to be prepared to handle these complications somehow, likely using retransmission or error correcting codes. In summary, UDP can be used for every type of application that TCP can, as long as you also implement a proper retransmission mechanism.
UDP can be very fast, has less delay, is not affected by congestion on a connection basis, transmits fixed sized datagrams, and can be used for multicasting. UDP is a connection-less protocol and is used in protocols like SNMP and DNS in which data packets arriving out of order is acceptable and immediate transmission of the data packet matters. It is used in SNMP since network management must often be done when the network is in stress i.
It is used in DNS since it does not involve connection establishment, thereby avoiding connection establishment delays. UDP does have less overhead and is good for doing things like streaming real time data like audio or video, or in any case where it is ok if data is lost.
This answer is so good I'm just going to quote it as-is. TCP has head-of-queue blocking, as it guarantees complete and in-order delivery, so when a packet gets lost in transit, it has to wait for a retransmit of the missing packet, whereas UDP delivers packets to the application as they arrive, including duplicates and without any guarantee that a packet arrives at all or which order they arrive it really is essentially IP with port numbers and an optional payload checksum added , but that is fine for telephony, for example, where it usually simply doesn't matter when a few milliseconds of audio are missing, but delay is very annoying, so you don't bother with retransmits, you just drop any duplicates, sort reordered packets into the right order for a few hundred milliseconds of jitter buffer, and if packets don't show up in time or at all, they are simply skipped, possible interpolated where supported by the codec.
Also, a major part of TCP is flow control, to make sure you get as much througput as possible, but without overloading the network which is kinda redundant, as an overloaded network will drop your packets, which means you'd have to do retransmits, which hurts throughput , UDP doesn't have any of that - which makes sense for applications like telephony, as telephony with a given codec needs a certain amount of bandwidth, you can not "slow it down", and additional bandwidth also doesn't make the call go faster.
If your request is smaller than a typical MTU and the repsonse probably is, too, you can be done in one roundtrip, with no need to keep any state at the server, and flow control als ordering and all that probably isn't particularly useful for such uses either. And then, you can use UDP to build your own TCP replacements, of course, but it's probably not a good idea without some deep understanding of network dynamics, modern TCP algorithms are pretty sophisticated. UDP has lower overhead, as stated already is good for streaming things like video and audio where it is better to just lose a packet then try to resend and catch up.
There are no guarantees on TCP delivery, you are simply supposed to be told if the socket disconnected or basically if the data is not going to arrive. Otherwise it gets there when it gets there. A big thing that people forget is that udp is packet based, and tcp is bytestream based, there is no guarantee that the "tcp packet" you sent is the packet that shows up on the other end, it can be dissected into as many packets as the routers and stacks desire.
So your software has the additional overhead of parsing bytes back into usable chunks of data, that can take a fair amount of overhead.
UDP can be out of order so you have to number your packets or use some other mechanism to re-order them if you care to do so. But if you get that udp packet it arrives with all the same bytes in the same order as it left, no changes.
So the term udp packet makes sense but tcp packet doesnt necessarily. TCP has its own re-try and ordering mechanism that is hidden from your application, you can re-invent that with UDP to tailor it to your needs. UDP is far easier to write code for on both ends, basically because you do not have to make and maintain the point to point connections. My question is typically where are the situations where you would want the TCP overhead?
And if you take shortcuts like assuming a tcp "packet" received is the complete packet that was sent, are you better off? Open the Lifesize web or desktop app to get started. Lifesize supports a wide range of devices and user preferences, with apps for PC and Mac computers, Android and iOS phones and tablets, and a browser-based web app for any devices unable to download applications.
To place calls to other devices through a firewall, you need to configure your firewall to allow incoming and outgoing traffic to the Lifesize system through the reserved TCP or UDP ports. By default, Lifesize systems communicate through ports in the range — for video, voice, presentations, and camera control.
While Lifesize encourages users to stick to this range, you do have the ability to restrict the number of UDP ports that are available. If the range you choose is not a subset of the default, be sure it begins with a port number greater than Additionally, the range has to start with an even number and end with an odd number to include an even number of total ports.
For example, if a range starts at , set the lower end to and the upper end to to allocate ports the required minimum. Be sure to click Save on your updates. With UDP enabled on Lifesize, users can make the most of their video calls and conferencing, thanks to 30 frames of video or more per second. Not only does UDP avoid the transport traps and clogged networks common with TCP, but it boasts exceptional speed for all your streaming needs.
And by enabling UDP for Lifesize, companies enjoy enhanced workflows, less overhead, and fewer interruptions all around, making this pairing a true win-win. While some workers will gradually find their way back to in-person office or otherwise workplace settings, this is just the on-ramp to the highway of working from anywhere for many others. Skip to content. What is TCP? 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. For example, it may be better to use UDP in an application sending data from a fast acquisition where it is acceptable to lose some data points. You can also use UDP to broadcast to any machine s listening to the server.
It is frequently stated that UDP is unreliable, which makes it sound as though it has inherent non-delivery. This is false: what it lacks is an inbuilt retry mechanism, leaving it to the upstairs protocols compare DNS and streaming for approaches. Under some very nasty real-world conditions with very high packet loss, you also find that UDP gets through where TCP often doesn't. They each do one job well.
Because of the separation of comms into discrete tasks, testing and debugging is much easier. Sign up to join this community. The best answers are voted up and rise to the top.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Asked 5 years, 5 months ago. Active 3 years, 11 months ago. Viewed 13k times. Improve this question. Oliver K Oliver K 1 1 gold badge 5 5 silver badges 11 11 bronze badges. Network engineers don't chose protocols. Application developers do.
A similar question was asked and answered here.
0コメント