Hello guys! Today I am going to start a series of Networking Basics and I will be covering absolute basic networking in it and I am sure that at the end of this series you will get a basic idea of how Internet works. So lets head over to TCP/UDP Protocols. I hope coughs I know you will enjoy. Let us think of a situation where John (computer A) have a document (a file in computer) that he wants to send to Katie (computer B). John puts the document in an envelope and drops it in at a post office so post office will deliver it to Katie. Suppose that the document is 20 pages long, and for some reason, the only available envelope can only fit 1 page. Now what to do? Well, he can put one page of the document in each envelope, and send the mail 20 times. Now, those mails can be delivered to Katie. And yeah when Katie receives it, there’s no guarantee that she will receive the pages of the documents in the order they were sent. So then we have to write on the envelope that it contains page 1 of 20, page 2 of 20 and so on. Therefore, when Katie receives it, she can rearrange the pages in the correct order.
How is it related to data transfer? When you have a file that you need to send, it is then broken into smaller parts, put an envelope on it and send it to your ISP (Internet Service Provider). Just like a regular mail, the envelope contains the address where the recipient should be as well as the sequence number. The envelope along with the data that is ready to be sent is called a Datagram.
User Datagram Protocol (UDP)
So John would have to send 20 packets and Katie will receive 20 datagrams. Katie will know the sequence of the envelopes and all he has to do is to open the envelope and put the page inside it in the same order as marked on the envelope. Similarly, the recipient computer will get all 20 datagrams and it will be able to reconstruct the file correctly. This methodology is called User Datagram Protocol (UDP) Well, there is a problem with implementation of this methodology.Let’s suppose that in the example above, Katie receives all mails, but not envelope number 12. She can then tell John to re-send envelope 12, but then how would Katie know when to request? It is fairly possible that as soon as Katie sends request to re-send envelope 12, the postman delivers the missing envelope 12. There can be lots of reasons why envelope 12 may be delayed. So we need a better way to make sure that Katie receives all the data properly. Well in computer networking, UDP is not the only protocol to send data among computers.
Transmission Control Protocol (TCP)
For example, John can send a mail to Katie without Katie expecting it. And once he sends the mail, he will just have to assume that it is delivered, unless Katie comes back requesting to re-send a particular envelope she didn’t receive. Unlike UDP, TCP protocol requires that you have to establish a connection first. So if John is to send mail using TCP protocol, he has to first establish a connection with Katie. Once a connection is established, John then sends the first envelope and waits for Katie to receive it. Once John is assured that envelope 1 is safely received, John can send envelope 2. This process repeats until Katie receives all sent packets. Now unlike in UDP, using TCP protocol Katie is guaranteed to have all the envelopes in the correct order because John will send one envelop and waits for Katie to receive and then sends the next envelope and so on.
So here is a comparison of both Protocols