OSI Model

 OSI model consists of seven independent layers ,each of which do some particular functions .All the layers and their functions combine to achieve Computer to Computer communication.

 The Open Systems Interconnect model (OSI Model) tells us all the individual functions that are necessary for the Internet to work.

Layer 1 – Physical

The Physical layer has two responsibilities, sending and receiveing bits (1's  and  0's) between nodes.
 examples: Ethernet cable or Serial Cable. And WiFi, doesnt have a physical presence, but its still considered a Layer 1 protocol.

Layer 2 – Data Link
Data Link Layer is responsible for transmitting and receiving 1’s and 0’s from the wire.
Layer 2 will group together those 1’s and 0’s into chunks known as Frames.
layer 2 is responsible for packet delivery from hop to hop.
The Network Interface Card (NIC) controls the functionality of layer 2.we connect ethernet wire to NIC and it receives and transmits signals on to the wire.
addressing system which exists at Layer 2 is Media Access Control address(MAC address).  Each and every NIC has unique MAC address assigned by manufacturer. so every computer/device has a unique burned-in MAC address .
Switch also operates in this layer, which uniquely identifies a device by its MAC address

Layer 3 – Network

The Network layer of the OSI model is responsible for packet delivery from end to end,by using the Internet Protocol address(IP Address),which logically identify every node connected to the Internet.

An IP address is a number assigned to a network connection.

every computer/device has an unique MAC address, but IP address is not unique for a device and a particular network connection has unique IP address.

Routers are Network Devices that operate at Layer 3 ,which uniquely identifies a device's network connection with help of network-assigned IP address. Router helps in communication between Networks. 

Layer 4 – Transport

The Transport layer of the OSI model is responsible for distinguishing network streams, by using an addressing scheme known as Port Numbers.

if a user on he's computer is using online chatting messenger , a live gaming streaming or some internet browser at a particular time ,these applications are sending and receiving data from the internet , so the layer 4 distinguishes which data belongs to chatting or to live gaming or to the browser. 

These methods help in doing this :
Transmission Control Protocol (TCP), or
User Datagram Protocol (UDP).

Layer 5, 6, and 7

The Session, Presentation, and Application layers of the OSI model do the final steps and the data is transfered through their network

For Network Engineering , the difference between Layers 5, 6, and 7 is not that important . for another communication model known as the TCP/IP model in which these 3 layers are grouped into one single encompassing layer.

Encapsulation and Decapsulation

 Encapsulation : while sending data is moved through layers from top to bottom ie. from  layer 7 to layer 1

 Decapsulation : while receiving data is moved through layers from bottom to top  ie. from  layer 1 to layer 7.

while sending data is passed from L7->L5,when it reaches transport layer (layer 4) tcp header is added to the data .now data + tcp header is called segment. 
this segment reaches network layer (layer 3) where IP header is added to the segment .now segment + IP header is called as packet.

this packet reaches data link layer (layer 2)  where ethernet header is added to the packet .now packet+ ethernet header is called as frame.

this frame reaches physical layer (layer 1)  where it is converted to 0's and 1's to be sent through the wire to the destination with all the corresponding 7 layers

On the receiving end, the process is reverse of sending ,the headers are removed one at a time, layer by layer(from layer 1 to layer 7) , and the data is sent to the Application layer.