如何用C#获取 iperf量测到的 throughput数据

lglsnialgame 2015-12-06 02:41:25
请教各位一个问题,如何在C#中解析 通过iperf量测到的throughput值 如下:
[268] local 192.168.1.102 port 5001 connected with 192.168.1.102 port 14929
[284] local 192.168.1.102 port 5001 connected with 192.168.1.102 port 14931
[304] local 192.168.1.102 port 5001 connected with 192.168.1.102 port 14933
[172] local 192.168.1.102 port 5001 connected with 192.168.1.102 port 14927
[260] local 192.168.1.102 port 5001 connected with 192.168.1.102 port 14928
[276] local 192.168.1.102 port 5001 connected with 192.168.1.102 port 14930
[292] local 192.168.1.102 port 5001 connected with 192.168.1.102 port 14932
[312] local 192.168.1.102 port 5001 connected with 192.168.1.102 port 14934
[ ID] Interval Transfer Bandwidth
[260] 0.0-10.1 sec 300 MBytes 250 Mbits/sec
[172] 0.0-10.1 sec 301 MBytes 250 Mbits/sec
[276] 0.0-10.1 sec 297 MBytes 247 Mbits/sec
[292] 0.0-10.1 sec 300 MBytes 250 Mbits/sec
[312] 0.0-10.0 sec 300 MBytes 251 Mbits/sec
[268] 0.0-10.1 sec 324 MBytes 269 Mbits/sec
[304] 0.0-10.1 sec 328 MBytes 271 Mbits/sec
[284] 0.0-10.1 sec 324 MBytes 268 Mbits/sec
[SUM] 0.0-10.1 sec 2.42 GBytes 2.05 Gbits/sec

上面量测的值为2.05 Gbits/sec ,如何解析获得这个值呢,还请大家不吝赐教,谢谢!
...全文
523 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
秋的红果实 2016-04-17
  • 打赏
  • 举报
回复

string instr="[SUM]  0.0-10.1 sec  2.42 GBytes  2.05 Gbits/sec";
string outstr = "";
Regex rgx = new Regex(@"2.05 Gbits/sec");
foreach(Match m in rgx.Matches(instr))
{
    outstr += m.Value;
}
//outstr就是你要的值
lglsnialgame 2016-04-16
  • 打赏
  • 举报
回复
自己顶,用正则表达式解析即可

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧