Skip to content

An adaptive eBPF-based router built to discourage network users from compulsive web usage

License

Notifications You must be signed in to change notification settings

atomic77/nethadone

Repository files navigation

Nethadone

Nethadone is an adaptive L4 router built to discourage and train users on a network out of compulsive or addictive web usage.

It uses eBPF to efficiently monitor and dynamically adjust traffic speeds to gently nudge users off of configured sites. The goal is to get the benefit of these platforms (occasional surfing, ability to respond to messages, etc.) while avoiding the downsides of excessive use.

Getting Started

Nethadone is in active development and has been tested on the following devices:

Please check out doc/install.md for more details.

For development or testing on a local VM, please see doc/development.md

How does it work?

Nethadone leverages several eBPF programs to monitor and classify routed traffic as it passes through. Based on the configured policies, packets are slotted into a series of bandwidth classes. The default configuration corresponds roughly to:

  • Full throttle (no restriction)
  • Decent DSL connection
  • Good 4G connection
  • Flaky 3G connection
  • A top of the line US Robotics 56K modem

As a user continues to compulsively use a given site, traffic to flagged IPs gradually works its way down the list above.

Nethadone currently only supports a single policy, for more details see policy/README.md.

For more details on bandwidth classes (i.e. qdisc configuration), see doc/qdisc.md.

Traffic flow

The following diagram shows the approximate life of a packet as it flows through the nethadone router, and most of the moving parts involved:

overview

Design Goals

  • Protect all devices in a network with zero client-side configuration or software
  • Dynamically throttle traffic from clients to configurable sites or groups of sites to "train" good habits
  • Use only IP and (sniffed) DNS (i.e. as close to a pure L4 solution as possible)
  • Introduce no latency on "good" traffic
  • Usable on minimal hardware like an Orange Pi R1plus or similar

Current milestones

Milestone 8: Improved overall installation experience and support for lower-end 32-bit arm devices such as Orange Pi Zero/R1.

References & Acknowlegements

Projects

A number of projects were invaluable reference points in trying to understand the intracies of eBPF:

While a very different technical solution, the product experience of Pi-hole from the users' persective is a huge inspiration for nethadone.

Papers and Books

Learning eBPF - Full Book

Replacing HTB with EDT and BPF

Scaling Linux Traffic Shaping with BPF

Understanding tc “direct action” mode for BPF

Linux Advanced Routing & Traffic Control HOWTO