its pretty simple.
first setup a test server(s) that you can call for the speed test. professional speed testers will have lots of server in different geographic locations, and will use geolocation to pick/display close servers.
for upload speed test you send a packet to the test server, and the server sends a response. using wall clock time, you time the response.
for download, you request a packet from the test server and measure time to receive. there is no need to save the data.
you can measure latency by timing how long the tcp connection to the test server takes.
note: if you expected to get network performance for non test requests, than that not doable. If you created a proxy or vpn service you could get performance data. your proxy/vpn code measure traffic time, by wrapping the requests with a protocol that measured the packet times. This is beyond the scope of a Maui app.