计算网络延迟对多个连接的适配器 [英] Compute Network Latency on Multiple Connected Adapters
问题描述
我需要计算系统,该系统有多个连接的适配器上的网络延迟。 我现在用的是System.Net.NetworkInformation.Ping类来ping一个地址,并使用RoundtripTime属性来确定延迟。
这工作得很好。然而在具有多个连接的适配器的系统,我需要 提供的源IP来使用,以确定在每个可用的连接的等待时间。
本类然而,这并不提供一个选项,使用特定的源IP地址来ping
我需要类似于平DOS命令的东西。该命令有-S的选项,使您可以提供一个源IP地址。
有没有一种方法来指定System.Net.NetworkInformation.Ping的源IP地址。该PingOptions类不提供任何这样的选择。
感谢。
//提供任何网址平。
乌里objURL =新的URI(任何URL);
System.Net.NetworkInformation.Ping objPing =新System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingOptions objPingOptn =新System.Net.NetworkInformation.PingOptions();
//如果决定在小块一展身手或除法发送数据包
objPingOptn.DontFragment = TRUE;
//创建的32字节的缓冲器。
字符串tPacketData =DummyPacketsDataDummyPacketsData;
byte []的bBuffer = Encoding.ASCII.GetBytes(tPacketData);
//可以直接如有提供主机名
System.Net.NetworkInformation.PingReply objPingRply = objPing.Send(objURL.Host,120,bBuffer,objPingOptn);
objPing.Dispose();
如果(objPingRply.Status == System.Net.NetworkInformation.IPStatus.Success)
返回true;
其他
返回false;
I need to calculate the network latency on a system which has multiple connected adapters . I am using the System.Net.NetworkInformation.Ping class to ping an address and use the RoundtripTime property to determine latency.
This works fine. However on a system with multiple connected adapters , I need to provide the source IP to use, to determine the latency on each of the available connections.
This class however does not provide an option to ping using a particular source IP address
I need something similar to the ping DOS command . This command has the option of -S which allows you to provide a source IP address.
Is there a way to specify the source IP address in System.Net.NetworkInformation.Ping. The PingOptions class does not provide any such option .
Thanks.
//Provide any URL to ping.
Uri objURL = new Uri("ANY URL");
System.Net.NetworkInformation.Ping objPing = new System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingOptions objPingOptn = new System.Net.NetworkInformation.PingOptions();
//Decides if packet to be sent in a go or divide in small chunks
objPingOptn.DontFragment = true;
//Creating a buffer of 32 bytes.
string tPacketData = "DummyPacketsDataDummyPacketsData";
byte[] bBuffer = Encoding.ASCII.GetBytes(tPacketData);
//Can provide host name directly if available
System.Net.NetworkInformation.PingReply objPingRply = objPing.Send(objURL.Host, 120, bBuffer, objPingOptn);
objPing.Dispose();
if (objPingRply.Status == System.Net.NetworkInformation.IPStatus.Success)
return true;
else
return false;
这篇关于计算网络延迟对多个连接的适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!