Поместите 3 группы узлов в три adhoc канала, и эти узлы в одном IPV4 net
вот проблема :
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;
}