Transport Layer Protocol

Both TCP and UDP are protocols at the Transport layer (of both OSI and TCP/IP model) but why we need both of them? The answer is:

+ TCP is slower but reliable
+ UDP is faster but unreliable

In most cases we will want to be reliable in web accessing, email communicating, file uploading… as we don’t expect a few corrupted packets would destroy our whole work. With TCP, these corrupted packets will be resent or repaired to make sure everything is correct. Yes, TCP is really nice to ensure your work is accurate!

But with a price…

To guarantee the sending segments is free of error, TCP adds some bits for tracking and checking purpose so that the other end can verify and ask for missing pieces of segments. As a result of this, the segments become larger, consume more bandwidth and CPU resources to proceed.

Although UDP cannot guarantee everything is accurate like TCP but UDP is faster than TCP because it does not require additional bits for tracking and checking purposes. So which tasks need speed? Video (streaming) and audio are ideal for this task because they are considered real-time applications. Suppose you are talking to your friend, surely you want your voice to reach your friend without any delay. It would be very weird if your friend can only hear your voice after a few seconds.

Three-way HandShake for TCP

Suppose host A wants to start communicating with host B using TCP. Before they can send real data, a three-way handshake must be established first. Let’s see how this process takes place:

TCP_Three_way_handshake.jpg

1. First host A will send a SYN message (a TCP segment with SYN flag set to 1, SYN is short for SYNchronize) to indicate it wants to setup a connection with host B. This message includes a sequence (SEQ) number for tracking purpose. This sequence number can be any 32-bit number (range from 0 to 232) so we use “x” to represent it.

2. After receiving SYN message from host A, host B replies with SYN-ACK message (some books may call it “SYN/ACK” or “SYN, ACK” message. ACK is short for ACKnowledge). This message includes a SYN sequence number and an ACK number:
+ SYN sequence number (let’s called it “y”) is a random number and does not have any relationship with Host A’s SYN SEQ number.
+ ACK number is the next number of Host A’s SYN sequence number it received, so we represent it with “x+1”. It means “I received your part. Now send me the next part (x + 1)”.

The SYN-ACK message indicates host B accepts to talk to host A (via ACK part). And ask if host A still wants to talk to it as well (via SYN part).

3. After Host A received the SYN-ACK message from host B, it sends an ACK message with ACK number “y+1” to host B. This confirms host A still wants to talk to host B.

If you are still unclear about this process, let’s assign: x = 1 and y = 50:

TCP four-way termination (to end the communication)

TCP_Four_way_Termination.jpg

Suppose Host A wants to end the connection to host B, Host A will send a FIN message (a TCP segment with FIN flag set to 1), FIN is short for FINISH. The purpose of FIN message is to enable TCP to gracefully terminate an established connection. Host A then enters a state called the FIN-WAIT state. In FIN-WAIT state, Host A continues to receive TCP segments from Host B and proceed the segments already in the queue, but Host A will not send any additional data.

Device B will confirm it has received the FIN message with an ACK (with sequence x+1). From this point, Host B will no longer accept data from Host A. Host B can continue sending data to Host A. If Host B does not have any more data to send, it will also terminate the connection by sending a FIN message. Host A will then ACK that segment and terminate the connection.

TCP requires establishing and terminate the connection before and after exchanging real traffic so it is called a connection-oriented protocol. UDP does not support these features so it is called a connectionless protocol.

More formally, these terms can be defined as follows:
Connection-oriented protocol: requires a logical connection to be established between the two processes before data is exchanged
Connectionless protocol: allow data to be exchanged without setting up a link between processes

Comments

  1. this g

    Howdy would you mind letting me know which hosting company you’re using?
    I’ve loaded your blog in 3 completely different web browsers and I must say this blog loads a lot quicker then most.
    Can you suggest a good internet hosting provider at a fair price?

    Kudos, I appreciate it!

  2. g than

    Hmm is anyone else experiencing problems with the images on this blog loading?
    I’m trying to find out if its a problem on my end or if it’s the
    blog. Any feed-back would be greatly appreciated.

  3. http://www.ergoplus.it

    Hey there! I know this is somewhat off topic but I was wondering
    which blog platform are you using for this site? I’m getting
    tired of WordPress because I’ve had issues with hackers and I’m looking at options for another platform.

    I would be great if you could point me in the direction of a good
    platform.

  4. cbd oil that works 2020

    Hello there, just became alert to your blog through Google, and found that it is truly informative.
    I am gonna watch out for brussels. I will be
    grateful if you continue this in future. Numerous people will be benefited
    from your writing. Cheers!

  5. Ethan

    Hello! I simply wish to offer you a huge thumbs up for the excellent information you
    have here on this post. I will be returning to your site for more soon.

  6. website hosting

    I believe everything posted was actually very reasonable.
    But, think about this, suppose you typed a catchier title?
    I ain’t suggesting your content is not solid, however suppose you added a headline that grabbed
    people’s attention? I mean Transport Layer Protocol is kinda
    boring. You might peek at Yahoo’s front page and note how they create article
    titles to get viewers interested. You might add a related video or a picture or two to get people
    excited about everything’ve got to say. Just my opinion, it might make
    your website a little livelier.

  7. web host

    Aw, this was an extremely nice post. Finding the time and actual effort to produce
    a very good article… but what can I say… I hesitate a whole lot and don’t seem to get anything done.

  8. website host

    It’s truly very complex in this active life to listen news on TV, therefore I simply use world wide web for that reason, and get the most recent information.

  9. 유흥

    Even the things you don’t like about yourself make you interesting.
    You are the reason I am smiling today.
    You 유흥 me float up like I’m on millions of bubbles (We got this one from one of our kids after he got a new coat.)
    I enjoy spending time with you.

  10. best hosting

    This is really interesting, You are a very skilled blogger.

    I’ve joined your rss feed and look forward to seeking more of your great post.
    Also, I’ve shared your web site in my social networks!

  11. website hosting companies

    I’ve been browsing online more than 3 hours today,
    yet I never found any interesting article like yours.
    It’s pretty worth enough for me. In my view, if all
    site owners and bloggers made good content as you did, the internet will
    be a lot more useful than ever before.

  12. web hosting reviews

    Hello there, I believe your site may be having browser compatibility issues.

    Whenever I look at your website in Safari,
    it looks fine however, if opening in IE, it’s got some overlapping issues.
    I simply wanted to give you a quick heads up! Apart from that, great blog!

  13. cheap flights

    I’m not sure why but this site is loading incredibly
    slow for me. Is anyone else having this issue or is it a issue on my end?
    I’ll check back later on and see if the problem still exists.

  14. cheap flights

    I am really enjoying the theme/design of your site.
    Do you ever run into any browser compatibility problems?
    A handful of my blog audience have complained about my website not working correctly in Explorer but
    looks great in Safari. Do you have any tips to help fix this issue?
    cheap flights 32hvAj4

  15. cheap flights

    I do not know whether it’s just me or if everybody else experiencing issues with your website.
    It appears as though some of the written text in your content are running off the screen. Can someone else please comment and let me know if this is happening to them too?
    This may be a issue with my internet browser because I’ve had this
    happen previously. Cheers 3aN8IMa cheap flights

  16. cheap flights

    Excellent post. Keep posting such kind of information on your
    site. Im really impressed by your blog.
    Hello there, You have performed a great job. I’ll certainly digg it and personally suggest to my friends.

    I am confident they will be benefited from this website. cheap flights 3aN8IMa

  17. cheap flights

    I am not sure where you’re getting your info, but good topic.
    I needs to spend some time learning much more or understanding more.
    Thanks for magnificent information I was looking for this information for my mission.

  18. w88club

    959234 613143definitely like your internet site but you need to have to check the spelling on several of your posts. Several of them are rife with spelling problems and I locate it extremely troublesome to tell the truth nevertheless I will undoubtedly come back once again. 595624

  19. mơ thấy tiền đánh con gì

    560864 228917Your talent is really appreciated!! Thank you. You saved me a great deal of frustration. I switched from Joomla to Drupal to the WordPress platform and Ive fully embraced WordPress. Its so a lot easier and easier to tweak. Anyway, thanks once more. Awesome domain! 5606

Leave a Reply

Your email address will not be published.