Explain how network protocols work at the transport and application layers, focusing on how to debug packet loss or high latency.