This is automatically generated documentation. Edit after the "COMMENTS" heading; changes to the main body will be lost.

KernelTap Element Documentation


KernelTap -- Click element; interface to /dev/tap or ethertap (user-level)



Ports: at most 1 input, 1-2 outputs
Drivers: userlevel
Package: userlevel (core)


Reads Ethernet packets from and writes Ethernet packets to a /dev/tun* or /dev/tap* device. This allows a user-level Click to hand packets to the virtual Ethernet device. KernelTap will also transfer packets from the virtual Ethernet device. KernelTap allocates a /dev/tun* or tap* device (this might fail) and runs ifconfig to set the interface's local (i.e., kernel) address to ADDR and the netmask to MASK. If a nonzero GATEWAY IP address (which must be on the same network as the tun) is specified, then KernelTap tries to set up a default route through that host. Keyword arguments are:

Ethernet address. Specifies the fake device's Ethernet address. Default is 00:01:02:03:04:05. On Linux, you must supply an ETHER argument, and use that address as the destination Ethernet address for all packets sent to the tap element; otherwise, Linux will ignore your packets. On FreeBSD, there is no way to set the Ethernet address, and any ETHER argument is silently ignored, but it is safe to use any destination Ethernet address for packets sent to the tap.
Integer. The interface's maximum transmission unit, not including the Ethernet header. Default is 1500; some operating systems do not allow it to be set.
Integer. The number of bytes left empty before the packet data (to leave room for additional encapsulation headers). Default is 0.
Boolean. If true, don't print more than one error message when there are queue overflow errors (ENOBUFS) when sending or receiving packets via the tun device. Default is false. KernelTap accepts the same arguments as KernelTun.


Linux will send ARP queries to the fake device. You must respond to these queries in order to receive any IP packets, but you can obviously respond with any Ethernet address you'd like. Here is one common idiom:

  tap0 :: KernelTap(
       -> fromhost_cl :: Classifier(12/0806, 12/0800);
  fromhost_cl[0] -> ARPResponder( 1:1:1:1:1:1) -> tap0;
  fromhost_cl[1] -> ... // IP packets

An error like "could not allocate a /dev/tap* device : No such file or directory" usually means that you have not enabled /dev/tap* in your kernel.


ToHost, KernelTun, ifconfig

Generated by 'click-elem2man' from '../elements/userlevel/kerneltap.hh:7' on 12/Jul/2011.


elements/kerneltap.txt · Last modified: 2011/07/12 11:29 (external edit)
Recent changes RSS feed Driven by DokuWiki