带宽/吞吐量测试 (NTTTCP)Bandwidth/Throughput testing (NTTTCP)

在 Azure 中测试网络吞吐量性能时,最好使用以要测试的网络为目标并能最大程度减少其他资源(这些资源可能会对性能产生影响)的使用的工具。When testing network throughput performance in Azure, it's best to use a tool that targets the network for testing and minimizes the use of other resources that could impact performance. 建议使用 NTTTCP。NTTTCP is recommended.

将此工具复制到大小相同的两个 Azure VM 中。Copy the tool to two Azure VMs of the same size. 一个 VM 充当发送方,另一个充当接收方。One VM functions as SENDER and the other as RECEIVER.

部署 VM 以进行测试Deploying VMs for testing

为了达到此测试的目的,两个 VM 应位于同一云服务或同一可用性集中,这样便可使用其内部 IP 并从测试中排除负载均衡器。For the purposes of this test, the two VMs should be in either the same Cloud Service or the same Availability Set so that we can use their internal IPs and exclude the Load Balancers from the test. 也可以使用 VIP 进行测试,但这类测试不在本文档的讨论范围内。It is possible to test with the VIP but this kind of testing is outside the scope of this document.

记下接收方的 IP 地址。Make a note of the RECEIVER's IP address. 暂且将该 IP 称为“a.b.c.r”Let's call that IP "a.b.c.r"

记下 VM 上的核心数。Make a note of the number of cores on the VM. 我们将其称为“#num_cores”Let's call this "#num_cores"

在发送方 VM 和接收方 VM 上运行 NTTTCP 测试 300 秒(5 分钟)。Run the NTTTCP test for 300 seconds (or 5 minutes) on the sender VM and receiver VM.

提示:第一次设置此测试时,可以尝试更短的测试时间,以更快地获取反馈。Tip: When setting up this test for the first time, you might try a shorter test period to get feedback sooner. 在工具按预期工作后,将测试时间延长到 300 秒,以获取最准确的结果。Once the tool is working as expected, extend the test period to 300 seconds for the most accurate results.

备注

发送方接收方必须指定相同的测试持续时间参数 (-t)。The sender and receiver must specify the same test duration parameter (-t).

测试单个 TCP 流 10 秒:To test a single TCP stream for 10 seconds:

接收方参数:ntttcp -r -t 10 -P 1Receiver parameters: ntttcp -r -t 10 -P 1

发送方参数:ntttcp -s10.27.33.7 -t 10 -n 1 -P 1Sender parameters: ntttcp -s10.27.33.7 -t 10 -n 1 -P 1

备注

以上示例应仅用于确认配置。The preceding sample should only be used to confirm your configuration. 本文档稍后会介绍测试的有效示例。Valid examples of testing are covered later in this document.

测试运行 WINDOWS 的 VM:Testing VMs running WINDOWS:

在 VM 上安装 NTTTCP。Get NTTTCP onto the VMs.

下载最新版本:https://gallery.technet.microsoft.com/NTttcp-Version-528-Now-f8b12769Download the latest version: https://gallery.technet.microsoft.com/NTttcp-Version-528-Now-f8b12769

或者搜索它(如果已移动):https://www.bing.com/search?q=ntttcp+download< - 应先点击Or search for it if moved: https://www.bing.com/search?q=ntttcp+download< -- should be first hit

请考虑将 NTTTCP 放在单独的文件夹中,如 c:\toolsConsider putting NTTTCP in separate folder, like c:\tools

允许 NTTTCP 通过 Windows 防火墙Allow NTTTCP through the Windows firewall

在接收方上,在 Windows 防火墙上创建允许规则,以允许接收 NTTTCP 流量。On the RECEIVER, create an Allow rule on the Windows Firewall to allow the NTTTCP traffic to arrive. 最简单的方法是按名称允许整个 NTTTCP 程序,而不是允许特定的 TCP 端口入站。It's easiest to allow the entire NTTTCP program by name rather than to allow specific TCP ports inbound.

允许 ntttcp 通过 Windows 防火墙,如下所示:Allow ntttcp through the Windows Firewall like this:

netsh advfirewall firewall add rule program=<PATH>\ntttcp.exe name="ntttcp" protocol=any dir=in action=allow enable=yes profile=ANYnetsh advfirewall firewall add rule program=<PATH>\ntttcp.exe name="ntttcp" protocol=any dir=in action=allow enable=yes profile=ANY

例如,如果已将 ntttcp.exe 复制到“c:\tools”文件夹中,则此命令为:For example, if you copied ntttcp.exe to the "c:\tools" folder, this would be the command: 

netsh advfirewall firewall add rule program=c:\tools\ntttcp.exe name="ntttcp" protocol=any dir=in action=allow enable=yes profile=ANYnetsh advfirewall firewall add rule program=c:\tools\ntttcp.exe name="ntttcp" protocol=any dir=in action=allow enable=yes profile=ANY

运行 NTTTCP 测试Running NTTTCP tests

在接收方上启动 NTTTCP(从 CMD 运行,而不是从 PowerShell 运行):Start NTTTCP on the RECEIVER (run from CMD, not from PowerShell):

ntttcp -r -m [2*#num_cores],*,a.b.c.r -t 300ntttcp -r -m [2*#num_cores],*,a.b.c.r -t 300

如果 VM 有四个核心且 IP 地址为 10.0.0.4,则为如下所示:If the VM has four cores and an IP address of 10.0.0.4, it would look like this:

ntttcp -r -m 8,*,10.0.0.4 -t 300ntttcp -r -m 8,*,10.0.0.4 -t 300

在发送方上启动 NTTTCP(从 CMD 运行,而不是从 PowerShell 运行):Start NTTTCP on the SENDER (run from CMD, not from PowerShell):

ntttcp -s -m 8,*,10.0.0.4 -t 300ntttcp -s -m 8,*,10.0.0.4 -t 300 

等待结果。Wait for the results.

测试运行 LINUX 的 VM:Testing VMs running LINUX:

使用 nttcp-for-linux。Use nttcp-for-linux. 可从 https://github.com/Microsoft/ntttcp-for-linux 获得它It is available from https://github.com/Microsoft/ntttcp-for-linux

在 Linux VM上(发送方和接收方),运行以下命令以在 VM 上准备 nttcp-for-linux:On the Linux VMs (both SENDER and RECEIVER), run these commands to prepare ntttcp-for-linux on your VMs:

CentOS — 安装 Git:CentOS - Install Git:

  yum install gcc -y  
  yum install git -y

Ubuntu — 安装 Git:Ubuntu - Install Git:

 apt-get -y install build-essential  
 apt-get -y install git

在这两者上生成并安装:Make and Install on both:

 git clone https://github.com/Microsoft/ntttcp-for-linux
 cd ntttcp-for-linux/src
 make && make install

如 Windows 示例中一样,假设 Linux 接收方的 IP 为 10.0.0.4As in the Windows example, we assume the Linux RECEIVER's IP is 10.0.0.4

在接收方上启动 NTTTCP-for-Linux:Start NTTTCP-for-Linux on the RECEIVER:

ntttcp -r -t 300

然后在发送方上运行:And on the SENDER, run:

ntttcp -s10.0.0.4 -t 300

如果未给定时间参数,默认的测试持续时间为 60 秒Test length defaults to 60 seconds if no time parameter is given

在运行 Windows 和 LINUX 的 VM 之间进行测试:Testing between VMs running Windows and LINUX:

在此方案中,我们应启用非同步模式,以便可以运行测试。On this scenarios we should enable the no-sync mode so the test can run. 通过对 Linux 使用“-N 标志” ,对 Windows 使用“-ns 标志” 完成此操作。This is done by using the -N flag for Linux, and -ns flag for Windows.

从 Linux 到 Windows:From Linux to Windows:

接收方 <Windows>:Receiver <Windows>:

ntttcp -r -m <2 x nr cores>,*,<Windows server IP>

发送方 <Linux>:Sender <Linux> :

ntttcp -s -m <2 x nr cores>,*,<Windows server IP> -N -t 300

从 Windows 到 Linux:From Windows to Linux:

接收方 <Linux>:Receiver <Linux>:

ntttcp -r -m <2 x nr cores>,*,<Linux server IP>

发件方 <Windows>:Sender <Windows>:

ntttcp -s -m <2 x nr cores>,*,<Linux  server IP> -ns -t 300

测试云服务实例:Testing Cloud Service Instances:

需要将以下部分添加到 ServiceDefinition.csdefYou need to add following section into your ServiceDefinition.csdef

<Endpoints>
  <InternalEndpoint name="Endpoint3" protocol="any" />
</Endpoints> 

后续步骤Next steps