Track Mania Nations ESWC, LAN game extender

Purpose:

Allow Track Mania Nations ESWC LAN games to be played outside of a LAN, enabling true cross LAN and cross site multiplayer games. This has been tested to work over multiple VPNs connecting cable modems and adsl modems. The relay will run on a Linux machine acting as firewall, or, using the Windows version on the machine that runs the TmNations game. Tests have shown all client subnets (but not the server subnet) require tmnrelay. Tests forwarding ports without using a VPN have not yet been made. If you have machines connected via a LAN but on different subnets, that will also work - this amounts to the same situation as a VPN.

A port to Windows is provided, run from an msdos prompt.

Look in the ToDo section for more Windows references.

Has been tested to work with patch level V1.7.5 english.

Download:

tmnrelay.c - the Linux/Windows source
tmnrelay.zip - the Windows executable

Compile with:

gcc -O2 tmnrelay.c -o tmnrelay

Usage:

As root:
./tmnrelay <server IP> [potential server IP] [potential server IP] ...

where the IP addresses are machines potentiall running TMN. If you run tmnrelay on the same machine as the game itself, you need to run tmnrelay first, or tmnrelay will be unable to bind to the the local UDP port.

General usage:

tmnrelay needs to be running on the subnets of all TMN client machines, this normally means each client must be connected via a switch to an instance of tmnrelay.

tmnrelay without a VPN:

We have yet to test this scenario.

Theory of operation:

The job of tmnrelay is to relay broadcast packets sent out by TMN when looking for a game server. Once the clients/server know each others IP address, there is no need for tmnrelay as the clients/server talk directly to each other using the IP addresses obtained during the broadcast (or tmnrelay's relayed broadcast).

As broadcast packets only spread as far as the subnet from which they originated, TMN clients can't normally find TMN servers on a nearby subnet. tmnrelay looks for these broadcasts and sends a copy of what it receives to the IP addresses given as arguments. tmnrelay fakes the source IP addrees, so the relayed broadcast packet (which is no longer a broadcast as it is sent directly to single machines) looks like it came from the original machine, making the packet relay process transparent.

For example, if 192.168.15.51 is the TMN client, 192.168.0.7 is the TMN server, both machines (and networks) are connected by a Linux machine on IPs 192.168.15.1 and 192.168.0.100. When told to look for LAN games, TMN looks for servers by sending out a udp broadcast to port 2360 (among others, but that doesn't seem to matter):
192.168.15.51:1356 -> 255.255.255.255:2350 udp (subnet 192.168.15.0/24)
tmnrelay receives the broadcast, and sends it to the other given IP faking the original sender IP address:
192.168.15.51:1356 -> 192.168.0.7:2350 udp (subnet 192.168.0.0/24)
TMN server will receive this spoofed packet and accept this as if it was a broadcast on the same subnet by the client.

When the clients and server are not on nearby subnets, the same idea still works but in this case tmnrelay needs to redirect the clients packet across a VPN.

To do:

Playing externally across sites without the VPN will probably need additional changes, to send the firewall IP as the source address rather than the private IP. Its possible that you don't need this, as there is a "NAT Local connections" kernel configuration option which might NAT the spoofed packet correctly.

As a more general solution, look for the Gamers Internet Tunnel. Don't know if this supports Rainbow 6, but it could do.

As an even more general solution, you can look at OpenVPN, a secure cross platform VPN.

Credits:

in_cksum(), pseudohdr and udpsend() came from a German language 'hacker' howto, one of the few examples of RAW packet generation that actually generated well formed packets.

Other code and the main idea came from Richard Gregory, greg at csc.liv.ac.uk

This program is from the same stable as nfsu2relay, nfsu3relay and rain6relay, all doing mostly the same thing to/from different ports.

History:

1.0 11/5/2006

Hacked this up in a about an hour, as it is based on rain6relay.

Linux and Windows versions have been tested to work over a ppp-ssh based VPN between 3 sites.