rtsp session via Internet - NAT problem

About encoding, codec settings, muxers and filter usage
evd
Blank Cone
Blank Cone
Posts: 13
Joined: 19 Jan 2008 01:52

rtsp session via Internet - NAT problem

Postby evd » 12 Nov 2008 00:06

Hi,

My system consists of three nodes at different locations on the Internet:

IP-camera <---> LAN1 <---> ADSL-router/firewall/NAT-1 <---> INTERNET

VLC Server <---> LAN2 <---> ADSL-router/firewall/NAT-2 <---> INTERNET

VLC Client <---> LAN3 <---> ADSL-router/firewall/NAT-3 <---> INTERNET

The VLC Server connects to the IP camera using the following command:
vlc -I dummy -vvv rtsp://xxxx.dyndns.org:554/mpeg4/media.amp --sout "#rtp{sdp=rtsp://:8081/test.sdp}"

This works fine. The rtsp session setup shows a.o. the following:

Sending request: SETUP rtsp://xxxx.dyndns.org:554/mpeg4/media.amp/trackID=1
RTSP/1.0
CSeq: 3
Transport: RTP/AVP;unicast;client_port=61954-61955
User-Agent: openRTSP (LIVE555 Streaming Media v2007.12.06)

Received SETUP response: RTSP/1.0 200 OK
CSeq: 3
Session: 0700422311;timeout=60
Transport:
RTP/AVP;unicast;client_port=61954-61955;server_port=50018-50019;ssrc=3CFA4EEC;mode="PLAY"



As the next step, I connect the VLC client to the VLC server by opening the following network stream in a VLC player:
rtsp://yyyy.dyndns.org:8081/test.sdp

This does not work. Testing the session setup to the VLC Server with the openRTSP tool shows the following:

Sending request: SETUP
rtsp://yyyy.dyndns.org:8081/test.sdp/trackID=0 RTSP/1.0
CSeq: 3
Transport: RTP/AVP;unicast;client_port=1232-1233
User-Agent: openRTSP (LIVE555 Streaming Media v2008.11.04)

Received SETUP response: RTSP/1.0 200 OK
Transport: RTP/AVP/UDP;client_port=1232-1233
Server: VLC Server
Content-Length: 0
Cseq: 3
Cache-Control: no-cache
Session: 101027544



Comparing the session setup between the IP camera and the VLC server on one hand, and the VLC Server and VLC client on the other hand, I see one major difference:
IP-camera <---> VLC Server: as a response to the SETUP request both the client_port range and the server_port range are communicated.
VLC Server <---> VLC Client: as a response to the SETUP request only the client_port range is communicated.

NAT devices interpet SETUP request/response packets in order to build dynamic NAT rules. As a consequence:
1) once the IP-camera starts streaming UDP packets to the VLC Server, the NAT device at the VLC Server location knows that incoming UDP packets with source ports 50018-50019 need to be forwarded to ports 61954-61955 of the VLC Server host, because this information was communicated in the SETUP response.
2) after the VLC client has established an rtsp session with the VLC Server, it starts waiting for UDP packets. But the NAT device at the VLC Client location does not know with which source ports these UDP packets will be coming in, because the server_port range has not been communicated. Therefore, the NAT device at the Client location will discard the UDP packets that are sent by the VLC server, and the VLC Client ends up with a message like "no data received for over 10 seconds", eventually ending up with "nothing to play".

Note that this system works properly if all nodes are located within the same LAN (no NAT devices involved).

Does anybody know if there is a way to get the server_port range being communicated in a rtsp session setup?

Cheers........
Erik

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: rtsp session via Internet - NAT problem

Postby Rémi Denis-Courmont » 12 Nov 2008 17:20

The problem seems to be that you're using the VLC RTSP broadcast mode in the first and the VLC RTSP buggy VoD mode in the second.

That being noted, knowing the server_port does not solve NAT traversal. You would need to know the server_port first to determine the client_port anyway, which RTSP does not allow.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

evd
Blank Cone
Blank Cone
Posts: 13
Joined: 19 Jan 2008 01:52

Re: rtsp session via Internet - NAT problem

Postby evd » 12 Nov 2008 18:16

Thanks. What should I change in order to use the VLC rtsp broadcast mode for both the "IP-camera <--> VLC-Server" session and the "VLC-Server <--> VLC Client" session?

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: rtsp session via Internet - NAT problem

Postby Rémi Denis-Courmont » 12 Nov 2008 21:03

Broadcast is a live stream. Every receivers gets the same, and you cannot seek or pause. If the input is a live camera, then you really should use broadcast mode anyway. Also make sure you have vlc 0.9.*
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 13 guests