Why there are 3 different UDP ports in the SITL configuration file?

Hi.

I am using PX4 software-in-the-loop app to simulate multi vehicles setup which I am able to complete.

For each simulated vehicle, there is a configuration file which defines the vehicle configurations/parameters, see this.

In the end of the configuration file, the mavlink instances and the streamed information are set, see this
According to those settings, there are three different UDP ports that are being set.

There is also another UDP port which allows external interface (e.g. with MAVROS) with the SITL which is defined by the SITL_UDP_PRT parameter in this line.

My question is, why there are 3 different ports for the mavlink instance(s)? are they necessary? what are they used for?
These ports are namely 14556, 14557, 14540 .

Thanks.

One is for the simulator (gazebo or jmavsim) and one is for the connection to QGC. I’m not sure about the 3rd, but maybe for MAVROS?

Actually they become 4 with the simulator port. There are 2 ports for mavros, source and destination. However, using only one of them was enough for me to connect mavros to the SITL app.

Thanks, we should get this documented. https://dev.px4.io/en/
https://github.com/PX4/Devguide

It is already documented, but I dont see why we need two ports for comms with mavros.