In computer networks, a tunneling protocol is a communication protocol that allows for the movement of data from one network to another. They can, for example, allow private communications to be sent across a public network (such as the Internet), or for one network protocol to be carried over an incompatible network, through a process called encapsulation. Because tunneling involves repackaging the traffic data into a different form, perhaps with encryption as standard, it can hide the nature of the traffic that is run through a tunnel. Tunneling protocols work by using the data portion of a packet (the payload) to carry the packets that actually provide the service. Tunneling uses a layered protocol model such as those of the OSI or TCP/IP protocol suite, but usually violates the layering when using the payload to carry a service not normally provided by the network. Typically, the delivery protocol operates at an equal or higher level in the layered model than the payload protocol.
Uses A tunneling protocol may, for example, allow a foreign protocol to run over a network that does not support that particular protocol, such as running IPv6 over IPv4. Another important use is to provide services that are impractical or unsafe to be offered using only the underlying network services, such as providing a corporate network address to a remote user whose physical network address is not part of the corporate network.
Circumventing firewall policy Users can also use tunneling to "sneak through" a firewall, using a protocol that the firewall would normally block, but "wrapped" inside a protocol that the firewall does not block, such as HTTP. If the firewall policy does not specifically exclude this kind of "wrapping", this trick can function to get around the intended firewall policy (or any set of interlocked firewall policies). Another HTTP-based tunneling method uses the HTTP CONNECT method/command. A client issues the HTTP CONNECT command to an HTTP proxy. The proxy then makes a TCP connection to a particular server:port, and relays data between that server:port and the client connection. Because this creates a security hole, CONNECT-capable HTTP proxies commonly restrict access to the CONNECT method. The proxy allows connections only to specific ports, such as 443 for HTTPS. Other tunneling methods able to bypass network firewalls make use of different protocols such as DNS, MQTT, and SMS.
Technical overview As an example of network layer over network layer, Generic Routing Encapsulation (GRE), a protocol running over IP (IP protocol number 47), often serves to carry IP packets, with RFC 1918 private addresses, over the Internet using delivery packets with public IP addresses. In this case, the delivery and payload protocols are the same, but the payload addresses are incompatible with those of the delivery network. It is also possible to establish a connection using the data link layer. The Layer 2 Tunneling Protocol (L2TP) allows the transmission of frames between two nodes. A tunnel is not encrypted by default: the TCP/IP protocol chosen determines the level of security. SSH uses port 22 to enable data encryption of payloads being transmitted over a public network (such as the Internet) connection, thereby providing VPN functionality. IPsec has an end-to-end Transport Mode, but can also operate in a tunneling mode through a trusted security gateway. To understand a particular protocol stack imposed by tunneling, network engineers must understand both the payload and delivery protocol sets.
Common tunneling protocols IP in IP (IP protocol 4): IP in IPv4/IPv6 SIT/IPv6 (IP protocol 41): IPv6 in IPv4/IPv6 GRE (IP protocol 47): Generic Routing Encapsulation OpenVPN (UDP port 1194) SSTP (TCP port 443): Secure Socket Tunneling Protocol IPSec (IP protocols 50 and 51): Internet Protocol Security L2TP (UDP port 1701): Layer 2 Tunneling Protocol L2TPv3 (IP protocol 115): Layer 2 Tunneling Protocol version 3 VXLAN (UDP port 4789): Virtual Extensible Local Area Network PPTP (TCP port 1723 for control, GRE for data): Point-to-Point Tunneling Protocol PPPoE (EtherType 0x8863 for control, 0x8864 for data): Point-to-Point Protocol over Ethernet GENEVE WireGuard (UDP dynamic port)
TCP meltdown problem Tunneling a TCP-encapsulating payload (such as PPP) over a TCP-based connection (such as SSH's port forwarding) is known as "TCP-over-TCP", and doing so can induce a dramatic loss in transmission performance — known as the TCP meltdown problem, which is why virtual private network (VPN) software may instead use a protocol simpler than TCP for the tunnel connection. The throughput of a TCP‑over‑TCP connection can be degraded because the control loops in the inner and outer TCPs interfere destructively with each other. Because TCP is designed to guarantee in‑order and complete packet delivery, the outer TCP masks the connection's health from the inner TCP. In normal TCP operation, packet loss is detected when the receiver replies with duplicate ACKs to a packet received before the missing packet in the sequence. In response, the sender retransmits the lost packet and halves the Congestion Window (CWND). In TCP‑over‑TCP, the outer TCP handles lost packets normally through retransmission and CWND reduction. Still, since the inner TCP has not received any information indicating latency in the connection, it continues to transmit packets at the rate currently governed by its CWND. Because the inner TCP’s CWND is greater than the outer TCP’s, the outer TCP’s send buffer eventually fills. As the buffer inflates, packets experience longer and more variable queueing delays before transmission, thereby increasing the outer TCP’s measured round-trip time (RTT) and RTT variability. This inflates its retransmission timeout (RTO). Once the send buffer becomes full, the tunnel process can no longer forward inner‑TCP ACKs, so the inner TCP stops receiving acknowledgments entirely. Because the inner TCP is no longer receiving ACKs, its RTO expires, causing it to retransmit the oldest unacknowledged segment and double its RTO. The inner TCP’s RTO then grows exponentially because it doubles with every timeout, and no ACKs are received to reset it. The result of a TCP meltdown is an outer TCP with a severely reduced CWND, an inflated RTO, and a full send buffer. This indicates that the inner TCP cannot write and that ACKs are not being sent in either direction.
… excerpt ends here. Continue reading the full article.

