Jump to content

atomic77

Members
  • Posts

    15
  • Joined

  • Last visited

Profile Information

  • Location
    Toronto

Contact Methods

  • Github
    https://github.com/atomic77

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi everyone, it's been a while since i've posted but I have a new project that i'd like to share and hopefully get feedback and ideas from the community. Ever since the first 2 x gigabit ethernet devices came out, I've been thinking that there were a lot of potentially interesting networking use cases. I happened to be re-configuring pihole on a new opi zero, and I had some hardware issues that caused my connection to be a bit flaky on a website that I "shouldn't" have been using. This gave me the inspiration to create a gateway that intentionally manipulates traffic in such a way that you train good usage habits of websites that can be addictive. 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. For anyone not familiar with eBPF, it's a powerful capability of newer Linux kernels, that allows C and Rust code to be compiled and run in a sort of kernel-space sandbox and loaded in realtime. Due to the efficiency of JIT-optimized eBPF code running inside the kernel, features that were possible only with expensive networking equipment are now feasible on something like an Orange Pi R1Plus. The flow of a packet through the moving parts of the system is here: There are three eBPF modules at work: A traffic monitor captures (saddr, daddr) pairs from clients on the network to external IPs, counting the bytes used. These counters are exposed by the webapp and collected in a local prometheus instance. A DNS sniffer captures DNS requests passing through the router, in order to cache the likely domain of a given IP address A throttler eBPF is dynamically recompiled based on traffic patterns, and classifies traffic based on a policy. Packets classified into one of the slower bandwidth classes ends up passing through a netem qdisc, which simulates a slower network connection. As "bad" usage continues, the policy is changed until traffic is passing through the equivalent of a 56k modem. I think most people here would probably get the hint and stop scrolling if they were forced to use a telephone-based modem again Deployment Example This diagram shows how I've installed it at home - any device connected to the nethadone AP is subject to throttling: This setup was mainly to have an easy way to get back online if there were issues, but after a couple of weeks of general usage with both desktop and mobile clients, there have been no major issues, apart from the need to restart after 24h or so. Armbian-related TODOs While there are some things that could be better, the tool is working well enough that it has already had a positive impact on my and my wife's usage of a number of sites. My goal is to now make it as user-friendly to set up as possible. One big issue is that Armbian understandably does not enable BTF in the images that ship. The dae project has been a life-saver, providing BTF-enabled kernel builds for a lot of devices for Armbian 23.08. I tried to create a custom image with a BTF-enabled kernel, but had a lot of difficulty getting something bootable and set it aside. I also ran into some kernel configuration issues when attempting to make an older OPI R1 (not plus) work, even with the dae kernels. My gratitude to everyone who helps maintain Armbian and helps on this forum. In the coming weeks as I try to work on making it easier to use this on other devices, I may seek out some advice from forum members on how to work through these issues. For anyone interested in trying it out, or wants to find out more about how to use eBPF on an arm-based device, the code and documentation can be found here: https://github.com/atomic77/nethadone 👋 -Alex
  2. Thank you for sharing this! I have a DHT22 that i've been trying to get working with an OrangePi Lite and I've had terrible results with all of the python-based libraries i've tried. I'm getting about 25-30% of the readings with this every 2s, which is good enough for my purposes. FWIW, my opi lite is showing about 5.2 and 3.8v for the 5V and 3.3V pins
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines