Intro to transport layer – Introduction to OSI layer model – The internetworking Part2
The transport layer deals with segmentation and reassembly . 2 protocols work on this layer TCP and UDP. TCP(Transmission control protocol) being the connection oriented and UDP(user datagram protocol) being connectionless.
I will get to UDP later on .Now talking about TCP. It is said to be connection oriented protocol .TCP employs sequencing, acknowledgments and retransmission . If the data is not reached in order at the receiver it has to be retransmitted .
First thing that makes it reliable is 3 way handshake . The process involves establishing a connection with a server .Which is a 3 phase process hence called 3 way handshake. This is also called establishment of virtual circuit.
The server is in passive mode i.e. always accepting connection
1.)The client sends a SYN (synchronization) message to the server which is random number. Eg X.
2.)If the server accepts this communication it replies back with SYN-ACK (synchronized acknowledged).This number is one more than number sent by client, in our case it will be X+1.Actually it means the next number that I (Server) will be expecting is X+1. Apart from SYN-ACK the server also choose a random number Y for its packets and sends it to client with X+1.
3.)Now client responds back with ACK and Y+1 which means the 3 way communication is established.
After the connection is established the data transfer can take place.
Flow Control:- Imagine a teacher reading very fast in class and students writing the notes down . Hmm what can happen fast that students can miss important information solution student asking teacher to slow down or repeat … You got it this is the basic concept of flow control.
One router can be sending information at a very high speed but the receiving router cant be so fast that it can accept all the information at once . So concept of buffers were used so as to avoid dropping the loss of information but buffers can also get full ( and they do get full). Now when this situation arrives the receiver sends a NOT READY signal to the sender . Now sender lower its pace or completely stops sending the data to the receiver now when receiver has processed all its data from buffers or the moment a slot gets free in buffers it sends back the ready signal .
Now flow control can be achieved by many techniques .
a.)Windowing– I prefer to use examples a lot so consider you going to a party and saying “The food is nice “ after every bite hmm this is stupid and waste of energy why not finish the food first and then say the “ food was nice” hahahah weird example, as TCP involves acknowledgments after every packet is sent it expects an acknowledgment . Consider how much time and bandwidth is wasted for every acknowledgment . The sender remains idle till it gets the acknowledgment and receiver also has to reply back every time. So get out of this and make it more productive concept of windowing was introduced .The window size means the amount of packets than can be sent while the receiver is waiting for an acknowledgment .. Not getting so here is an example consider a host and a server.
Initially the sender sends data of size 2K and sequence is 0. The buffer initially at receiver was empty (capacity 4k) so the receiver sends back ACK for 2048 and windows size of 2048(4024-2048) as buffer is half full now.The sends now sends another 2k of data and buffer is full so the receivers sends WIN=0 means stop sending data my window is full.The sends stops sending data till the receiver sends back a request again with window size
Now I think this diagram made you clear.
b.)Acknowledgments– by considering the above figure again we can see that next stream of data is sent only when the acknowledgment is received.(I mean windows size).Now if the data is lost somewhere may be due to media loss or router shutting down or any other problem then what will happen to overcome this problem there are timers. When a device sends data it starts a timer if the acknowledgment is received before the timer expires then it sends the next segment if acknowledgment is not received the data is retransmitted again . All these techniques make TCP a reliable protocol
Actually a lot of stuff is left out in the article like silly windows syndrome or how to select window size or what happens if acknowledgment comes after the timer has expired .These are very minute details and every topic cant be discussed here if you are interested do read them