FEZ Cerbuino Net Multicast Join

Hello and thank you in advance for your time.

I have a FEZ Cerbuino Net and I am trying to join a multicast group. The following codes executes without error but the devices doesn’t actually register as joining the multicast group in wireshark.

Till now I have been trying with a netduino but it crashes when you try and set ttl or join the group. With the code below I set the ttl and then read it back and it is successful.


using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;
using Microsoft.SPOT.Net.NetworkInformation;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using System.Net;
using System.Net.Sockets;
using Microsoft.SPOT.Hardware;

namespace GadgeteerApp2
{
    public partial class Program
    {
        InterruptPort x;

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {

            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");
            NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;
            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;

            Mainboard.Ethernet.EnableDhcp();
            Mainboard.Ethernet.EnableDynamicDns();
          //  Mainboard.Ethernet.RenewDhcpLease();
            Mainboard.Ethernet.Open();

            Debug.Print(Mainboard.Ethernet.IPAddress);

            IPAddress anyIPAddr = IPAddress.Any;
            IPEndPoint endPoint = new IPEndPoint(anyIPAddr, 9000);
            System.Net.Sockets.Socket socket = new System.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
            socket.Bind(endPoint);

            byte[] discoveryAddr = IPAddress.Parse("239.255.255.0").GetAddressBytes();  // administratively scoped IPv4 multicast address
            byte[] ipAddr = IPAddress.Any.GetAddressBytes();
            byte[] multicastOpt = new byte[] {  discoveryAddr[0], discoveryAddr[1], discoveryAddr[2], discoveryAddr[3], ipAddr[0], ipAddr[1], ipAddr[2], ipAddr[3] }; // Local IPAddress
            Debug.Print("Setting Multicast");
              socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, multicastOpt);
              socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 32);
            Debug.Print("Multicast TTL is " + socket.GetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive));
        }

        void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            Debug.Print("NetworkChange_NetworkAvailabilityChanged");
        }

        void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
        {
           Debug.Print("NetworkChange_NetworkAddressChanged");
        }
    }
}


Ps.
If the Cerbuino board won’t handle multicast is there a board that will? As multicast is a deal breaker for this project.

Thanks again.

Hey Team.

Looks like it’s actually working, there is now membership report in wireshark but the device is receiving Multicast traffic.

Cheers