Rewrite network testing using asyncore/asynchat

As Nick points out in #8531 (moved), we should use asyncore or maybe even asynchat for the network testing in Traffic.py.

This will give us more readable code and higher code quality.