phpandroidlinuxpacketwireless

How to control Android data packets using PHP?


I know that Android is based on Linux. Also, I know PHP fairly well and I think PHP for Linux is a suitable choice (correct me if I'm wrong).

Many days ago, I faced a problem. The problem was and is, how to control packets using a PHP code? Can I do that?

Let me say further. To connect to the network, we have network interfaces (see /sys/class/net). In Android, there are many interfaces, such as wlan0 (for my case). It is used for such wireless connections as WiFi and WiFi tethering.

After a lot of researching, I found a Linux command called tc (Traffic Control) that is used to control network packets. However, I don't really know how to use that command to control bandwidth of each connected device to my WiFi hotspot. I want to set quotas for each one and if they reach them, I stop them from using my internet. I want to use PHP for that purpose. How to do that? (Sorry, but I'm a little bit new to Linux!)

Note: I want to limit my users via MAC address, not IP address.


Solution

  • Thanks to @Gudgip, I've written a command line tool which runs on Linux (also, obviously Android) using the power of PHP that sniff packets over an interface and saves the results into files. For example, you can see how much data each user used from your WiFi. See:

    https://github.com/machitgarha/dej

    If you see issues, please open one. Hope it helps someone!