Skip to content
Tom Barbette edited this page Oct 3, 2018 · 2 revisions

KernelTap Element Documentation

NAME

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

SYNOPSIS

KernelTap(ADDR/MASK [, GATEWAY, keywords ETHER, MTU, HEADROOM, IGNORE_QUEUE_OVERFLOWS])

Batching: Batching natively supported
Ports: at most 1 input, 1-2 outputs
Drivers: userlevel

DESCRIPTION

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:

  • ETHER — 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.
  • MTU — 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.
  • HEADROOM — Integer. The number of bytes left empty before the packet data (to leave room for additional encapsulation headers). Default is 0.
  • IGNORE_QUEUE_OVERFLOWS — 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.

NOTES

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(192.0.0.1/8)
       -> fromhost_cl :: Classifier(12/0806, 12/0800);
  fromhost_cl[0] -> ARPResponder(0.0.0.0/0 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.

SEE ALSO

ToHost, KernelTun, ifconfig

Generated by click-elem2man from ../elements/userlevel/kerneltap.hh:7 on 2018/10/03.

Clone this wiki locally