Undefined iperf3 ports?

Undefined iperf3 ports?

Я пытаюсь определить все порты, связанные с сеансом UDP iperf3, и замечаю, что TCP-рукопожатие использует неопределенный(?) порт на сервере iperf3.

Есть ли способ указать все порты, используемые для теста iperf3?

Иллюстрирующий пример:

In this example, I am observing the following IP addresses and ports used:

  • [client] 10.0.1.20, port 5222
  • [server] 10.0.1.89, port 5205
  • [client] 10.0.1.20, port 56039 ????

Client:

// iperf3 (v3.1.3) Client running on Ubuntu 16.04 IP address: 10.0.1.20, port 5222
$ iperf3 -c 10.0.1.89 -u -p 5205 --cport 5222 -B 10.0.1.20

Server:

// iperf3 (v3.1.3) Server running on Ubuntu 16.04 IP address: 10.0.1.89, port 5205
$ iperf3 -s -p 5205
-----------------------------------------------------------
Server listening on 5205
-----------------------------------------------------------
Accepted connection from 10.0.1.20, port 56039
[  5] local 10.0.1.89 port 5205 connected to 10.0.1.20 port 5222
[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
...

This is also confirmed by a wireshark capture running on the client.

решение1

No, it is not possible to set this client port through a command line argument, neither using the iperf API.

This at least applies for the current 3.1 iperf version. Looking at the source code, it is possible to find the function responsible for establishing the initial TCP connection:

/* iperf_connect -- client to server connection function */
int
iperf_connect(struct iperf_test *test)
{
[...]
    /* Create and connect the control channel */
    if (test->ctrl_sck < 0)
        // Create the control channel using an ephemeral port
        test->ctrl_sck = netdial(test->settings->domain, Ptcp, test->bind_address, 0, test->server_hostname, test->server_port, test->settings->connect_timeout);

    if (test->ctrl_sck < 0) {
        i_errno = IECONNECT;
        return -1;
    }
[...]

Looking at the netdial() function signature, which is responsible for creating the connection to a server:

netdial(int domain, int proto, char *local, int local_port, char *server, int port, int timeout)

More specifically, we can see that it sets the netdial() local_port parameter as 0. This should establish a random port to the client side when creating the TCP control channel.

As Thomas mentioned, the --cport option will only control the data streams port and we can also check that looking at the source code for the function responsible for establishing the UDP data stream:

 if ((s = netdial(test->settings->domain, Pudp, test->bind_address, test->bind_port, test->server_hostname, test->server_port, -1)) < 0) 

This function uses the test->bind_port option as the local_port parameter, which is retrieved from the --cport option.

решение2

On the iperf3 website there is a description on this behaviour.

...The initial TCP connection is used to exchange test parameters, control the start and end of the test, and to exchange test results. This is sometimes referred to as the "control connection". The actual test data is sent over a separate TCP connection, as a separate flow of UDP packets, or as an independent SCTP connection, depending on what protocol was specified by the client...

Looking at the man iperf3 and the option --cport, this seems to only affect the data streams and not affecting the control connection which is the third port you are identifying as undefined port.

Связанный контент