-->

Contact Form

 

Protocols of Transport Layer























USER DATAGRAM PROTOCOL:

UDP is a transport layer protocol which basically ensures fast speed but compromises with the Reliability. When I say reliability, I mean that it enables noise to enter and sends the data including the bugs at the fastest rate possible.
Now I know that you might be thinking: "Hey! What is the whole point of transmitting a bugged data at high speed???"
Well here's a scenario Mr. "Smarty Pants",
Consider you're talking to your mommy…"Why mommy? I could also talk to my girlfriend or boyfriend?", you ask ... Well that’s because you probably don't have a girlfriend or a boyfriend and therefore you're reading this blog-"NERD!".
Anyways while talking on a phone we don’t need any reliability check. Of coarse I don’t mean completely unreliable service:-

You: " Hello… "
Mommy: " Hey! Where are you? When are you coming for dinner …"
You: " I am at …. Don't …. Can I bring …. too"
Mommy: " Wait! I'm getting a lot of disturbances. Let me call you back."

Your Mommy calls you again and everything goes well…..

If there is some disturbance in the call, you can always ask the speaker to repeat his/her sentences.
So How does UDP ensures speed?
Well You probably should know that in either of the network models that we follow currently, the UDP or TCP being a transport layer protocol, adds a header to each segments while transporting it to the receiver's host, which later on is "stripped" off by it’s peer node(At Receiver's end ). "Hehehe, stripped!" . Anyways this header is added to the data segment. Hence it’s own memory size increases the size of the data segment itself. By reducing this memory size of this header and setting it to a minimum, we are basically increasing the speed of the data transmission.
The header's format looks like this: - 


 Here Length is the total length of a packet including the Header size.
Checksum is a method to check if there is some error in the segment. Basically it is an algorithm that (in a way)compares the data in segment at both ends(Sender and Receiver).
Now, This is what a UDP Header looks like :                        
                                                                                                   AB01810199710013

These 16 bytes are broken down into 4 bytes for 4 different sections each belonging to the header.
AB01: SRC Port No.(Of coarse in hexadecimal) OR 43777(in decimal number system)
8101: DST Port No.(again in hexadecimal) OR 33025
9971:Length of the data 39281)
0013:Checksum (19)

So the total size of the whole segment is: 33025 bytes - 8 bytes =33017 bytes of total data.


Checksum:


Checksum in this protocol is optional as it does not emphasizes security or reliability.
Checksum could be like the following depicted as follows:-
Step1:-Each Symbol is converted to it's binary. Summation of all these binaries are taken.
Step2:-Then the 1's complement of the no. is sent to the receiver.
Step3:-When the receiver receives all the data, he takes sum of all the binaries of each symbols.
Step4:-Then he adds his data with the number sent by the sender.
Step5:-If he gets All 0's,the data received is correct. Otherwise it is wrong.



Remember this is just an example to give you a brief idea of the Checksum Process. The actual algorithms may be far more complex.
So this was the User Datagram Protocol - fast but unreliable.

But there are certain cases where we cannot compromise with the Data's quality. This is when TCP comes into role.

Transmission Control Protocol:

TCP ensures Reliable data to be transmitted irrespective of the time it takes.(This doesn't mean that to make a call perfectly you have to wait for a whole day…DUH!)
In UDP, the header size was made of the possible minimum size. Here we do not compromise and the protocol offers Connection-Oriented services. The TCP Header is comprised of the following fields:-
1>.SRC port address
2>.DST port address
3>.Sequence No.
4>.Acknowledgement No.
5>.A Flag that contains subsections.
6>.Length
7>.Checksum


The fields 1,2,7 and 8 are now quiet familiar to you. So, let's talk about Sequence no.

Sequence Number :-

A Sequence no. is a no. that is assigned to each packet that is being sent to the receiver. This Sequence no. is between the range : 0 to 2^32 -1.
Why up to 2^32 -1 you ask… this is because 32 bits are assigned for each sequence no. and the total no. of permutations that can be made if we enter these nos. in binary(0's or 1's) are 2^32 . If we start from 0 up to 2^32 numbers ,we get (2^32 )-1.
But why only 32 bits for a sequence no. you ask… Well this is because for a data to be sent, surplus amount of segments would be required. These segments depend upon the length of the data. But the data being highly flexible from person to person, we had to assign a number that could be of larger range so as to satisfy the total data length. But not so large as to waste the memory. Apart from this only the designer can answer you this question cause I know nothing more than this.(There I said it!!! You feel better now???)
So now that we have given a sequence or serial no. to each segment we can move on to the next field of the header.

 Acknowledgement no:-

This field is basically for the receiver. But since the connection is Full Duplex, gradually all the parties involved in the transmission acts as a Sender or Receiver at some point. When a receiver gets all the segments up to a certain sequence number, the next sequence number he/she is expecting is known as the Acknowledgment number. For example :if the receiver receives up to sequence no. 1800, he/she sends 1801 as the acknowledgement number notifying that I have successfully received segments up to sequence number 1800 and I am now expecting 1801.

So basically Acknowledgment no. is 1 plus the sequence number received last.

The Flag:- 

It contains the following flags: URG,PSH,RST,SYN,FIN




1>. URG: Urgent

This flag is set to 1 if the message to be sent is urgent and remains 0 rest of the times.

2>. SYN: Synchronization. 

This is a 1 bit number.(Either 0 or 1). It is set to 1 if the connection between sender and receiver is established for the first time. Rest of the times it is 0.

3>. PSH: 

There are times when the sender even after sending the segments does not receive any acknowledgement number. Non-receival of any data may result in a Session Timeout. To prevent this the sender pushes one segment without any request from the receiver. If the reply to that push request comes then the receiver is assumed to be online but engaged for some reasons. Incase no reply is received, the sender waits for the receiver until timeout.

4>. RST:

 Reset. When the connection is required to be refreshed for some reasons.

5>. FIN: 

Finish. Used at the time of connection termination.

How does TCP maintain Reliability:-

TCP uses a circular Buffer on both sending and receiving Hosts. These Buffers transport the packets one by one. As soon as a buffer gets a "package received " confirmation message, that package is removed from the buffer. Assume that Sender's buffer carries a packet with sequence number 1000. The sender's buffer transports the packet to the receiver's buffer. It still keeps the copy of the sent packet(1000). As soon as it gets an Acknowledgement no. 1001, it removes the packet 1000 and sends the packet with sequence number 1001 to the receiver. This Acknowledgement number is basically a confirmation message.


This was a great way to keep the track of undelivered packets. However, The buffer's size was limitation. The number of Packets that could be sent were now limited. Even if Google(Server) has a large Buffer size, our PC's(Clients) don't. This is why the concept of Window size was made.

Window Size:



In this concept, we measure the number of packets that could be sent or received by both Server and Client. Then we set the Window size to the minimum of the two(Client or Server). All throughout the connection, the number of packets sent and received by either sides cannot exceed Window size. This information was sent every time with the Acknowledgement number.
Well, this was just a mere introduction to TCP and UDP. There are various versions of TCP that are implemented these days- Tahoe, Reno, New-Reno and many more.

Untill now, we dealt with a lot of Theory. In our upcoming articles, we'll practically try to implement some real networks (Virtually real) . We'll be using a well known Network simulator known as the " Cisco Packet Tracer ". Also we'll be starting with shell programming and Unix .
Please let me know if you have any doubts . Do share this post and comment below.
Till then, keep exploring…..

Total comment

Author

Akshat Bajpai