RTSP server UDP static port range

About encoding, codec settings, muxers and filter usage
ner0
Blank Cone
Blank Cone
Posts: 10
Joined: 25 Apr 2010 13:49

RTSP server UDP static port range

Postby ner0 » 12 Jun 2016 15:48

Hi.

I have searched the forums, and the internet in general, for a solution to this issue.
I don't know why there is no information on this or why it's so hard to find it, is it technically impossible?

So, I'm serving an RTSP stream and I need to port forward on the firewall the incoming ports to the correct host inside the local network.
The problem is that the ports are always randomly assigned to a range than spans across more than 15000 UDP ports.

Here are a few examples of TCP packets broadcasting the ports to be used in the streaming sessions:

Code: Select all

Transport: RTP/AVP/UDP;unicast;client_port=60746-60747;server_port=55266-55267;ssrc=E3AD4365;mode=play Transport: RTP/AVP/UDP;unicast;client_port=56000-56001;server_port=60981-60982;ssrc=D499D164;mode=play Transport: RTP/AVP/UDP;unicast;client_port=52234-52235;server_port=61618-61619;ssrc=FE52B1D0;mode=play Transport: RTP/AVP/UDP;unicast;client_port=54984-54985;server_port=62476-62477;ssrc=769B8B20;mode=play
As you can see, the server_port range is always changing wildly in each of the sessions started.
I've been able to do the opposite of what I want, which is to set the port range used by the client:

Code: Select all

rtp{dst=127.0.0.1,port=5123
The arguments above result in something like this:

Code: Select all

Transport: RTP/AVP/UDP;unicast;client_port=5122-5123;server_port=61339-61340;ssrc=9F837FC8;mode=play
This has set a static range for the client_port, but no argument seems to be able to set a static range for the server_port.

Any suggestions would be very welcome, thank you.

kmf31
Cone that earned his stripes
Cone that earned his stripes
Posts: 308
Joined: 11 Mar 2007 21:47

Re: RTSP server UDP static port range

Postby kmf31 » 12 Jun 2016 19:40

I don't know if you can fix this on the server side but I think you can fix the udp port used by RTSP in the client-vlc instance either in the preferences: Input/Codecs => demuxers => RTP/RTSP => client port, or as command line parameter with "--rtp-client-port=...". Here the value "-1" is automatic and the default. In this way the client tells the serveur which port to use, at least I think so.

I know that on the Freebox IP-TV (RTSP-IP-TV from a french provider) this works in this way and allows to program the proper redirections on the router (for only one pair of udp ports and not all ports). With the Freebox IP-TV it is only necessary if one uses his own router. The official Freebox-router-mode already takes care of this automatically.


Theoretically there is also another solution on the router side (without udp-port fixing): using a parameter called port-triggering (or something similar) in the router configuration (if available) or if you are using a Linux PC as router (e. g. a Linux PC with two network cards and configured as Nat-Router) one can download (and compile/install) a kernel modul for rtsp conntrack: https://github.com/maru-sama/rtsp-linux
This modul helps also if the Linux PC is only a simple vlc-client in order to open automatically the proper udp-ports on the firewall of this PC.
Apparently this modul never found it's way in the official linux kernel (but I did not verify for the most recent linux kernel versions) but you can add it on your own. I used it my self some time ago and it helps to avoid to fix the udp ports in vlc as client (better solution if you want to use several vlc-client instances simultaneously). Also the Freebox itself needs to use a module like this in its routeur configuration.

ner0
Blank Cone
Blank Cone
Posts: 10
Joined: 25 Apr 2010 13:49

Re: RTSP server UDP static port range

Postby ner0 » 12 Jun 2016 20:26

Thanks for the reply.

The "--rtp-client-port=xxxx" argument works, but unfortunately that is the complete opposite of what I need and there doesn't seem to be any way to override VLC's stubborn behavior.
I actually need something to set the range of the server's incoming ports for UDP traffic while streaming, "rtp-client-port" would set the client's incoming port range (server's outgoing port range).

As for the port triggering possibility, I don't think it would work because in order to do that I would need to define a range of ports to forward and the trigger port, and there I have more than one problem.
I still wouldn't know what outgoing port to use as a trigger and what port range the server will choose for the stream. So far I've seen traffic from ports 45000+ through 64000+
I can't create any forwarding rule for that and my router will tell me why: because it will create conflict with other ports already in use among those thousands of ports.
Also, I'm using Windows which is a downside but also one less headache to care about :)

I'm completely at loss here. Maybe I'm misunderstanding something, I don't know.
The closer I've come to a solution was some forum I found about a French user that compiled his own version of VLC with a fixed range of UDP ports, but that was a very old thread for a very old version of VLC, no longer useful this point.

I appreciate your suggestions, thank you.

kmf31
Cone that earned his stripes
Cone that earned his stripes
Posts: 308
Joined: 11 Mar 2007 21:47

Re: RTSP server UDP static port range

Postby kmf31 » 12 Jun 2016 21:48

The closer I've come to a solution was some forum I found about a French user that compiled his own version of VLC with a fixed range of UDP ports, but that was a very old thread for a very old version of VLC, no longer useful this point.
I suppose you speak of the vlc version from "crazyfred", a patched version to vlc-0.8.4a. I remember this because of the routeur issue for the IP-TV of Freebox around 2006. To my understanding this version did exactly what the option "client port" does and which was not present in the stock version of vlc-0.8.4a. However as of vlc-0.8.5 this option was integrated in the official version and there was no longer need for the crazyfred version.

What I know for certain to use the RTSP-flux of Free's IP-TV behind a router (other than the freebox itself as router) one needed (and still needs):

1) either crazyfred version or a more "recent" vlc version (i.e. vlc-0.8.5 or later) and to fix the udp-client port thus allowing a simple redirection in the router for this udp-port (actually two neighbor ports X and X+1 if X is an even number),

2) either a router with working port-triggering thus the router opens/redirects exactly the used udp-ports by vlc when necessary,

3) either a linux PC-router with this rtps-conntrack module installed with the same effect as 2).

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

Re: RTSP server UDP static port range

Postby Rémi Denis-Courmont » 13 Jun 2016 11:17

VLC uses the OS dynamic port range. You are free to tune it in the OS settings.

Sharing the server ports for multiple RTSP client is not supported and is anyway a bad idea for performance and reliability reasons.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

ner0
Blank Cone
Blank Cone
Posts: 10
Joined: 25 Apr 2010 13:49

Re: RTSP server UDP static port range

Postby ner0 » 13 Jun 2016 14:17

Thanks for the reply.
Could you elaborate a bit more, please?
How would I tune the range for VLC only?
Thank you.


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 37 guests