The Open Systems Interconnection(OSI) Model is a conceptual framework which shows us how data moves from one computer to another throughout network. It is merely a reference model created to give us a guide about the functions of a networking system. So unlike TCP/IP Model, it is not implemented in the real world.
The OSI Model breaks down the task of communication between a computing system into 7 abstraction layers: Physical, Data Link, Network, Transport, Session, Presentation, and Application.
The upper four layers of OSI Model are host layers. These layers exist in the source/destination host devices and interoperate with communication partner.
Users communicate to the computer directly at application layer. It acts as an interface between an end user and an application. It provides protocols that allow software to send and receive data. For example, if we want to send or receive email, we use IMAP, POP3, or SMTP. We use HTTP, HTTPS protocol to browse the internet. These are application layer protocols. Email application and web browsers do not reside in the application layer protocol. Instead, they interface with application layer protocols.
The presentation layer establishes context between application layer entities, so that data sent from one system's application layer can be read by the application layer on another one. It does character code conversion(ASCII, html etc.), and data compression/encryption.
The session layer controls and coordinates communication between computers. A session between network devices are set up, managed and torn down at this layer. And it ensures data from different application sessions are kept separate.
The transport Layer is responsible for delivering data error-free and in sequence. It controls the reliability of a given link through flow control, segmentation/desegmentation, and error control.
Some protocols such as TCP(Transmission Control protocol) are connection-oriented. In this case, the transport layer can keep track of the segments and retransmit those that fail delivery. So connection-oriented protocols can be delivered error-free. On the other hand, UDP(User Datagram Protocol) delivers data in connectionless manner, so it is not always delivered error-free. Segmentation/desegmentation means the transport layer segments data and reassembles them.
Layer3 to 1 are called 'Media layers'. These layers manage the information in the LAN or WAN which connects the devices.
The network layer works as a "Routing" layer. In this layer, data is broken into packets. The network layer provides path destination, logical addressing(IP addressing) and routing service. It transfers packets from one node to another connected in different networks.
The data link layer works as a "Switching" layer. Routing is to connect multiple networks. Switching, on the other hand, is to connect multiple devices in a network. At this layer, data is packaged into frames. The data link layer provides node-to-node physical transmission of these frames using hardware addresses(MAC address).