The layer 5 of the OSI model is called as the session layer. As the name suggests, this layer is about establishing and maintaining sessions between two computers. If you remember, the transport layer is associated with transfer of data from one host to another. In a similar fashion, the session layer too provides data transport options, but with enhanced features that give added advantages to certain applications.
A session is nothing but the current state of a connection. Have you noticed session timed out messages while doing something? (Most probably when you leave a connection idle for a certain period of time) This is due to the fact that the session layer has closed the connection itself after the default time interval of no activity.
Session Layer Functions
Have you used FTP softwares to transfer files or even remotely login to a system? These facilities are all provided by a session layer. When you remotely log in to another machine, your session starts and it lasts until you log out or the connection times out after a certain period of inactivity.
If you want the session layer to keep track of the turn, it can do so. This can be accomplished by allowing traffic flow in one direction only. Normally session layer can allow traffic flow in both directions.
In some cases, it is desired that both the machines do not perform the same operation at the same time. In such situation, session layer can manage the process by introducing token management functions. Consider the case where you have an ID card. Only the employee having the ID card is given access to the company office. If another person needs to access the office, then he needs to get the ID card from the other employee. The ID card can be considered a token and only the host machine having the token can perform the operation at that particular time.
We talked about session layer being able to deploy file transfer operations. Consider the case where you need to transfer 2 GB of data. After sometime the transfer fails due to computer network connectivity issues and you find that only 1GB has been transfered. Would you prefer to restart the session and transfer the remaining 1GB or just resend the entire 2GB again? What if the transfer fails again? This problem can be addressed by the synchronization operation of the session layer.
