Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Problem with multicast client
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Azdo
n00b
n00b


Joined: 22 Nov 2009
Posts: 8

PostPosted: Tue Mar 16, 2010 8:45 pm    Post subject: Problem with multicast client Reply with quote

Hello,

I have a multicast server and another computer acting as a client. The server sends packets from a Windows program. I have a code snippet that joins the multicast channel and tries to read the packets. However, it is not working in Gentoo while the same code is ok in Windows. Some information:

* My kernel supports multicast. The MULTICAST word is shown when issuing an 'ifconfig eth0':


Code:
eth0      Link encap:Ethernet
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

* The client program binds the UDP socket and joins the channel without errors:

Code:
DataSocket = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in MySocketAddr;
memset(&MySocketAddr, 0, sizeof(MySocketAddr));
MySocketAddr.sin_family = AF_INET;
MySocketAddr.sin_port = htons(1001);
MySocketAddr.sin_addr = MyAddress;
if (bind(DataSocket, (struct sockaddr *)&MySocketAddr, sizeof(struct sockaddr)) == -1)
{
  printf("[PacketClient] bind failed (error: )\n");
  return 0;
}
// join multicast group
struct ip_mreq Mreq;
Mreq.imr_multiaddr = MultiCastAddress;
Mreq.imr_interface = MyAddress;
retval = setsockopt(DataSocket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&Mreq, sizeof(Mreq));

where MyAddress is "224.0.0.1", since the server sends packets to 224.0.0.1:1001

* I added a route rule for the multicast packets:
Code:

route add 224.0.0.1 eth0

* Using wireshark, I can see the server sending the UDP packets to 224.0.0.1 and port 1001, but the call to recvfrom() from the client waits forever.

* When the client is running, it seems that the join is succesful:

Code:
# cat /proc/net/igmp
Idx   Device    : Count Querier   Group    Users Timer   Reporter
1   lo        :     1      V3
            010000E0     1 0:00000000      0
4   eth0     :     1      V3
            010000E0     2 0:00000000      0


What else could be failing?

Thank you for any hint!

P.S.: A good hint would be how to know if my kernel is discarding those packets. I have no firewall set up.
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6715

PostPosted: Thu Mar 18, 2010 8:03 pm    Post subject: Reply with quote

You shouldn't need to manually add any routes. Try it without that if you haven't already done so.

Also you might want to see whether other multicast stuff (e.g. avahi) works first.
Back to top
View user's profile Send private message
Azdo
n00b
n00b


Joined: 22 Nov 2009
Posts: 8

PostPosted: Sun Mar 21, 2010 10:12 am    Post subject: Reply with quote

You are right, Ant_P. No other routing needed. I indeed tried my multicast setup with VLC and it worked fine, so it's working for my system.

I found a code snippet at http://www.tenouk.com/Module41c.html implementing a multicast client and server. I could narrow down the problem to my program. For the snippet, I can see with Wireshark that join requests to the multicast group are sent. This is not happening for my program. The only difference is that my program tries to join 224.0.0.1 while the snippet does it to 226.0.0.1.

This is very weird, 224.0.0.1 should be a valid multicast address and furthermore, the socket option function doesn't return any error. What could be happening?
Back to top
View user's profile Send private message
Azdo
n00b
n00b


Joined: 22 Nov 2009
Posts: 8

PostPosted: Sun Mar 21, 2010 10:43 am    Post subject: Reply with quote

Ooops, I think I have a big problem. Following the weird behaviour of the 224.0.0.1, I arrived to this page of the multicast HowTo that says that addresses from 224.0.0.0 to 224.0.0.255 are reserved for local administrative purposes, so they are "never" forwarded by multicast routers, http://tldp.org/HOWTO/Multicast-HOWTO-2.html

It seems I have to talk with the writers of the server for them to change the multicast address they are using to stream their data or make a ssh tunneling hack in order to feed my program.
Back to top
View user's profile Send private message
Azdo
n00b
n00b


Joined: 22 Nov 2009
Posts: 8

PostPosted: Tue Mar 23, 2010 1:07 pm    Post subject: Reply with quote

What I have to do in order to route the packets sent to 224.0.0.1 to 226.0.0.1? I don't know if I have to use route or iptables. I fail to set the correct parameters to accomplish this.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum