Search code examples
tcpudp

Different Applications of TCP and UDP


In one of my classes, we went through TCP and UDP. Largely, I understand the fundamental difference.

  • TCP uses, 3 way handshake, congestion control, flow control and other mechanism to make sure the reliable transmission.
  • UDP is mostly used in cases where the packet delay is more serious than packet loss

The question outlined below, believe that TCP makes most for TCP, sense the order of the data that would translate to a conversation would be essential and UDP for the network handler that send player data because speed is most important for playing a competitive online game that relies on reflexes.

Does this make sense? Or am I generalizing the problems too much?


Question:

TCP and UDP. The online game is a first person shooter game where real players fight each other with guns in 5 versus 5 matches. You are in charge of two features:

  • an implementation of real time voice chat,
  • the network handlers that send player data from the end user’s clients to your dedicated, central servers

Which protocols do you use for each and why?


Solution

  • With TCP the devices at the end points need to establish a connection through a "handshake" before any data is sent. TCP also uses flow control, sequence numbers, acknowledgements and timers, to ensure reliable data transfer. Congestion control is also used by TCP to adjust the transmission rate. The implementation of the above mechanisms comes at a time cost.

    UDP, on the other hand, does almost nothing except from multiplexing/demultiplexing and a simple error checking.

    Real time applications often need a minimum bitrate and can tolerate some data loss. In your example, of a real time voice chat, it is more important for the users to hear each other without delay even if a few milliseconds are inaudible. The network handlers that send player data to the server, should use TCP because reliability of the data there is vital.