ospf没有multipath的问题定位

[root@gdc1000 ospf_no_multi]# cat debug
3台设备跑ospf,只有1台成功出现multipath,其他两台没有。
比较日志,其他两台出现如下日志。




Breakpoint 1, ospf_hello (iph=0x7ffff01ac008, ospfh=0x7ffff01ac01c, s=0x7ffff01c1218, oi=0x7ffff01a5728, size=20) at ospf_packet.c:848

848        zlog_warn ("Packet %s [Hello:RECV]: NetworkMask mismatch on %s (configured prefix length is %d, but hello packet indicates %d).",
(gdb) b
Note: breakpoint 1 also set at pc 0x7ffff0279eac.
Breakpoint 2 at 0x7ffff0279eac: file ospf_packet.c, line 848.
(gdb) bt
#0  ospf_hello (iph=0x7ffff01ac008, ospfh=0x7ffff01ac01c, s=0x7ffff01c1218, oi=0x7ffff01a5728, size=20) at ospf_packet.c:848
#1  0x00007ffff027ee0e in ospf_read (thread=0x7ffff058bb10) at ospf_packet.c:2947
#2  0x00007ffff02cd8fd in thread_call (thread=0x7ffff058bb10) at thread.c:1271
#3  0x00007ffff0265375 in main (argc=5, argv=0x674d10) at ospf_main.c:347
#4  0x00007ffff79ff3bf in ns3::DceManager::DoStartProcess (context=0x763330) at ../model/dce-manager.cc:283
#5  0x00007ffff7a88b78 in ns3::TaskManager::Trampoline (context=0x763510) at ../model/task-manager.cc:274
#6  0x00007ffff7a84b53 in ns3::PthreadFiberManager::Run (arg=0x763530) at ../model/pthread-fiber-manager.cc:402
#7  0x000000318b2079d1 in start_thread () from /lib64/libpthread.so.0
#8  0x000000318a6e88fd in clone () from /lib64/libc.so.6
(gdb)


发送


Breakpoint 6, ospf_write (thread=0x7ffff058bb10) at ospf_packet.c:761
761      ret = sendmsg (ospf->fd, &msg, flags);
(gdb) s
sendmsg () at ../model/libc-ns3.h:190
190    DCE (sendmsg)
(gdb) s
dce_sendmsg (fd=4, msg=0x7ffff058b860, flags=0) at ../model/dce-fd.cc:268
268      Thread *current = Current ();
(gdb)

接收 ospf_read
ns3::UnixSocketFd::Sendmsg (this=0x7fffdc0077d0, msg=0x7ffff058b860, flags=0) at ../model/unix-socket-fd.cc:232
232      bool nonBlocking = (m_statusFlags & O_NONBLOCK) == O_NONBLOCK;
(gdb)

gdb) s
ns3::UnixDatagramSocketFd::DoSendmsg (this=0x7fffdc0077d0, msg=0x7ffff058b860, flags=0) at ../model/unix-datagram-socket-fd.cc:314
314      Thread *current = Current ();
(gdb) n


将报文转换为Packet,并发送出去

Breakpoint 7, ns3::UnixDatagramSocketFd::MainSendTo (this=0x7fffdc0077d0, r=0x7ffff058b31c, p=..., f=0, ad=...) at ../model/unix-datagram-socket-fd.cc:510
510      *r = m_socket->SendTo (p, f, ad);
(gdb) s
ns3::Ptr<ns3::Socket>::operator-> (this=0x7fffdc007810) at /home/z/new/dce/build/include/ns3.23/ns3/ptr.h:781
781      return m_ptr;
(gdb) fin
Run till exit from #0  ns3::Ptr<ns3::Socket>::operator-> (this=0x7fffdc007810) at /home/z/new/dce/build/include/ns3.23/ns3/ptr.h:781
0x00007ffff7a4534e in ns3::UnixDatagramSocketFd::MainSendTo (this=0x7fffdc0077d0, r=0x7ffff058b31c, p=..., f=0, ad=...) at ../model/unix-datagram-socket-fd.cc:510
510      *r = m_socket->SendTo (p, f, ad);
Value returned is $44 = (ns3::Socket *) 0x7fffdc002b30
(gdb) s
ns3::Ptr<ns3::Packet>::Ptr (this=0x7fffffffbfb0, o=...) at /home/z/new/dce/build/include/ns3.23/ns3/ptr.h:739
739      : m_ptr (PeekPointer (o))
(gdb) fin
Run till exit from #0  ns3::Ptr<ns3::Packet>::Ptr (this=0x7fffffffbfb0, o=...) at /home/z/new/dce/build/include/ns3.23/ns3/ptr.h:739
0x00007ffff7a45370 in ns3::UnixDatagramSocketFd::MainSendTo (this=0x7fffdc0077d0, r=0x7ffff058b31c, p=..., f=0, ad=...) at ../model/unix-datagram-socket-fd.cc:510
510      *r = m_socket->SendTo (p, f, ad);
(gdb) s
ns3::Ipv4RawSocketImpl::SendTo (this=0x7fffdc002b30, p=..., flags=0, toAddress=...) at ../src/internet/model/ipv4-raw-socket-impl.cc:196
196      NS_LOG_FUNCTION (this << p << flags << toAddress);
(gdb)

先会验证一下有没有出口路由
0x00007ffff6374672 in ns3::Ipv4RawSocketImpl::SendTo (this=0x7fffdc002b30, p=..., flags=0, toAddress=...) at ../src/internet/model/ipv4-raw-socket-impl.cc:236
236          route = ipv4->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_);
(gdb) s
ns3::Ipv4DceRouting::RouteOutput (this=0x713e00, p=..., header=..., oif=..., sockerr=@0x7fffffffbd7c: ns3::Socket::ERROR_NOTERROR) at ../model/ipv4-dce-routing.cc:649
649      NS_LOG_FUNCTION (this << p<< header << oif << sockerr);
(gdb) bt
#0  ns3::Ipv4DceRouting::RouteOutput (this=0x713e00, p=..., header=..., oif=..., sockerr=@0x7fffffffbd7c: ns3::Socket::ERROR_NOTERROR) at ../model/ipv4-dce-routing.cc:649
#1  0x00007ffff63746a4 in ns3::Ipv4RawSocketImpl::SendTo (this=0x7fffdc002b30, p=..., flags=0, toAddress=...) at ../src/internet/model/ipv4-raw-socket-impl.cc:236
#2  0x00007ffff7a45384 in ns3::UnixDatagramSocketFd::MainSendTo (this=0x7fffdc0077d0, r=0x7ffff058b31c, p=..., f=0, ad=...) at ../model/unix-datagram-socket-fd.cc:510
#3  0x00007ffff7a45d17 in ns3::EventImpl* ns3::MakeEvent<void (ns3::UnixDatagramSocketFd::*)(int*, ns3::Ptr<ns3::Packet>, unsigned int, ns3::Address), ns3::UnixDatagramSocketFd*, int*, ns3::Ptr<ns3::Packet>, int, ns3::Address>(void (ns3::UnixDatagramSocketFd::*)(int*, ns3::Ptr<ns3::Packet>, unsigned int, ns3::Address), ns3::UnixDatagramSocketFd*, int*, ns3::Ptr<ns3::Packet>, int, ns3::Address)::EventMemberImpl4::Notify() (this=0x7fffdc02aa40) at /home/z/new/dce/build/include/ns3.23/ns3/make-event.h:452
#4  0x00007ffff733e5e7 in ns3::EventImpl::Invoke (this=0x7fffdc02aa40) at ../src/core/model/event-impl.cc:51
#5  0x00007ffff7a8ab2e in ns3::TaskManager::Schedule (this=0x6bbe90) at ../model/task-manager.cc:441
#6  0x00007ffff7a8cb21 in ns3::EventImpl* ns3::MakeEvent<void (ns3::TaskManager::*)(), ns3::TaskManager*>(void (ns3::TaskManager::*)(), ns3::TaskManager*)::EventMemberImpl0::Notify() (this=0x69d030) at /home/z/new/dce/build/include/ns3.23/ns3/make-event.h:323
#7  0x00007ffff733e5e7 in ns3::EventImpl::Invoke (this=0x69d030) at ../src/core/model/event-impl.cc:51
#8  0x00007ffff73432ac in ns3::DefaultSimulatorImpl::ProcessOneEvent (this=0x732510) at ../src/core/model/default-simulator-impl.cc:147
#9  0x00007ffff7343638 in ns3::DefaultSimulatorImpl::Run (this=0x732510) at ../src/core/model/default-simulator-impl.cc:200
#10 0x00007ffff733f378 in ns3::Simulator::Run () at ../src/core/model/simulator.cc:204
#11 0x0000000000423580 in generate_routing_table () at ../myscripts/ns-3-dce-quagga/example/dce-test-11.cc:354
#12 0x0000000000424538 in main (argc=1, argv=0x7fffffffdc18) at ../myscripts/ns-3-dce-quagga/example/dce-test-11.cc:396
(gdb)


hello是多播报文,多播报文的路由被作为单播已经做了记录,所以能够被查到。
      // Note:  Multicast routes for outbound packets are stored in the
      // normal unicast table.  An implication of this is that it is not
      // possible to source multicast datagrams on multiple interfaces.
      // This is a well-known property of sockets implementation on
      // many Unix variants.
      // So, we just log it and fall through to LookupStatic ()

发送

(gdb) s
ns3::Ipv4L3Protocol::SendWithHeader (this=0x713be0, packet=..., ipHeader=..., route=...) at ../src/internet/model/ipv4-l3-protocol.cc:603
603      NS_LOG_FUNCTION (this << packet << ipHeader << route);
(gdb) fin


发送的时候为什么不带mask?


Breakpoint 8, ospf_make_hello (oi=0x7ffff00dc378, s=0x7ffff00c53a8) at ospf_packet.c:3071
3071      stream_put_ipv4 (s, mask.s_addr);
(gdb) p mask
$62 = {s_addr = 0}
(gdb) bt
#0  ospf_make_hello (oi=0x7ffff00dc378, s=0x7ffff00c53a8) at ospf_packet.c:3071
#1  0x00007ffff028001f in ospf_hello_send_sub (oi=0x7ffff00dc378, addr=83886304) at ospf_packet.c:3391
#2  0x00007ffff02805f5 in ospf_hello_send (oi=0x7ffff00dc378) at ospf_packet.c:3525
#3  0x00007ffff026f4ea in ospf_hello_timer (thread=0x7ffff01a1b10) at ospf_ism.c:262
#4  0x00007ffff02cd8fd in thread_call (thread=0x7ffff01a1b10) at thread.c:1271
#5  0x00007ffff0265375 in main (argc=5, argv=0x6c5480) at ospf_main.c:347
#6  0x00007ffff79ff3bf in ns3::DceManager::DoStartProcess (context=0x763eb0) at ../model/dce-manager.cc:283
#7  0x00007ffff7a88b78 in ns3::TaskManager::Trampoline (context=0x69cea0) at ../model/task-manager.cc:274
#8  0x00007ffff7a84b53 in ns3::PthreadFiberManager::Run (arg=0x7641a0) at ../model/pthread-fiber-manager.cc:402
#9  0x000000318b2079d1 in start_thread () from /lib64/libpthread.so.0
#10 0x000000318a6e88fd in clone () from /lib64/libc.so.6
(gdb)

两个仿真网卡被认为分别属于两种类型,其中
1 是PPP
2 是csma

Breakpoint 3, ospf_hello_send (oi=0x7fffdbfd8728) at ospf_packet.c:3484
3484      if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_PASSIVE)
(gdb) p oi->ifp->name
$66 = "coco-device2\000\000\000\000\000\000\000\000"
(gdb) watch oi->type
Hardware watchpoint 9: oi->type
(gdb) p oi->type
$67 = 2 '\002'
(gdb)


Breakpoint 1, ospf_hello (iph=0x7ffff01ac008, ospfh=0x7ffff01ac01c, s=0x7ffff01c1218, oi=0x7ffff01a5728, size=24) at ospf_packet.c:848
848        zlog_warn ("Packet %s [Hello:RECV]: NetworkMask mismatch on %s (configured prefix length is %d, but hello packet indicates %d).",
(gdb) p oi
$80 = (struct ospf_interface *) 0x7ffff01a5728
(gdb) p oi->type
$81 = 2 '\002'
(gdb) p oi->ifp->name
$82 = "coco-device2\000\000\000\000\000\000\000\000"
(gdb)


原因是1台设备的1口连到了另一台设备的2口,而两个口,一个是PPP,一个是CSMA







[root@gdc1000 ospf_no_multi]#



修改方法: 增加配置,将两端都配置为ppp


说明:配置规范里有一条就是要求ospf不能使用默认type配置,必须手工配置为ppp,我违反了这条规范,该!

你可能感兴趣的:(ospf没有multipath的问题定位)