Refactor iostream patching code, wrapping functions instead of overriding them. Measure receiving and sending speed and output them to console.