-
Notifications
You must be signed in to change notification settings - Fork 57
NAT traversal
In this scenario, we assume one host has a public IP while the other doesn't. Obviously we are assuming that the side behind NAT is a receiver. If it were a sender only, the situation is trivial and doesn't need any workaround.
The idea behind the approach described below is that the computer behind NAT initializes the connection. It is analogous to TCP in a sense that the NAT keeps track of the "connection" state even for UDP. Client behind the NAT is required to send keepalive data to keep the UDP hole open the whole time (even if it acts as a receiver only).
In easiest scenario, we create an UDP hole from inside and send to it from outside. We are assuming use of default ports (5004 for video, 5006 for audio). Assuming that A has public IP while B is behind NAT (doesn't have a public IP address).
A ---------------- B NAT --- B ^ ^ ^ | | \ A IP (pub) NAT IP (pub) B IP (private)
Follows the setup of both machines.
If we act in a full-duplex way (both sender and receiver), you can use:
uv -t decklink -c JPEG -d gl A
Please note that both -t and -d are required.
If you want to receive only, use something like:
uv -t testcard:32:32:10:UYVY -d gl A
to generate a dummy keepalive traffic (to keep the connection open).
Furthermore, if you want to only send, you'll need specify ports explicitly:
uv -t decklink -c JPEG -P 5004:5004
This is because if UltraGrid acts as a sender only, it uses random source port. It is better to use a deterministic port (although not strictly required).
In easiest case you can run UltraGrid as usual (assuming you now B's NAT IP address):
uv -t decklink -d gl NAT
This works as long as you know the NAT address and NAT keeps port numbers unchanged. If not, you may obtain the address of the B's NAT and source port by runnig:
sudo jnettop -i eth0 -x 'udp port 5004'
There you should see address and src port (in jnettop the column right next to address) of the NAT.
With this knowledge, you can send to B using the NAT address and port:
uv -t decklink -P 5004:NAT_RX NAT_IP
Audio setup is not described to details for simplicity but is analogous to video - we need always send data from inside the NAT (host B) to keep the UDP hole opened.
If the NAT changes port numbers you will also need to obtain the audio source port used by NAT (can be done by jnettop - see above). Full commands may look like:
B$ uv -t decklink -s analog A
A$ uv -t decklink -s alsa -P 5004:NAT_VID_RX:5006:NAT_AUD_RX NAT_IP
or simply (if NAT keeps port numbers):
A$ uv -t decklink -s alsa NAT_IP
If you have any technical or non-technical question or suggestion please feel free to contact us at