简体   繁体   中英

UDP client multicast address

I am developing a system that is sending UDP packets using LWIP on Nios processor. I have developed a C# application to allow visualization of the received data.

The issue that I am having is on receiving data on the C# application when sending to multicast addresses. On the com+uter running the C# app I am able to visualized the incoming packets addressed for IP 225.0.0.1(multicast address) but my C# app does not receive them.

The C# app receives data sent to a.network address, for example 192.168.0.100 or when data is sent to 255.255.255.255 (in this case I can run the app in two diferrent computers and both receive the same data).

I have read several answers here on the forum and tried them all.

The code that I am using currently is:

UdpClient udpClientImage;

IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 8884);

udpClientImage = new UdpClient(RemoteIpEndPoint);
udpClientImage.EnableBroadcast = true;

IPAddress m_GrpAddr;
m_GrpAddr = IPAddress.Parse("225.0.0.1");
udpClientImage.JoinMulticastGroup(m_GrpAddr);


while (true)
{
    Byte[] receiveBytes = udpClientImage.Receive(ref RemoteIpEndPoint);

    senderIPAddress = RemoteIpEndPoint.Address;
    string returnData = Encoding.ASCII.GetString(receiveBytes);
}

Am I missing something in order to receive the multicast addresses?

Any help would be welcome,

Your UdpClient has to join the multicast group to listen. It's not automatic.

udpClientImage.JoinMulticastGroup(multicastAddress);

See MSDN for more information about this method.

The address passed into the constructor is the NIC(s) that you are listening on. The address passed into the Receive method is a filter and gets updated to reflect the source of the message. I don't think you want to reuse that one, and I don't think it should be the same as the bound NIC.

Try disabling rp_filter on the receiving system You can check out this post: UDP multicast client does not see UDP multicast traffic generated by tcpreplay

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM