[ROS2] Finding the originating socket for a ROS2 node
I have created my own little node called tester_publisht
, and am trying to find the originating socket of the node. However, the node is using 4 separate ports, and I have no idea what the output means.
user@ubuntu:~$ lsof -iUDP
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
spotify 2067 user 92u IPv4 276438 0t0 UDP *:57621
spotify 2067 user 108u IPv4 276451 0t0 UDP *:1900
spotify 2067 user 128u IPv4 276452 0t0 UDP *:55193
tester_pu 9642 user 6u IPv4 241204 0t0 UDP *:7400
tester_pu 9642 user 7u IPv4 241207 0t0 UDP *:7412
tester_pu 9642 user 8u IPv4 241210 0t0 UDP *:7413
tester_pu 9642 user 9u IPv4 241213 0t0 UDP *:41004
rqt_graph 14766 user 24u IPv4 243242 0t0 UDP *:7400
rqt_graph 14766 user 25u IPv4 243246 0t0 UDP *:7414
rqt_graph 14766 user 26u IPv4 243250 0t0 UDP *:7415
rqt_graph 14766 user 27u IPv4 243253 0t0 UDP *:39130
_ros2_dae 19978 user 6u IPv4 250922 0t0 UDP *:7400
_ros2_dae 19978 user 7u IPv4 250927 0t0 UDP *:7416
_ros2_dae 19978 user 8u IPv4 250932 0t0 UDP *:7417
_ros2_dae 19978 user 9u IPv4 250935 0t0 UDP *:36155
tester_publisht
, rqt_graph
and _ros2_daemon
are the nodes that are running (sorry about Spotify :) ).
Running ros2 node list -a
reveals the three nodes above, and running ros2 topic list
returns /clock
(the topic that tester_publisht
is publishing to), /parameter_events
and /rosout
.
I tried to listen in on the ports for tester_publisht
, but was only able to listen onto port 7400. The rest (7412, 7413, and 41004) could not be listened to:
user@ubuntu:~$ nc -lvu 7400
Listening on [0.0.0.0] (family 0, port 7400)
Connection from ubuntu 39130 received!
RTPS
®9 �f]�̓K���P
®9�3���2��
�1��
��X?
brqt_gui_py_node_14766,,(name=rqt_gui_py_node_14766;namespace=/;^C
user@ubuntu:~$ nc -lvu 7412
nc: Address already in use
user@ubuntu:~$ nc -lvu 7413
nc: Address already in use
user@ubuntu:~$ nc -lvu 41004
nc: Address already in use
However, port 7400 is also shared with the other two nodes rqt_graph
and _ros2_daemon
, as shown in the first code block.
So I don't really understand what is the significance of port 7400. And also, which is the originating socket for tester_publisht
, or for each of the nodes for that matter?
ROS 2 uses DDS by default as the underlying middleware. You're question could be rephrased as: "how does DDS use these ports that my nodes are opening?".
This is not an answer, but for your understanding it might help to find some documentation on DDS and how it makes use of UDP and TCP ports in various situations.