The callback function path cannot be connected

146 views
Skip to first unread message

王小胜

unread,
Dec 8, 2024, 10:34:17 AM12/8/24
to ns-3-users
微信图片_20241208232737.png
I'm trying to build the LTE PDCP layer callback and the following error is reported, I'm a newbie ns3, I don't know where the error is, and my source code is below, can you help me take a look?

#include <string>
#include "ns3/lte-helper.h"
#include "ns3/epc-helper.h"
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/internet-module.h"
#include "ns3/mobility-module.h"
#include "ns3/lte-module.h"
#include "ns3/applications-module.h"
#include "ns3/point-to-point-helper.h"
#include "ns3/config-store.h"
#include "ns3/netanim-module.h"
#include "ns3/wifi-module.h"
//#include "ns3/gtk-config-store.h"
#include "/data/user/wangtengsheng/ns3/ns3_wifi/ns3-mmwave-5.0/src/lte/model/lwa-tag.h"
#include "/data/user/wangtengsheng/ns3/ns3_wifi/ns3-mmwave-5.0/src/lte/model/pdcp-lcid.h"
#include "/data/user/wangtengsheng/ns3/ns3_wifi/ns3-mmwave-5.0/src/lte/model/lwalwip-header.h"
using namespace ns3;
std::map<uint16_t, Ptr<Socket>> lwaSocketMap;
std::map<std::string, Ptr<Socket>> contextSocketMap;
// function for lwa/lwip packet handling transmitted through the LtePdcp::DoTransmitPdcpSdu
void LtePdcpLwaHandler (LteRlcSapProvider::TransmitPdcpPduParameters params){

  //NS_LOG_DEBUG("rnti : " << params.rnti);

  // copy incoming packet
  Ptr<Packet> currentPacket = params.pdcpPdu->Copy();

  // remove headers to get sequence number and include lwa/lwip header
  //wifi接收到的数据包
  LtePdcpHeader pdcpHeader;
  currentPacket->RemoveHeader (pdcpHeader);
  Ipv4Header ipHeader;
  currentPacket->RemoveHeader (ipHeader);
  TcpHeader tcpHeader;
  currentPacket->RemoveHeader (tcpHeader);

  // add headers again
  currentPacket->AddHeader (tcpHeader);
  currentPacket->AddHeader (ipHeader);
  currentPacket->AddHeader (pdcpHeader);

  // read lwa tags added by pdcp layer and add lwa information
  // as separate header to data packets (won't be removed when transmitting
  // packets via API)
  LwaTag   lwaTag;
  PdcpLcid lcidTag;
  uint32_t lcid=0;
  uint32_t bid=0;
  LwaLwipHeader lwaLwipHeader;

  // tag to copy the logical channel id of the frame
  if(currentPacket->FindFirstMatchingByteTag (lcidTag)){
      lcid = lcidTag.Get();
      bid = lcid - 2;
  }
  lwaLwipHeader.SetBearerId (bid);

  // packet handling for lwa packets
  if (currentPacket->PeekPacketTag(lwaTag)){
      //copy the status of LWA activation (LTE, Split, swtiched)
      lwaLwipHeader.SetLwaActivate (lwaTag.Get());
      // add lwa lwip header
      currentPacket->AddHeader (lwaLwipHeader);
      lwaSocketMap.find(params.rnti)->second->Send(currentPacket);
  //NS_LOG_DEBUG ("LWA: Sent packet with PDCP Sequence Number " << pdcpHeader.GetSequenceNumber());
  }
}
// assign callback function to the pdcp object
// NOTE: object is created after bearer release which is after attach procedure
static void
Callback_LtePDCPTX
(uint16_t rnti){
std::string rntiPath = "/NodeList/*/DeviceList/*/$ns3::LteNetDevice/$ns3::LteEnbNetDevice/LteEnbRrc/UeMap/" + std::to_string(rnti) + "/DataRadioBearerMap/*/LtePdcp/TxPDUtrace";
  Config::ConnectWithoutContext (rntiPath, MakeCallback (&LtePdcpLwaHandler));
}

  void NotifyConnectionEstablishedUe (
              std::string context,
                        uint64_t imsi,
                        uint16_t cellId,
                        uint16_t rnti)
  {
    std::cout << Simulator::Now ().GetSeconds ()
              << " UE IMSI " << imsi
              << ": connected to CellId " << cellId
              << " with RNTI " << rnti
        << " context " << context
              << std::endl;
    // create socket on lwaap socket to enable transmission of lwa packets
  /*
            Ptr<Socket> lwaapTxSocket = Socket::CreateSocket (lwaapNode, tid);
            lwaapTxSocket->Bind ();
            lwaapTxSocket->Connect (InetSocketAddress (Ipv4Address::ConvertFrom(wifiIpInterfaces.GetAddress (i+1)), 9));
            lwaapTxSocket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ());
            lwaapTxSocket->SetAllowBroadcast (true);

            //TODO: temporary fix assuming rnti=i+1
            lwaSocketMap.insert(std::pair<uint16_t, Ptr<Socket>>(i+1, lwaapTxSocket));
        NS_LOG_INFO("STA Socket bound " << i+1);
  */
 
    lwaSocketMap.insert(std::pair<uint16_t, Ptr<Socket>>(rnti, contextSocketMap.find(context)->second));
    Simulator::Schedule(MilliSeconds(100), &Callback_LtePDCPTX, rnti);
  }


/**
 * Sample simulation script for LTE+EPC. It instantiates several eNodeB,
 * attaches one UE per eNodeB starts a flow for each UE to  and from a remote host.
 * It also  starts yet another flow between each UE pair.
 */

NS_LOG_COMPONENT_DEFINE ("EpcFirstExample");

int
main (int argc, char *argv[])
{
  uint16_t numberOfNodes = 1;
  Time simTime = MilliSeconds (11000);
  double distance = 40.0;
  Time interPacketInterval = MilliSeconds (10);
    // MTU size for P2P link between EnB and Wifi AP
  double xwLwaLinkMtuSize=1500;
  //delay of p2p link
  std::string xwLwaLinkDelay="0ms";
  //data rate of p2p link
  std::string xwLwaLinkDataRate="100Mbps";
  // Command line arguments
  CommandLine cmd;
  cmd.AddValue ("numberOfNodes", "Number of eNodeBs + UE pairs", numberOfNodes);
  cmd.AddValue ("simTime", "Total duration of the simulation", simTime);
  cmd.AddValue ("distance", "Distance between eNBs [m]", distance);
  cmd.AddValue ("interPacketInterval", "Inter packet interval", interPacketInterval);
  cmd.Parse(argc, argv);


  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
  Ptr<PointToPointEpcHelper>  epcHelper = CreateObject<PointToPointEpcHelper> ();
  lteHelper->SetEpcHelper (epcHelper);

  ConfigStore inputConfig;
  inputConfig.ConfigureDefaults();

  // parse again so you can override default values from the command line
  cmd.Parse(argc, argv);

  Ptr<Node> pgw = epcHelper->GetPgwNode ();
 
   // Create a single RemoteHost
  NodeContainer remoteHostContainer;
  remoteHostContainer.Create (1);
  Ptr<Node> remoteHost = remoteHostContainer.Get (0);
  InternetStackHelper internet;
  internet.Install (remoteHostContainer);

  // Create the Internet
  PointToPointHelper p2ph;
  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
  p2ph.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (10)));
  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
  Ipv4AddressHelper ipv4h;
  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
  // interface 0 is localhost, 1 is the p2p device
 // Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);

  Ipv4StaticRoutingHelper ipv4RoutingHelper;
  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);


 
    NodeContainer ueNodes, enbNodes, wifiApNodes, wifiStaNodes;
    enbNodes.Create(numberOfNodes);
    ueNodes.Create(numberOfNodes);
    wifiApNodes.Create(1);
    wifiStaNodes.Add(ueNodes); // LTE 用户设备同时作为 Wi-Fi STA


    // Configure Wi-Fi
    WifiHelper wifiHelper;
    YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();
    YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
    wifiPhy.SetChannel(wifiChannel.Create());

    WifiMacHelper wifiMac;
    Ssid ssid = Ssid("LteWifiNetwork");

    wifiMac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
    NetDeviceContainer wifiApDevs = wifiHelper.Install(wifiPhy, wifiMac, wifiApNodes);

    wifiMac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
   NetDeviceContainer wifiStaDevs = wifiHelper.Install(wifiPhy, wifiMac, wifiStaNodes);

 
  // start call back 100ms before datageneration
  // uint32_t callbackStartMs = uint32_t (3 * 1000 - 100);
  // Simulator::Schedule (MilliSeconds(callbackStartMs),&Callback_LtePDCPTX);
  // Install Mobility Model
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
    // 分配 eNB 和 UE 的位置,距离不超过 30
    for (uint16_t i = 0; i < numberOfNodes; i++)
    {
        positionAlloc->Add(Vector(10.0 * i+10, 10.0 * i, 0.0)); // eNB 位置
        positionAlloc->Add(Vector(10.0 * i, 10.0 * i + 10.0, 0.0)); // 对应 UE 位置
        positionAlloc->Add(Vector(10.0 * i+40, 10.0 * i+10, 0.0)); // remoteHost 位置
        positionAlloc->Add(Vector(10.0 * i+10, 10.0 * i+20, 0.0)); // wifiAp 位置
       

    }
  MobilityHelper mobility;
  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
  mobility.SetPositionAllocator(positionAlloc);
  mobility.Install(enbNodes);
  mobility.Install(ueNodes);
  mobility.Install(remoteHostContainer);
  mobility.Install(wifiApNodes);

  // Install LTE Devices to the nodes
  NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNodes);
  NetDeviceContainer ueLteDevs = lteHelper->InstallUeDevice (ueNodes);

  // Install the IP stack on the UEs
  internet.Install (ueNodes);
   internet.Install(wifiApNodes);
  Ipv4InterfaceContainer ueIpIface;
  ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteDevs));
  // Assign IP address to UEs, and install applications
  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
    {
      Ptr<Node> ueNode = ueNodes.Get (u);
      // Set the default gateway for the UE
      Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
      ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
      // ueStaticRouting->AddNetworkRouteTo(Ipv4Address("192.168.1.0"),Ipv4Mask("255.255.255.0"),)
    }


 // Assign IP addresses for Wi-Fi
    ipv4h.SetBase("192.168.1.0", "255.255.255.0");
  // Ipv4InterfaceContainer wifiApInterfaces = ipv4h.Assign(wifiApDevs);
  // Ipv4InterfaceContainer wifiStaInterfaces = ipv4h.Assign(wifiStaDevs);
  Ipv4InterfaceContainer wifiIpInterfaces;
                         wifiIpInterfaces.Add (ipv4h.Assign (wifiApDevs));
                         wifiIpInterfaces.Add (ipv4h.Assign (wifiStaDevs));
    // Configure Applications
    // create p2p helper for LWA/Xw link
  PointToPointHelper p2pHelpXw;
                     p2pHelpXw.SetDeviceAttribute ("DataRate", StringValue (xwLwaLinkDataRate));
                     p2pHelpXw.SetChannelAttribute ("Delay", StringValue (xwLwaLinkDelay));
                     p2pHelpXw.SetDeviceAttribute ("Mtu", UintegerValue (xwLwaLinkMtuSize));

  // create lwaap node
  // NodeContainer lwaNode;
  Ptr<Node> lwaapNode = CreateObject<Node> ();
  // lwaNode.Add(lwaapNode);
  Names::Add("LWAAP", lwaapNode);
  // install p2p net devices to create parallel lwa and lwip links
  NetDeviceContainer xwLwaDevices  = p2pHelpXw.Install (lwaapNode, wifiApNodes.Get(0));
  xwLwaDevices.Add(p2pHelpXw.Install (lwaapNode, wifiApNodes.Get(0)));

  // install ip stack on additional nodes
  internet.Install(lwaapNode);

  // assign ip adresses to lwa / lwip links
  Ipv4AddressHelper XwAddress;
  XwAddress.SetBase ("20.1.2.0", "255.255.255.0");
  Ipv4InterfaceContainer xwLwaIpInterfaces = XwAddress.Assign (xwLwaDevices);
  Ptr<ListPositionAllocator> positionAlloclwa = CreateObject<ListPositionAllocator> ();
  mobility.SetPositionAllocator(positionAlloclwa);
  positionAlloclwa->Add(Vector(10.0 +10, 15, 0.0)); // lwa 位置
  MobilityHelper Lwamobility;
  Lwamobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
  mobility.SetPositionAllocator(positionAlloclwa);
  mobility.Install(lwaapNode);

    // Attach one UE per eNodeB
  for (uint16_t i = 0; i < numberOfNodes; i++)
    {
      lteHelper->Attach (ueLteDevs.Get(i), enbLteDevs.Get(i));
      // side effect: the default EPS bearer will be activated
      Ptr<LteUeNetDevice> ueDev = ueLteDevs.Get(i)->GetObject<LteUeNetDevice> ();
      Ptr<LteUeRrc> ueRrc = ueDev->GetRrc ();
       
      ueRrc->TraceConnect("ConnectionEstablished", std::to_string(i), MakeCallback(&NotifyConnectionEstablishedUe));

      //创建UDP套接字
      TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
      Ptr<Socket> lwaapTxSocket = Socket::CreateSocket (lwaapNode, tid);
      lwaapTxSocket->Bind ();
      lwaapTxSocket->Connect (InetSocketAddress (Ipv4Address::ConvertFrom(wifiIpInterfaces.GetAddress (i+1)), 9));
      lwaapTxSocket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ());
      lwaapTxSocket->SetAllowBroadcast (true);

      //TODO: temporary fix assuming rnti=i+1
      contextSocketMap.insert(std::pair<std::string, Ptr<Socket>>(std::to_string(i+1), lwaapTxSocket));
     
      //创建接收wifiSta->UE套接字
      Ptr<Socket> staRxSocket = Socket::CreateSocket (ueNodes.Get(i), tid);
      staRxSocket->Bind (InetSocketAddress (Ipv4Address::GetAny(), 9));
      ueRrc->m_staRxSocket = staRxSocket;
    }


  // Install and start applications on UEs and remote host
  uint16_t dlPort = 1100;
  ApplicationContainer clientApps;
  ApplicationContainer serverApps;
  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
    {
     
          PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
          serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get(u)));

          UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort);
          dlClient.SetAttribute ("Interval", TimeValue (interPacketInterval));
          dlClient.SetAttribute ("MaxPackets", UintegerValue (1000000));
          clientApps.Add (dlClient.Install (remoteHost));
    }

  serverApps.Start (Seconds (1));
  clientApps.Start (Seconds (10));
    AnimationInterface anim("lte-wifi-distribution.xml");

    anim.UpdateNodeDescription(remoteHost, "RemoteHost");
    anim.UpdateNodeColor(remoteHost, 0, 0, 255);
    anim.UpdateNodeDescription(pgw, "PGW");
    anim.UpdateNodeColor(pgw, 0, 0, 255);
    anim.UpdateNodeDescription(lwaapNode, "LWAAP");
    anim.UpdateNodeColor(lwaapNode, 0, 0, 255);
    for (uint32_t i = 0; i < wifiApNodes.GetN(); ++i)
    {
        anim.UpdateNodeDescription(wifiApNodes.Get(i), "WiFi-AP");
        anim.UpdateNodeColor(wifiApNodes.Get(i), 255, 0, 0);
    }

    for (uint32_t i = 0; i < enbNodes.GetN(); ++i)
    {
        anim.UpdateNodeDescription(enbNodes.Get(i), "eNB");
        anim.UpdateNodeColor(enbNodes.Get(i), 0, 255, 0);
    }

    for (uint32_t i = 0; i < ueNodes.GetN(); ++i)
    {
        anim.UpdateNodeDescription(ueNodes.Get(i), "UE");
        anim.UpdateNodeColor(ueNodes.Get(i), 0, 255, 255);
    }
  //lteHelper->EnableTraces ();
  // Uncomment to enable PCAP tracing
  //p2ph.EnablePcapAll("lena-simple-epc");

  Simulator::Stop (simTime);
  Simulator::Run ();

  /*GtkConfigStore config;
  config.ConfigureAttributes();*/

  Simulator::Destroy ();
  return 0;
}

Tommaso Pecorella

unread,
Dec 8, 2024, 11:51:02 AM12/8/24
to ns-3-users
On Sunday, 8 December 2024 at 16:34:17 UTC+1 wangxiao...@gmail.com wrote:
微信图片_20241208232737.png
I'm trying to build the LTE PDCP layer callback and the following error is reported, I'm a newbie ns3, I don't know where the error is, and my source code is below, can you help me take a look?

We could, if we'd knew where you downloaded your code from (the mmWave model is a contributed one).
Moreover, you did include haters as absolute paths, so to take a look at it we'd have also to modify your script.

Furthermore, the error is detailed in the lines after the error itself (i.e., you attached an incomplete screenshot), so we can't figure out the issue without the painful process to 1) figure out what you have, 2) recreate your setup, 3) fix your include paths.

Try attaching a more complete error message. 
As a side note, you can attach scripts as attachments to the message. It's far better than copy-pasting the code in the message, isn't it? 

Kent Huns

unread,
Dec 8, 2024, 12:20:25 PM12/8/24
to ns-3-users
I found this paper while checking whether "TxPDUtrace" is an already implemented path or your idea.
https://www.researchgate.net/publication/330357678_Implementation_of_the_3GPP_LTE-WLAN_Interworking_Protocols_in_NS-3

I won't ask how you got the source, but don't publish anything on the web that you didn't make yourself.
Or,  please explain a valid reason first if you have.

王小胜

unread,
Dec 8, 2024, 7:07:38 PM12/8/24
to ns-3-users
This one is indeed written by myself, and I'm trying to reproduce the paper.

王小胜

unread,
Dec 8, 2024, 7:11:42 PM12/8/24
to ns-3-users
msg="Could not connect callback to /NodeList/*/DeviceList/*/$ns3::LteNetDevice/$ns3::LteEnbNetDevice/LteEnbRrc/UeMap/1/DataRadioBearerMap/*/LtePdcp/TxPDUtrace", +0.121214285s 4 file=.. /src/core/model/config.cc, line=906
terminate called without an active exception
 This is the full error message. Please help me take a look, thank you very much.

Tommaso Pecorella

unread,
Dec 9, 2024, 3:04:36 AM12/9/24
to ns-3-users
The error message seems to be due to the path being wrong. In particular this seems suspicious: "$ns3::LteNetDevice/$ns3::LteEnbNetDevice"

Kent Huns

unread,
Dec 9, 2024, 5:26:35 AM12/9/24
to ns-3-users
>> I'm trying to reproduce the paper.
I deeply apologize for doubting you. I don't think your work is newbie's one.

Please check where you wrote ".AddTraceSource("TxPDUtrace"...)". If properly implemented, it should be in lte-pdcp.cc.
And below "TxPDU" & "RxPDU" are in the same directory.
If the callback path you wrote is correct, you should be able to call these too.

src/lte/model/lte-pdcp.cc
TypeId
LtePdcp::GetTypeId()
{
    static TypeId tid = TypeId("ns3::LtePdcp")
                            .SetParent<Object>()
                            .SetGroupName("Lte")
                            .AddTraceSource("TxPDU",
                                            "PDU transmission notified to the RLC.",
                                            MakeTraceSourceAccessor(&LtePdcp::m_txPdu),
                                            "ns3::LtePdcp::PduTxTracedCallback")
                            .AddTraceSource("RxPDU",
                                            "PDU received.",
                                            MakeTraceSourceAccessor(&LtePdcp::m_rxPdu),
                                            "ns3::LtePdcp::PduRxTracedCallback");
    return tid;
}

And this thread will be helpful. (There may be more difficulties than I imagine.)

Gabriel Ferreira

unread,
Dec 9, 2024, 1:24:46 PM12/9/24
to ns-3-users
Seems like a typo. The suffix "trace" isn't part of the path, just says this path is a trace source. So it was supposed to have a space.

Try again with
/NodeList/*/DeviceList/*/$ns3::LteNetDevice/$ns3::LteEnbNetDevice/LteEnbRrc/UeMap/1/DataRadioBearerMap/*/LtePdcp/TxPDU

instead of
/NodeList/*/DeviceList/*/$ns3::LteNetDevice/$ns3::LteEnbNetDevice/LteEnbRrc/UeMap/1/DataRadioBearerMap/*/LtePdcp/TxPDUtrace

王小胜

unread,
Dec 10, 2024, 2:27:56 AM12/10/24
to ns-3-users
I don't quite understand what you mean? Why is this problematic?

王小胜

unread,
Dec 10, 2024, 2:28:55 AM12/10/24
to ns-3-users
Never mind. But I've already defined the trace source.1.png

王小胜

unread,
Dec 10, 2024, 2:30:50 AM12/10/24
to ns-3-users
Not so, it's my custom trace source.

Gabriel Ferreira

unread,
Dec 10, 2024, 4:47:47 AM12/10/24
to ns-3-users
Hmm, good question then. Do the m_pdcptxtrace function have the same signature as your callback function?
If not, try to match them. Other than that, I don't see any possible issue.

王小胜

unread,
Dec 10, 2024, 6:47:25 AM12/10/24
to ns-3-users
This should not be the case, otherwise an error will be reported as incompatible, rather than the source cannot be found.

王小胜

unread,
Dec 12, 2024, 2:01:20 AM12/12/24
to ns-3-users
Sorry to bother again, can you give me some advice on this issue?

在2024年12月9日星期一 UTC+8 16:04:36<Tommaso Pecorella> 写道:
Reply all
Reply to author
Forward
Message has been deleted
0 new messages