The purpose of this program is to remotely monitor the bandwidth usage of the platform on which it is installed, and to dynamically manipulate the bandwidth usage of the platform network interfaces. The communication interface between the remote system and the system being monitored is performed through the CoAP transmission protocol. The server side where the monitored system receives new commands or simply the latest bandwidth usage and transfer the requested measurement to the requester.
The test environment is composed of a Raspberry Pi 3B+, a remote computer and Firefox (version 55.0.3 or lower) that supports the CoAP plugin. The newest version of the Firefox does not unfortunately support the CoAP plugin.
The software wraps indeed two Linux programs, namely, wondershaper and ifstat to provide an easy usage to manipulate the network interface. The source code hasn’t been dockerized, therefore the installation of those programs are required. Wondershaper allow us to change the upload&download amount for a specific interface, whereas ifstat is utilized for the bandwidth monitoring purposes.
We can start the wondershaper with some initial parameters as below:
- netint = network interface
- upload = KB/s
- download = KB/s
It is also possible to start with a duration parameter, which executes the wondershaper for a specific amount of time. For instance, the following URL will run this software only 3 secondes, afterwards wondershaper configuration will be removed:
- duration = seconds
As we can define a number of rules, we can also manually remove all configuration of a network interface below:
As mentioned before, the bandwidth monitoring is operated through the ifstat Linux command and it is performed with the following URL:
- netint = network interface
- wTime = waiting Time for each taken measurement
- mCount = the number of the measurement to be taken
Based on the given parameters, we can give the interval of the measurement times and the number of the total measurements to be taken. Afterwards, it is possible to retrieve the measurement results with the following URL:
The intention in this software was to create a REST-based bandwidth monitoring and controlling system. If the bandwidth observation is important and analyzed later on, it is recommended to replace the CoAP protocol with a pub/sub system, i.e. MQTT. The source code of the software can be acceded via this reference.
Creating Environment and Testing
Test Environment: Linux Ubuntu Required Tools: wondershaper, ifstat
sudo apt-get install wondershaper trickle ifstat
Run the controller on the side where the bandwidth will be controlled:
$ python BandwidthController.py
Open Firefox Coap Client and search for the published services and call them:
The usages of wondershaper and ifstat on the Linux console:
$wondershaper <interface> <download-rate> <upload-rate>
# ifstat -i etho <timeToBeWaited> <MeasurementCount>
$ ifstat -t -i eth0 1 1 > bwmon.log