我们的支持团队已诊断出计算机配置的某些特定区域可能会导致基于网络的数据库应用程序速度变慢。我的任务是创建一个工具来测试可能的减速问题。我在检测Windows中是否为其活动网络适配器启用了链接层拓扑时遇到问题。我有一个查找活动(最常用)网络适配器的方法。
有没有一种方法可以检测链接层拓扑,我如何测试它?
发布于 2012-07-13 06:06:57
这不是一个纯粹的.Net解决方案,但似乎可以工作。函数接受本地连接的名称和协议名称。我有一个到一个网站的链接,这个网站有很多不同的协议驱动程序名称,但你想要的那些都包含在代码中。
这使用了您可以从http://archive.msdn.microsoft.com/nvspbind获得的nvspbind.exe。
代码
class Program
{
static void Main(string[] args)
{
//check Link-Layer Topology Discover Mapper I/O Driver
bool result1 = IsProtocalEnabled("Local Area Connection", "ms_lltdio");
//check Link-Layer Topology Discovery Responder
bool result2 = IsProtocalEnabled("Local Area Connection", "ms_rspndr");
}
private static bool IsProtocalEnabled(string adapter, string protocol)
{
var p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "nvspbind.exe");
p.StartInfo.Arguments = string.Format("/o \"{0}\" {1}", adapter, protocol);
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
return output.Contains("enabled");
}
}我从这里获得了协议驱动程序的名称:http://djseppie.wordpress.com/category/windows/scripting/
https://stackoverflow.com/questions/10691874
复制相似问题