Cannot receive Multicast package

  • Thread starter Thread starter PHLICS_Admin
  • Start date Start date
P

PHLICS_Admin

Hi All,

There are two network cards in one computer (named A) , and there is one
network card in another computer(named B).

On computer A: one network card is used to connect to internet, and the
other network card is used in intranet whose ipaddress is 192.168.0.1
On computer B: the network card's ipaddress is 192.168.0.2.

These two computer can connect to each other.

The question is :
B can receive multicast sent from A, A cannot receive the package from B
(A can receive multicast package from itself)
If disable the internet network card on A, A can receive multicast
package from B.

Would you please give me some advise on this issue.

Thanks ,

Phlics.
 
PHLICS_Admin said:
Hi All,

There are two network cards in one computer (named A) , and there is one
network card in another computer(named B).

On computer A: one network card is used to connect to internet, and the
other network card is used in intranet whose ipaddress is 192.168.0.1
On computer B: the network card's ipaddress is 192.168.0.2.

These two computer can connect to each other.

The question is :
B can receive multicast sent from A, A cannot receive the package from B
(A can receive multicast package from itself)
If disable the internet network card on A, A can receive multicast
package from B.
Phlics -

When you have more than one network card in a computer, you should
specify which card you want to receive multicast messages on in your
socket constructor, otherwise the socket will choose one for itself
(which may or may not be a good thing).

If you are using a UdpClient object, this would look like:

IPEndPoint iep = new IPEndPoint(IPAddress.Parse("192.168.0.1"),
9050);
UdpClient sock = new UdpClient(iep);
sock.JoinMulticastGroup(IPAddress.Parse("224.100.0.1"));

If you are using a Socket object, it would look like this:

Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);
IPEndPoint iep = new IPEndPoint(IPAddress.Parse("192.168.0.1"),
9050);
sock.Bind(iep);
sock.SetSocketOption(SocketLevel.IP,
SocketOptionName.AddMembership,
new
MulticastOption(IPAddress.Parse("224.100.0.1")));


As a side note, if you want to receive multicast packets on both
interfaces, you can use the IPAddress.Any value for the IPEndPoint
constructor. Hope this helps solve your problem.

Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0471433012.html
 
Thanks , but it does not work.

Other information:
If I switch the network cards(change the card used for internet to
intranet ...), it works .

Regards,
 
Following code snip is used :

this._clsMCastReceiver = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
IPEndPoint ipep=new IPEndPoint(IPAddress.Any , CIMSys.MCastPort);
this._clsMCastReceiver.Bind(ipep);
IPAddress ip=IPAddress.Parse(CIMSys.MCastIPAddress);

this._clsMCastReceiver.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.AddMembership, new MulticastOption(ip , IPAddress.Any));

When I disable the internet network card , it works correctly.

Please give me advise on it .

Thanks,

Phlics.
 
PHLICS_Admin said:
this._clsMCastReceiver.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.AddMembership, new MulticastOption(ip , IPAddress.Any));

When I disable the internet network card , it works correctly.
Phlics -

Have you tried using the MulticastOption constructor that only
uses the multicast IP address, and not the local IP address?
Alternatively, have you tried specifying just the proper network card
IP address as the local address?

Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0471433012.html
 
I have tried , but it does not work .

There are two network card on the computer. If disable the network card
(which connect to internet) , it works .

Thanks,
 
Following code snip is used :

this._clsMCastReceiver = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
IPEndPoint ipep=new IPEndPoint(IPAddress.Any , CIMSys.MCastPort);
this._clsMCastReceiver.Bind(ipep);
IPAddress ip=IPAddress.Parse(CIMSys.MCastIPAddress);

this._clsMCastReceiver.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.AddMembership, new MulticastOption(ip , IPAddress.Any));

When I disable the internet network card , it works correctly.

Please give me advise on it .

Thanks,

Phlics.
 
Back
Top