The User Datagram Protocol (UDP)

Navigation menu

List of TCP and UDP port numbers
Port number may use the protocol conditionally only, or alternate its use fallback if the other protocol fails. Framework web server []. Pylons project Pyramid Default Pylons Pyramid web service port. Port 0 is reserved, but is a permissible source port value if the sending process does not expect messages in response. In cases where an application involves two, known hosts, UDP will likely only offer marginal performance benefits for substantially increased costs of code complexity. A UDP datagram header contains four fields of two bytes each:

Latest Articles

UDP (User Datagram Protocol)

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 lower 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 lower delay. UDP is still vulnerable to congestion and packet drops though, so your application have to be prepared to handle these less losses 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, with low delay, are not affected by congestion on a connection basis, transmits fixed sized datagrams and can be used for multicasting. 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?

Speed is of utmost importance and it doesn't really matter if updates are missed since each update contains the complete current state of what the player can see. In some cases, which others have highlighted, guaranteed arrival of packets isn't important, and hence using UDP is fine.

The key question was related to "what kind of situations would UDP be the better choice [over tcp]". There are many great answers above but what is lacking is any formal, objective assessment of the impact of transport uncertainty upon TCP performance. With the massive growth of mobile applications, and the "occasionally connected" or "occasionally disconnected" paradigms that go with them, there are certainly situations where the overhead of TCP's attempts to maintain a connection when connections are hard to come by leads to a strong case for UDP and its "message oriented" nature.

You get this in regional and rural areas of many western countries UDP can be used when an app cares more about "real-time" data instead of exact data replication. Maybe you here a "glitch" in the voice quality, but the main purpose is that you get the message and not that it is recreated perfectly on the other side. UDP is also used in situations where the expense of creating a connection and syncing with TCP outweighs the payload. DNS queries are a perfect example. One packet out, one packet back, per query.

If using TCP this would be much more intensive. If you dont' get the DNS response back, you just retry. UDP is often harder in that you must write your program in such a way that it is not dependent on the accuracy of the packets.

It's not always clear cut. However, if you need guaranteed delivery of packets with no loss and in the right sequence then TCP is probably what you want. On the other hand UDP is appropriate for transmitting short packets of information where the sequence of the information is less important or where the data can fit into a single packet. Other times, it's appropriate when you are sending sequenced data but if some of it goes missing you're not too concerned e. Some protocols are more complex because what's needed are some but not all of the features of TCP, but more than what UDP provides.

That's where the application layer has to implement the additional functionality. In those cases, UDP is also appropriate e. Internet radio, order is important but not every packet needs to get through. Look at section You want to use UDP over TCP in the cases where losing some of the data along the way will not completely ruin the data being transmitted. A lot of its uses are in real-time applications, such as gaming i. We have web service that has thousands of winforms client in as many PCs.

The PCs have no connection with DB backend, all access is via the web service. So we decided to develop a central logging server that listens on a UDP port and all the clients sends an xml error log packet using log4net UDP appender that gets dumped to a DB table upon received. Since we don't really care if a few error logs are missed and with thousands of client it is fast with a dedicated logging service not loading the main web service.

For example in video games typically don't need a reliable network but the speed is the most important and using UDP for games has the advantage of reducing network delay. The problem is that if TCP isn't working for some reason, because the connection is too laggy or congested, changing the application to use UDP is unlikely to help. A bad connection is bad for UDP too. TCP already does a very good job of minimizing congestion.

The only case I can think of where UDP is required is for broadcast protocols. In cases where an application involves two, known hosts, UDP will likely only offer marginal performance benefits for substantially increased costs of code complexity. Only use UDP if you really know what you are doing.

UDP is in extremely rare cases today, but the number of even very experienced experts who would try to stick it everywhere seems to be out of proportion. Perhaps they enjoy implementing error-handling and connection maintenance code themselves. TCP should be expected to be much faster with modern network interface cards due to what's known as checksum imprint.

Surprisingly, at fast connection speeds such as 1Gbps computing a checksum would be a big load for a CPU so it is offloaded to NIC hardware that recognizes TCP packets for imprint, and it won't offer you the same service.

Video chatting is an example of UDP you can check it by wireshark network capture during any video chatting.. Deep LF Jeff L 3, 3 17 As well as suffering from possible packet loss, UDP does not guarantee that you'll only receive the packet once. If you have convoluted or badly configured networks, you can receive the same packet multiple times.

Although UDP provides integrity verification via checksum of the header and payload, [2] it provides no guarantees to the upper layer protocol for message delivery and the UDP layer retains no state of UDP messages once sent.

Applications can use datagram sockets to establish host-to-host communications. An application binds a socket to its endpoint of data transmission, which is a combination of an IP address and a port. In this way, UDP provides application multiplexing.

A port is a software structure that is identified by the port number , a 16 bit integer value, allowing for port numbers between 0 and Port 0 is reserved, but is a permissible source port value if the sending process does not expect messages in response. On Unix -like operating systems , using one of these ports requires superuser operating permission. Port numbers through are the registered ports used for IANA-registered services. Ports through are dynamic ports that are not officially designated for any specific service, and may be used for any purpose.

These may also be used as ephemeral ports , which software running on the host may use to dynamically create communications endpoints as needed. The UDP header consists of 4 fields, each of which is 2 bytes 16 bits. In IPv6 only the source port is optional see below. Checksum is the bit one's complement of the one's complement sum of a pseudo header of information from the IP header, the UDP header, and the data, padded with zero octets at the end if necessary to make a multiple of two octets.

In other words, all bit words are summed using one's complement arithmetic. Add the bit values up. On each addition, if a carry-out 17th bit is produced, swing that 17th carry bit around and add it to the least significant bit of the running total. If the checksum calculation results in the value zero all 16 bits 0 it should be sent as the one's complement all 1s. The difference between IPv4 and IPv6 is in the data used to compute the checksum.

When UDP runs over IPv4, the checksum is computed using a "pseudo header" [9] that contains some of the same information from the real IPv4 header. The pseudo header is not the real IPv4 header used to send an IP packet, it is used only for the checksum calculation.

The source and destination addresses are those in the IPv4 header. The field data stands for the transmitted data. If this is your first time visiting TechTarget, welcome!

Sorry for the circumstances under which we're meeting. Here's where you can go from here:. VPN services, enterprises choosing between the technologies should consider factors like Companies are approaching network infrastructure upgrades with SD-WAN deployment, but a new survey shows they're weighing issues Figuring out how to calculate bandwidth requirements is vital to ensuring your network runs smoothly, and it's best to get the Learn about the different types of noise in data communication -- including thermal, intermodulation, cross-talk, impulse and This slideshow highlights the best VPNs used in enterprise wide-area networks WANs and offers principles for designing and Large-room video conferencing systems are seeing renewed growth, as corporate mandates, employee demand and productivity Twilio has acquired startup Ytica to improve the native analytics and workforce optimization tools of its Twilio Flex cloud Tsahi Levent-Levi explains how IAM is at the heart of an organization's security strategy.

To develop a strong IAM strategy, it's important to stay on top of Mobile device management can be a challenge for IT admins.

TCP and UDP Ports Explained

Both TCP and UDP are protocols used for sending bits of data—known as packets—over the Internet. Both protocols build on top of the IP protocol. In other words, whether you’re sending a packet via TCP or UDP, that packet is sent to an IP address. These packets are treated similarly, as they’re forwarded from your computer to intermediary routers and . UDP (User Datagram Protocol) is an alternative communications protocol to Transmission Control Protocol used primarily for establishing low-latency and loss-tolerating connections between applications on the internet. The UDP length field is the length of the UDP header and data. The field data stands for the transmitted data. UDP checksum computation is optional for IPv4. If a checksum is not used it should be set to the value zero. IPv6 Pseudo Header. When UDP runs over IPv6, the checksum is mandatory.