Thursday 21 January 2010

UDP is a different animal to TCP

This post is all about how Globe is going to work or is working from a networking perspective.
Firstly I'll explain a bit about TCP and UDP sockets.

TCP
Transmission Control Protocol is a connection based protocol, so the client makes a direct connection with the server, data is sent and received and when everything is complete the socket is disconnected.

UDP
User Datagram Protocol is a connectionless packet based protocol, so no connection between client and server is made, instead packets are created and sent across networks via routers. UDP is an unreliable protocol, as in there is no guarantee the data will arrive at its destination and in the same order it was sent. Because the protocol is connectionless, it has much less overhead and is far more efficient than TCP at transferring data.

UDP also comes with some interesting features that I am still in the process of researching.

Multicasting
A server creates a multicasting group, clients join the group which acts as an end point, the server sends streaming data once to the group and it is automatically duplicated and distributed to client group members as required by the network. There isn't a more efficient way to send data across a network than this, and recently BT has talked of plans to unveil HDTV over this kind of connection, which shows the kind of data transfer possible.
I am not sure of ISP support of multicasting or what is involved yet, so more to come on this when I find out.

Unicasting
Still researching this one.

Broadcasting
I have found with broadcasting, unlike multicasting, everyone in range of the server receives the packet, not just clients subscribed to a group. From what I have read this is only really useful in a LAN environment, so I won't be researching this any further.

As you know, there are 3 types of server to the Globe system.
Login Server
Asset Server
Simulator Server

All 3 servers were originally implemented with TCP sockets. The login and asset server will stay as TCP, but the simulator needs constant fast data transfer, so it is moving to UDP.

What flavour of UDP depends on my research.

The plan is to get the UDP implemented in the simulator server at the same time as the temporary box avatar, so that features can be developed such positioning of other nearby avatars and chat.

I looked at the Enet network library in a bit more detail and it seems they have devised a wrapper for UDP to guarantee delivery of packets in the right order, so this is still a strong contender. Again, needs more research.

I'll keep ya posted.

No comments:

Post a Comment