Fakeroute

From Bobs Projects
Jump to: navigation, search

fakeroute is a user-space application that listens to network traffic from a Linux network tunnel interface and pretends to be a series of IPv4 routers to a destination. The responses to incoming datagrams (ICMP, UDP, TCP) to the destination from each of the routers is delayed with millisecond precision (depending upon host kernel configuration), so that, eg. traceroute etc. can be "tricked" into seeing a route to the final destination.

Available at my SVN repository.

Usage

fakeroute uses the user-space nanosleep() call to simulate network delays. In older Linux kernels, the resolution of the scheduler was determined by the kernel tick rate, typically 100Hz (10ms resolution) or 250Hz (4ms). To get better (1ms) resolution required re-compiling the kernel with a 1kHz kernel clock. With newer "no-tick" Linux kernels (eg. kernel version 2.6.32 in Debian Squeeze etc.), it is no longer necessary to re-compile the kernel as the scheduler can cause the nanosleep() call to return with much higher resolution.

After compiling etc., fakeroute needs a configuration file (typically fakeroute.conf) which has a list of lines each with the IPv4 address of a router, then the delay from the previous router (in integer millisecs), then a "spreading" factor to introduce some "jitter" in the timing, all comma-separated. This list can be derived from the output of a traceroute.

Once started, fakeroute will typically go into background and be listening on a network tunnel (tun0). It is necessary to configure this network tunnel interface (as superuser):

# ifconfig tun0 10.0.0.1 up
# route add default gw 10.0.0.1
# echo 1 > /proc/sys/net/ipv4/ip_forward

Technically, you only need to route the IPv4 address of the final destination via the tun0 gateway, but if you also want to, eg., ping intermediate routers, then you'll need to route almost everything via the tunnel.

Then configure other routers etc. to route via the machine running fakeroute.

Todo

  • include tools to generate a conf file directly from a traceroute
  • allow more than one destination, using a directed graph (tree) of all interesting destinations and their routes back to the source (root). Modify the conf file format to specify directed links (source and dest IP) and the associated latency. No need to explicitly list nodes, as they are inferred from the src/dest of each link.