UDP vs. TCP


  A number of advantages appear in the use of UDP over TCP.  The first of these
is that every connection to the server is managed with the same socket with
UDP, while TCP requires a separate connection for each client.  There is a
system limit to the number of files that may be open per process, and each
socket counts as a file this could become a problem for a large client base.
Also with TCP each socket was managed by a separate thread and each open TCP
socket is associated with a protocol control block(PCB) by the operating
system. In addition to the memory usage generated by the PCB's there is also
upkeep involving things such as demultiplexing incoming packets to a port to 
separate TCP sockets and placing the packets into separate datastreams for each
socket.  With UDP there is one PCB, one socket, and one thread.  UDP generates
far less upkeep.

  Also, since we do not require the level of packet guarantees that TCP offers,
extra latency was added due to the packet guarantees.  However, with UDP we
recieve NO packet guarantees, so to guarantee packets that have to arrive we
had to build that functionality in ourselves.

  Other general effects of switching over to UDP: the PCB's created by a 
server under TCP would hang around for several minutes after a connection was 
closed to prevent connections from reforming from the same address and 
port (this is part of the general TCP protocol and protects against old packets 
disrupting communications).  This causes problems most often found in web 
servers where due to the number of tcp connections used memory is quickly eaten 
by space allocated to the PCB's that are no longer needed.  If VRMidtown 
were to ever generate enough tcp connects and disconnects this would become a 
problem.

  Overall UDP generates a more scalable system by reducing the memory 
and cpu overhead.  Also there is a large boost in network performance due to 
the time saved by eliminating the unnecessary features of TCP, packet
guarantees, etc..

  UDP however required extra work to implement any required guarantee systems 
and to determine if someone is still "connected" as these were inherent in TCP.
  
  The boost in performance is noticeable over the TCP implementation.