Using EthernetInterface revision 45:d1ccbed7687a on the FRDM K64 platform, the following code does not receive any multicast packets whatsoever.
It does however receive unicast packets sent to its IP address, so it has not frozen.
Wireshark indicates that it does sends the IGMP v2 join requests.
(IGMP snooping is turned off in my switch so this should work even without any IGMP.)
When I send a multicast packet to 224.1.1.1 the activity LED blinks implying multicast packets do enter the device, however receiveFrom() does not return.
It appears that EthernetInterface is discarding any packets sent to the multicast address that has been joined instead of passing them onwards to the user application.
I don't know whether this works on the LPC1768 as I don't have the hardware to test.
Looking at the K64 reference manual it appears that the K64 has hardware multicast (and IP!) filtering support, which needs to be properly configured.
I'm looking into how this should be done but don't know yet.
(And the online compiler has been falling over a lot today so it's got frustrating to test.)
Test Multicast
#include "mbed.h"
#include "rtos.h"
#include "EthernetInterface.h"
const int ECHO_SERVER_PORT = 5007;
const int BUFFER_SIZE = 256;
const char* MCAST_GRP = "224.1.1.1";
char buffer[BUFFER_SIZE] = { 0 };
DigitalOut ledRed(LED_RED, 1);
DigitalOut ledGreen(LED_GREEN, 1);
DigitalOut ledBlue(LED_BLUE, 1);
Serial pc(USBTX, USBRX);
int main()
{
pc.puts("Start\r\n");
ledRed = 0;
EthernetInterface eth;
pc.puts("Init...\r\n");
eth.init(); //Use DHCP
//eth.init(ip,mask,gateway); //Use Static IP Configuration
pc.puts("Connect\r\n");
while (eth.connect(10000)) {ledRed = !ledRed;} // Keep trying until it connects
// Turn LED blue
ledRed = 1;
ledBlue = 0;
pc.printf("Server IP Address is %s:%d\r\n", eth.getIPAddress(), ECHO_SERVER_PORT);
UDPSocket server;
server.bind(ECHO_SERVER_PORT);
if (server.join_multicast_group(MCAST_GRP) != 0) {
pc.printf("Error %d joining the multicast group\n");
while (true) {}
}
// Turn LED Green
ledBlue = 1;
ledGreen = 0;
Endpoint client;
char buffer[256];
while (true) {
pc.printf("\nWait for packet...\r\n");
int n = server.receiveFrom(client, buffer, sizeof(buffer));
pc.printf("Packet from \"%s\": %s\r\n", client.get_address(), buffer);
ledRed = !ledRed;
}
}
Using EthernetInterface revision 45:d1ccbed7687a on the FRDM K64 platform, the following code does not receive any multicast packets whatsoever.
It does however receive unicast packets sent to its IP address, so it has not frozen.
Wireshark indicates that it does sends the IGMP v2 join requests. (IGMP snooping is turned off in my switch so this should work even without any IGMP.)
When I send a multicast packet to 224.1.1.1 the activity LED blinks implying multicast packets do enter the device, however receiveFrom() does not return.
It appears that EthernetInterface is discarding any packets sent to the multicast address that has been joined instead of passing them onwards to the user application.
I don't know whether this works on the LPC1768 as I don't have the hardware to test.
Looking at the K64 reference manual it appears that the K64 has hardware multicast (and IP!) filtering support, which needs to be properly configured. I'm looking into how this should be done but don't know yet. (And the online compiler has been falling over a lot today so it's got frustrating to test.)
Test Multicast