DhcpClient GetDhcpServer error

19 views
Skip to first unread message

Giovanna Garcia

unread,
Sep 25, 2018, 8:57:30 AM9/25/18
to ns-3-users
Hello,

I've tried to get the DHCP Server Ipv4Address when a node gets a new lease and I am getting the following error:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b9a242 in ns3::DhcpClient::GetDhcpServer (this=0x0) at ../src/internet-apps/model/dhcp-client.cc:137
137      return m_server;
(gdb)

I changed the DHCP-example.cc to simulate my problem, it is attached in the post.

Trying to identify the problem I have added some prints to the DHCP-client.cc file every time that the m_server attribute is used and I just got a problem when the method GetDhcpServer is called:

(gdb) r
Starting program: /home/garcia/nsnam_ns3/build/src/internet-apps/examples/ns3.29-dhcp-example-debug \<args\>
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Server 0.0.0.0
Server 0.0.0.0
Server 0.0.0.0
Server 172.30.0.12

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5b07185 in ns3::Ipv4Address::Print (this=0xa8, os=...) at ../src/network/utils/ipv4-address.cc:336
336      os << ((m_address >> 24) & 0xff) << "."
(gdb) bt
#0  0x00007ffff5b07185 in ns3::Ipv4Address::Print (this=0xa8, os=...) at ../src/network/utils/ipv4-address.cc:336
#1  0x00007ffff5b07ffb in ns3::operator<< (os=..., address=...) at ../src/network/utils/ipv4-address.cc:416
#2  0x00007ffff7b9a270 in ns3::DhcpClient::GetDhcpServer (this=0x0) at ../src/internet-apps/model/dhcp-client.cc:136
#3  0x00005555555671f1 in Teste::TracedCallbackNewLease (this=0x5555557a2eb0, ip=...) at ../src/internet-apps/examples/dhcp-example.cc:47
#4  0x000055555556c546 in ns3::MemPtrCallbackImpl<Teste*, void (Teste::*)(ns3::Ipv4Address const&), void, ns3::Ipv4Address const&, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator() (this=0x55555579e540, a1=...)
    at
./ns3/callback.h:612

I couldn't identify what is causing the error.
dhcp-example.cc

Giovanna Garcia

unread,
Sep 25, 2018, 9:56:39 AM9/25/18
to ns-3-users
I found the problem.
The structure that I used to get the Application from the node was wrong.
I used:

Ptr<DhcpClient> dhcp = m_node->GetObject<DhcpClient>();

But the correct:

Ptr<DhcpClient> dhcp = DynamicCast<DhcpClient>(GetNode()->GetApplication(m_idDHCP));


Reply all
Reply to author
Forward
0 new messages