Disable ARP, Configure static ARP tables

559 views
Skip to first unread message

msolima3

unread,
Jul 9, 2012, 1:01:24 PM7/9/12
to ns-3-...@googlegroups.com
Hi all,
I'm new in ns3 and trying to do some simulations with ns3-openflow modules. The current ns3 openflow switch modules doesn't support STP so I wanted to disable the ARP broadcasts to avoid broadcast storms. Can anybody please tell me how to add static ARP entries to the nodes "code if possible" ?
I've tried a function called  PopulateArpCache() but it produces a "terminated with signal SIGSEGV." error.

Thanks

PopulateArpCache ()
{
  Ptr<ArpCache> arp = CreateObject<ArpCache> ();
  arp->SetAliveTimeout (Seconds(3600 * 24 * 365));
  for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i)
  {
    Ptr<Ipv4L3Protocol> ip = (*i)->GetObject<Ipv4L3Protocol> ();
    // NS_ASSERT(ip !=0);
    ObjectVectorValue interfaces;
    ip->GetAttribute("InterfaceList", interfaces);

    for(ObjectVectorValue::Iterator j = interfaces.Begin(); j != interfaces.End (); j ++)
    {
      Ptr<Ipv4Interface> ipIface = (*j)->GetObject<Ipv4Interface> ();
      // NS_ASSERT(ipIface != 0);
      Ptr<NetDevice> device = ipIface->GetDevice();
      // NS_ASSERT(device != 0);
       Mac48Address addr = Mac48Address::ConvertFrom(device->GetAddress());

      for(uint32_t k = 0; k < ipIface->GetNAddresses (); k ++)
      {
        Ipv4Address ipAddr = ipIface->GetAddress (k).GetLocal();
        if(ipAddr == Ipv4Address::GetLoopback())
          continue;
        ArpCache::Entry * entry = arp->Add(ipAddr);
        entry->MarkWaitReply(0);
        entry->MarkAlive(addr);
      }
    }
  }
  for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i)
  {
    Ptr<Ipv4L3Protocol> ip = (*i)->GetObject<Ipv4L3Protocol> ();
    NS_ASSERT(ip !=0);
    ObjectVectorValue interfaces;
    ip->GetAttribute("InterfaceList", interfaces);
    for(ObjectVectorValue::Iterator j = interfaces.Begin(); j != interfaces.End (); j ++)
    {
      Ptr<Ipv4Interface> ipIface = (*j)->GetObject<Ipv4Interface> ();
      ipIface->SetAttribute("ArpCache", PointerValue(arp));
      }
    }

}

Jz bao

unread,
Jan 15, 2016, 7:18:31 AM1/15/16
to ns-3-users
hello, i am also have the problem, and have you ever solved this problem? thank you very much!

在 2012年7月10日星期二 UTC+8上午1:01:24,msolima3写道:

Tommaso Pecorella

unread,
Jan 15, 2016, 10:49:13 AM1/15/16
to ns-3-users
You seems to have too many problems that are (apparently) identical to ones in dead threads from the past.

Please consider opening a thread explaining your problems as a whole and to NOT reply to things from the long forgotten past.
moreover, in 3-4 years ns-3 did evolve a LOT. Please take your time to read and understand the manual and the tutorial of the latest ns-3 release.

Thanks,

T.
Reply all
Reply to author
Forward
0 new messages