netperf常用命令使用方法

启动netserver服务报错

[root@localhost ~]# netserver -p 12865
Unable to start netserver with  'IN(6)ADDR_ANY' port '12865' and family AF_UNSPEC

解决方案:

这个错误提示意味着netserver无法使用给定的IP地址和端口号来启动监听服务。可能的解决方案包括:

  1. 检查是否已经有其他程序在占用端口号12865。可以使用netstat -tlnp命令来列出当前正在监听的端口,并查找是否有其他程序正在使用12865端口。

  2. 使用sudo权限来启动netserver,以确保有足够的权限。

  3. 确保输入的IP地址和端口号正确。如果IP地址不正确,可以尝试使用特定的IP地址(如127.0.0.1)或替换为主机名。

  4. 检查系统防火墙设置,确保允许来自该端口的流量通过。可以尝试暂时关闭防火墙来测试是否可以正常启动netserver。

一、启动netserver服务

在使用netperf进行网络性能测试时,需要在测试目标服务器上启动netserver。以下是netserver启动命令的例子:

  1. 在单个端口上启动netserver:
sudo netserver -p 12865

说明:启动netserver监听端口号为12865的连接请求。

  1. 在多个端口上启动netserver:
sudo netserver -p 12865,12866,12867

说明:启动netserver同时监听端口号为12865、12866、12867的连接请求。

注意:netserver命令需要以root权限运行。

启动完成后,可以使用netperf命令连接到netserver进行网络性能测试。

二、netperf常用命令

netperf是一个网络性能测试工具,可以用来测试网络吞吐量、延迟、CPU利用率等指标。以下是一些netperf命令的使用方法示例:

        1. 测试TCP吞吐量

命令:netperf -H <server_ip> -t TCP_STREAM

说明:使用TCP_STREAM测试传输速度

        2. 测试UDP吞吐量

命令:netperf -H <server_ip> -t UDP_STREAM -l 10

说明:使用UDP_STREAM测试传输速度,测试时间为10秒

        3. 测试TCP延迟

命令:netperf -H <server_ip> -t TCP_RR

说明:使用TCP_RR测试延迟

        4. 测试多线程TCP吞吐量

命令:netperf -H <server_ip> -t TCP_STREAM -P 4

说明:使用4个线程测试TCP传输速度

        5. 测试多连接TCP吞吐量

命令:netperf -H <server_ip> -t TCP_STREAM -c 4

说明:使用4个连接测试TCP传输速度

        6. 指定测试端口

命令:netperf -H <server_ip> -t TCP_STREAM -p 8000

说明:使用TCP_STREAM测试端口为8000的传输速度

注意:以上命令只是示例,具体使用方法需要根据实际情况进行调整。

三、netperf使用

server:

[root@localhost ~]# netserver -p 12865
Unable to start netserver with  'IN(6)ADDR_ANY' port '12865' and family AF_UNSPEC
[root@localhost ~]# netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:4369            0.0.0.0:*               LISTEN      69785/epmd          
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      981/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1149/master         
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      70851/sshd: root@pt 
tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      69970/beam          
tcp6       0      0 :::4369                 :::*                    LISTEN      69785/epmd          
tcp6       0      0 :::22                   :::*                    LISTEN      981/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      1149/master         
tcp6       0      0 ::1:6010                :::*                    LISTEN      70851/sshd: root@pt 
tcp6       0      0 :::12865                :::*                    LISTEN      123820/netserver    
tcp6       0      0 :::5672                 :::*                    LISTEN      69970/beam          
[root@localhost ~]# netserver -p 12866
Starting netserver with host 'IN(6)ADDR_ANY' port '12866' and family AF_UNSPEC
[root@localhost ~]# netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:4369            0.0.0.0:*               LISTEN      69785/epmd          
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      981/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1149/master         
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      70851/sshd: root@pt 
tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      69970/beam          
tcp6       0      0 :::4369                 :::*                    LISTEN      69785/epmd          
tcp6       0      0 :::22                   :::*                    LISTEN      981/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      1149/master         
tcp6       0      0 ::1:6010                :::*                    LISTEN      70851/sshd: root@pt 
tcp6       0      0 :::12865                :::*                    LISTEN      123820/netserver    
tcp6       0      0 :::12866                :::*                    LISTEN      123971/netserver    
tcp6       0      0 :::5672                 :::*                    LISTEN      69970/beam          
[root@localhost ~]# 

已启动12865, 12866端口

client:

[root@localhost netperf-netperf-2.7.0]# netperf -H 192.168.6.211
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.6.211 () port 0 AF_INET

Recv   Send    Send                          
Socket Socket  Message  Elapsed              
Size   Size    Size     Time     Throughput  
bytes  bytes   bytes    secs.    10^6bits/sec  

 87380  16384  16384    10.00    5349.45   
[root@localhost netperf-netperf-2.7.0]# 
[root@localhost netperf-netperf-2.7.0]# netperf -H 192.168.6.211 -t TCP_STREAM
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.6.211 () port 0 AF_INET
Recv   Send    Send                          
Socket Socket  Message  Elapsed              
Size   Size    Size     Time     Throughput  
bytes  bytes   bytes    secs.    10^6bits/sec  

 87380  16384  16384    10.01    5107.45   
[root@localhost netperf-netperf-2.7.0]# netperf -H 192.168.6.211 -t UDP_STREAM -l 10
MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.6.211 () port 0 AF_INET
Socket  Message  Elapsed      Messages                
Size    Size     Time         Okay Errors   Throughput
bytes   bytes    secs            #      #   10^6bits/sec

212992   65507   10.00       20303      0    1063.97
212992           10.00       20268           1062.13

[root@localhost netperf-netperf-2.7.0]# netperf -H 192.168.6.211 -t TCP_RR
MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.6.211 () port 0 AF_INET : first burst 0
Local /Remote
Socket Size   Request  Resp.   Elapsed  Trans.
Send   Recv   Size     Size    Time     Rate         
bytes  Bytes  bytes    bytes   secs.    per sec   

16384  87380  1        1       10.00    2413.84   
16384  87380 
[root@localhost netperf-netperf-2.7.0]# netperf -H 192.168.6.211 -t TCP_STREAM -P 4
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.6.211 () port 0 AF_INET
Recv   Send    Send                          
Socket Socket  Message  Elapsed              
Size   Size    Size     Time     Throughput  
bytes  bytes   bytes    secs.    10^6bits/sec  

 87380  16384  16384    10.00    5091.41   
[root@localhost netperf-netperf-2.7.0]# netperf -H 192.168.6.211 -t TCP_STREAM -c 4
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.6.211 () port 0 AF_INET
Recv   Send    Send                          Utilization       Service Demand
Socket Socket  Message  Elapsed              Send     Recv     Send    Recv
Size   Size    Size     Time     Throughput  local    remote   local   remote
bytes  bytes   bytes    secs.    10^6bits/s  % S      % U      us/KB   us/KB

 87380  16384  16384    10.00      4885.78   75.60    -1.00    1.268   -1.000 
[root@localhost netperf-netperf-2.7.0]# netperf -H 192.168.6.211 -t TCP_STREAM -p 8000
establish control: are you sure there is a netserver listening on 192.168.6.211 at port 8000?
establish_control could not establish the control connection from 0.0.0.0 port 0 address family AF_UNSPEC to 192.168.6.211 port 8000 address family AF_INET
[root@localhost netperf-netperf-2.7.0]#
[root@localhost netperf-netperf-2.7.0]# netperf -H 192.168.6.211 -t TCP_STREAM -p 12866
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.6.211 () port 0 AF_INET
Recv   Send    Send                          
Socket Socket  Message  Elapsed              
Size   Size    Size     Time     Throughput  
bytes  bytes   bytes    secs.    10^6bits/sec  

 87380  16384  16384    10.01    5153.50   
[root@localhost netperf-netperf-2.7.0]#

结果说明:

实际的netperf命令输出结果可能因测试参数、网络环境等因素而有所不同。以下是一个示例输出及其解释:

[root@localhost ~]# netperf -H 10.0.0.2 -t TCP_STREAM

MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 10.0.0.2 (10.0.0.2) port 0 AF_INET : demo
Recv   Send    Send                          
Socket Socket  Message  Elapsed              
Size   Size    Size     Time     Throughput  
bytes  bytes   bytes    secs.    MB/sec      
16384  16384  16384    10.00     9.99       

以上输出结果中,包括以下几个方面:

  1. 连接信息:MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 10.0.0.2 (10.0.0.2) port 0 AF_INET : demo。该信息表明正在进行TCP流测试,客户端和服务器的IP地址分别为0.0.0.0和10.0.0.2。

  2. 平均延迟:该测试的延迟不是最重要的指标,因此没有给出。如果进行延迟测试,输出结果中应该会包括平均延迟的数值。

  3. 吞吐量:Throughput列表示本次测试的数据传输吞吐量为9.99 MB/sec。这个指标通常用来衡量网络的传输能力,该值越高,网络传输速度越快。

  4. CPU利用率:本次测试没有给出该指标。

  5. 测试时长:本次测试共持续10秒钟。

  6. 错误率:本次测试中没有检测到任何传输错误,因此没有给出该指标。

根据输出结果,可以初步判断网络传输能力比较好,能够稳定地达到9.99 MB/sec的数据传输速度。

猜你喜欢

转载自blog.csdn.net/songpeiying/article/details/131814853