Ask Your Question
2

specifying tcp port range for nodes

asked 2011-12-04 12:55:09 -0500

we're extremely port limited and would like to specify a range of ports for nodes to use when communicating with each other. For example: 9000-9500

any ideas how to assign specific ports for node communication? Looking at roscpp and the docs it looks like the publisher sends a connection header to subscriber with how to connect to itself. Does this means the port is already determined at this point in time? or is connection header sent through XMLRPC with the new port? It looks like the info is sent into the 'callerid' variable. Unfortunately, i haven't been able to track down exactly how this gets assigned....

how does port assignment make sure it doesn't class with other ports?

all this is very mysterious and it would be great if someone could provide even the smallest bit of info.

thank you

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
2

answered 2011-12-11 18:31:56 -0500

tfoote gravatar image

updated 2011-12-11 18:57:58 -0500

Ports are automatically assigned by the system when the publishers socket is created. The tcp and udp code would need to be modified to constrain the ports within a range. After the listening port is opened, it is registered on the master so that the other nodes can contact it when they want to connect to it. (The client side ports are also auto assigned.)

edit flag offensive delete link more

Comments

so in other words, the port selection happens in the linux kernel somewhere, interesting. that would explain why there's only calls to get the port. thanks!
Rosen Diankov gravatar imageRosen Diankov ( 2011-12-11 21:43:18 -0500 )edit
3

answered 2016-06-17 06:31:11 -0500

Michael Kopp gravatar image

I know, that this is an old question, but this is where google led me, so for future reference:

You can limit the range of ephemeral ports (i.e. ports that are assigned to sockets that do not request a certain port number) using

echo 4000-4200,5000-6000 | sudo tee /proc/sys/net/ipv4/ip_local_reserved_ports

here you forbid to use ports in the range 4000 to 4200 or 5000 to 6000. You can check all available ports using

echo /proc/sys/net/ipv4/ip_local_port_range

If you want this changes to take effect on startup, add a line similar to the following to /etc/rc.local:

echo 4000-4200,5000-6000 > /proc/sys/net/ipv4/ip_local_reserved_ports
edit flag offensive delete link more
1

answered 2011-12-11 15:15:00 -0500

hi guys,

does anyone have any idea where we could begin looking? is the port assignment happening on the ros master, topic publisher, or topic subscriber?

any help would be very appreciated.

thank you

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-12-04 12:55:09 -0500

Seen: 1,695 times

Last updated: Dec 11 '11