Any updates to Transmitting Multicast Packets

General discussion on mikroC.
Post Reply
Author
Message
weinhard
Posts: 11
Joined: 03 Sep 2010 23:05

Any updates to Transmitting Multicast Packets

#1 Post by weinhard » 04 Nov 2010 08:10

I see some pretty old forum posts regarding transmitting a multicast packet. Have there been any changes to the SPI_Ethernet library to make that a little easier? I'm trying to use the sendUDP function to send out a packet to a multicast address 224.0.100.100 and it doesn't seem to be working. Wireshark isn't showing any packets on the wire.

I did try my code using a direct UDP connection to 192.168.0.206 and it works fine. So it really does appear that my problems are in trying to use a multicast address.

I tried setting

Code: Select all

SPI_Ethernet_Enable(_SPI_Ethernet_MULTICAST);
, but that only appears to affect the receive filters.

Here's my codebase so far...

Code: Select all

unsigned char   myMacAddr[6] = {0x00, 0x14, 0xA5, 0x76, 0x19, 0x3f} ;   // my MAC address
unsigned char   myIpAddr[4]  = {192, 168, 0, 160} ;                     // my IP address
unsigned char IpAddr[4]  = {224, 0, 100, 100 };  // remote IP address
char ipMask[4]    = {255, 255, 255,  0 };  // network mask (for example : 255.255.255.0)
char gwIpAddr[4]  = {192, 168,   0,  1 };  // gateway (router) IP address
char dnsIpAddr[4] = {192, 168,   0,  1 };  // DNS server IP address

SPI1_Init();
SPI_Ethernet_Init(myMacAddr, myIpAddr, Spi_Ethernet_FULLDUPLEX) ;
SPI_Ethernet_confNetwork(ipMask, gwIpAddr, dnsIpAddr); // set network configuration parameters
SPI_Ethernet_Enable(_SPI_Ethernet_MULTICAST);
...
stat = SPI_Ethernet_sendUDP(IpAddr, 10001, 10001, output, lenc);
Any help would be appreciated.

weinhard
Posts: 11
Joined: 03 Sep 2010 23:05

Re: Any updates to Transmitting Multicast Packets

#2 Post by weinhard » 05 Nov 2010 07:54

After some trickery, I came up with a hack. Basically, I use the SPI_Ethernet_sendUDP function to initialize the ethernet controller memory for me, then I perform the following...

Code: Select all

unsigned char   destMacAddr[6] = {0x01, 0x00, 0x5E, 0x00, 0x64, 0x64}; // MAKE SURE TO SET THE MULTICAST BIT IN THE FIRST OCTET. Everything else is whatever.
...
stat = SPI_Ethernet_sendUDP(IpAddr, 10001, 10001, output, lenc); // no packets appear on the wire because bad IP maybe?  I dont have insight into mikroC lib
Spi_Ethernet_memcpy(REPLY_START, destMacAddr, 6) ;          // where destMacAddr is initilized with the multicast bit set
Spi_Ethernet_TXPacket(lenc + 42);     // lenc is the payload length.  Add 42 bytes of header.  Dont know if theres a #define for this somewhere 
Maybe someone from ME can enlighten me if there's a better way? This is sort of a hack. Which relies on the sendUDP function to initialize (and not send) the UDP packet because of a multicast IP Address.

Post Reply

Return to “mikroC General”