iPerf3 -B (--bind host) binds the sending network card/sending IP address

On a host with multiple network cards, when using iPerf3 to stream, how to control which network card is used to stream is a common problem.

Read the official documentation of iperf3, we can see the following instructions

-B, --bind host

Bind to host, one of this machine's addresses. For the client this sets the outbound interface.

For a server this sets the incoming interface. This is only useful on multihomed hosts, which have multiple network interfaces.

Translation: bind to the host, an address of the host. For the client, this sets which interface the data is sent from.

For the server, this is to set which interface the data is received from. This command is only useful on multihomed hosts (two or more network interfaces).

(In the latest iperf3 3.13 version, this parameter has been updated and is compatible with the old version of iperf3, so it does not change the validity of the content of this article. For details, see: iperf3 specified network card test -B parameter update or --bind-dev parameter detailed explanation )

It seems to be a very clear description, but in fact, the interface (interface) is not detailed here. This interface refers to the network card.

Or is it referring to the IP interface? What is the relationship between -B option and host routing?

The -B option means to the client:

If your client host has multiple networks, but the multiple networks belong to different subnets, and only one network port can

to reach your target server host, then you will not have the following problems.

If your client host has multiple networks, and multiple network ports can reach your target server host, and you want

Want to specify iPerf3 to send data from a specific network port to the target server host, then this article will help you achieve your goal faster.

question:

Which interface (interface) to send from is related to the IP address followed by -B, or is it related to the entry set in the host routing table?

What should I do if the routing table setting conflicts with the IP address bound to -B?

Answers and conclusions (I don’t want to read the details, just read the conclusions below):

1) If you use the -B parameter, iPerf3 will bypass the binding relationship between the host ip address and the physical network card.

2) iPerf3 will use the IP address specified by the -B parameter to send data.

3) iPerf3 will send the data from the physical NIC specified in the host routing table.

( Note: The conclusion of iperf3 on the windows side does not seem to be true. The behavior on the windows side: it seems that the IP specified by -B will go out from the network card corresponding to the IP. I have not studied it carefully.

Try to find a WINDOWS machine with two network cards)

Let's look at the following test:

Test environment configuration:

The test host environment is two Linux hosts, one is a Raspberry Pi host, installed with raspberry pi OS, and has two network interfaces eth0 and wlan0,

They are two IP addresses of 192.168.3.15 and 192.168.3.243 respectively, and the mask is 255.255.255.0, through the two-layer switch and the ordinary PC host

Connected, the PC host is installed with ubuntu, and there is only one network card, the IP address is 192.168.3.231, and the mask is 255.255.255.0.

The three network cards belong to the same LAN, and the default gateway address is 192.168.3.1. The iPerf3 client works on the Raspberry Pi, and the iPerf3 server works on the ordinary PC host.

Test without -B option:

The default host routing table in the Raspberry Pi is as follows:

Since our target address is a common host (192.168.3.231), it can be seen from the above host route:

If there is no -B specification, as shown in the figure below, we can see that the iPerf3 client selects the 192.168.3.15 end through eth0 to

The data is sent to the 192.168.3.231 server (through the ifconfig command, we can see that the number of data packets sent by eth0 has increased by about

100M Bytes). This is as expected, because the Metric of the third network routing table entry is 202, and the priority is higher than that of the fourth network

Metric 303 of the routing entry.

There is -B option configuration:

Below we use:

sudo route add -host 192.168.3.231 metric 100 dev eth0

The command adds a host route for the Raspberry Pi host, and specifies the data packet sent to 192.168.3.231 (ordinary PC, iPerf3 server),

Send from eth0 (host route priority > network route > default route, and set Metric to 100 as double insurance).

first step:

View the previous network status through ifconfig and route (eth0 has sent 1.1G bytes data)

second step,

Use the iperf3 -c 192.168.3.231 -B 192.168.3.243 command to specify to send data from the 192.168.3.243 interface

We can see from the iperf3 server that the server receives the data sent from 192.168.3.243.

So which network card is this data sent from? eth0 or wlan0? Let's see the next step.

third step,

View the previous network status through ifconfig (eth0 has sent 1.2G bytes data)

We will see that the amount of data sent by the eth0 port has increased from the original 1.1G to 1.2G, while the data sent by the wlan port has remained at 46.3M bytes with little change

This shows: iperf3 -c 192.168.3.231 -B 192.168.3.243, use the IP of WLAN0 port: 192.168.3.243, send data to the server through eth0.

Then: The ip address is specified by -B, and the network card that actually sends data uses the network card specified by the host routing table entry.

Further tests with -B option:

Next, we do further tests to illustrate our above conclusions:

first step:

Modify the host routing table:

sudo route del  -host 192.168.3.231 metric 100 dev eth0

sudo route add -host 192.168.3.231 metric 100 dev wlan0

After the modification is successful, specify the data packet sent to 192.168.3.231 (ordinary PC, iPerf3 server) and send it from wlan0

(Host routing priority > network routing > default routing, and set Metric to 100 as double insurance)

Through the ifconfig command, we can see the current network status as follows:

Step two:

Use iperf3 -c 192.168.3.231 -B 192.168.3.15 to specify to send data through 192.168.3.15

The server received the data packet from 192.168.3.15.

third step,

Through the ifconfig command, check the network status after sending

The sending data packet of eth0 has hardly changed, remaining at 1.3G bytes, while the sending data packet of wlan0 has increased from 46.3M to 49.5M bytes

This shows: iperf3 -c 192.168.3.231 -B 192.168.3.15, use the IP of eth0 port: 192.168.3.15, send data to the server through wlan0.

Explain again: the ip address is specified by -B, and the network card that actually sends data uses the network card specified by the host routing table entry.

in conclusion:

1) If you use the -B parameter, iPerf3 will bypass the binding relationship between the host ip address and the physical network card.

2) iPerf3 will use the IP address specified by the -B parameter to send data.

3) iPerf3 will send the data from the physical NIC specified in the host routing table.

Table of contents

The -B option means to the client:

question:

Answers and conclusions (I don’t want to read the details, just read the conclusions below):

Test environment configuration:

Test without -B option:

There is -B option configuration:

first step:

second step,

third step,

Further tests with -B option:

first step:

Step two:

third step,

in conclusion:


Guess you like

Origin blog.csdn.net/meihualing/article/details/112390106