Manual IPv6 Address Assignment to an IPv6 Interface

34 views
Skip to first unread message

m8.s...@gmail.com

unread,
May 29, 2017, 8:44:32 AM5/29/17
to ns-3-users
Hello all,

I am trying to assign an IPv6 address to an Ipv6 Interface 'manually', but I am getting the following error,

Command ['/home/xxxxx/Desktop/ns-allinone-3.26/ns-3.26/build/scratch/ripng-simple-network02'] terminated with signal SIGSEGV. Run it under a debugger to get more information (./waf --run <program> --command-template="gdb --args %s <args>").

I have tried many things, but it is not working. Will greatly appreciate if someone could guide me, as to how to accomplish this.



Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:db8:f00d:cafe::42"), Ipv6Prefix (64));

 
  Ptr<Ipv6> ipv6Proto = database->GetObject<Ipv6>();  //'database is a node'

  int32_t ifIndex = ipv6Proto->GetInterfaceForDevice(ndc15.Get(1)); //GetInterfaceForDevice() returns the interface of the specified NetDevice.
  ipv6Proto->AddAddress (ifIndex, ipv6Addr);



I have tried to search for the relevant information, but have not been able to locate for what I have been looking for. The code is attached, and I will be grateful for any useful feedback.
ripng-simple-network02.cc
RipNgSimple02.PNG

Rediet

unread,
May 30, 2017, 3:03:33 AM5/30/17
to ns-3-users
Hello,

It is because you didn't add the interface before retrieving it. If you add the following lines (extracted from Ipv6AddressHelper) before adding the address, it will work:
if (ifIndex == -1)
    {
      ifIndex = ipv6Proto->AddInterface (ndc15.Get(1));
    }
You can also simply replace the GetInterfaceForDevice with AddInterface...

Cheers,

Rediet
Reply all
Reply to author
Forward
Message has been deleted
0 new messages