ns3中loopback接口是在什么时候创建的?

来源:互联网 发布:现代软件学院 编辑:程序博客网 时间:2024/05/16 06:06

参考定位的地方:

Breakpoint 3, ns3::Node::GetNDevices (this=0x6617f0) at ../src/network/model/node.cc:146
146      return m_devices.size ();
(gdb) bt
#0  ns3::Node::GetNDevices (this=0x6617f0) at ../src/network/model/node.cc:146
#1  0x00007ffff6cb8c7c in ns3::Ipv4L3Protocol::SetupLoopback (this=0x662cf0) at ../src/internet/model/ipv4-l3-protocol.cc:265
#2  0x00007ffff6cb7a24 in ns3::Ipv4L3Protocol::SetNode (this=0x662cf0, node=...) at ../src/internet/model/ipv4-l3-protocol.cc:156
#3  0x00007ffff6cb8077 in ns3::Ipv4L3Protocol::NotifyNewAggregate (this=0x662cf0) at ../src/internet/model/ipv4-l3-protocol.cc:197
#4  0x00007ffff73714e3 in ns3::Object::AggregateObject (this=0x6617f0, o=...) at ../src/core/model/object.cc:306
#5  0x00007ffff6ee4784 in ns3::InternetStackHelper::CreateAndAggregateObjectFromTypeId (node=..., typeId=...) at ../src/internet/helper/internet-stack-helper.cc:419
#6  0x00007ffff6ee49f9 in ns3::InternetStackHelper::Install (this=0x7fffffffd320, node=...) at ../src/internet/helper/internet-stack-helper.cc:435
#7  0x00007ffff6ee4632 in ns3::InternetStackHelper::Install (this=0x7fffffffd320, c=...) at ../src/internet/helper/internet-stack-helper.cc:403
#8  0x000000000040f43c in main (argc=1, argv=0x7fffffffdc98) at ../myscripts/ns-3-dce-quagga/example/dce-quagga-isisd.cc:98
(gdb) p m_devices.size()
$3 = 1
(gdb) 


寻迹象找到的创建lo接口的地方如下,

  // First check whether an existing LoopbackNetDevice exists on the node  for (uint32_t i = 0; i < m_node->GetNDevices (); i++)    {      if ((device = DynamicCast<LoopbackNetDevice> (m_node->GetDevice (i))))        {          break;        }    }  if (device == 0)    {      device = CreateObject<LoopbackNetDevice> ();       m_node->AddDevice (device);    }

通常创建的方法是,

      Ipv4AddressHelper ipv4AddrHelper;      // Internet stack install      InternetStackHelper stack;    // IPv4 is required for GlobalRouteMan      Ipv4DceRoutingHelper ipv4RoutingHelper;      stack.SetRoutingHelper (ipv4RoutingHelper);      stack.Install (nodes);

这里的routingHelper可以是别的routingHelper,而非一定是dce的。

stack.Install(nodes)调用的顺序会影响接口ifIndex的值。

节点计算ifIndex的方法是:累加

  uint32_t index = m_devices.size ();  m_devices.push_back (device);  device->SetNode (this);  device->SetIfIndex (index);



0 0
原创粉丝点击