ipef3工具,是一个用于测试网络带宽的开源工具,用于评估网络的性能和吞吐量,他是iperf工具的第三个版本。
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace RunServerProcess
{
internal class Program
{
static void Main(string[] args)
{
Thread thread = new Thread(() => { coniont("iperf3.exe -s -1"); });
thread.Start();
//通过客户端等待10秒获取到结果
coniont(" iperf3.exe -c 127.0.0.1");
Console.Read();
}
public static void coniont(string cmd)
{
ProcessStartInfo startInfo = new ProcessStartInfo("cmd")
{
Verb = "runas",
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
Process cmdProcess = new Process()
{
StartInfo = startInfo
};
cmdProcess.Start();
cmdProcess.StandardInput.WriteLine(cmd);
cmdProcess.StandardInput.Flush();
cmdProcess.StandardInput.Close();
string output = cmdProcess.StandardOutput.ReadToEnd();
cmdProcess.WaitForExit();
Console.WriteLine(output);
cmdProcess.Close();
}
}
}