LerTex
LerTex

Reputation: 11

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,

Upvotes: 1

Views: 1836

Answers (3)

Ananth Regulapati
Ananth Regulapati

Reputation: 186

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

Upvotes: 0

Brannon
Brannon

Reputation: 5424

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.

Upvotes: 0

eddie_cat
eddie_cat

Reputation: 2583

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.

Upvotes: 0

Related Questions