Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to test multicast IP on same box?

If I want to test a set of multicast IP programs (sender/receiver) without having to set up the networking, can this be done on the same box? If so, what needs to be setup or done differently?

like image 675
Andy Faibishenko Avatar asked Nov 12 '09 00:11

Andy Faibishenko


People also ask

How do you test if multicast is working?

PROCEDURE. In order to verify if Multicast is working correctly in your network, you can use the following quick tcpdump/ping test. If the Multicast is working correctly then you should see packets arriving at the first node. Repeat this procedure in each node to verify that Multicast is OK in your network.

Can you ping multicast IP addresses?

You can only ping, via multicast, hosts which are subscribed to the multicast group which you are pinging. You need to be careful about which multicast groups you use, and, in general, you should use multicast groups from the administratively scoped range of 239.0.

How would you detect if a packet is a multicast packet in a local network?

A router will determine if any of the hosts on a locally attached network are configured to receive multicast datagrams using IGMP( Internet Group Management Protocol). Routers will listen for IGMP messages and periodically send queries on the local subnet.


1 Answers

You may have figured this out already (since the question is now 2 years old) but to do multicast on a single host, you only have to do two things: (1) make sure that your receiving multicast sockets have SO_REUSEADDR set (so that multiple processes can bind the same multicast address) and (2) make sure your sending multicast sockets have IP_MULTICAST_LOOP set (so that packets will be "looped back" to receivers on the same system). If your application uses a single socket for both sending and receiving multicasts, you would set both socket options on it.

int recv_s = socket(AF_INET, SOCK_DGRAM, 0);
int send_s = socket(AF_INET, SOCK_DGRAM, 0);
u_int yes = 1;
setsockopt(recv_s, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
setsockopt(send_s, IPPROTO_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes));
like image 133
Alex Dupuy Avatar answered Nov 02 '22 04:11

Alex Dupuy