Getting LCM to send/receive on multiple interfaces?

116 views
Skip to first unread message

Pritpaul Mahal

unread,
Jan 17, 2012, 1:49:37 PM1/17/12
to lcm-...@googlegroups.com
We have a need for LCM programs (using the default UDP multicast
implementation) to listen and send on all interfaces, including those
that are not up yet when the program is started. From what I can tell
from the LCM source, at least for the listen side it binds to INADDR_ANY
which as I understand it should give me everything at least from
interfaces that are up when the program is started.

But what I've found in practice is that it only ends up listening on one
of the interfaces (but if I disable that one, then after a program
restart it will listen on the other). Similarly for sending, it will
just pick one of the interfaces that are up when the program is started,
and stick with it for the entire run of the program. I haven't noticed
a pattern either in which interface gets picked.

Does anyone have any suggestions on how I can accomplish the
multi-interface behavior I need, both on send and receive? I was
considering setting up a virtual interface and tunneling to/from all
other interfaces, but I'm not sure if this is possible or would work
with the UDP multicast.

Thanks,
--Pritpaul


Albert Huang

unread,
Jan 18, 2012, 11:42:43 PM1/18/12
to lcm-...@googlegroups.com
Hi Pritpaul,

There's no good way for a single LCM instance to listen on multiple
interfaces at once. One thing you can try is to create multiple
instances attached to different multicast addresses, and then set
network routes to attach those addresses to different interfaces.
e.g.,

lcm_t* lcm1 = lcm_create("udpm://239.255.100.1")
lcm_t* lcm2 = lcm_create("udpm://239.255.100.2")

Then, if you're running linux, you can do:
$ sudo route add -net 239.255.100.1 netmask 255.255.255.255 dev eth0
$ sudo route add -net 239.255.100.2 netmask 255.255.255.255 dev eth1

or something like that. You'll need to take care of publishing and
subscribing to both instances yourself.

Albert

> --
> You received this message because you are subscribed to the Google Groups
> "Lightweight Communications and Marshalling" group.
> To post to this group, send email to lcm-...@googlegroups.com.
> To unsubscribe from this group, send email to
> lcm-users+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/lcm-users?hl=en.
>

Reply all
Reply to author
Forward
0 new messages