TUN/TAP 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 program opens /dev/net/tun, driver creates and registers corresponding net device tunX or tapX. After a program closed above devices, driver will automatically delete tunX or tapX device and all routes corresponding to it.
And also, here is a web site about Universal TUN/TAP device driver Frequently Asked Question.
The description of Universal TUN/TAP device driver