|
From: Jim K. <jk...@sa...> - 2004-03-03 16:21:22
|
Kevin, When you set up the socket, you also do a setsockopt(IP_ADD_MEMBERSHIP, mreq) to join the multicast group. The ip_mreq struct contains members for both a mulicast address and an interface address. I haven't looked at the iperf code in a while, but I think I remember that the interface address was set to "ANY." Unfortunately, "ANY" doesn't mean "ALL" for multicast, the way it does with unicast. This means the OS will pick which interface to join the mcast group on. I think all you have to do is set that mreq.imr_interface to the desired local network interface address for this to work. Jim Kevin Gibbs wrote: > > Thanks for the input Jim, but I was looking for code sequences to do what > you suggest. Modifying the command line parameters or even adding one can > be done quite easily. However in my time searching on this topic I have > not seen a way for a berkeley socket to specify an interface with a call > other than bind(), which needs to be given the multicast address. So if > anyone has a snippet of code that shows what calls need to be made that > would be helpful. > > Currently using: > socket(stuff); > bind(multicast-addr); > recvfrom(stuff); > > Kevin > > On Fri, 27 Feb 2004, Jim Kaba wrote: > > > Kevin, > > About a month or so ago I suggested an approach that *should* be > > portable. (If by portable you mean cross-OS, this *should* work. It is > > using plain vanilla standard socket API. I haven't done windoze > > programming in a long time, but I think it is all there...) > > > > ...here's a link to the posting > > http://archive.ncsa.uiuc.edu/lists/iperf-users/jan04/msg00003.html > > > > In a nutshell, I suggested using the -B and -c/-s flags in a consistent > > way whether in client or server mode --- that is, if you want to bind to a > > specific interface address, use -B (client or server mode). If you want to > > specify exactly which pkts to receive based on their dest addr, use the -c > > or -s flag. The arg following -s could still be optional to receive pkts > > of any ipaddr. > > > > The combination of interface address, multicast address, and port can be > > used as the arguments to both join the multicast group (mcast addr, iface > > addr) and bind the socket to receive only packets addressed to mcast addr > > and port that come in on the specified iface addr. > > > > (Check out UNIX Network Programming Vol. 1 by Richard Stevens. It is an > > excellent resource and is a must-have for anyone doing any kind of real > > network programming. Some regard it as the "bible" for network > > programming.) > > > > Jim > > > > > > > > Kevin Gibbs wrote: > > > > > > This has been an on going concern that has been voiced by many. Does any > > > one know of a way to portably support this feature? Normally to bind to a > > > specific NIC you use -B nic which results in a bind() call with that > > > address. However when you do a -B multicast-address that also results in a > > > bind() call but since it specifies a multicast address that is a valid > > > address on all NICs so that is what you get. Any insights? This feature > > > would not be difficult to add if I knew that it was possible and portable. > > > > > > Kevin > > > > > > On Thu, 26 Feb 2004, Jim Kaba wrote: > > > > > > > Jacob, > > > > If I understand your question correctly, I think I ran into the same > > > > problem a few weeks back---i.e. there is currently not a good way to bind > > > > the iperf server to a multicast address on a specific network interface on > > > > machines that have more than one interface. > > > > > > > > ...the way I got around it was to create a static route whenever I needed > > > > to do it: > > > > > > > > route add 224.0.67.67 dev eth1 (this is assuming that "eth1" is the > > > > network device corresponding to the network interface whose hostname is > > > > "node2") > > > > > > > > > > > > ...by default mcast routes will be associated with an interface the kernel > > > > picks (usually the first to come up). > > > > > > > > > > > > Jim > > > > > > > > > > > > Jacob Teplitsky wrote: > > > > > > > > > > Hi, > > > > > Is therte a way to bind a server to an interface: > > > > > > > > > > node5> iperf -s -u -B 224.0.67.67 -i 1 > > > > > ------------------------------------------------------------ > > > > > Server listening on UDP port 5001 > > > > > Binding to local address 224.0.67.67 > > > > > Joining multicast group 224.0.67.67 > > > > > Receiving 1470 byte datagrams > > > > > UDP buffer size: 32.0 KByte (default) > > > > > > > > > > I how it can be done for the client: > > > > > > > > > > /usr/local/bin/iperf -c 224.0.67.67 -u --ttl 5 -t 5 -B node2 > > > > > > > > > > Thanks > > > > > - Jacob > > > > > > > > > > > > -- ---------------------------------------------------------------------- James T. Kaba Sarnoff Corporation There are 10 kinds of people in the world: jk...@sa... those who understand binary, and those who don't. 609-734-2246 |