DCE: my simple application using libpcap fails, and cannot find why

125 views
Skip to first unread message

Byoungheon Shin

unread,
Dec 1, 2016, 2:25:11 AM12/1/16
to ns-3-users
Hello,
I am testing a custom C application using libpcap which is super simple.
When I create a node and just asks one node to run this "testpcap" application, the simulation fails with SIGUSR1

[testpcap.c]
#include <stdio.h>
#include <pcap.h>

pcap_t
*handle;

int main(int argc, char *argv[])
{
 
char *dev, errbuf[PCAP_ERRBUF_SIZE];

 dev
= "sim0"; // i saw "ip route" uses the interface name like this.

 handle
= pcap_open_live(dev, BUFSIZ, 1, 1000, errbuf);
 
if (handle == NULL) {
   fprintf
(stderr, "Couldn't open device %s: %s\n", dev, errbuf);
   
return(2);
 
}

 
return(0);
}


Here I attach the result of running the simulation with gdb.
$ ./waf --run dce-bhshin-test --command-template="gdb --args %s"
Waf: Entering directory `/home/cdsn/repos/dce/source/ns-3-dce/build'

--------------------------------------------------------------------
 Python bindings compilation
--------------------------------------------------------------------
[ 10/375] lib/pkgconfig/libns3-dev-netlink-debug.pc:  -> build/lib/pkgconfig/libns3-dev-netlink-debug.pc
[116/375] lib/pkgconfig/libns3-dev-dce-debug.pc:  -> build/lib/pkgconfig/libns3-dev-dce-debug.pc
Waf: Leaving directory `
/home/cdsn/repos/dce/source/ns-3-dce/build'
'
build' finished successfully (0.351s)
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/cdsn/repos/dce/source/ns-3-dce/build/myscripts/bhshin-test/bin/dce-bhshin-test...done.
(gdb) run
Starting program: /home/cdsn/repos/dce/source/ns-3-dce/build/myscripts/bhshin-test/bin/dce-bhshin-test

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGUSR1, User defined signal 1.
0x00007fffedec31fb in raise (sig=10) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:37
37 ../nptl/sysdeps/unix/sysv/linux/pt-raise.c: No such file or directory.
(gdb)
(gdb) list
32 in ../nptl/sysdeps/unix/sysv/linux/pt-raise.c
(gdb)


I have no idea how to solve this.
I found that someone previously tested a DCE application using libpcap, but I could't find a proper example code.

Can anyone help me?
Or is there any example code which opens and captures libpcap inside the DCE node?

Best Regards,

Byoungheon Shin

Byoungheon Shin

unread,
Dec 1, 2016, 2:28:43 AM12/1/16
to ns-3-users
I forgot adding backtrace.

(gdb) continue
Continuing.

Program received signal SIGUSR1, User defined signal 1.
0x00007fffedec31fb in raise (sig=10) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:37
37 in ../nptl/sysdeps/unix/sysv/linux/pt-raise.c
(gdb) backtrace
#0  0x00007fffedec31fb in raise (sig=10) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:37
#1  0x00007ffff7abeff7 in ns3::StackTrampoline::StackTrampoline (this=0x691da0) at ../model/pthread-fiber-manager.cc:143
#2  0x00007ffff7abca17 in ns3::PthreadFiberManager::PthreadFiberManager (this=0x6e5b40) at ../model/pthread-fiber-manager.cc:244
#3  0x00007ffff7ac4e23 in ns3::TaskManager::SetFiberManagerType (this=0x6919f0, type=ns3::TaskManager::PTHREAD_FIBER_MANAGER) at ../model/task-manager.cc:509
#4  0x00007ffff7ac6bc9 in ns3::Ptr<ns3::AttributeAccessor const> ns3::DoMakeAccessorHelperOne<ns3::EnumValue, ns3::TaskManager, ns3::TaskManager::FiberManagerType>(void (ns3::TaskManager::*)(ns3::TaskManager::FiberManagerType))::MemberMethod::DoSet(ns3::TaskManager*, ns3::EnumValue const*) const (this=0x6bb1b0, object=0x6919f0, v=0x6ee810)
    at /home/cdsn/repos/dce/build/include/ns3.26/ns3/attribute-accessor-helper.h:384
#5  0x00007ffff7ac75e9 in ns3::AccessorHelper<ns3::TaskManager, ns3::EnumValue>::Set (this=0x6bb1b0, object=0x6919f0, val=...)
    at /home/cdsn/repos/dce/build/include/ns3.26/ns3/attribute-accessor-helper.h:188
#6  0x00007ffff7393987 in ns3::ObjectBase::DoSet (this=0x6919f0, accessor=..., checker=..., value=...) at ../src/core/model/object-base.cc:186
#7  0x00007ffff739317f in ns3::ObjectBase::ConstructSelf (this=0x6919f0, attributes=...) at ../src/core/model/object-base.cc:165
#8  0x00007ffff73975b9 in ns3::Object::Construct (this=0x6919f0, attributes=...) at ../src/core/model/object.cc:145
#9  0x00007ffff73e3751 in ns3::ObjectFactory::Create (this=0x7fffffffd9a0) at ../src/core/model/object-factory.cc:103
#10 0x00007ffff7b3123a in ns3::ObjectFactory::Create<ns3::TaskManager> (this=0x7fffffffd9a0) at /home/cdsn/repos/dce/build/include/ns3.26/ns3/object-factory.h:200
#11 0x00007ffff7b2fe70 in ns3::DceManagerHelper::Install (this=0x7fffffffd950, node=...) at ../helper/dce-manager-helper.cc:112
#12 0x00007ffff7b2fdba in ns3::DceManagerHelper::Install (this=0x7fffffffd950, nodes=...) at ../helper/dce-manager-helper.cc:104
#13 0x000000000040cead in main (argc=1, argv=0x7fffffffe108) at ../myscripts/bhshin-test/dce-bhshin-test.cc:114
(gdb) 



2016년 12월 1일 목요일 오후 4시 25분 11초 UTC+9, Byoungheon Shin 님의 말:

Matt Anonyme

unread,
Dec 1, 2016, 9:58:24 AM12/1/16
to ns-3-users
It's a signal launched by DCE, maybe to signal a change of running processus, you can safely ignore it via launching the ocmmand in utils/gdbinit :)
https://www.gnu.org/software/libc/manual/html_node/Miscellaneous-Signals.html

Cheers

Andreas Pantelopoulos

unread,
Jun 17, 2017, 11:44:42 AM6/17/17
to ns-3-users
Hello there,

I managed to run libpcap with DCE binaries. 

Make sure you use a newer kernel (use the latest from net-next-nuse), clone libpcap from source and disable the ring mapping via adding the line #undef HAVE_PACKET_RING in pcap-linux.c

Of course, I can not guarantee that it will work, for me worked just fine. 

Andreas
Reply all
Reply to author
Forward
0 new messages