Has anyone tried IP multicast with RTEMS?
Thomas Rauscher
trauscher at loytec.com
Tue Oct 21 06:33:40 UTC 2003
> -----Original Message-----
> From: Phil Torre [mailto:ptorre at zetron.com]
> Sent: Monday, October 20, 2003 8:16 PM
> To: RTEMS User List
> Subject: Has anyone tried IP multicast with RTEMS?
>
>
> Greetings All,
>
> Can anyone report success with RTEMS and multicast? From what I can
> tell by looking through the source, it looks like the FreeBSD stack
> is multicast-capable, but I may have some work to do in the Ethernet
> device driver (for MPC860, as used in the eth_comm BSP).
>
> I haven't done any experiments yet, but we will want to be doing
> multicast in future product development, so I'm just looking ahead.
>
> Thanks,
> -Phil
>
Multicasting works. Basically, two things are important:
1) Ethernet layer:
The driver must support ethernet multicasting. That is, it must
configure its ethernet multicast list/hash table when
a socket joins a multicast group.
This is done in the driver's ioctl. Required commands
are SIOCADDMULTI and SIOCDELMULTI
There is a macro ETHER_MAP_IP_MULTICAST to map IP addresses
and ethernet multicast addresses.
2) IP layer:
Sending works immediately by just using an IP multicast address.
Receiving requires to add the node to an IP multicast group
(so that IP/Ethernet multicasting is configured properly).
This is done like in the code snippet below.
#include <sys/socket.h>
#include <sys/sockio.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
struct ip_mreq mreq;
int fd;
mreq.imr_multiaddr.s_addr=inet_addr(HELLO_GROUP);
mreq.imr_interface.s_addr=htonl(INADDR_ANY);
if (setsockopt(fd,IPPROTO_IP,IP_ADD_MEMBERSHIP,&mreq,sizeof(mreq)) < 0) {
perror("setsockopt");
exit(1);
}
Best regards,
Thomas
--
Dipl.-Ing. Thomas Rauscher Tel.: ++43 1 402 08 05 15
Fax: ++43 1 402 08 05 99
LOYTEC electronics GmbH E-mail: trauscher at loytec.com
Stolzenthalergasse 24/3, A-1080 Wien Web: http://www.loytec.com
More information about the users
mailing list