signetlabdei / quic-ns-3

QUIC implementation for ns-3
GNU General Public License v2.0
44 stars 17 forks source link

Error: Assert socketFactory != 0 during runtime. #12

Closed tnull closed 4 years ago

tnull commented 4 years ago

Hello,

I'm trying to get the QUIC implementation working in an application of mine. For that I try to create a QUIC socket:

ns3::TypeId tid = ns3::TypeId::LookupByName ("ns3::QuicSocketFactory");

m_socket = ns3::Socket::CreateSocket (GetNode (), tid);

While this code builds fine for me, ns-3 crashes during runtime, giving the error:

assert failed. cond="socketFactory != 0", +0.000000000s -1 file=../../src/network/model/socket.cc, line=77
libc++abi.dylib: terminating

It seems, that curiously, the QuicSocketFactory is not found during runtime. I tried this on ns-3.32 and ns-3-dev running on macOS, and with the quic version living in contrib (as described in the ns-3 App Store), as well as cloning it directly into source and modifying the wscript file (as described in the quic repository's README).

What am I missing/doing wrong?

You can replicate this by running the following MVE out of the scratch folder:

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/socket.h"
#include "ns3/quic-socket.h"
#include "ns3/quic-socket-factory.h"

int
main (int argc, char *argv[])
{
  ns3::NodeContainer nodes;
  nodes.Create (1);

  ns3::InternetStackHelper stack;
  stack.Install (nodes);

  ns3::Ptr<ns3::Node> node = nodes.Get(0);

  ns3::TypeId tid = ns3::TypeId::LookupByName ("ns3::QuicSocketFactory");

  ns3::Ptr<ns3::Socket> m_socket = 0;
  m_socket = ns3::Socket::CreateSocket (node, tid);

  ns3::Simulator::Run ();
  ns3::Simulator::Destroy ();
  return 0;
}
fedech commented 4 years ago

Hi,

the problem is in the stack installation: the QUIC stack is not installed on the nodes, as you're using the Internet module's stack. The following code executes correctly:

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/socket.h"
#include "ns3/quic-socket.h"
#include "ns3/quic-socket-factory.h"
#include "ns3/quic-helper.h"

int
main (int argc, char *argv[])
{
    ns3::NodeContainer nodes;
    nodes.Create (1);

    ns3::QuicHelper stack;
    stack.InstallQuic (nodes);

    ns3::Ptr<ns3::Node> node = nodes.Get(0);

    ns3::TypeId tid = ns3::TypeId::LookupByName ("ns3::QuicSocketFactory");

    ns3::Ptr<ns3::Socket> m_socket = 0;
    m_socket = ns3::Socket::CreateSocket (node, tid);

    ns3::Simulator::Run ();
    ns3::Simulator::Destroy ();
    return 0;
} 

The InstallQuic() module also calls Install(), so you will get the full internet stack along with the QUIC stack. Hope this solved your problem :)

tnull commented 4 years ago

Ah, thank you, that works! :)