ArticleslgStudy

computer science

TUN/TAP

TUN/TAP is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand TUN/TAP rather than just read about it. In short: In computer networking, TUN and TAP are kernel virtual network devices. Being network devices supported entirely in software, they differ from ordinary network devices which are backed by physical network adapters.

TUN/TAP — main illustration
TUN/TAP — illustration

Key takeaways

  • TUN/TAP belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect TUN/TAP to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of TUN/TAP from memory before moving on to harder problems.

Reference excerpt

In computer networking, TUN and TAP are kernel virtual network devices. Being network devices supported entirely in software, they differ from ordinary network devices which are backed by physical network adapters. The Universal TUN/TAP Driver originated in 2000 as a merger of the corresponding drivers in Solaris, Linux and BSD. The driver continues to be maintained as part of the Linux and FreeBSD kernels.

Design

Though both are for tunneling purposes, TUN and TAP cannot be used together because they transmit and receive packets at different layers of the network stack. TUN, namely network TUNnel, simulates a network layer device and operates in layer 3 carrying IP packets. TAP, namely network TAP, simulates a link layer device and operates in layer 2 carrying Ethernet frames. TUN is used with routing. TAP can be used to create a user space network bridge. Packets sent by an operating system via a TUN/TAP device are delivered to a user space program which attaches itself to the device. A user space program may also pass packets into a TUN/TAP device. In this case the TUN/TAP device delivers (or "injects") these packets to the operating-system network stack thus emulating their reception from an external source.

Applications Virtual private networks

OpenVPN, Ethernet/IP over TCP/UDP; encrypted, compressed ZeroTier, Ethernet/IP over TCP/UDP; encrypted, compressed, cryptographic addressing scheme FreeLAN, open-source, free, multi-platform IPv4, IPv6 and peer-to-peer VPN software over UDP/IP. n2n, an open source Layer 2 over Layer 3 VPN application which uses a peer-to-peer architecture for network membership and routing Tinc, Ethernet/IPv4/IPv6 over TCP/UDP; encrypted, compressed VTun, Ethernet/IP/serial/Unix pipe over TCP; encrypted, compressed, traffic-shaping OpenSSH coLinux, Ethernet/IP over TCP/UDP Hamachi OpenConnect WireGuard Tailscale Virtual-machine networking

Bochs coLinux Hercules (S/390 emulator) Open vSwitch QEMU/KVM User-mode Linux VirtualBox Connecting real machines with network simulation

ns-3 GNU Radio NAT

TAYGA, a stateless NAT64 implementation for Linux

Platforms Platforms with TUN/TAP drivers include:

FreeBSD Linux, starting around version 2.1.60 of the Linux kernel mainline iOS (tun driver only) macOS (native support only for TUN (utun)) NetBSD OpenBSD Android Solaris Windows 2000/XP/Vista/7/8/8.1/10 QNX

See also Point-to-point (telecommunications) MacVTap

References

External links Tun/Tap interface tutorial Linux Networking: MAC VLANs and Virtual Ethernets Archived 2015-02-18 at the Wayback Machine

Worked examples

Example 1 — a first encounter with TUN/TAP

Start with the simplest possible case. Write down what TUN/TAP claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to TUN/TAP before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about TUN/TAP ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of TUN/TAP

In research
TUN/TAP appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses TUN/TAP in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
TUN/TAP is common in secondary-school and first-year university syllabi. It links to neighbouring topics Free system software, Internet Protocol based network software, Linux drivers, so understanding it makes those chapters shorter.
In everyday life
Look for TUN/TAP outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “TUN/TAP” →

How to study TUN/TAP in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what TUN/TAP means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain TUN/TAP out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is TUN/TAP in simple terms?

In computer networking, TUN and TAP are kernel virtual network devices. Being network devices supported entirely in software, they differ from ordinary network devices which are backed by physical network adapters.

Why does TUN/TAP matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study TUN/TAP?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on TUN/TAP.

Tags

  • Free system software
  • Internet Protocol based network software
  • Linux drivers
  • Network software stubs
  • Virtual private networks

Keep exploring