Categories
Game Development

New congestion control thanks to UDT

A few years ago, a user in the forum stated that UDT had much higher throughput than RakNet for LAN transfers. I took a look at it and it was made by a couple of research scientists for the purpose of being faster than TCP. While they published details of their work, the documentation is […]

A few years ago, a user in the forum stated that UDT had much higher throughput than RakNet for LAN transfers. I took a look at it and it was made by a couple of research scientists for the purpose of being faster than TCP. While they published details of their work, the documentation is extremely technical and academic. Anyway, I said at the time that RakNet was designed with different goals, and if all they wanted was high speed LAN transfer to use UDT instead.

Since that time, I had ongoing problems with congestion control. Every 2-6 months I’d try a different approach with incremental improvements. But with the wide range of scenarios under which RakNet is used, there was always a new scenario where it didn’t work. So I basically gave up, and turned to UDT for help.

My first approach was to directly integrate UDT into RakNet. I spent about a week removing all exceptions from the UDT source, changing to the RakNet memory allocator, and integrating RakNet to use UDT for sends and receives through RakNet’s own sockets. I had it working, but had problems where UDT didn’t connect as fast as RakNet. UDT also didn’t support priority levels or different sending types other than RELIABLE_ORDERED. I wasn’t happy about having another UDP library integrated into my core product just for one feature (congestion control). In the end, I released this an optional define flag. It’s present in version 3.62 though I left it disabled by default.

At random, I saw an advertisement by one of the authors of UDT, Yunhong Gu, for paid contracting. Rather than have him code a solution, I had him write a technical design document on how the UDT congestion control was implemented, so I could implement it myself.

The result of my implementation

Using DevPartner performance analysis I eliminated the top 20% CPU utilization from RakNet. I also reduced the bandwidth overhead, even though more information is sent. In the end, I raised the file transfer rate on localhost from 2 to over 20 megabytes per second (I’ve seen it go as high as 40 on another computer). And the transfer rate to my remote server went up by 50%.

I’m pretty happy with the end-result. This is probably the most significant improvement to RakNet I’ve made since it was developed. I’ll be releasing this as version 3.7 in the very near future.

Leave a Reply

Your email address will not be published. Required fields are marked *