> Hello,
> Does anybody know if it is possible to assign /32 address to node (not
> necessarily using a helper - I'm aware of that bug), that will act as
> RID (Router ID).
> I'm basically looking for a sort of Loopback 0 interface (in Cisco
> terminology).
> I tried to achieve this goal doing something like this:
> void makerid(char *ipaddr, Ptr<Node> n) {
> ObjectFactory m_queueFactory;
> m_queueFactory.SetTypeId ("ns3::DropTailQueue");
> ObjectFactory m_deviceFactory;
> m_deviceFactory.SetTypeId ("ns3::CsmaNetDevice");
> ObjectFactory m_channelFactory;
> m_channelFactory.SetTypeId ("ns3::CsmaChannel");
> Ptr<CsmaChannel> channel = m_channelFactory.Create ()-
> >GetObject<CsmaChannel> ();
> Ptr<CsmaNetDevice> csmadevice =
> m_deviceFactory.Create<CsmaNetDevice> ();
> csmadevice->SetAddress (Mac48Address::Allocate ());
> csmadevice->SetName("rid");
> n->AddDevice (csmadevice);
> Ptr<Queue> queue = m_queueFactory.Create<Queue> ();
> csmadevice->SetQueue (queue);
> csmadevice->Attach (channel);
> Ptr<NetDevice> device;
> for(uint32_t i=0; i < n->GetNDevices(); i++) {
> device = n->GetDevice(i);
> if(device->GetName() == "rid") {
> Ptr<Node> node = device->GetNode ();
> NS_ASSERT_MSG (node, "Ipv4AddressHelper::Allocate(): Bad node");
> Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
> NS_ASSERT_MSG (ipv4, "Ipv4AddressHelper::Allocate(): Bad ipv4");
> int32_t ifIndex = ipv4->FindInterfaceForDevice (device);
> if (ifIndex == -1) {
> ifIndex = ipv4->AddInterface (device);
> }
> NS_ASSERT_MSG (ifIndex >= 0, "Ipv4AddressHelper::Allocate():
> Interface index not found");
> Ipv4Address ip(ipaddr);
> ipv4->SetAddress (ifIndex, ip);
> ipv4->SetNetworkMask (ifIndex, 0xffffffff);
> //ipv4->SetNetworkMask (ifIndex, 0xffffff00);
> ipv4->SetMetric (ifIndex, 1);
> ipv4->SetUp (ifIndex);
> }
> }
> }
> However such a approach doesn't work. In short I tried to create an
> extra interface that would act as loopback.
> What I noticed is that if interface is created (doesn't matter which
> one i.e. p2p or csma), and has only one "client" i.e. nobody else is
> connected to that interface it doesn't work.
> For testing I'm using modified version of "first.cc", and what to
> achieve (topology below) is to have a transmission from router's A
> loopback 5.2.0.4 to router's B loopback 5.2.0.2 (in a similar way
> like multihop BGP works).
> RouterA(RID: 5.2.0.4) .73 <= p2p: 1.0.1.72/30 => .74 RouterB (RID:
> 5.2.0.2)
> One more thing. I'm using global route manage to populate routing
> tables.
> Your input is highly appreciated!
Your code above seems awfully complicated. I would suggest looking at Hope it helps.