What is Hole Punching?

Hole Punching is a technique to overcome NAT boundaries. To achieve this, the NATed parties have to contact a publicly reachable server. From this server the peers can request the partner’s connection data. Once both peers have got the connection data they simultaneously try to establish a direct connection to each other. The peer’s NAT now considers the incoming request an answer to the own outgoing request and hence does not drop it. Find out more about hole punching at http://www.brynosaurus.com/pub/net/p2pnat/.

What is Hole Punching RMI?

Standard Java RMI uses HTTP tunneling to cross firewalls and NAT boundaries. This technique, however, is limited to only a restricted set of network scenarios. In addition, it requires configuration that conflicts with most security policies. We have integrated the hole punching approach described above into Java RMI, providing a light-weight NAT traversal solution for Java RMI. Our solution consists of the following components:

  • Mediator: The mediator is a public reachable server that exchanges the public and private IP addresses between client and server objects. An implementation can be downloaded as an executable jar archive.
  • RRR: If you want to register the server stubs with an RMI registry, you need a registry that can handle remote registration. We have implemented such a remote registry, see RRR.
  • Custom Socket Factories: To change the communications behavior at network level to the hole punching behavior you have to export your server object with our custom socket factories.

How to Use Hole Punching RMI?

Using Hole Punching RMI is easy as using any other custom socket factories. Just download our custom socket factory and use the class HolePunchingRemoteObject to export your remote objects. See the detailed usage instructions

You also need a publicly reachable mediator server. You can download our implementation and start it with java –jar port. If you omit the port, the default port 8765 will be used.