What is the use of tun.ko

Tun.ko or the tun driver provides packet reception and transmission for user space programs. It can be viewed as a simple Point-to-Point or Ethernet device, which instead of receiving packets from a physical media, receives them from user space program and instead of sending packets via physical media writes them to the user space program.

When a vpn application opens /dev/tun, the driver creates and registers corresponding net device tunX or tapX. After a program closed above devices, driver will automatically delete tunXX or tapXX device and all routes corresponding to it. Let's say that you configured tun0 as your default gateway, then whenever kernel sends any IP packet to tun0, it is passed to the application (DroidVPN for example). Application encrypts, compresses and sends it to the other side over TCP,UDP or ICMP. Application on other side decompress and decrypts them and write packet to the TUN device, kernel handles the packet like it came from real physical device.

In simple terms, the tun driver acts like the messenger of your internet traffic. It captures all your internet traffic and passes it to DroidVPN for processing, DroidVPN will then encapsulate those IP frames and pass it to our servers.