internet: cleaner way to manually set ARP or NDISC caches entries

This is a followup of https://www.nsnam.org/bugzilla/show_bug.cgi?id=2145

The actual code to set manually an ARP cache is somewhat ugly:

  Ptr<Ipv4L3Protocol> ip1 = node1->GetObject<Ipv4L3Protocol> ();
  int32_t interface1 = ip1->GetInterfaceForDevice (dev1);
  Ptr<Ipv4Interface> ipv4Interface1 = ip1->GetInterface (interface1);
  Ptr<ArpCache> cache1 = ipv4Interface1->GetArpCache ();
  ArpCache::Entry* entry1 = cache1->Add (Ipv4Address ("192.168.1.1"));
  entry1->SetMacAddress (Mac48Address ("00:00:00:00:00:01"));
  entry1->MarkPermanent ();

Beside the (long needed) idea of having a "CrystalBallArp" (and "CrystallBallNdisc"), a simpler solution is to add a super-simple API to InternetStackHelper (simply because it's almost always used).

The proposed interface is:

  • InternetStackHelper::AddPermanentArpEntry (Ptr<NetDevice> targetDevice, Ipv4Address ipv4Address, Address macAddress)
  • InternetStackHelper::RemoveArpEntry (Ptr<NetDevice> targetDevice, Ipv4Address ipv4Address, Address macAddress)
  • InternetStackHelper::AddPermanentNdiscEntry (Ptr<NetDevice> targetDevice, Ipv6Address ipv6Address, Address macAddress)
  • InternetStackHelper::RemoveNdiscEntry (Ptr<NetDevice> targetDevice, Ipv6Address ipv6Address, Address macAddress)

Where the "AddPermanent" adds an entry in permanent state (or change an existing entry to permanent state), and "Remove" removes an existing entry, regardless of its state.

The above are (practically) just syntactic sugar for the above code.

Edited by Tommaso Pecorella