Show how Much Data (MBs) has been Saved

Not sure if it's possible to calculate the file size of an ad based on DNS queries alone, but I think it would be pretty satisfying to look at the dashboard and see that X amount of data has been saved, especially for those of us with metered connections.

Since we block connections to the ad server and don't download the ad, the only way to know the size saved would be to download the ad and thus save no data.

Ok, that makes sense. Adguard for Android has this feature and that's what made me think of it. I'd be curious to know how they do it.

I have experimented with this feature in the past. By using curl -I, you can parse out the Content-Length field, which is how many Bytes the asset is. The URLs of these assets can be found in the /var/log/lighttpd/access.log, so we could make a script that would download the headers of these assets and then add up how many Bytes total would have been downloaded.

The header from the actual asset would need to be downloaded via curl, so you would need to bypass Pi-hole and use a different DNS server and you may run into issues with caching.

This solution is also slightly paradoxical because even though you are not downloading only the HTTP header and not the actual asset, you are using some bandwidth to get the header. These headers are relatively small (8KB-16KB), but you still need to download them.

So Pi-hole would block the ad completely by not downloading it, thus saving on bandwidth, but if you download the headers, the calculations would be off. I suppose this could be adjusted for after adding everything up and then accounting for the average header size...

It looks like Adguard for Android acts as a proxy, meaning that all traffic flows through it. With a Pi, that would mean your bandwidth is limited to how fast you can move it through the Pi (it only has a 100mbps bus, and usually doesn't reach that speed).

I want to see how much bandwidth I actually saved. And to that, I would love to see how much bandwidth each client is using.

I also would like to see how much bandwidth each client has used in their current session or all time

DNS requests don't really correlate to bandwidth directly. You can see how many requests from ad based domains you blocked but one ad domain could serve you 1K small text ads and another could serve 100G of video ads a month. We don't know this kind of info though so even estimating would be impossible. Pi-hole has a flat number of blocked DNS requests and anything beyond that is guess work.

The only way to really know would be to run a controlled experiment. Browse a whole bunch of sites and the whole time duplicate all requests, one going through conventional unfiltered internet and the other through a pi-hole. Then compare the bandwidth at the end.

Routers measure bandwidth quite well and have these kind of stats/graphs typically, but without actually making the requests for the ads (hence not saving any bandwidth) we don't know what bandwidth was saved.

Out of scope using Pi-hole