A向B发送报文:A sendto ------->B
B輪询收到的报文:A 《———recvfrom B
A:
1 发送包
Breakpoint 1, dce_sendto (fd=8, buf=0x7ffff4265898, len=1500, flags=0, to=0x7ffff4582aa0, tolen=20) at ../model/dce-fd.cc:250
250 NS_LOG_FUNCTION (Current () << fd << buf << len << flags << to << tolen);
2 socket处理
Breakpoint 2, ns3::PacketDgramSocket::SendTo (this=0x7fffe402e9c0, p=..., flags=0, address=...) at ../src/network/utils/packet-dgram-socket.cc:315
315 PacketSocketAddress ad;
(gdb) bt
#0 ns3::PacketDgramSocket::SendTo (this=0x7fffe402e9c0, p=..., flags=0, address=...) at ../src/network/utils/packet-dgram-socket.cc:315
#1 0x00007ffff7a4cb02 in ns3::UnixDatagramSocketFd::MainSendTo (this=0x7fffe402eb50, r=0x7ffff45824bc, p=..., f=0, ad=...) at ../model/unix-datagram-socket-fd.cc:510
#2 0x00007ffff7a4d495 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=0x7fffe402e7d0) at /home/z/dce/build/include/ns3.23/ns3/make-event.h:452
#3 0x00007ffff73465e7 in ns3::EventImpl::Invoke (this=0x7fffe402e7d0) at ../src/core/model/event-impl.cc:51
#4 0x00007ffff7a922ae in ns3::TaskManager::Schedule (this=0x664fc0) at ../model/task-manager.cc:441
#5 0x00007ffff7a942a1 in ns3::EventImpl* ns3::MakeEvent<void (ns3::TaskManager::*)(), ns3::TaskManager*>(void (ns3::TaskManager::*)(), ns3::TaskManager*)::EventMemberImpl0::Notify() (this=0x662600) at /home/z/dce/build/include/ns3.23/ns3/make-event.h:323
#6 0x00007ffff73465e7 in ns3::EventImpl::Invoke (this=0x662600) at ../src/core/model/event-impl.cc:51
#7 0x00007ffff734b2ac in ns3::DefaultSimulatorImpl::ProcessOneEvent (this=0x660910) at ../src/core/model/default-simulator-impl.cc:147
#8 0x00007ffff734b638 in ns3::DefaultSimulatorImpl::Run (this=0x660910) at ../src/core/model/default-simulator-impl.cc:200
#9 0x00007ffff7347378 in ns3::Simulator::Run () at ../src/core/model/simulator.cc:204
#10 0x000000000041016e in main (argc=1, argv=0x7fffffffdc98) at ../myscripts/ns-3-dce-quagga/example/dce-quagga-isisd.cc:214
(gdb)
3 发送到对端
Breakpoint 1, ns3::PointToPointNetDevice::SendLL (this=0x66ead0, packet=..., dest=..., protocolNumber=254) at ../src/point-to-point/model/point-to-point-net-device.cc:707 707 NS_LOG_FUNCTION (this << packet << dest << protocolNumber); (gdb) c Continuing.
4 指定对端所调用的Receive,
5 对端收到并NotifyRecv
6 对端放入Queue中
Breakpoint 3, ns3::PacketDgramSocket::ForwardUp (this=0x7fffe402e9c0, device=..., packet=..., protocol=254, from=..., to=..., packetType=0) at ../src/network/utils/packet-dgram-socket.cc:413 413 NotifyDataRecv (); (gdb) bt #0 ns3::PacketDgramSocket::ForwardUp (this=0x7fffe402e9c0, device=..., packet=..., protocol=254, from=..., to=..., packetType=0) at ../src/network/utils/packet-dgram-socket.cc:413 #1 0x00007ffff62ddec3 in ns3::MemPtrCallbackImpl<ns3::PacketDgramSocket*, void (ns3::PacketDgramSocket::*)(ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet const>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType), void, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet const>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty>::operator() (this=0x7fffe402e670, a1=..., a2=..., a3=254, a4=..., a5=..., a6=0) at ./ns3/callback.h:464 #2 0x00007ffff6245efb in ns3::Callback<void, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet const>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty>::operator() (this=0x7fffe402ec50, a1=..., a2=..., a3=254, a4=..., a5=..., a6=0) at ./ns3/callback.h:1149 #3 0x00007ffff6243691 in ns3::Node::ReceiveFromDevice (this=0x6607f0, device=..., packet=..., protocol=254, from=..., to=..., packetType=0, promiscuous=false) at ../src/network/model/node.cc:317 #4 0x00007ffff6242e80 in ns3::Node::NonPromiscReceiveFromDevice (this=0x6607f0, device=..., packet=..., protocol=254, from=...) at ../src/network/model/node.cc:290 #5 0x00007ffff624bc80 in ns3::MemPtrCallbackImpl<ns3::Node*, bool (ns3::Node::*)(ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet const>, unsigned short, ns3::Address const&), bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet const>, unsigned short, ns3::Address const&, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator() ( this=0x66e730, a1=..., a2=..., a3=254, a4=...) at ./ns3/callback.h:441 #6 0x00007ffff6d48c4e in ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet const>, unsigned short, ns3::Address const&, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator() (this=0x66e998, a1=..., a2=..., a3=254, a4=...) at ./ns3/callback.h:1126 #7 0x00007ffff5c0efd8 in ns3::PointToPointNetDevice::ReceiveLL (this=0x66e870, packet=...) at ../src/point-to-point/model/point-to-point-net-device.cc:519 #8 0x00007ffff5c1fe2a in ns3::EventImpl* ns3::MakeEvent<void (ns3::PointToPointNetDevice::*)(ns3::Ptr<ns3::Packet>), ns3::Ptr<ns3::PointToPointNetDevice>, ns3::Ptr<ns3::Packet> >(void (ns3::PointToPointNetDevice::*)(ns3::Ptr<ns3::Packet>), ns3::Ptr<ns3::PointToPointNetDevice>, ns3::Ptr<ns3::Packet>)::EventMemberImpl1::Notify() (this=0x671370) at ./ns3/make-event.h:353 #9 0x00007ffff73465e7 in ns3::EventImpl::Invoke (this=0x671370) at ../src/core/model/event-impl.cc:51 #10 0x00007ffff734b2ac in ns3::DefaultSimulatorImpl::ProcessOneEvent (this=0x660910) at ../src/core/model/default-simulator-impl.cc:147 #11 0x00007ffff734b638 in ns3::DefaultSimulatorImpl::Run (this=0x660910) at ../src/core/model/default-simulator-impl.cc:200 #12 0x00007ffff7347378 in ns3::Simulator::Run () at ../src/core/model/simulator.cc:204 #13 0x000000000041016e in main (argc=1, argv=0x7fffffffdc98) at ../myscripts/ns-3-dce-quagga/example/dce-quagga-isisd.cc:214 (gdb)
B:
1 对端(B)recvfrom
(gdb) bt #0 dce_recvfrom (fd=8, buf=0x7ffff41d8008, len=1500, flags=0, from=0x7ffff4262b20, fromlen=0x7ffff4262b38) at ../model/dce-fd.cc:492 #1 0x00007ffff5471ae1 in recvfrom () at ../model/libc-ns3.h:192 #2 0x00007ffff4300647 in stream_recvfrom (s=0x7ffff41d9818, fd=8, size=1500, flags=0, from=0x7ffff4262b20, fromlen=0x7ffff4262b38) at stream.c:786 #3 0x00007ffff42e01d8 in isis_recv_pdu_p2p (circuit=0x7ffff41f08c8, ssnpa=0x7ffff4262b60 "\200+&\364\377\177") at isis_pfpacket.c:284 #4 0x00007ffff42ce57a in isis_receive (thread=0x7ffff4262cc0) at isis_pdu.c:1792 #5 0x00007ffff42f24ef in thread_call (thread=0x7ffff4262cc0) at thread.c:1177 #6 0x00007ffff42bda3d in main (argc=5, argv=0x668180, envp=0x6456a0) at isis_main.c:353 #7 0x00007ffff7a06fef in ns3::DceManager::DoStartProcess (context=0x677210) at ../model/dce-manager.cc:283 #8 0x00007ffff7a902ec in ns3::TaskManager::Trampoline (context=0x670cc0) at ../model/task-manager.cc:274 #9 0x00007ffff7a8c2c7 in ns3::PthreadFiberManager::Run (arg=0x678fc0) at ../model/pthread-fiber-manager.cc:402 #10 0x000000318b2079d1 in start_thread () from /lib64/libpthread.so.0 #11 0x000000318a6e88fd in clone () from /lib64/libc.so.6 (gdb)
Breakpoint 7, ns3::PacketDgramSocket::RecvFrom (this=0x7fffdc008200, maxSize=1500, flags=0, fromAddress=...) at ../src/network/utils/packet-dgram-socket.cc:466 466 NS_LOG_FUNCTION (this << maxSize << flags << fromAddress); (gdb) bt #0 ns3::PacketDgramSocket::RecvFrom (this=0x7fffdc008200, maxSize=1500, flags=0, fromAddress=...) at ../src/network/utils/packet-dgram-socket.cc:466 #1 0x00007ffff7a4a677 in ns3::UnixDatagramSocketFd::DoRecvmsg (this=0x7fffdc0083e0, msg=0x7ffff4262830, flags=0) at ../model/unix-datagram-socket-fd.cc:187 #2 0x00007ffff7a419a4 in ns3::UnixSocketFd::Recvmsg (this=0x7fffdc0083e0, msg=0x7ffff4262830, flags=0) at ../model/unix-socket-fd.cc:227 #3 0x00007ffff7a5e5ee in dce_recvmsg (fd=8, msg=0x7ffff4262830, flags=0) at ../model/dce-fd.cc:513 #4 0x00007ffff7a5e2c9 in dce_recvfrom (fd=8, buf=0x7ffff41d8008, len=1500, flags=0, from=0x7ffff4262b20, fromlen=0x7ffff4262b38) at ../model/dce-fd.cc:503 #5 0x00007ffff5471ae1 in recvfrom () at ../model/libc-ns3.h:192 #6 0x00007ffff4300647 in stream_recvfrom (s=0x7ffff41d9818, fd=8, size=1500, flags=0, from=0x7ffff4262b20, fromlen=0x7ffff4262b38) at stream.c:786 #7 0x00007ffff42e01d8 in isis_recv_pdu_p2p (circuit=0x7ffff41f08c8, ssnpa=0x7ffff4262b60 "\200+&\364\377\177") at isis_pfpacket.c:284 #8 0x00007ffff42ce57a in isis_receive (thread=0x7ffff4262cc0) at isis_pdu.c:1792 #9 0x00007ffff42f24ef in thread_call (thread=0x7ffff4262cc0) at thread.c:1177 #10 0x00007ffff42bda3d in main (argc=5, argv=0x668180, envp=0x6456a0) at isis_main.c:353 #11 0x00007ffff7a06fef in ns3::DceManager::DoStartProcess (context=0x677210) at ../model/dce-manager.cc:283 #12 0x00007ffff7a902ec in ns3::TaskManager::Trampoline (context=0x670cc0) at ../model/task-manager.cc:274 #13 0x00007ffff7a8c2c7 in ns3::PthreadFiberManager::Run (arg=0x678fc0) at ../model/pthread-fiber-manager.cc:402 #14 0x000000318b2079d1 in start_thread () from /lib64/libpthread.so.0 #15 0x000000318a6e88fd in clone () from /lib64/libc.so.6 (gdb)
参考上面堆栈
4 读queue,
5 处理读到的报文,业务处理