Online advertising can be said to be one of the most annoying things for many people when they go online every day. In order to block ads, many people may buy some ad-blocking tools. However, a god-level foreign developer only spent a measly $5 to create a “hardware-level” miniature ad-blocking artifact!
Not only can it directly block up to 537,000 advertising domains from the DNS stage, but even more exaggeratedly, the entire firmware operation only consumes less than 50KB of RAM.

Just $5 can block 537,000 domains! ESP32-C3 turns into a super mini backup advertising device
This open source project was produced by Egyptian full-end developer ZedAxis, using a very small Wi-Fi microcontroller development board ESP32-C3 SuperMini.
ESP32-C3 itself uses a single-core 32-bit RISC-V processor with a clock speed of up to 160MHz and 400KB SRAM, 16KB of which will be used as cache. This SuperMini development board is also equipped with 4MB flash memory, but there is no PSRAM common in high-end ESP32 development boards:

The operating principle is similar to Pi-hole, which blocks advertising domains through DNS blacklists so that mobile phones, computers, TVs and other devices at home cannot connect to these advertising servers.
However, this device is not meant to completely replace the Pi-hole. Pi-hole is still responsible for the main DNS and DHCP services in developers’ homes, and ESP32-C3 is positioned as the second set of DNS with the ability to block advertisements. When Pi-hole is rebooting, updating, or temporarily unavailable, there is another DNS available for devices at home, without having to directly switch to a public DNS that has no filtering function at all.

The hardware that needs to be prepared is as follows: an ESP32-C3 development board with 4MB Flash, plus a USB cable or USB-A to USB-C connector.
ESP32-C3 AdBlock ProjectA dedicated 3D printing housing file for ESP32-C3 SuperMini is also provided, which requires no support material and can be printed using a layer height of 0.2mm and about 15% infill. The lack of a 3D printer doesn’t affect functionality, the casing just completes the finished product.

There is no need to prepare special equipment for power supply. Developers directly use the USB port behind the Huawei OptiXstar fiber optic gateway for power supply. USB is only responsible for providing 5V power. All DNS traffic is transmitted through the built-in 2.4GHz Wi-Fi of ESP32-C3, without the need for physical network lines.
The connection method is very simple. Just connect ESP32-C3 to the USB adapter, then plug it into the USB port on the back of the router, and the physical assembly is complete:

However, it should be noted that if the cheap USB-C to USB-A connector has poor contact, it may restart due to unstable power supply during Wi-Fi transmission.
The developer also reminds that the 3D printing shell should not cover the onboard antenna, try to avoid metal nearby, and keep ventilation holes. This board has a standby temperature of about 45-55°C. Although it is small, it cannot be completely sealed.
The picture below is the web control interface of ESP32-C3 AdBlock. You can view the number of blacklists, memory, temperature and blocking statistics of each device:

The most interesting part of this project is how to fit hundreds of thousands of domains into only 4MB of flash memory.
Generally, the blacklist will store plain text domains such as `doubleclick.net`. If hundreds of thousands of data are added together, it will soon exceed the capacity that ESP32-C3 can afford. ZedAxis does not directly save the complete name, but uses a 40-bit FNV-1a hash to convert each domain into a fixed 5 Bytes value, then sorts these values and writes them into flash memory.
It’s like replacing hundreds of thousands of names of varying lengths with fixed-length numbers. Not only does each piece of data take up less space, but the entire list doesn’t have to be read into RAM to search.
When a network device sends a DNS query, ESP32-C3 will first retrieve the domain name, use the same algorithm to calculate the hash value, and then compare it to the sorted database through binary search. If the same value is found, it will reply `0.0.0.0`, so that the device cannot connect to the corresponding advertising domain; if there is no hit, the query will be forwarded to the normal upstream DNS, and the real IP address will be obtained and then passed back to the client.
As for why not use the shorter 32-bit? The developers explain that hashing is not completely non-repetitive.
If two different domains produce the same value, an otherwise normal website may be blocked by mistake. Although 32-bit can save about 20% more space, it is estimated that there will be about 7 collisions when the blacklist reaches 250,000 transactions; 40-bit has no collision when the blacklist reaches 141,000 transactions, and about one collision when the blacklist is expanded to 537,000 transactions. 64-bit can further reduce the probability, but it will make each domain occupy 3 Bytes, which is not cost-effective for a device with only 4MB of space.
According to information released by the developer, if the approximately 141,000 domains are stored in string format, it may require approximately 2.5MB of RAM; after switching to 40-bit hashing, it only takes up approximately 0.67MB of flash memory. The entire firmware uses approximately 50KB of RAM when operating, and it takes approximately 10ms to complete a block query. This figure includes Wi-Fi round-trip time.
More detailed information can be found at ESP32-C3 AdBlock Project learn more.
Although the developer’s video mentions that it only costs $2, foreign media Tom’s Hardware The actual price found was about $5.
Source: KOCPC Chinese