Data encapsulation is an important concept in the OSI model.
What is Data Encapsulation?
– The private data in classes is wrapped up to prevent accidental alteration of data and misuse.
– This is a way of implementing the concept of data hiding in object – oriented programming.
– The details of the implementation are not presented to the user.
– The user is restricted to only a certain number of operations to carry out on the encapsulated or the hidden members.
– These specific operations are carried out through functions known as methods.
How is data encapsulation done in OSI model?
– In OSI model, it acts as a guide for the system telling to what to do when transfer of data takes place.
Let us give an analogy:
– Consider a car being built.
– All the jobs are not done by one person rather it is placed in to production line where at various steps different parts are added to it by different persons.
– Therefore, at the end of the production process, the car is ready to be sent to the dealer.
– Same thing applies to data in flowing through a network.
– The guidelines of the OSI model guide this process.
There are two types of data flows in the OSI model namely:
1. Data encapsulation i.e., DOWN flow
2. Data decapsulation i.e., UP flow
– Data encapsulation is done when data has to be sent.
– This encapsulation process takes place through the first 5 layers of OSI model.
– At the last two layers, the data is ready for transmission.
Let us understand how it all happens:
– Consider a computer requires to send some data to some other system.
– Now the user interface exists at the application layer level.
– The interaction between the user and the application takes place here and data obtained from the user is passed on to the presentation layer.
– From this layer it passes on to the session layer.
– Through these 3 layers some extra information is added to the original data and then it is passed on to the transport layer.
– At this layer, the data is broken down in to a number of smaller units.
– These smaller units of data are transmitted one by one with the addition of TCP header to them.
– The data unit is now called a data segment.
– Each segment has a particular sequence which helps in putting the data stream back together at the receiver’s end in its original form.
– Each of these segments is then sent to the network layer for logical addressing as well as routing through the network.
– At this network layer, the segments are termed as data packets.
– At this level, the data packet consists of upper layer information and the transport header.
– At network layer, IP header is added to the packet and then it is passed to the data link layer.
– Now since the data packet consists of upper layer information, transport layer header and network layer header, it is termed as the frame.
– It is the responsibility of the data link layer to receive packets and place them on the transmission medium, for example cable.
– Then, it encapsulates each data packet containing the MAC address of the source host and the destination host.
– At the end, an FCS (frame check sequence) field is also added to the frame.
– This field is required for error checking in frame.
– If the destination host is located on a remote network, then it has to be sent to a gateway or router to be routed. – For putting these frames on network, they have to put on to a digital signal.
– A logical group of 0’s and 1’s is what that makes a frame.
– These 0’s and 1’s are encapsulated by the physical layer in to a digital signal.
– These signals are read by the devices present on same network.
– At the beginning of the frame few 0’s and 1’s are added so that synchronization can be done at the receiving end.