m_socket = Socket::CreateSocket (GetNode(), m_tid);
m_socket->BindToNetDevice(GetNode()->GetDevice(m_devNum)); //
added this line
m_socket->Bind ();
m_socket->Connect (m_peer);
Thanks!
Michael
There should be a viable route via both of these devices to your
destination for it to work. See examples/socket/socket-bound* for an
example.
Hmm - I didn't actually test this configuration where multiple
interfaces are connected to *same* subnet. Any chance you could post
some sort of abridged source code where the issue appears (preferably
not your full simulation, but some simple case that demonstrates the
issue)?
Also, are you using latest ns-dev (the patch has been merged and
there were a few revisions since my original post)?
Packets are only sent from the highest numbered device on the node
with multiple devices.
When the "source[chan]->BindToNetDevice(dev);" line is active, only
numPackets are sent. When the line is commented out, all of the
packets (numPackets*numChannels) are sent out over a single device
with different socket values.
I am using the latest dev package, I did an hg pull just before
starting this earlier today.
Thanks for your assistance!
Michael
Ok,
Key information seems to be that your remote address is broadcast,
InetSocketAddress remote = InetSocketAddress (Ipv4Address
("255.255.255.255"), 80);
so this case is something I definitely didn't test. There *is* a
check in place though.
Right now I would probably simply run this with gdb with a
breakpoint at udp-socket-impl.cc and line 371 and see what happens
there. Since it seems that you are having issues even *without* device
binding in place (all packets going out of a single interface anyway)?
So there may be something there..
I can get back onto this on next week if you wish to try your own
debugs in the meantime. I'd also suggest filing a bug report.
Michael,
I did not know where to look for your uploaded file, but is it possible
you are running OLSR (or AODV) and are encountering this bug?
http://www.nsnam.org/bugzilla/show_bug.cgi?id=778
If you are not running static routing, then most likely the routing
protocol will not honor the request to bind to the device until these
bugs are fixed.
- Tom
http://ns-3-users.googlegroups.com/web/testBindTo.cc?gda=dsFdDD8AAADbpj5ltU5plboFYd9CaUiLt3zeAZNtpHhfjSlSX4E-OV05kApfN1Dp5BLlGj2CGlmccyFKn-rNKC-d1pM_IdV0
is the file (visible in group view of google groups web interface).
Just reading the source doesn't have any references to OLSR, unless
mobility models automagically install it.
I think I have found something. This is in fact NOT a problem with
BindToNetDevice(), but looks like in the handling of broadcasts in
general in ipv4-l3-protocol.cc.
Lines 555-> handle subnet-directed broadcasts. Note that the choice
of output device is based *solely* on the destination mask matching
and, on line 575 there's a "return" statement. So whenever sending
limited broadcasts, the interface that is iterated first and matches
the mask sends stuff out.
I added
LogComponentEnable("UdpSocketImpl", LOG_LEVEL_LOGIC);
LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_LOGIC);
to your code and and commented bindtonetdevice out, and got this:
Testing 3 packets sent with receiver rss
-80
dev[0]=
0
source[0]=
0x8f19688
dev[1]=
0
source[1]=
0x8f19b68
called by 0x8f19688 pktCount=
3
UdpSocketImpl:Send(0x8f19688, 0x8f1f748,
0)
UdpSocketImpl:DoSend(0x8f19688,
0x8f1f748)
UdpSocketImpl:Bind
()
UdpSocketImpl:FinishBind
()
UdpSocketImpl:DoSendTo(0x8f19688, 0x8f1f748, 255.255.255.255,
80)
UdpSocketImpl:GetTxAvailable
()
Limited broadcast
start.
Ipv4L3Protocol:GetNInterfaces
()
Ipv4L3Protocol:GetAddress(0x8f16670, 0,
0)
Ipv4L3Protocol:GetInterface(0x8f16670,
0)
Ipv4L3Protocol:GetNInterfaces
()
Ipv4L3Protocol:GetAddress(0x8f16670, 1,
0)
Ipv4L3Protocol:GetInterface(0x8f16670,
1)
Sending one copy from 10.1.1.1 to 10.1.1.255 (mask is
255.255.255.0)
Ipv4L3Protocol:Send(0x8f16670, 0x8f217d8, 10.1.1.1, 10.1.1.255, 17,
0)
Ipv4L3Protocol:GetNAddresses(0x8f16670,
0)
Ipv4L3Protocol:GetInterface(0x8f16670,
0)
Ipv4L3Protocol:GetAddress(0x8f16670, 0,
0)
Ipv4L3Protocol:GetInterface(0x8f16670,
0)
Testing address 127.0.0.1 with mask
255.0.0.0
Ipv4L3Protocol:GetNAddresses(0x8f16670,
0)
Ipv4L3Protocol:GetInterface(0x8f16670,
0)
Ipv4L3Protocol:GetNAddresses(0x8f16670,
1)
Ipv4L3Protocol:GetInterface(0x8f16670,
1)
Ipv4L3Protocol:GetAddress(0x8f16670, 1,
0)
Ipv4L3Protocol:GetInterface(0x8f16670,
1)
Testing address 10.1.1.1 with mask
255.255.255.0
Ipv4L3Protocol::Send case 2: subnet directed bcast to
10.1.1.1
Ipv4L3Protocol:BuildHeader
()
UdpSocketImpl:GetTxAvailable
()
Ipv4L3Protocol:GetNInterfaces
()
Limited broadcast
end.
called by 0x8f19b68 pktCount=
3
UdpSocketImpl:Send(0x8f19b68, 0x8f1a4f8,
0)
UdpSocketImpl:DoSend(0x8f19b68,
0x8f1a4f8)
UdpSocketImpl:Bind
()
UdpSocketImpl:FinishBind
()
UdpSocketImpl:DoSendTo(0x8f19b68, 0x8f1a4f8, 255.255.255.255,
80)
UdpSocketImpl:GetTxAvailable
()
Limited broadcast
start.
Ipv4L3Protocol:GetNInterfaces
()
Ipv4L3Protocol:GetAddress(0x8f16670, 0,
0)
Ipv4L3Protocol:GetInterface(0x8f16670,
0)
Ipv4L3Protocol:GetNInterfaces
()
Ipv4L3Protocol:GetAddress(0x8f16670, 1,
0)
Ipv4L3Protocol:GetInterface(0x8f16670,
1)
Sending one copy from 10.1.1.1 to 10.1.1.255 (mask is
255.255.255.0)
Ipv4L3Protocol:Send(0x8f16670, 0x8f217d8, 10.1.1.1, 10.1.1.255, 17,
0)
Ipv4L3Protocol:GetNAddresses(0x8f16670,
0)
Ipv4L3Protocol:GetInterface(0x8f16670,
0)
Ipv4L3Protocol:GetAddress(0x8f16670, 0,
0)
Ipv4L3Protocol:GetInterface(0x8f16670,
0)
Testing address 127.0.0.1 with mask
255.0.0.0
Ipv4L3Protocol:GetNAddresses(0x8f16670,
0)
Ipv4L3Protocol:GetInterface(0x8f16670,
0)
Ipv4L3Protocol:GetNAddresses(0x8f16670,
1)
Ipv4L3Protocol:GetInterface(0x8f16670,
1)
Ipv4L3Protocol:GetAddress(0x8f16670, 1,
0)
Ipv4L3Protocol:GetInterface(0x8f16670,
1)
Testing address 10.1.1.1 with mask
255.255.255.0
Ipv4L3Protocol::Send case 2: subnet directed bcast to
10.1.1.1
Ipv4L3Protocol:BuildHeader
()
UdpSocketImpl:GetTxAvailable
()
Ipv4L3Protocol:GetNInterfaces
()
Limited broadcast
end.
So what happens is that even though the *socket* is sending via a
specific device, the broadcast-address-matching doesn't work properly.
Only difference if bindtonetdevice is active is that the *socket*
skips the non-matching devices, but the ipv4-l3-protocol still sends
whatever way it wishes..
I'm not sure if this is actually working as-intended - like I said,
connecting multiple devices from a single node to same subnet sounds a
bit odd to me so I have never encountered this configuration. Of
course, you could also start matching the source address in the ipv4-
l3-protocol.cc (simply add a check "if source == ifAddr.GetLocal()"
around line 565), but no idea what it would break.
Thanks again!
Michael
If you want to skip IP altogether, look into Packet Sockets (for
sending stuff at Ethernet level). Look in examples/csma-packet-
socket.cc to help you along the way. I haven't experimented with them
at all so can't help you there.
Michael
Michael
> > at all so can't help you there.- Hide quoted text -
>
> - Show quoted text -