Bug in IPv4 L3 Protocol?

24 views
Skip to first unread message

Xia Yang

unread,
Jun 7, 2011, 1:56:08 AM6/7/11
to ns-3-users
Dear All,

I notice there might be a bug in the implementation of ipv4-l3-
protocol. The problem surfaces when doing a subnet directed broadcast
over multiple interfaces which are assigned with IPv4 addresses under
the same subnet. It seems the current code (3.10) only finds the first
interface with the same subnet, even the socket is bound to a
different netdevice and the packet is sent using a different source
address. This will cause the broadcast traffic being sent out to wrong
network interfaces.

If anyone encounters similar problems, please confirm my observation
so that this bug can be reported to the development team. Thanks!


The code snippet handling this part is as follows:

src/internet-stack/ipv4-l3-protocol.cc

// 2) check: packet is destined to a subnet-directed broadcast
address
uint32_t ifaceIndex = 0;
for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin ();
ifaceIter != m_interfaces.end (); ifaceIter++, ifaceIndex++)
{
Ptr<Ipv4Interface> outInterface = *ifaceIter;
for (uint32_t j = 0; j < GetNAddresses (ifaceIndex); j++)
{
Ipv4InterfaceAddress ifAddr = GetAddress (ifaceIndex, j);
NS_LOG_LOGIC ("Testing address " << ifAddr.GetLocal () << "
with mask " << ifAddr.GetMask ());
if (destination.IsSubnetDirectedBroadcast (ifAddr.GetMask
()) &&
destination.CombineMask (ifAddr.GetMask ()) ==
ifAddr.GetLocal ().CombineMask (ifAddr.GetMask ()) )
{
NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 2: subnet
directed bcast to " << ifAddr.GetLocal ());
ipHeader = BuildHeader (source, destination, protocol,
packet->GetSize (), ttl, mayFragment);
Ptr<Packet> packetCopy = packet->Copy ();
m_sendOutgoingTrace (ipHeader, packetCopy, ifaceIndex);
packetCopy->AddHeader (ipHeader);
m_txTrace (packetCopy, m_node->GetObject<Ipv4> (),
ifaceIndex);
outInterface->Send (packetCopy, destination);
return;
}
}
}

Lalith Suresh

unread,
Jun 7, 2011, 5:23:07 AM6/7/11
to ns-3-...@googlegroups.com
Hello,

Yikes. That code is the same in current ns-3-dev as well. Can you please post a bug report at [0] with a test script to reproduce the bug (that works with the latest clone of ns-3-dev)?

 
--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.




--
Lalith Suresh
Department of Computer Science and Engineering
Instituto Superior Técnico
www.lalith.in

Yang Chi

unread,
Jun 7, 2011, 4:49:11 PM6/7/11
to ns-3-...@googlegroups.com
Hi

I found this problem too but was too lazy to submit. Sorry.
My working-around code:

// 2) check: packet is destined to a subnet-directed broadcast address
  uint32_t ifaceIndex = 0;
  for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin ();
    ifaceIter != m_interfaces.end (); ifaceIter++, ifaceIndex++)
    {
NS_LOG_LOGIC("Ipv4L3Protocol::Send test case 2.");
      Ptr<Ipv4Interface> outInterface = *ifaceIter;
 Ipv4InterfaceAddress interfaceAddress = outInterface->GetAddress(0);
 Ipv4Address addr = interfaceAddress.GetLocal();
 if(addr != source)
 continue;
 else
 NS_LOG_LOGIC("Ipv4L3Protocol::Send finish test case 2: "<<source<<addr);
Reply all
Reply to author
Forward
0 new messages