Teensy 3.5 and WIZ850 Multicast

Status
Not open for further replies.

AllenCherry

Active member
Anyone who can help please!

I am using the Teensy 3.5 and WIZ8510, trying to receive a UDP multicast data stream on 224.11.5.62, port 41000.

I am using the sketch 'UDPSendReceiveString', which works perfectly if the data is sent out from the 'sending' computer to (say) 192.168.0.100 port 55278, and I set that as the IP address of the WIZ8510 and local port 55278.

But I can't get it to receive the data from the multicast address of 224.11.5.62 port 41000, which is being used by the 'sending' computer, even with the WIZ8510 set to that IP and port.
I am using the MAC address 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED as in the sketch example.

Can anyone suggest what I am doing wrong?

Thank you in anticipation of your help,

Allen
 
Need more info . Code examples are helpful. What Ethernet library are you using because Older ones did not support multicast. Fire up wireshark and see if you get any igmp registrations coming from your wiz. If using a managed switch that is strictly following multicast flow will require a igmp querier. If so just use a non managed switch or directly connect the wiz to your testing source.
 
Many thanks for your help - the relevant code for the UDP is as follows:

#include <Ethernet.h>
#include <EthernetUdp.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; //Assign MAC address
IPAddress ip(192, 168, 0, 177); // Assign IP address
unsigned int localPort = 55278; // local port to listen on as defined in Condor setup file

// buffers for receiving and sending data

char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; // buffer to hold incoming packet,
char SendBuffer[UDP_TX_PACKET_MAX_SIZE]; // buffer to send out revised data
EthernetUDP Udp;

#define UDP_TX_PACKET_MAX_SIZE 1024


void setup()
{

Ethernet.init(10); // For Teensy 3.5
Ethernet.begin(mac, ip); // start the Ethernet
Udp.begin(localPort); // start UDP

}

void loop()
{

// if there's data available, read a packet
int packetSize = Udp.parsePacket();
if (packetSize)

// read the packet into packetBufffer
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
String Datapacket = packetBuffer;
int ASI = Datapacket.indexOf('d');
Speed = (Datapacket.substring((ASI+2),(ASI+4)));
int Velocity = (Speed.toInt());
analogWrite(FFPin,(255-(Velocity * 5)));

// send a reply to the IP address and port that sent us the packet we received
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write(SendBuffer);
Udp.endPacket();

}

The code is directly from the 'examples' for the Teensy board, with the change for the buffer size.

I will experiment with Wireshark and send you the received data. I am using a non-managed hub / switch (5 port 'NetGear') to connect the WIZ and other computers.

Many thanks,

Allen
 
Correction - that is the code that actually receives the UDP data - the changes for the multicast that I make are:

IPAddress ip(224,11,5,62); // Assign IP address
unsigned int localPort = 41000; // local port to listen on for the multicast

This does NOT receive the multicast data.

Thanks,

Allen
 
I think you need Udp.beginMulticast(). Here is a 3 year old example
https://github.com/manitou48/teensy3/blob/master/mtalk.ino

and a little python script (mtalk.py) to exercise mutlicast:
Code:
#https://gist.github.com/quiver/4111310
import socket
import struct

multicast_addr = '224.7.8.9'
bind_addr = '0.0.0.0'
port = 7654

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
membership = socket.inet_aton(multicast_addr) + socket.inet_aton(bind_addr)

sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, membership)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

sock.bind((bind_addr, port))

while True:
    message, address = sock.recvfrom(255)
    print message
For MAC and linux users, you can send a UDP packet to a multicast IP with netcat
echo "1234" | nc -u -w0 224.7.8.9 7654
 
Last edited:
Dear Manitou,

Many thanks - that example looks very promising! I will give it a test and let you know!

Best wishes,

Allen
 
Dear Manitou,

Sorry - just another question - does the Udp.beginMulticast() apply to a CAT5 connection as well as WiFi? I am only using CAT5 - all the Ardunio examples appear to relate to WiFi for Udp.beginMulticast().

Many thanks,

Allen
 
the example sketch provided was run with wiznet hardware (hardwired Ethernet RJ45) -- example should also work with wifi
 
The Udp.beginMulticast() Initializes the wiz chips built in multicast capabilities. This is essential since it is what handles IGMP for you. Just remember that once you place this on a managed switched network that you will need to make sure your network is configured for multicast (igmp snooping, igmp querier etc) . On the other hand multicast traffic on a unmanaged switch also becomes broadcasts.
 
Status
Not open for further replies.
Back
Top