Encapsulation is the process of data going through the TCP/IP stack, as more data gets added by each layer until it ready to send, like a little capsule (probably not proper terminology, data packet is probably more correct). Decapsulation is then the process that happens when the packets are received, which is basically encapsulation in reverse. I'll go through it in more detail:
1- Application layer- When data is sent off, this is the first layer. It is named so because it is the protocols applied by the application before it is sent to the next layer. This is the top level encapsulation, so is mostly formatting, encryption and other app validation. Some examples are HTTP and HTTPS, which are browser protocols, and SMTP, which is the protocol used by email services.
2- Transport layer- After the app layer, this layer kind of assumes that the data is all correct, and just focuses on transporting the data. Even this it can fail at, if the destination isn't found, but that is supposed to be it's job. It splits the data (which would be too big to send in one) into smaller segments called TCP packets, which each have a header, and the payload, which is the actual data to be transported.
-The header is added to the packet in the transport layer, and this stores important data about the transport (kind of like metadata). 2 parts of this is the source and destination port numbers. The port number is basically an id of the application the data was sent from/delivered to, so the data gets sent to the right place. When the request is reached at the server, the source and destination port numbers are swapped (this happens later on). Sockets are something for the data, which is a combination of the IP address and port number, which is just another id for the connection basically.
There are 2 possible protocols for the transport layer:
-TCP (Transmission Control Protocol)- yes, I know this is the name in the overall stack, but I guess that title is just a simplifying label for the stack. This protocol makes sure that no data gets lost, as especially for sensitive transactions this would be wanted (though I don't think in any circumstance anyone would be happy with their data lost). The TCP assigns every segment a sequence number at the sender end, and at the receiver end it records all the segment coming in. If a segment isn't received, then it can be sent again (which does sadly slow down the sending). The sequence numbers also help with the re-ordering of the packets.
UDP (User Datagram Protocol)- this protocol prioritises speed over completion of data. It is less reliable, but tolerating some loss of data means UDP can be used in real-time apps. For example, live video/audio streaming, e.g. calls or facetime, can use this as a loss of data will mean only a little cut in the media, but loss in speed would mean for time delays.
3- Internet Layer- after the transport layer has cut the data into segments, and the port numbers are allocated, the route across the internet still needs to be added. The IP (internet protocol) is the most common protocol for this, and (again assuming the data is validated from the app layer), it encapsulates some data to a header around all the packets, forming an IP packet. It adds the source and destination IP addresses, and also adds data saying how many segments there are (though the segment retransmission is still covered by the TCP, not the IP).
4- Link Layer- Finally, this layer is where the data is actually sent. This could be done with a number of protocols, wired or wireless, e.g. 4G, WiFi or ethernet. With these, the IP packet would be transported across the network, and be received at the destination IP address. With ethernet or WiFi, this would be at the router, and then the switch would forward the packet to the correct device. Then the TCP/IP stack goes in reverse
3- Internet- the packet has arrived at the IP address
2- Transport- the TCP (if used) checks for any missed segments, and if there are then it sends off for them. Then the segments are put back together.
1- App- any formatting, decryption, validation is performed, and then the data can be viewed at the destination device.
Compression
-Compression makes files smaller for more efficient storage or transmission of files over the Internet or network.
-Lossy – an algorithm for file compression which permanently removes part of the file so that it will not be the same as the original.
-Lossless – an algorithm for file compression which does not permanently remove part of the file so it can be decompressed back into its exact original state.
Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.