Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/138.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用NS3和xFF0C提供的DSR模型;CAN‘;衍射信道中的T通信_C++_Adhoc_Ns 3 - Fatal编程技术网

C++ 使用NS3和xFF0C提供的DSR模型;CAN‘;衍射信道中的T通信

C++ 使用NS3和xFF0C提供的DSR模型;CAN‘;衍射信道中的T通信,c++,adhoc,ns-3,C++,Adhoc,Ns 3,将3组节点放在三个临时通道中,这些节点位于相同的IPV4网络中 这是问题所在: assert failed. cond="mainVector.front () == source", file=../src/dsr/model/dsr-options.cc, line=908 terminate called without an active exception 我真的很想知道你是如何在不同的渠道之间交流的 请帮我离开这里(╥﹏╥) 非常感谢 #include "ns3/core-mod

将3组节点放在三个临时通道中,这些节点位于相同的IPV4网络中

这是问题所在:

assert failed. cond="mainVector.front () == source", file=../src/dsr/model/dsr-options.cc, line=908
terminate called without an active exception
我真的很想知道你是如何在不同的渠道之间交流的 请帮我离开这里(╥﹏╥) 非常感谢

#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/netanim-module.h"
#include "ns3/olsr-module.h"
#include "ns3/dsr-module.h"
#include "ns3/dsdv-module.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample");
int
main (int argc, char *argv[])
{
  Time::SetResolution (Time::NS);
  bool verbose = true;
  uint32_t nWifi = 3; //设置 无线站点个数
  //bool tracing = false;
  CommandLine cmd;
  cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi);
  cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
  //用命令行修改参数
  cmd.Parse (argc,argv);

  if (nWifi > 250)
    {
      std::cout << "Too many wifi or csma nodes, no more than 250 each." << std::endl;
      return 1;
    }
  if (verbose)
    {
      LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_ALL);
      LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_ALL);
    }

  NodeContainer wifiStaNodes;
  wifiStaNodes.Create (nWifi);  //创建无线站点STA的节点
  NodeContainer wifiApNode;
  wifiApNode.Create(1);   //创建一个AP节点
//**************************
  NodeContainer wifiStaNodes2;
  wifiStaNodes2.Create (5);  //创建无线站点STA的节点
  NodeContainer wifiApNode2;
  wifiApNode2.Create(1);   //创建一个AP节点
//****************************

  //*************************************************
  NodeContainer nodeall;
  nodeall.Add(wifiStaNodes);
  nodeall.Add(wifiStaNodes2);
  nodeall.Add(wifiApNode);
  nodeall.Add(wifiApNode2);
  //*************************************************

  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();   //使用默认的信道模型
  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();  //使用默认的PHY模型
  phy.SetChannel (channel.Create ());  //创建通道对象并把他关联到物理层对象管理器
  WifiHelper wifi;
  wifi.SetRemoteStationManager ("ns3::AarfWifiManager");  //设置wifi助手用AARF速率控制算法
 //*******************************************************
    YansWifiChannelHelper channel1 = YansWifiChannelHelper::Default ();   //使用默认的信道模型
     YansWifiPhyHelper phy1 = YansWifiPhyHelper::Default ();  //使用默认的PHY模型
     phy1.SetChannel (channel1.Create ());  //创建通道对象并把他关联到物理层对象管理器
     wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
     NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
     wifiMac.SetType ("ns3::AdhocWifiMac");
     NodeContainer mixnode1;
     mixnode1.Add(wifiStaNodes);
     mixnode1.Add(wifiApNode);
     NetDeviceContainer devices = wifi.Install (phy1, wifiMac, mixnode1);
 //*******************************************************
     YansWifiChannelHelper channel3 = YansWifiChannelHelper::Default ();   //使用默认的信道模型
      YansWifiPhyHelper phy3 = YansWifiPhyHelper::Default ();  //使用默认的PHY模型
      phy3.SetChannel (channel3.Create ());  //创建通道对象并把他关联到物理层对象管理器
      NodeContainer wifiDAP;
      wifiDAP.Add(wifiApNode2);
      wifiDAP.Add(wifiApNode);
      wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
      NqosWifiMacHelper wifiMac3 = NqosWifiMacHelper::Default ();
      wifiMac3.SetType ("ns3::AdhocWifiMac");
      NetDeviceContainer devices3 = wifi.Install (phy3, wifiMac3, wifiDAP);
 //*******************************************************
      YansWifiChannelHelper channel4 = YansWifiChannelHelper::Default ();   //使用默认的信道模型
       YansWifiPhyHelper phy4 = YansWifiPhyHelper::Default ();  //使用默认的PHY模型
       phy4.SetChannel (channel4.Create ());  //创建通道对象并把他关联到物理层对象管理器
       wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
       NqosWifiMacHelper wifiMac4 = NqosWifiMacHelper::Default ();
       wifiMac4.SetType ("ns3::AdhocWifiMac");
       NodeContainer mixnode2;
       mixnode2.Add(wifiStaNodes2);
       mixnode2.Add(wifiApNode2);
       NetDeviceContainer devices4 = wifi.Install (phy4, wifiMac4, mixnode2);
//******************************************************

  // 加入移动模型,让STA可以移动,AP固定
  MobilityHelper mobility;
  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
                                 "MinX", DoubleValue (0.0),
                                 "MinY", DoubleValue (0.0),
                                 "DeltaX", DoubleValue (5.0),
                                 "DeltaY", DoubleValue (10.0),
                                 "GridWidth", UintegerValue (3),
                                 "LayoutType", StringValue ("RowFirst"));
  //设置初始时,节点的摆放位置
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",   //设置移动模式为"ns3::RandomWalk2dMobilityModel",随机移动
                             "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));   //移动范围
  mobility.Install (wifiStaNodes);
  //**********************************************
  mobility.Install (wifiStaNodes2);
  //**********************************************
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");  //设置AP的不能够移动的,"ns3::ConstantPositionMobilityModel"
  mobility.Install (wifiApNode);
  //**********************************************
  mobility.Install (wifiApNode2);
  //**********************************************
  //mobility.Install(nodeall);

  InternetStackHelper internet;
  DsrMainHelper dsrMain;
  DsrHelper dsr;
  internet.Install (nodeall);
  dsrMain.Install (dsr, nodeall);
/*
  InternetStackHelper stack;
  ns3::OlsrHelper Olsr;
  stack.SetRoutingHelper(Olsr);
  stack.Install(nodeall);
*/
   //********************************************************
  Ipv4AddressHelper address;
  address.SetBase ("198.1.2.0", "255.255.255.0");
  Ipv4InterfaceContainer wifiInterfaces3;
  wifiInterfaces3=address.Assign (devices3);
//*******************************************************
  address.SetBase ("198.1.0.0", "255.255.255.0");
  Ipv4InterfaceContainer mixInterfaces;
    mixInterfaces=address.Assign (devices);
 //********************************************************
    address.SetBase ("198.2.0.0", "255.255.255.0");
    Ipv4InterfaceContainer mixInterfaces4;
      mixInterfaces4=address.Assign (devices4);

      std::cout<<"mi "<<mixInterfaces4.GetAddress(5)<<std::endl;
 //********************************************************
  //安装UDP程序,使用UDP,与之前的UDP的使用方法一致
  UdpEchoServerHelper echoServer (9);
  ApplicationContainer serverApps = echoServer.Install (wifiStaNodes2.Get (0));//wifiApNode2
  serverApps.Start (Seconds (1.0));
  serverApps.Stop (Seconds (40.0));
  UdpEchoClientHelper echoClient (mixInterfaces4.GetAddress (0), 9);
  echoClient.SetAttribute ("MaxPackets", UintegerValue (10000));
  echoClient.SetAttribute ("Interval", TimeValue (Seconds(1 / ((double) 20))));
  echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
  ApplicationContainer clientApps =
    echoClient.Install (wifiStaNodes2.Get (1));
  clientApps.Start (Seconds (2.0));
  clientApps.Stop (Seconds (40.0));

  //Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
  phy4.EnablePcap("AAA",wifiStaNodes2);
  Simulator::Stop (Seconds (41.0));
  AnimationInterface anim("amix.xml");
  Simulator::Run ();
  Simulator::Destroy ();
  return 0;
}
#包括“ns3/core module.h”
#包括“ns3/点对点模块.h”
#包括“ns3/网络模块.h”
#包括“ns3/applications module.h”
#包括“ns3/wifi模块.h”
#包括“ns3/mobility module.h”
#包括“ns3/csma模块.h”
#包括“ns3/internet模块.h”
#包括“ns3/netanim模块.h”
#包括“ns3/olsr模块.h”
#包括“ns3/dsr模块.h”
#包括“ns3/dsdv模块.h”
使用名称空间ns3;
NS_LOG_COMPONENT_DEFINE(“ThirdScriptExample”);
int
main(int argc,char*argv[])
{
时间::设置分辨率(时间::NS);
bool verbose=true;
uint32_t nWifi=3//设置 无线站点个数
//布尔跟踪=假;
命令行命令;
cmd.AddValue(“nWifi”,“wifi STA设备数量”,nWifi);
cmd.AddValue(“verbose”,“如果为true,则告诉echo应用程序记录”,verbose);
//用命令行修改参数
cmd.Parse(argc,argv);
如果(nWifi>250)
{

这个问题已经搁置很久了,没有人愿意帮助我,可能是因为我的问题太简单了

通过解释DSR源文件代码可以了解此问题。NS3提供的DSR模块根本无法提供跨网关功能,并且DSR在实现过程中不支持一个节点的多个接口。如果您这样做,可能是因为您设置了接口的顺序,从而导致程序失败报告错误

解决方案:

  • 首先,我记录了dsr_路由中每个节点的接口 文件,然后每个接口处理
    rreq
    的转发,因此
    rreq
    消息被转发出网关

  • 当目标节点收到
    rreq
    消息时,它将 回复.Rrep消息时,还需要注意 nodelist是路由路径地址,但仅表示接口 一个节点,所以您还需要定义一个全局映射

    此映射将记录接口对应的节点

  • 具体的想法上面已经提到了,当然很多细节都没有提到。如果你想了解细节,可以联系我