Skip to content

[new-feature]: Per-endpoint RTP port range configuration for PJSIP #71

@mahirgul

Description

@mahirgul

Feature Description

1. The Problem
Currently, Asterisk manages RTP ports globally through rtp.conf. While this is suitable for most deployments, it lacks granular control. In complex environments, especially those involving multiple NATs or specific firewall rules, it would be highly beneficial to define a dedicated RTP port range for each PJSIP endpoint.

For instance, a proxy or a session border controller (SBC) might require specific endpoints to communicate on a predefined, restricted set of ports. The current global rtp.conf setting forces all endpoints to use the same large port range, which is inefficient and difficult to manage in such scenarios.

2. The Proposed Solution
I propose adding a new configuration parameter to the PJSIP endpoint configuration in pjsip.conf. This parameter would allow developers to specify a dedicated RTP port range for each endpoint, overriding the global rtp.conf settings for that specific endpoint.

Proposed Parameters:
rtp_start: Defines the starting port number for the dedicated RTP range.
rtp_end: Defines the ending port number for the dedicated RTP range.

Example in pjsip.conf:

[webrtc_endpoint_1]
type=endpoint
context=webrtc-context
aors=webrtc_endpoint_1
transport=transport-ws
rtp_start=15000
rtp_end=15005

[webrtc_endpoint_2]
type=endpoint
context=webrtc-context
aors=webrtc_endpoint_2
transport=transport-ws
rtp_start=15006
rtp_end=15011

3. Benefits of this Feature
Improved NAT Traversal: Provides better control for devices behind complex NAT configurations, allowing specific port forwarding rules.

Enhanced Security: Allows administrators to restrict RTP traffic to a minimal, endpoint-specific port range, reducing the attack surface.

Greater Flexibility for Integrators: Enables third-party applications, like media proxies or SBCs, to integrate with Asterisk more seamlessly by using predictable and non-conflicting port ranges.

Efficient Port Management: Prevents the exhaustion of the global port range in large-scale deployments by assigning smaller, dedicated ranges to each endpoint.

4. Technical Considerations
Conflict Resolution: The implementation must handle potential conflicts if multiple endpoints are configured with overlapping or identical port ranges. The system should log an error and fall back to the global rtp.conf setting in case of a conflict.

Dynamic vs. Static: This feature should be an override for the dynamic port allocation. If rtp_start and rtp_end are not defined for an endpoint, Asterisk should continue to use the global rtp.conf range as it does today.

5. Call to Action
I believe this feature would be a valuable addition to Asterisk, addressing real-world challenges faced by system integrators and administrators. I am open to discussing the implementation details and contributing to the development of this feature.

Thank you for your consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions