clemens gmeiner(deleted)
|
Re: broadcast UDP with multiple interfaces
|
clemens gmeiner(deleted)
10/30/2008 1:36 PM
post15742
|
Re: broadcast UDP with multiple interfaces
> Hi Tim,
>
> I do have a problem using UDP multicast on en1 (one special interface of 2).
> I bound to a specific ip (en1) I can send multicast
> messages on each nic but I'm not able to receive multicast
> frames with this configuration anymore.
>
> With wireshark I can see the IGMP multicast messages (join and leave)
> and I can see the udp multicast frames on the net which should be received
> by en1 but the stack doesn't receive them.
>
> I am going to post more details tomorrow including some sample
> code but I am still not sure if this is a problem
>
> 1.in my code
> 2.within multicast managing of the nic driver
> 3.within the tcp/ip stack.
>
> Could you please post a sample code as well and describe
> the ip configuration you are using and what happens on the net
>
> post the output of ifconfig and netstat -nr as well. I am going to
> debug deeper into my problem it might be I find something
> helpful for you as well.
>
> regards,
> Clemens
Hi all,
now I have written a simple test program which can be
used to test receive and send of multicast packets
I am able to send in all 3 possible modes
(socket bound to ip of en0,en1 or to INADDR_ANY).
Tim, if I bind to different sockets the src address changes
as well.
I am just able to receive multicast messages with
INADDR_ANY configuration.
Looking into the documentation tells me it is not forbidden
and I should be able to do that but it doesn't work.
see the attached sample file
Does somebody have an idea, did I something wrong within
my code ?
regards,
Clemens
|
|
|
Tim Gessner
|
Re: broadcast UDP with multiple interfaces
|
Tim Gessner
11/03/2008 10:00 AM
post15857
|
Re: broadcast UDP with multiple interfaces
Here is how I create the socket
m_fdDMCPSock = ::socket(PF_INET, SOCK_DGRAM, 0);
if ( m_fdDMCPSock == -1 )
{
// <<ERROR>>
LOG_STD_ERROR("Failed to create a socket for DMCP processing.");
}
if ( m_fdDMCPSock != -1 )
{
int nRet = -1;
int nOptVal = 1;
nRet = ::setsockopt(m_fdDMCPSock,SOL_SOCKET,SO_BROADCAST,&nOptVal,sizeof(nOptVal));
if ( nRet < 0 )
{
// <<ERROR>>
LOG_STD_ERROR("Failed to set options for DMCP processing socket.");
bRet = false;
}
struct ifreq ifr;
::strcpy(ifr.ifr_name,"en1");
::ioctl(m_fdDMCPSock,SIOCGIFADDR,reinterpret_cast<int>(&ifr));
nRet = ::setsockopt(m_fdDMCPSock,SOL_SOCKET,SO_BINDTODEVICE,&ifr,sizeof(ifr));
if ( nRet < 0 )
{
// <<ERROR>>
LOG_STD_ERROR("Failed to set options for DMCP processing socket.");
bRet = false;
}
}
From that point on - I operate pretty normally. Things are working fine for me now.
Tim
|
|
|