NS-3例程注解与拓展

2023-11-06

准备

运行准备

要运行自己的脚本,只需把脚本放到scratch目录下,通过waf脚本就会被编译。

cp examples/tutorial/first.cc scratch/myfirst.cc

使用waf命令来编译自己的第一个实例脚本:

sudo ./waf

运行这个例子

sudo ./waf --run scratch/myfirst

本文均在代码中加入输出XMl文件相应的语句,从而利用NetAnim生成可视化的动画。

在这里插入代码片

概览

NS-3给出的例程在 XXX 目录中,其中first-third.cc均是关于构建网络拓扑结构的。
其中:

  • first 是 :点到点的网络模型(P + P)
  • second 是 :点到以太网的网络模型 (P + LAN )
  • third:是 :WIFI到以太网的网络模型 (WIFI + LAN)

最后我自己给出的网络则是:

  • myfourth.cc:是 :以太网到以太网的网络模型 ( LAN + LAN)

分析

first.cc

网络拓扑如下:
// Default Network Topology
//
//       10.1.1.0
// n0 -------------- n1  
//    point-to-point  
//                    
// 
源码分析:
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/netanim-module.h"


using namespace ns3;

// 定义一个日志组件
NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");

int
main (int argc, char *argv[])
{
  CommandLine cmd;
  cmd.Parse (argc, argv);
  
  //设置时间精度,只能设置一次,因为动态设置对内存需求大,
  //因此一旦设置,就会释放内存,如果不设置,使用默认值ns(纳秒)
  Time::SetResolution (Time::NS);
  
  // 使两个日志组件生效,内置在EchoClient和EchoServer应用中
  LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
  LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);

  // 创建节点对象,并且在内部存储Node对象指针
  NodeContainer nodes;
  nodes.Create (2);

  // 设置网络设备和信道属性
  PointToPointHelper pointToPoint;
  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
  pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));


  NetDeviceContainer devices; 
  // install方法将设备安装到节点中
  //在NodeContainer中的每一个Node创建一个PointToPointNetDevice,
  devices = pointToPoint.Install (nodes);
   

  // ***为计算机每个node中安装协议栈
  InternetStackHelper stack;
  stack.Install (nodes);

  Ipv4AddressHelper address; // 声明了一个地址助手对象
  address.SetBase ("10.1.1.0", "255.255.255.0"); //从10.1.1.0 开始 以子网掩码为 255.255.255.0 分配地址

  //ns-3中使用interface来在device及IP地址间建立关联
  Ipv4InterfaceContainer interfaces = address.Assign (devices); // 完成了真正的地址配置
  

  // ***下面安装应用层
  UdpEchoServerHelper echoServer (9); // 服务器端

  ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
  serverApps.Start (Seconds (1.0)); // echoServer 在 1s 时开始 
  serverApps.Stop (Seconds (10.0)); //echoServer 在 10s时结束,可选可不选

  UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);//使用Node1的地址及端口号(9)初始化辅助对象
  echoClient.SetAttribute ("MaxPackets", UintegerValue (1)); // 能发送的最大数据分组个数
  echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0))); // 两个数据分组之间要等的时间
  echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); // 每个数据分组的大小

  ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
  clientApps.Start (Seconds (2.0));//同上,开始时间
  clientApps.Stop (Seconds (10.0));


  // 以下三行用于生成可视化文件
  AnimationInterface anim("first.xml"); //
  anim.SetConstantPosition(nodes.Get(0), 1.0, 2.0);
  anim.SetConstantPosition(nodes.Get(1), 2.0, 3.0);
  
  Simulator::Run (); // 启动模拟器
  Simulator::Destroy (); // 销毁任务
  return 0;
}

second.cc

网络拓扑如下:
> // Default Network Topology
//
//       10.1.1.0
// n0 -------------- n1   n2   n3   n4
//    point-to-point  |    |    |    |
//                    ================
//                      LAN 10.1.2.0
源码分析:
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/ipv4-global-routing-helper.h"

using namespace ns3;

// 定义一个日志组件
NS_LOG_COMPONENT_DEFINE("SecondScriptExample");

int main(int argc, char* argv[])
{
	bool verbose = true; // 用来决定是否开启日志组件
	uint32_t nCsma = 3; // 定义csma网络中有多少个节点

	CommandLine cmd;
	cmd.AddValue("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma);
	cmd.AddValue("verbose", "Tell echo applications to log if true", verbose);

	cmd.Parse(argc, argv);

	if (verbose) // 开启日志的情况下
	{
		LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
		LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
	}

	nCsma = nCsma == 0 ? 1 : nCsma; //csma中最少一个节点

	//创建p2p的两个节点
	NodeContainer p2pNodes;
	p2pNodes.Create(2);

	//创建csma的网络节点
	NodeContainer csmaNodes;
	csmaNodes.Add(p2pNodes.Get(1)); // p2p的一号节点加入csma作为接入点
	csmaNodes.Create(nCsma);

	// 设置p2p的传输速率及延迟
	PointToPointHelper pointToPoint;
	pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps"));
	pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));

	// p2p节点安装网卡
	NetDeviceContainer p2pDevices;
	p2pDevices = pointToPoint.Install(p2pNodes);

	// 设置csma的传输速率及延迟
	// 注意传输速率有channel指定,而非device属性。(CSMA不允许同一信道上有多个不同数据率的设备)
	CsmaHelper csma;
	csma.SetChannelAttribute("DataRate", StringValue("100Mbps"));
	csma.SetChannelAttribute("Delay", TimeValue(NanoSeconds(6560)));

	// csma节点安装网卡
	NetDeviceContainer csmaDevices;
	csmaDevices = csma.Install(csmaNodes);

	// 安装协议栈
	InternetStackHelper stack;
	stack.Install(p2pNodes.Get(0)); // p2p的0号节点安装
	stack.Install(csmaNodes); //p2p的1号节点包含在csma中一起安装

	Ipv4AddressHelper address;// 声明了一个地址助手对象
	address.SetBase("10.1.1.0", "255.255.255.0");//从10.1.1.0 开始 以子网掩码为 255.255.255.0 分配地址
	Ipv4InterfaceContainer p2pInterfaces;
	p2pInterfaces = address.Assign(p2pDevices);// 完成了p2p真正的地址配置

	address.SetBase("10.1.2.0", "255.255.255.0");//从10.1.2.0 开始 以子网掩码为 255.255.255.0 分配地址
	Ipv4InterfaceContainer csmaInterfaces;
	csmaInterfaces = address.Assign(csmaDevices);// 完成了csma真正的地址配置

	 // ***下面安装应用层
	UdpEchoServerHelper echoServer(9);// 服务器端 port为9
	// 将server服务器安装在CSMA的最后一个节点上即n4
	ApplicationContainer serverApps = echoServer.Install(csmaNodes.Get(nCsma));
	serverApps.Start(Seconds(1.0));// echoServer 在 1s 时开始 
	serverApps.Stop(Seconds(10.0));//echoServer 在 10s时结束

	UdpEchoClientHelper echoClient(csmaInterfaces.GetAddress(nCsma), 9);//设定远程服务器的IP地址和Port
	echoClient.SetAttribute("MaxPackets", UintegerValue(1));// 能发送的最大数据分组个数
	echoClient.SetAttribute("Interval", TimeValue(Seconds(1.0))); // 两个数据分组之间要等的时间
	echoClient.SetAttribute("PacketSize", UintegerValue(1024)); // 每个数据分组的大小

	// 将client服务器安装在p2p的第一个节点上即n0
	ApplicationContainer clientApps = echoClient.Install(p2pNodes.Get(0));
	clientApps.Start(Seconds(2.0));
	clientApps.Stop(Seconds(10.0));

	// 建立网络路由
	Ipv4GlobalRoutingHelper::PopulateRoutingTables();

	//开启p2pHelper,csmaHelper类对象的pcap追踪
	pointToPoint.EnablePcapAll("second"); //
	csma.EnablePcap("second", csmaDevices.Get(1), true);

	Simulator::Run(); // 启动模拟器
	Simulator::Destroy();
	return 0;
}

third.cc

网络拓扑如下:
// Default Network Topology
//
//   Wifi 10.1.3.0
//                 AP
//  *    *    *    *
//  |    |    |    |    10.1.1.0
// n5   n6   n7   n0 -------------- n1   n2   n3   n4
//                   point-to-point  |    |    |    |
//                                   ================
//                                     LAN 10.1.2.0
源码分析:
#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/mobility-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/yans-wifi-helper.h"
#include "ns3/ssid.h"

using namespace ns3;

NS_LOG_COMPONENT_DEFINE("ThirdScriptExample");

int main(int argc, char* argv[])
{
	bool verbose = true; // 用来决定是否开启日志组件
	uint32_t nCsma = 3; // 定义csma网络中有多少个节点
	uint32_t nWifi = 3; // 定义WIFI网络中有多少个节点
	bool tracing = false;

	CommandLine cmd;
	cmd.AddValue("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma);
	cmd.AddValue("nWifi", "Number of wifi STA devices", nWifi);
	cmd.AddValue("verbose", "Tell echo applications to log if true", verbose);
	cmd.AddValue("tracing", "Enable pcap tracing", tracing);

	cmd.Parse(argc, argv);

	// The underlying restriction of 18 is due to the grid position
	// allocator's configuration; the grid layout will exceed the
	// bounding box if more than 18 nodes are provided.
	if (nWifi > 18)
	{
		std::cout << "nWifi should be 18 or less; otherwise grid layout exceeds the bounding box" << std::endl;
		return 1;
	}

	if (verbose)
	{
		LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
		LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
	}

	//创建p2p链路2个节点
	NodeContainer p2pNodes;
	p2pNodes.Create(2);

	// 设置p2p的传输速率及延迟
	PointToPointHelper pointToPoint;
	pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps"));
	pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));

	// p2p节点安装网卡
	NetDeviceContainer p2pDevices;
	p2pDevices = pointToPoint.Install(p2pNodes);

	//创建csma的网络节点
	NodeContainer csmaNodes;
	csmaNodes.Add(p2pNodes.Get(1));// p2p的一号节点加入csma作为接入点
	csmaNodes.Create(nCsma);

	// 设置csma的传输速率及延迟
	CsmaHelper csma;
	csma.SetChannelAttribute("DataRate", StringValue("100Mbps"));
	csma.SetChannelAttribute("Delay", TimeValue(NanoSeconds(6560)));

	// csma节点安装网卡
	NetDeviceContainer csmaDevices;
	csmaDevices = csma.Install(csmaNodes);

	//创建WIFI的网络节点
	NodeContainer wifiStaNodes;
	wifiStaNodes.Create(nWifi);
	NodeContainer wifiApNode = p2pNodes.Get(0);//设置wifi的AP(无线接入点)为p2p的第一个节点


	//配置PHY和Channel通道助手
	YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
	YansWifiPhyHelper phy = YansWifiPhyHelper::Default();
	phy.SetChannel(channel.Create());//Channel对象与PHY对象关联

	//MAC层配置
	WifiHelper wifi;
	wifi.SetRemoteStationManager("ns3::AarfWifiManager");//使用AARF速率控制算法

	WifiMacHelper mac;
	Ssid ssid = Ssid("ns-3-ssid");
	mac.SetType("ns3::StaWifiMac",
		"Ssid", SsidValue(ssid),
		"ActiveProbing", BooleanValue(false));

	NetDeviceContainer staDevices;//STA 网络设备
	staDevices = wifi.Install(phy, mac, wifiStaNodes);//wifi的STA安装PHY层和MAC层

	//配置wifi网络AP网络设备的MAC类型和基础设施网络的SSID
	mac.SetType("ns3::ApWifiMac",
		"Ssid", SsidValue(ssid));

	NetDeviceContainer apDevices;
	apDevices = wifi.Install(phy, mac, wifiApNode);//与STA共同的PHY特性

	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",//以随机游走的方式移动
		"Bounds", RectangleValue(Rectangle(-50, 50, -50, 50)));
	mobility.Install(wifiStaNodes);//安装到wifi网络的STA

	mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
	mobility.Install(wifiApNode);//安装到wifi网络的AP

	 //安装协议栈
	InternetStackHelper stack;
	stack.Install(csmaNodes);
	stack.Install(wifiApNode);
	stack.Install(wifiStaNodes);

	Ipv4AddressHelper address;

	address.SetBase("10.1.1.0", "255.255.255.0");
	Ipv4InterfaceContainer p2pInterfaces;
	p2pInterfaces = address.Assign(p2pDevices);

	address.SetBase("10.1.2.0", "255.255.255.0");
	Ipv4InterfaceContainer csmaInterfaces;
	csmaInterfaces = address.Assign(csmaDevices);

	address.SetBase("10.1.3.0", "255.255.255.0");
	address.Assign(staDevices);
	address.Assign(apDevices);

	//安装应用
	UdpEchoServerHelper echoServer(9);

	ApplicationContainer serverApps = echoServer.Install(csmaNodes.Get(nCsma));
	serverApps.Start(Seconds(1.0));
	serverApps.Stop(Seconds(10.0));

	UdpEchoClientHelper echoClient(csmaInterfaces.GetAddress(nCsma), 9);
	echoClient.SetAttribute("MaxPackets", UintegerValue(1));
	echoClient.SetAttribute("Interval", TimeValue(Seconds(1.0)));
	echoClient.SetAttribute("PacketSize", UintegerValue(1024));

	ApplicationContainer clientApps =
		echoClient.Install(wifiStaNodes.Get(nWifi - 1));//在随后建立的wifi STA上安装客户机
	clientApps.Start(Seconds(2.0));
	clientApps.Stop(Seconds(10.0));

	//建立网络路由
	Ipv4GlobalRoutingHelper::PopulateRoutingTables();

	Simulator::Stop(Seconds(10.0));//无线接入点会一直产生信标,模拟器时间列表一直非空,仿真无法结束

	if (tracing == true)
	{
		pointToPoint.EnablePcapAll("third");
		phy.EnablePcap("third", apDevices.Get(0));
		csma.EnablePcap("third", csmaDevices.Get(0), true);
	}

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

总结:

通过分析以上三个源码,不难发现:

拓展

仿照上述程序,编写一个由两个LAN互联形成的网络。

myfourth.cc

网络拓扑如下:
// Default Network Topology
//
//       
//    n3   n2   n1   n0  -------------- n4   n5   n6   n7
//    |    |    |    |   point-to-point  |    |    |    |
//    ================                   ================
//     LAN 10.1.1.0                        LAN 10.1.2.0
源码分析:

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/netanim-module.h"


using namespace ns3;

// 定义一个日志组件
NS_LOG_COMPONENT_DEFINE("MyfourthScriptExample");

int main(int argc, char* argv[])
{
	bool verbose = true; // 用来决定是否开启日志组件
	uint32_t nCsma_1 = 3; // 定义csma1网络中有多少个节点
	uint32_t nCsma_2 = 3; // 定义csma2网络中有多少个节点

	CommandLine cmd;
	cmd.AddValue("nCsma_1", "Number of \"extra\" CSMA nodes/devices", nCsma_1);
	cmd.AddValue("nCsma_2", "Number of \"extra\" CSMA nodes/devices", nCsma_2);
	cmd.AddValue("verbose", "Tell echo applications to log if true", verbose);

	cmd.Parse(argc, argv);

	if (verbose) // 开启日志的情况下
	{
		LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
		LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
	}

	nCsma_1 = nCsma_1 == 0 ? 1 : nCsma_1; //csma中最少一个节点
	nCsma_2 = nCsma_2 == 0 ? 1 : nCsma_2;

	//创建p2p的两个节点
	NodeContainer p2pNodes;
	p2pNodes.Create(2);

	//创建csma_1的网络节点
	NodeContainer csmaNodes_1;
	csmaNodes_1.Add(p2pNodes.Get(0)); // p2p的0号节点加入csma1作为接入点
	csmaNodes_1.Create(nCsma_1);

	//创建csma_2的网络节点
	NodeContainer csmaNodes_2;
	csmaNodes_2.Add(p2pNodes.Get(1)); // p2p的1号节点加入csma2作为接入点
	csmaNodes_2.Create(nCsma_2);

	// 设置p2p的传输速率及延迟
	PointToPointHelper pointToPoint;
	pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps"));
	pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));

	// p2p节点安装网卡
	NetDeviceContainer p2pDevices;
	p2pDevices = pointToPoint.Install(p2pNodes);

	// 设置csma的传输速率及延迟
	// 注意传输速率有channel指定,而非device属性。(CSMA不允许同一信道上有多个不同数据率的设备)
	CsmaHelper csma;
	csma.SetChannelAttribute("DataRate", StringValue("100Mbps"));
	csma.SetChannelAttribute("Delay", TimeValue(NanoSeconds(6560)));

	// csma节点安装网卡
	NetDeviceContainer csmaDevices_1;
	csmaDevices_1 = csma.Install(csmaNodes_1);
	NetDeviceContainer csmaDevices_2;
	csmaDevices_2 = csma.Install(csmaNodes_2);

	// 安装协议栈
	InternetStackHelper stack;
	//stack.Install(p2pNodes); // p2p不需要独立安装
	stack.Install(csmaNodes_1); //p2p的0号节点包含在csma1中一起安装
	stack.Install(csmaNodes_2); //p2p的1号节点包含在csma2中一起安装

	// 下面是ip的分配
	Ipv4AddressHelper address;// 声明了一个地址助手对象
	
	address.SetBase("10.1.1.0", "255.255.255.0");
	Ipv4InterfaceContainer p2pInterfaces;
	p2pInterfaces = address.Assign(p2pDevices);

	address.SetBase("10.1.3.0", "255.255.255.0");//从10.1.1.0 开始 以子网掩码为 255.255.255.0 分配地址
	Ipv4InterfaceContainer csmaInterfaces_1;
	csmaInterfaces_1 = address.Assign(csmaDevices_1);// 完成了csma1真正的地址配置

	address.SetBase("10.1.2.0", "255.255.255.0");//从10.1.2.0 开始 以子网掩码为 255.255.255.0 分配地址
	Ipv4InterfaceContainer csmaInterfaces_2;
	csmaInterfaces_2 = address.Assign(csmaDevices_2);// 完成了csma2真正的地址配置

	 // ***下面安装应用层
	UdpEchoServerHelper echoServer(9);// 服务器端 port为9
	// 将server服务器安装在CSMA2的最后一个节点上即n7
	ApplicationContainer serverApps = echoServer.Install(csmaNodes_2.Get(nCsma_2));
	serverApps.Start(Seconds(1.0));// echoServer 在 1s 时开始 
	serverApps.Stop(Seconds(10.0));//echoServer 在 10s时结束

	UdpEchoClientHelper echoClient(csmaInterfaces_2.GetAddress(nCsma_2), 9);//设定远程服务器的IP地址和Port
	echoClient.SetAttribute("MaxPackets", UintegerValue(1));// 能发送的最大数据分组个数
	echoClient.SetAttribute("Interval", TimeValue(Seconds(1.0))); // 两个数据分组之间要等的时间
	echoClient.SetAttribute("PacketSize", UintegerValue(1024)); // 每个数据分组的大小

	// 将client服务器安装在csma1的最后一个节点上即n3
	ApplicationContainer clientApps = echoClient.Install(csmaNodes_1.Get(nCsma_1));
	clientApps.Start(Seconds(2.0));
	clientApps.Stop(Seconds(10.0));

	// 建立网络路由
	Ipv4GlobalRoutingHelper::PopulateRoutingTables();

	//开启p2pHelper,csmaHelper类对象的pcap追踪
	pointToPoint.EnablePcapAll("Myfourth"); //
	csma.EnablePcap("Myfourth", csmaDevices_1.Get(nCsma_1), true);
	csma.EnablePcap("Myfourth", csmaDevices_2.Get(nCsma_2), true);

	AnimationInterface anim("myfourth.xml");
	anim.SetConstantPosition(csmaNodes_1.Get(0), 5.0, 4.0);
	anim.SetConstantPosition(csmaNodes_1.Get(1), 3.0, 2.0);
	anim.SetConstantPosition(csmaNodes_1.Get(2), 5.0, 2.0);
	anim.SetConstantPosition(csmaNodes_1.Get(3), 7.0, 2.0);

	anim.SetConstantPosition(csmaNodes_2.Get(0), 5.0, 6.0);
	anim.SetConstantPosition(csmaNodes_2.Get(1), 3.0, 8.0);
	anim.SetConstantPosition(csmaNodes_2.Get(2), 5.0, 8.0);
	anim.SetConstantPosition(csmaNodes_2.Get(3), 7.0, 8.0);


	Simulator::Run(); // 启动模拟器
	Simulator::Destroy();
	return 0;
}
注意:

p2p的两个节点分别是两个CSMA的接入点,编程时:

  • 安装网卡时要分别独立安装
  • 协议栈p2p不需要重复安装
  • IP分配需要重复分配
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

NS-3例程注解与拓展 的相关文章

  • 具有相同参数类型但具有不同常量限定符的 std::vector 的转换

    问题很简单 静态转换 或其他一些转换 通常是安全的 std vector lt Foo gt to std vector lt const Foo gt 就二进制而言 我不明白为什么本机类型会有所不同 毕竟const是一种语言约束 不应影响
  • X11 模式对话框

    如何使用 Xlib 在 X11 中创建模式对话框 模态对话框是一个位于应用程序其他窗口之上的窗口 就像瞬态窗口一样 并且拒绝将焦点给予应用程序的其他窗口 在 Windows 中 当试图从模态窗口夺取焦点时 模态也会通过闪 烁模态窗口的标题栏
  • fopen_s 怎么会比 fopen 更安全呢?

    我正在处理遗留代码Windows平台 当我编译代码时VS2013 它给出以下警告 错误 C4996 fopen 该函数或变量可能不安全 考虑使用fopen s反而 要禁用弃用 请使用 CRT SECURE NO WARNINGS 详情请参见
  • 为什么我会收到未找到分析器的警告?

    我创建了一个玩具项目来检查最新的 NET 7 预览版 5 和正则表达式代码生成 它效果很好 所以我对现有项目应用了相同的更改 不是为了生产 而是为了个人生产力 由于某种原因 我收到这些警告 CS8032 An instance of ana
  • 如何在特定时间以毫秒精度触发 C# 函数?

    我有两台计算机 它们的时间通过 NTP 同步 确保时间仅相差几毫秒 其中一台计算机将通过 TCP 向另一台计算机发送一条消息 以在两台计算机上的未来指定时间启动某个 c 函数 我的问题是 如何在特定时间以毫秒精度 或更好 触发 C 中的函数
  • 深拷贝和动态转换 unique_ptr

    假设我有一个如下所示的类 class A virtual A class B public A class C public A 我还有一个 unique ptr 向量 它是这样声明的 std vector
  • Dapper 在执行时挂起

    我有一个 IDb连接 sql UPDATE 表名 SET json json lastupdate SYSDATE WHERE id id var param new DynamicParameters param Add json jso
  • ContentDialog 未与 UWP 中心对齐

    据我所知 ContentDialog的默认行为应该是使其在 PC 上居中并在移动设备上与顶部对齐 但就我而言 即使在 PC 上我也将其与顶部对齐 但我不明白发生了什么 我正在使用代码隐藏来创建它 这是我正在使用的代码片段 Creates t
  • Linq 合并列表

    我的课 public class Foo public int A get set public List
  • Visual Studio 中列表框的上移、下移按钮[重复]

    这个问题在这里已经有答案了 我正在尝试制作一个上移按钮和一个下移按钮 以移动 Microsoft Visual Studio 2012 中列表框中的选定项目 我已经在 WDF jquery winforms 和其他一些表单中看到了其他示例
  • 调用异步方法在视图模型的构造函数中加载数据有警告

    我的视图包含一个 ListView 它显示来自互联网的一些数据 我创建一个异步方法来加载数据并在我的视图模型的构造函数中调用该方法 它有一个警告提示我现在使用await关键字 还有其他解决方案可以在构造函数中异步加载数据吗 有几种可以应用的
  • 如何构建一棵与或树?

    我需要一个支持 与 和 或 的树结构 例如 给定一个正则表达式 如ab c d e 我想把它变成一棵树 所以 一开始我们有两个 或 分支 它可以向下ab or c d e 如果你低头ab分支 你得到两个节点 a and b or a其次是b
  • DataGridView 行背景颜色没有改变

    我想根据加载时的特定条件更改 DGV 行的背景颜色 即使在 Windows 窗体中也是如此 但我看不到任何 DGV 行的颜色有任何变化 谁能告诉我如何解决这个问题 private void frmSecondaryPumps Load ob
  • Gremlin.net 文本包含等效项

    我正在使用 Gremlin net 库连接到 janus 图形服务器 我使用 cassandra 和弹性搜索进行数据存储和索引 在我使用的 gremlin 语言和 gremlin 控制台中文本包含在属性的文本中进行搜索 我正在使用混合索引
  • 如何同步nosql db(ravendb)中的更改

    我已经开始在 RavenDB 的示例上学习 NoSQL 我从一个最简单的模型开始 假设我们有由用户创建的主题 public class Topic public string Id get protected set public stri
  • C++ 中是否有与 PHP 的explode() 函数等效的函数? [复制]

    这个问题在这里已经有答案了 可能的重复 在 C 中分割字符串 https stackoverflow com questions 236129 splitting a string in c 在 PHP 中 explode 函数将获取一个字
  • 选择合适的IDE

    您会推荐使用以下哪种 IDE 语言来在 Windows 下开发涉及识别手势并与操作系统交互的项目 我将使用 OpenCV 库来执行图像处理任务 之后 我将使用 win32 API 或 NET 框架与操作系统交互 具体取决于您建议的工具 性能
  • 如何将System.Windows dll添加到Visual Studio 2010 Express?

    我正在开发一个小型应用程序C and VS2010 as IDE with NET框架4 我想用CaptureSource类以便从笔记本电脑的网络摄像头捕获视频 为此我需要添加一个命名空间System Windows DependencyO
  • 如何在c#中创建多线程

    我需要监听机器中的所有串行端口 假设我的机器有 4 个串行端口 我必须创建 4 个线程并开始分别使用附加线程监听每个端口 我使用此代码来获取我的机器中的端口数量 private SerialPort comPort new SerialPo
  • 将一个 IEnumerable 拆分为多个 IEnumerable

    我是 linq 新手 我需要根据指示器将 Couple string text bool Indicator 类型的 IEnumerable 拆分为多个 IEnumerable 我尝试使用skipWhile 和 TakeWhile 但没有找

随机推荐

  • 赶紧来修炼内功发~内存函数详解大全-memcpy、memmove、memcmp

    目录 1 memcpy EX PS 模拟实现 2 memmove EX 编辑 模拟实现 3 memcmp EX PS 模拟实现 4 memset EX 模拟实现 1 memcpy memcpy函数的作用为 将source指向的地址拷贝num
  • 永别了功能测试,我要跑路了

    在软件测试行业 功能测试一直被视为软件测试工作的核心部分 然而 在不断变化的互联网时代 功能测试这个岗位正在面临着前所未有的挑战 对于一个职业生涯悠久的软件测试工程师来说 离开功能测试可能是他们必须要做出的选择 1 做好手工测试 了解各种测
  • numpy之tile

    numpy中tile函数 形式 numpy tile A reps A 1 2 3 b np tile A 3 输出为 1 2 3 1 2 3 1 2 3 tile函数第二个参数是一个数 用来控制A的重复次数的 c np tile A 2
  • 微服务开发系列 第十一篇:XXL-JOB

    总概 A 技术栈 开发语言 Java 1 8 数据库 MySQL Redis MongoDB Elasticsearch 微服务框架 Spring Cloud Alibaba 微服务网关 Spring Cloud Gateway 服务注册和
  • WSA - root,frida与ida测试

    本文旨在配置windows subsystem for android win安卓子系统 来作为win在开启了hyper v的情况下的一种轻量的安卓模拟器方案 使用MagiskOnWsa设置root权限 最终使其正常与开发环境 frida
  • docker--扩展学习-Machine--06

    一 简介 可以让您在虚拟主机上安装 Docker 的工具 可以使用 docker machine 命令来管理主机 可以集中管理所有的 docker 主机 比如快速的给 100 台服务器安装上 docker Docker Machine 管理
  • input[type='file']获取上传文件路径案例

    最近在项目时 需要获取用户的上传文件的路径 便写了一个demo
  • vue实现flv格式视频播放

    公司项目需要实现摄像头实时视频播放 flv格式的视频 先百度使用flv js插件实现 但是两个摄像头一个能放一个不能放 没有找到原因 开始两个都能放 后端更改地址后不有一个不能放 但是在另一个系统上是可以播放的 使用的是jessibuca
  • Python爬虫:爬取网页图片

    目录 开始 分析与步骤 第一步 第二步 第三步 第四步 最后 开始 最近在自学爬虫 自己也做了一些实例 自认为 写的比较好的就是对整个网站的爬取了 接下来我将会说一说我使用的工具及方法 注意 为了尊重网站维护人员 我只爬取了网站首页的24个
  • Android SDK安装教程(超详细),从零基础入门到精通,从这篇开始

    前言 在使用appnium的时候 除了安装JDK之外 也需要安装Android SDK 那么 正确安装Android SDK是怎样的呢 跟着小编继续往下看 安装Android SDK和环境配置 1 安装Android SDK 首先打开官网
  • template partial specialization模板特例化,偏特化

    文章目录 前言 模板类特例化 模板函数特例化 总结 前言 temlplate
  • Plt 图例legend设置字体大小

    用legend fontsize 方法是无效的 需要添加plt的属性参数 plt rcParams update font size 18
  • 建立机械臂与PC间的通信

    服务器的固定IP地址 127 0 0 1 机器臂的IP地址 192 168 0 156 端口 10003 采用TCP IP通信 机器臂当服务端 自己电脑当客户机 故修改自己电脑IP地址为192 168 0 157 使其在同一个域即可通信 用
  • (tomcat启动失败)The file is absent or does not have execute permission This file is needed t

    在服务器上启动tomcat失败 操作步骤 进入tomcat bin目录 执行startup sh命令报 解决方法 执行此命令后再次执行startup sh即可
  • IO进程线程-标准IO(结)

    目录 1 思维导图 2 笔记 3 作业 3 1题 3 2题 1 思维导图 2 笔记 有道云笔记 3 作业 3 1题 计算文件行数 使用fputs fgets 要求拷贝一个文件 例如将1 c中的内容拷贝到2 c中 要求计算一个文件的大小 in
  • c语言实现斐波那契数列

    include
  • Linux下编译安装以及配置PHP环境

    安装准备 依次执行下面命令 不存在的就搜差不多的就行 下面安装的都是后面安装环境可能需要用上的依赖 不管37是不是21 复制粘贴就是了 Ubuntu安装 sudo apt get update sudo apt get install gc
  • signature=f4447be2b03f94d344842fd53c708af2,nba/yarn.lock at 2f92e19f45008cc37dbff8c210320bed05e43377...

    THIS IS AN AUTOGENERATED FILE DO NOT EDIT THIS FILE DIRECTLY yarn lockfile v1 babel cli 7 5 5 version 7 5 5 resolved htt
  • shell练习2

    要求 1 取出 etc inittab文件的第6行 2 取出当前系统上所有用户的shell 要求 每种shell只显示一次 并且按顺序进行显示 使用cut sort结合管道实现 3 如果 var log messages文件的行数大于100
  • NS-3例程注解与拓展

    准备 运行准备 要运行自己的脚本 只需把脚本放到scratch目录下 通过waf脚本就会被编译 cp examples tutorial first cc scratch myfirst cc 使用waf命令来编译自己的第一个实例脚本 su