Encapsulation vs Tunneling
Encapsulation and tunneling are two important concepts found in Computer Networking. Tunneling is a method used to transfer a payload (a frame or a packet) of one protocol using an internetwork infrastructure of another protocol. Because the transmitted payload belongs to a different protocol it cannot be sent as it is created. Encapsulation is the process of encapsulating the payload with an additional header so that it can be sent (tunneled) through the intermediate network correctly. After the transmission, the encapsulated payload needs to be de-encapsulated at the routing end point and can be forwarded to the final destination. The whole process of encapsulating, transmitting and later de-encapsulating is called tunneling. However, tunneling is sometimes known as encapsulation (leading to confusion) as well.
What is Tunneling?
Tunneling is a method used to transfer a payload of one protocol using an internetwork transportation medium of another protocol. The data that need to be transferred are typically frames/packets belonging to a certain protocol (different to the protocol used to send data). Because of this, the payload cannot be sent as it is produced by its origin. Therefore, the frames need to be encapsulated in an additional header, which provides the routing information necessary to transmit the data correctly, before sending. Then a tunnel (a logical path, which interconnects the end points between that the frames must travel) is created and the frames are routed between the tunnel endpoints through the internetwork. When the encapsulated packets reach the destination end point of the tunnel, they are de-encapsulated and the original packets contained inside are sent to the intended destination. This overall process including the encapsulation and de-encapsulation is called tunneling. Both Layer 2 and Layer 3 (of Open Systems Interconnection Reference Model) use tunneling. Typical Layer 2 tunneling protocols are PPTP (Point-to-Point Tunneling Protocol) and L2TP (Layer Two Tunneling Protocol). Layer 3 usually uses IPSec tunnel mode as a tunneling protocol.
What is Encapsulation?
As mentioned above, Encapsulation is the process of encapsulating the packets inside an additional header before tunneling. This additional header contains the routing information necessary to send the encapsulated payload through the intermediate internetwork. This information is essential because the payload is sent through a network (protocol) different to the network in which the data was created. In Layer 2 (which uses frames as the unit of exchange) tunneling, both PPTP and L2TP do encapsulation in a PPP (Point-to-Point Protocol) frame. In Layer 3 (which uses packets as the unit of exchange) tunneling, IPSec tunnel mode encapsulates IP (Internet Protocol) packets with an additional IP header.
What is the difference between Encapsulation and Tunneling?
Tunneling is a method used to transfer a payload of one protocol using an internetwork infrastructure of another protocol. Encapsulation is the process of encapsulating the frame with an additional header so that it can be sent (tunneled) through the intermediate network correctly. Tunneling is referred to the whole process of encapsulation, transmission and de-encapsulation, while encapsulation is only a step within this entire process. However, regardless of this whole-part relationship, tunneling is sometimes also known as encapsulation.