NS3 C ++ UdpEchoClientApplication错误

时间:2015-04-21 20:15:17

标签: java c++ ns-3

我目前有9个节点,我想要其中两个作为服务器。这是我目前的代码:

Applicationcontainer serverApps =echoServer.Install (nodes.Get (3), nodes.Get (4));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));

当我尝试编译它时,它会给我错误

Build failed
-> task in 'harry24' failed (exit status 1): 
{task 48837520: cxx harry24.cc -> harry24.cc.5.o}
['/usr/bin/g++', '-O0', '-ggdb', '-g3', '-Wall', '-Werror', '-Wno-error=deprecated-declarations', '-fstrict-aliasing', '-Wstrict-aliasing', '-pthread', '-pthread', '-I.', '-I..', '-I/usr/include/gtk-2.0', '-I/usr/lib/x86_64-linux-gnu/gtk-2.0/include', '-I/usr/include/atk-1.0', '-I/usr/include/cairo', '-I/usr/include/gdk-pixbuf-2.0', '-I/usr/include/pango-1.0', '-I/usr/include/gio-unix-2.0', '-I/usr/include/glib-2.0', '-I/usr/lib/x86_64-linux-gnu/glib-2.0/include', '-I/usr/include/pixman-1', '-I/usr/include/freetype2', '-I/usr/include/libpng12', '-I/usr/include/libxml2', '-DNS3_ASSERT_ENABLE', '-DNS3_LOG_ENABLE', '-DHAVE_SYS_IOCTL_H=1', '-DHAVE_IF_NETS_H=1', '-DHAVE_NET_ETHERNET_H=1', '-DHAVE_PACKET_H=1', '-DHAVE_SQLITE3=1', '-DHAVE_IF_TUN_H=1', '-DHAVE_GSL=1', '../scratch/harry24.cc', '-c', '-o', 'scratch/harry24.cc.5.o']

1 个答案:

答案 0 :(得分:1)

您应将这两个节点放在NodeContainer内,然后在容器上调用echoServer.install

NodeContainer nc;
nc.Add(nodes.Get (3));
nc.Add(nodes.Get (4));

Applicationcontainer serverApps =echoServer.Install (nc);
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));

可用的安装方法在udp-echo-helper.h中重载。

   /**
   * Create a UdpEchoServerApplication on the specified Node.
   *
   * \param node The node on which to create the Application.  The node is
   *             specified by a Ptr<Node>.
   *
   * \returns An ApplicationContainer holding the Application created,
   */
  ApplicationContainer Install (Ptr<Node> node) const;

  /**
   * Create a UdpEchoServerApplication on specified node
   *
   * \param nodeName The node on which to create the application.  The node
   *                 is specified by a node name previously registered with
   *                 the Object Name Service.
   *
   * \returns An ApplicationContainer holding the Application created.
   */
  ApplicationContainer Install (std::string nodeName) const;

  /**
   * \param c The nodes on which to create the Applications.  The nodes
   *          are specified by a NodeContainer.
   *
   * Create one udp echo server application on each of the Nodes in the
   * NodeContainer.
   *
   * \returns The applications created, one Application per Node in the 
   *          NodeContainer.
   */
  ApplicationContainer Install (NodeContainer c) const;