{"id":1403,"date":"2017-11-21T06:13:32","date_gmt":"2017-11-21T06:13:32","guid":{"rendered":"http:\/\/www.notebookbattery.co.nz\/blog\/?p=1403"},"modified":"2017-11-21T06:14:06","modified_gmt":"2017-11-21T06:14:06","slug":"what%e2%80%99s-the-difference-between-tcp-and-udp","status":"publish","type":"post","link":"http:\/\/www.notebookbattery.co.nz\/blog\/uncategorized\/what%e2%80%99s-the-difference-between-tcp-and-udp.html","title":{"rendered":"What\u2019s the Difference Between TCP and UDP?"},"content":{"rendered":"<p>You\u2019ve probably seen references to TCP and UDP when setting up port-forwarding on a router or when configuring firewall software. These two protocols are used for different types of data.<\/p>\n<p>TCP\/IP is a suite of protocols used by devices to communicate over the Internet and most local networks. It is named after two of it\u2019s original protocols\u2014the Transmission Control Protocol (TCP) and the Internet Protocol (IP). TCP provides apps a way to deliver (and receive) an ordered and error-checked stream of information packets over the network. The User Datagram Protocol (UDP) is used by apps to deliver a faster stream of information by doing away with error-checking. When configuring some network hardware or software, you may need to know the difference.<\/p>\n<p>What They Have In Common<\/p>\n<p>Both TCP and UDP are protocols used for sending bits of data\u2014known as packets\u2014over the Internet. Both protocols build on top of the IP protocol. In other words, whether you\u2019re sending a packet via TCP or UDP, that packet is sent to an IP address. These packets are treated similarly, as they\u2019re forwarded from your computer to intermediary routers and on to the destination.<\/p>\n<p>TCP and UDP aren\u2019t the only protocols that work on top of IP. However, they are the most widely used.<\/p>\n<p>How TCP Works<\/p>\n<p>TCP is the most commonly used protocol on the Internet.<\/p>\n<p>When you request a web page in your browser, your computer sends TCP packets to the web server\u2019s address, asking it to send the web page back to you. The web server responds by sending a stream of TCP packets, which your web browser stitches together to form the web page. When you click a link, sign in, post a comment, or do anything else, your web browser sends TCP packets to the server and the server sends TCP packets back.<\/p>\n<p>TCP is all about reliability\u2014packets sent with TCP are tracked so no data is lost or corrupted in transit. This is why file downloads don\u2019t become corrupted even if there are network hiccups. Of course, if the recipient is completely offline, your computer will give up and you\u2019ll see an error message saying it can\u2019t communicate with the remote host.<\/p>\n<p>TCP achieves this in two ways. First, it orders packets by numbering them. Second, it error-checks by having the recipient send a response back to the sender saying that it has received the message. If the sender doesn\u2019t get a correct response, it can resend the packets to ensure the recipient receives them correctly.<\/p>\n<p>How UDP Works<\/p>\n<p>The UDP protocol works similarly to TCP, but it throws out all the error-checking stuff. All the back-and-forth communication introduce latency, slowing things down.<\/p>\n<p>When an app uses UDP, packets are just sent to the recipient. The sender doesn\u2019t wait to make sure the recipient received the packet\u2014it just continues sending the next packets. If the recipient misses a few UDP packets here and there, they are just lost\u2014the sender won\u2019t resend them. Losing all this overhead means the devices can communicate more quickly.<\/p>\n<p>UDP is used when speed is desirable and error correction isn\u2019t necessary. For example, UDP is frequently used for live broadcasts and online games.<\/p>\n<p>For example, let\u2019s say you\u2019re watching a live video stream, which are often broadcast using UDP instead of TCP. The server just sends a constant stream of UDP packets to computers watching. If you lose your connection for a few seconds, the video may freeze or get jumpy for a moment and then skip to the current bit of the broadcast. If you experience minor packet-loss, the video or audio may be distorted for a moment as the video continues to play without the missing data.<\/p>\n<p>This works similarly in online games. If you miss some UDP packets, player characters may appear to teleport across the map as you receive the newer UDP packets. There\u2019s no point in requesting the old packets if you missed them, as the game is continuing without you. All that matters is what\u2019s happening right now on the game server\u2014not what happened a few seconds ago. Ditching TCP\u2019s error correction helps speed up the game connection and reduce latency.<\/p>\n<p>So What?<\/p>\n<p>Whether an application uses TCP or UDP is up to its developer, and the choice depends on what an application needs. Most apps need the error-correction and robustness of TCP, but some applications need the speed and reduced overhead of UDP.<\/p>\n<p>Unless you\u2019re a network administrator or software developer, this shouldn\u2019t doesn\u2019t affect you too much. If you\u2019re configuring your router or firewall software and you\u2019re not sure whether an application uses TCP or UDP, you can generally select the \u201cBoth\u201d option to have your router or firewall apply the same rule to both TCP and UDP traffic.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You\u2019ve probably seen references to TCP and UDP when setting up port-forwarding on a router or when configuring firewall software. These two protocols are used for different types of data. TCP\/IP is a suite of protocols used by devices to communicate over the Internet and most local networks. It is named after two of it\u2019s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.notebookbattery.co.nz\/blog\/wp-json\/wp\/v2\/posts\/1403"}],"collection":[{"href":"http:\/\/www.notebookbattery.co.nz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.notebookbattery.co.nz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.notebookbattery.co.nz\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.notebookbattery.co.nz\/blog\/wp-json\/wp\/v2\/comments?post=1403"}],"version-history":[{"count":0,"href":"http:\/\/www.notebookbattery.co.nz\/blog\/wp-json\/wp\/v2\/posts\/1403\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.notebookbattery.co.nz\/blog\/wp-json\/wp\/v2\/media?parent=1403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.notebookbattery.co.nz\/blog\/wp-json\/wp\/v2\/categories?post=1403"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.notebookbattery.co.nz\/blog\/wp-json\/wp\/v2\/tags?post=1403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}