Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Multicast problem using virtual addresses
@ 1999-06-02  4:00 pacr99
  1999-06-03  4:00 ` Laurent Deniel
  0 siblings, 1 reply; 2+ messages in thread
From: pacr99 @ 1999-06-02  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2443 bytes --]

Hi all!

Problems regarding virual IP addressing combined with multicasting on
Digital UNIX 4.0D

First if we only have one network card with one IP address ifconfig �a
returns the real ipaddress (e.g zzz.zzz.zzz.zzz)

Using the shell command ifconfig as root in the following way permits
two IP addresses on one network card:
ifconfig tu0 alias xxx.xxx.xxx.xxx netmask yyy.yyy.yyy.yyy up
It is then possible to ping or rlogin to the IP addresses
xxx.xxx.xxx.xxx and zzz.zzz.zzz.zzz from another host.
We now have two IP addresses: xxx.xxx.xxx.xxx (virtual) and
zzz.zzz.zzz.zzz on one network card.

The problem shows up trying to receive multicast messages on the IP
addresses.

Short description of the program:
First we open a new socket: *UDPFD=socket(AF_INET,SOCK_DGRAM,0)

Then we set a socket option allowing both IP addresses to listen on the
same port: setsockopt(*UDPFD,SOL_SOCKET,SO_REUSEPORT,(const void*) &on,
sizeof(on)) where on = 1

Then we initiate a socket structure:
memset(&addr,0,sizeof(addr))
addr.sin_family = AF_INET;
addr.sin_port = htons(20000);
addr.sin_addr.s_addr = htonl(INADDR_ANY);

And associate this structure with our file descriptor:
bind(*UDPFD,(struct sockaddr *)&addr,sizeof(addr))

We now define our multicast address:
mcastaddr.s_addr=inet_addr(�239.255.0.0�)

Finally, we try to add the IP addresses to the multicast group using:
mreq.imr_multiaddr=mcastaddr;
mreq.imr_interface.s_addr = ipnumber; (ipnumber is a s_addr where
xxx.xxx.xxx.xxx has been stored)
setsockopt(*UDPFD,IPPROTO_IP,IP_ADD_MEMBERSHIP,((const void *) &mreq,
sizeof(mreq))

The same is done for the other IP address, zzz.zzz.zzz.zzz (changing
the content of s_addr to zzz.zzz.zzz.zzz)

The problem is that the last setsockopt returns �1, e.g does not
succeed. However, if one ignores the error return and tries to receive
multicasts anyway (stubborn) it seems to work anyway� (strange).
The drawback is that if one starts many threads all using the virtual
IP addresses as described in the program above it seems to run slower
comparing to using two network cards each having one IP address (also
the setsockopt succeeds without any error if one uses two network cards
instead).

We have the following questions:
1. Are we doing anything wrong (missed something)?
2. Is this an error on the part of setsockopt?

/Regards
Paul Cronholm


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Multicast problem using virtual addresses
  1999-06-02  4:00 Multicast problem using virtual addresses pacr99
@ 1999-06-03  4:00 ` Laurent Deniel
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Deniel @ 1999-06-03  4:00 UTC (permalink / raw)


pacr99@my-deja.com wrote:
> 
> We now define our multicast address:
> mcastaddr.s_addr=inet_addr(?239.255.0.0?)
> 
> Finally, we try to add the IP addresses to the multicast group using:
> mreq.imr_multiaddr=mcastaddr;
> mreq.imr_interface.s_addr = ipnumber; (ipnumber is a s_addr where
> xxx.xxx.xxx.xxx has been stored)
> setsockopt(*UDPFD,IPPROTO_IP,IP_ADD_MEMBERSHIP,((const void *) &mreq,
> sizeof(mreq))
> 
> The same is done for the other IP address, zzz.zzz.zzz.zzz (changing
> the content of s_addr to zzz.zzz.zzz.zzz)
> 
> The problem is that the last setsockopt returns -1, e.g does not
> succeed. 

The IP address specified in imr_interface is just there to choose the
desired interface. AFAIK, you can not become a member of the same 
multicast group two times on the same interface (i.e. on xxx and zzz 
when zzz in an alias on the same interface as xxx (but it is possible 
to join the same group on more than one interface).

Laurent.

--
Laurent DENIEL            | E-mail: deniel@worldnet.fr
Paris, FRANCE             |         deniel@fr.airsysatm.thomson-csf.com
                          | WWW   : http://www.worldnet.fr/~deniel
    All above opinions are personal, unless stated otherwise.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-06-03  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-06-02  4:00 Multicast problem using virtual addresses pacr99
1999-06-03  4:00 ` Laurent Deniel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox