4

私たちのサポートチームは、ネットワークベースのデータベースアプリケーションの速度低下を引き起こす可能性のあるコンピューター構成の特定の領域を診断しました。私は、速度低下の懸念をテストするためのツールを作成する任務を負っています。リンクされたレイヤートポロジがアクティブなネットワークアダプターに対してWindowsで有効になっているかどうかの検出に問題があります。アクティブな(最も使用されている)ネットワークアダプタを見つける方法があります。

リンクされたレイヤートポロジを検出する方法はありますか?それをテストするにはどうすればよいですか?

4

1 に答える 1

2

純粋な .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/

于 2012-07-12T22:06:57.010 に答える