When you live in an internet 3rd world country like Germany, chances are you’re using a Fritz!Box and have a bad or slow internet connection. In my case, the speed varies from time to time and it requires a restart of the router to get back to normal. There are a few projects out there to monitor internet speed on a Raspberry Pi, putting everything into a Grafana dashboard and so on.

However, you can also call the Fritz!Box API and get the current link speed back, it’s usually quite reliable, at least in my case where I want to check if I get the right speed from my provider. It also presented an opportunity to go back in time and use XML to make a SOAP request with curl. The good(?) thing is, there’s also no authentication required, so you can just run the command.

tl;dr:

curl 'http://192.168.178.1:49000/igdupnp/control/WANCommonIFC1' -H 'User-Agent: AVM UPnP/1.0 Client 1.0' -H 'Content-Type: text/xml' -H 'SoapAction: "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1#GetCommonLinkProperties"' -d '<?xml version="1.0" encoding="utf-8" ?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:GetCommonLinkProperties xmlns:u="urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1" /></s:Body></s:Envelope>'

the XML part looks like this when it’s not minified:

<?xml version="1.0" encoding="utf-8" ?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:GetCommonLinkProperties
            xmlns:u="urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1" />
        </s:Body>
    </s:Envelope>

You’ll get some XML with some information and the important bits about the up and downstream:

<NewLayer1UpstreamMaxBitRate>36147000</NewLayer1UpstreamMaxBitRate>
<NewLayer1DownstreamMaxBitRate>114103000</NewLayer1DownstreamMaxBitRate>

Here’s a python script to run this request and get just the up- & down link back in megabytes.