[lwip-users] Multicast Example?

1,269 views
Skip to first unread message

Jonathan Ross

unread,
Dec 16, 2009, 4:25:25 PM12/16/09
to lwip-...@nongnu.org
I'm using lwip 1.3.0 and I'm using it in raw mode (as provided in Xilinx EDK 11.1/11.4 - I had to change a .tcl script though to include igmp.c).

Using the code below I can see an IGMP join message exit my device and enter the switch its plugged into, but the router in charge of IGMP does not subsequently list my device/interface as being subscribed to the multicast group 239.253.1.1. The IGMP join message it sends out also has a lot of trailing zeros that I don't see when I issue a similar IGMP join from my workstation (OS X 10.6), and also unlike my workstation and other desktops at work, lwIP sends out a single IGMP join, and all other device send 2 or 3 (any idea why?). Also, whenever the IGMP Membership Query message is sent out, my device does not re-issue a join to 239.253.1.1. Did I do something wrong? Below is the code.

int main() {
struct netif *netif, server_netif;
struct ip_addr ipaddr, netmask, gw, ipgroup;

unsigned char mac_ethernet_address[] = { /* REDACTED */ };
err_t igmp_result;

netif = &server_netif;

        init_platform();

/* initliaze IP addresses to be used */
IP4_ADDR( &ipaddr, 10,  10,  12,  58 );
IP4_ADDR( &gw,      10,  10,  12, 254 );
IP4_ADDR( &netmask, 255, 255, 255,   0 );
IP4_ADDR( &ipgroup, 239, 253,   1,   1 );

print_ip_settings(&ipaddr, &netmask, &gw);

lwip_init();
netif->flags |= NETIF_FLAG_IGMP; // This has no effect as netif->flags is zeroed by netif_add when called in xemac_add... 
// but netif has conditional statements based on the value... so I'm confused.

   /* Add network interface to the netif_list, and set it as default */
if (!xemac_add(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, PLATFORM_EMAC_BASEADDR)) {
xil_printf("Error adding N/W interface\n\r");
return -1;
}
netif_set_default(netif);

/* now enable interrupts */
platform_enable_interrupts();

/* specify that the network if is up */
netif_set_up( netif );

/* start the application (web server, rxtest, txtest, etc..) */
udp_echo_init();
netif->flags |= NETIF_FLAG_IGMP;
igmp_result = igmp_start( netif );
igmp_result = igmp_joingroup( &ipaddr, &ipgroup );
/* receive and process packets */
while (1) {
xemacif_input(netif);
//transfer_data();
}

/* never reached */
cleanup_platform();

return 0;

}


Also, xemac_add calls netif_add, and within which there is the following code:

  netif->flags = 0;

// ...

#if LWIP_IGMP
  /* start IGMP processing */
  if (netif->flags & NETIF_FLAG_IGMP) {
    igmp_start( netif);
  }
#endif /* LWIP_IGMP */

How does igmp_start ever get called? I don't see any code in the file (where I write //... above) that could reset the flag to include NETIF_FLAG_IGMP.

Thanks!
Jonathan

Simon Goldschmidt

unread,
Dec 17, 2009, 1:43:21 AM12/17/09
to Mailing list for lwIP users

Jonathan Ross wrote:
> [..]

> Did I do something wrong?

Unfortunately, I can't help you much there, as I don't really use IGMP... However, your code does seem correct. Do other packets have trailing zeros? What does wireshark say to those zeros?

> [..]


> Also, xemac_add calls netif_add, and within which there is the following
> code:
>
> netif->flags = 0;
>
> // ...
>
> #if LWIP_IGMP
> /* start IGMP processing */
> if (netif->flags & NETIF_FLAG_IGMP) {
> igmp_start( netif);
> }
> #endif /* LWIP_IGMP */
>
> How does igmp_start ever get called? I don't see any code in the file
> (where I write //... above) that could reset the flag to include
> NETIF_FLAG_IGMP.

The init function of your netif (passed to netif_add) should set the flags (ARP if supported, IGMP if supported, etc). It gets called between the lines you pasted above (at the place of "// ...").

Simon
--
GRATIS f�r alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01


_______________________________________________
lwip-users mailing list
lwip-...@nongnu.org
http://lists.nongnu.org/mailman/listinfo/lwip-users

Jonathan Ross

unread,
Dec 17, 2009, 2:48:40 PM12/17/09
to Mailing list for lwIP users
The packets from my workstation do not have the trailing zeros, if that's what you mean. And wireshark doesn't say anything about those zeros, it just says they're there.

What I think I really need is someone telling me I'm doing everything right or I'm doing something wrong so I know where to focus my efforts at the moment. I think I see some multicast messages going to my device in wireshark, but I thought that I would get the message by listening via UDP on the interface for IP_ADDR_ANY and the port that the multicast packet is being sent to, but my udp_recv function is never called.

Supposing I did successfully subscribe to a multicast group, where would the data being multicast be found?

Thanks,
Jonathan


On Dec 17, 2009, at 1:43 AM, Simon Goldschmidt wrote:

>
> Jonathan Ross wrote:
>> [..]
>> Did I do something wrong?
>
> Unfortunately, I can't help you much there, as I don't really use IGMP... However, your code does seem correct. Do other packets have trailing zeros? What does wireshark say to those zeros?
>
>> [..]
>> Also, xemac_add calls netif_add, and within which there is the following
>> code:
>>
>> netif->flags = 0;
>>
>> // ...
>>
>> #if LWIP_IGMP
>> /* start IGMP processing */
>> if (netif->flags & NETIF_FLAG_IGMP) {
>> igmp_start( netif);
>> }
>> #endif /* LWIP_IGMP */
>>
>> How does igmp_start ever get called? I don't see any code in the file
>> (where I write //... above) that could reset the flag to include
>> NETIF_FLAG_IGMP.
>
> The init function of your netif (passed to netif_add) should set the flags (ARP if supported, IGMP if supported, etc). It gets called between the lines you pasted above (at the place of "// ...").
>
> Simon
> --

> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!

Joe Dupre

unread,
Dec 18, 2009, 12:40:10 PM12/18/09
to Mailing list for lwIP users, Jonathan Ross
I have this line:

netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP | NETIF_FLAG_IGMP;

In low_level_init() [ethernetif.c]

You have to have the IGMP flag set somewhere.

- Joe


> >> Also, xemac_add calls netif_add, and within which there is the
> following
> >> code:
> >>
> >> netif->flags = 0;
> >>
> >> // ...
> >>
> >> #if LWIP_IGMP
> >> /* start IGMP processing */
> >> if (netif->flags & NETIF_FLAG_IGMP) {
> >> igmp_start( netif);
> >> }
> >> #endif /* LWIP_IGMP */

Jonathan Ross

unread,
Dec 18, 2009, 2:48:59 PM12/18/09
to Joe Dupre, Mailing list for lwIP users
Thanks for the response!

I did this, and now I can subscribe, but my implementation is ignoring IGMP membership queries from the router and so gets dropped after a couple of minutes. Is there something I'm supposed to do to get this to work, or is my (Xilinx) implementation broken?

Also, I'm not sure how to get data being sent to the group I've joined. What function gets called when I receive a UDP packet sent to the group I'm subscribed to? I see it in wireshark as a packet sent to the group I'm listening to in UDP form to a specific port, but my udp_recv function, which is bound to IP_ADDR_ANY, and that port, is never called.

Thanks!
Jonathan

Reply all
Reply to author
Forward
0 new messages