# How many UDP ports Mediasoup needs per session?

**URL:** <https://mediasoup.discourse.group/t/how-many-udp-ports-mediasoup-needs-per-session/1031>\
**Category:** mediasoup libraries\
**Created:** [May 18, 2020, 5:54am UTC](https://mediasoup.discourse.group/t/how-many-udp-ports-mediasoup-needs-per-session/1031 "2020-05-18T05:54:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thehappycoder](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/thehappycoder/32/320_2.png) [@thehappycoder](https://mediasoup.discourse.group/u/thehappycoder)\
**Post date:** [May 18, 2020, 5:54am UTC](https://mediasoup.discourse.group/t/how-many-udp-ports-mediasoup-needs-per-session/1031/1 "2020-05-18T05:54:58Z")

</div>

1. There are _rtcMinPort_ and _rtcMaxPort_ settings [https://mediasoup.org/documentation/v3/mediasoup/api/](https://mediasoup.org/documentation/v3/mediasoup/api/)

I wonder how many ports are required for each “room” in case when there are:

- 1 video publisher
- 2 video consumers
- 2 audio publishers
- 3 audio consumers

I didn’t count gstreamer, which I use for recording, as a consumer. If gstreamer is a consumer too, then will it use more UDP ports for RTC?

1. I’ve found this checklist [https://github.com/versatica/mediasoup/wiki/Multi-Stream](https://github.com/versatica/mediasoup/wiki/Multi-Stream) that mentions [draft-ietf-avtcore-multiplex-guidelines](https://tools.ietf.org/html/draft-ietf-avtcore-multiplex-guidelines): Guidelines for using the Multiplexing Features of RTP to Support Multiple Media Streams

Is it implemented in Mediasoup v2 or v3 by any chance? The checklist hasn’t been updated since 2017 so I am not sure it’s up to date. As I understand, this feature is going to affect the number of ports required per room.

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [May 18, 2020, 10:10am UTC](https://mediasoup.discourse.group/t/how-many-udp-ports-mediasoup-needs-per-session/1031/2 "2020-05-18T10:10:37Z")

</div>

Each `SendTransport` or `RecvTransport` you create in mediasoup-client requires separate `WebRtcTransport` in the server, so the number of ports will be:

- number of `WebRtcTransport` in the server multiplied by the number of `listenIps` you pass to the `router.createWebRtcTransport()` in the server.

---

<div class="post-metadata">

**Author:** ![thehappycoder](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/thehappycoder/32/320_2.png) [@thehappycoder](https://mediasoup.discourse.group/u/thehappycoder)\
**Post date:** [May 18, 2020, 11:28pm UTC](https://mediasoup.discourse.group/t/how-many-udp-ports-mediasoup-needs-per-session/1031/3 "2020-05-18T23:28:24Z")

</div>

What about the 2nd part of the question about Multiplexing Features of RTP?

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [May 19, 2020, 12:04am UTC](https://mediasoup.discourse.group/t/how-many-udp-ports-mediasoup-needs-per-session/1031/4 "2020-05-19T00:04:19Z")

</div>

Yes, we implement that draft (the thing related to SFUs). But forget about that. We do BUNDLE (N streams over the same ICE/RTP connection, etc). This is in documented in the website.

---

<div class="post-metadata">

**Author:** ![footniko](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/footniko/32/79_2.png) [@footniko](https://mediasoup.discourse.group/u/footniko)\
**Post date:** [October 12, 2020, 7:39am UTC](https://mediasoup.discourse.group/t/how-many-udp-ports-mediasoup-needs-per-session/1031/5 "2020-10-12T07:39:01Z")

</div>

> [@ibc](#):
>
> number of `WebRtcTransport` in the server multiplied by the number of `listenIps` you pass to the `router.createWebRtcTransport()` in the server.

@ibc How this is being applied to the number of CPUs and piping between routes (if the number of routes = number of workers/CPUs)?
