{"id":10567,"date":"2015-10-08T09:15:18","date_gmt":"2015-10-08T16:15:18","guid":{"rendered":"https:\/\/blog.digilentinc.com\/?p=10567"},"modified":"2024-12-28T11:46:35","modified_gmt":"2024-12-28T19:46:35","slug":"udp-vs-tcp","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/udp-vs-tcp\/","title":{"rendered":"TCP vs UDP: Header Size, Packet Size, and Differences"},"content":{"rendered":"<p>Communication protocols are (in my opinion) one of the most difficult things to get a handle on when working on networking projects. Well, today we&#8217;re going to go over the differences between two common types of protocols (TCP and UDP).\u00a0TCP (transmission control protocol) is the most standard protocol used. This is largely because, while slower then UDP, TCP is more\u00a0reliable and allows for error-correction. This makes it ideal for loading websites and other sensitive things. UDP (user datagram protocol) is light-weight and fast, and that makes it great for things like audio and video files. If you&#8217;ve ever checked out the <em>DEIPck<\/em> and <em>DEWFck<\/em> examples in MPIDE, half the examples are UDP related, and the other half are TCP related, so if you want to test out the two, you can easily do so.<\/p>\n<p><a href=\"https:\/\/digilent.com\/blog\/udp-vs-tcp\/udpvstcp\/\" rel=\"attachment wp-att-10624\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-10624 aligncenter\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/10\/UDPvsTCp.png\" alt=\"UDPvsTCp\" width=\"594\" height=\"473\" data-wp-pid=\"10624\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2><\/h2>\n<h2>Connection<\/h2>\n<p>How TCP and UDP handle connections is one of the main difference&#8217;s between the two. TCP requires a connection to work. Known as a &#8220;handshake&#8221;, the client and the server will communicate. UDP is connection-less, meaning a connection is not necessarily established before data is sent. Below is a comic I found in the office that represents how UDP connection works (more or less).<\/p>\n<figure id=\"attachment_10630\" aria-describedby=\"caption-attachment-10630\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/udp-vs-tcp\/compare-2\/\" rel=\"attachment wp-att-10630\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-10630\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/10\/compare-600x248.png\" alt=\"TCP vs UDP connection (more or less)\" width=\"600\" height=\"248\" data-wp-pid=\"10630\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/10\/compare-600x248.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/10\/compare-1024x423.png 1024w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/10\/compare-800x331.png 800w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/10\/compare.png 1376w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-10630\" class=\"wp-caption-text\">TCP vs UDP connection (more or less).<\/figcaption><\/figure>\n<h2>Speed<\/h2>\n<p>TCP is slower than UDP, but that isn&#8217;t necessarily a bad thing. TCP has a back and forth of information going on, and makes sure that the recieving computer isn&#8217;t being overloaded with information. UDP is sending as many packets of information as possible outwards. Taking those two things into account, you can see the pros and cons between the two. UDP is ideal for when you want quick updates (like video or audio files), and TCP is great for when you want sensitive projects (websites and file transfers).<\/p>\n<h2>Weight and Header Size<\/h2>\n<p>Weight is what the protocol is doing to actually work. TCP has a lot of things going on at once, UDP is sending out messages without being held down by things such as recovery options. This leads into the purpose of Header Size. The standard size of a TCP packet has a minimum size of 20 bytes, and a maximum of 60 bytes. The UDP packet consists of only 8 bytes for each packet.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_10644\" aria-describedby=\"caption-attachment-10644\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/udp-vs-tcp\/header-4\/\" rel=\"attachment wp-att-10644\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-10644\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/10\/header-600x336.jpg\" alt=\"Credit to Microchip\" width=\"600\" height=\"336\" data-wp-pid=\"10644\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/10\/header-600x336.jpg 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/10\/header-800x448.jpg 800w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/10\/header.jpg 998w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-10644\" class=\"wp-caption-text\">Image from<a href=\"http:\/\/microchip.wikidot.com\/tcpip:tcp-vs-udp\" target=\"_blank\" rel=\"noopener\">\u00a0Microchip<\/a>.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h3>Review<\/h3>\n<p>While there are more differences between UDP and TCP connections, the differences given in this blog are the most important ones and give the everyday user enough information on how choosing with protocol type would be best for their project!<\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-10567 jlk' data-task='like' data-post_id='10567' data-nonce='e5335d04d0' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-10567 lc'>+6<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-10567 jlk' data-task='unlike' data-post_id='10567' data-nonce='e5335d04d0' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-10567 unlc'>-9<\/span><\/a><\/div><\/div> <div class='status-10567 status align-left'><\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>What are the differences between UDP and TCP?<\/p>\n","protected":false},"author":29,"featured_media":10630,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,4322,1563],"tags":[],"ppma_author":[4478],"class_list":["post-10567","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-expansion-modules","category-accessories","category-guide"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/10\/compare.png","authors":[{"term_id":4478,"user_id":29,"is_guest":0,"slug":"josh-woldstad","display_name":"Josh","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/b4b62729a3daba9bb76117db7130e81e?s=96&d=mm&r=g","author_category":"","user_url":"","last_name":"Woldstad","last_name_2":"","first_name":"Josh","first_name_2":"","job_title":"","description":"I love Coding!"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/10567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=10567"}],"version-history":[{"count":1,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/10567\/revisions"}],"predecessor-version":[{"id":31168,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/10567\/revisions\/31168"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/10630"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=10567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=10567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=10567"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=10567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}