
I am sure, folks working on Networking technologies must have used iPerf at least once in their lifetime. It is a good testing tool for Network bandwidth validations for tcp/udp applications. Have you ever noticed that iPerf opens up one more tcp session apart from the data connection!
Check this, I started a iPerf tcp session,
at client:[root@rhos-nfv-07 ~]# cat /proc/net/nf_conntrack
ipv4 2 tcp 6 431996 ESTABLISHED src=6.6.6.6 dst=6.6.6.192 sport=38774 dport=5201 src=6.6.6.192 dst=6.6.6.6 sport=5201 dport=38774 [ASSURED] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=2
ipv4 2 tcp 6 300 ESTABLISHED src=6.6.6.6 dst=6.6.6.192 sport=38776 dport=5201 src=6.6.6.192 dst=6.6.6.6 sport=5201 dport=38776 [ASSURED] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=6
at server:[root@computesriov-0 tripleo-admin]# cat /proc/net/nf_conntrack
ipv4 2 tcp 6 432000 ESTABLISHED src=6.6.6.6 dst=6.6.6.192 sport=38774 dport=5201 src=6.6.6.192 dst=6.6.6.6 sport=5201 dport=38774 [ASSURED] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=16
ipv4 2 tcp 6 431990 ESTABLISHED src=6.6.6.6 dst=6.6.6.192 sport=38776 dport=5201 src=6.6.6.192 dst=6.6.6.6 sport=5201 dport=38776 [ASSURED] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=2
Similarly when i started iPerf udp session,
at client:
[root@rhos-nfv-07 ~]# cat /proc/net/nf_conntrack
ipv4 2 udp 17 119 src=6.6.6.6 dst=6.6.6.192 sport=41988 dport=5201 src=6.6.6.192 dst=6.6.6.6 sport=5201 dport=41988 [ASSURED] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=2
ipv4 2 tcp 6 431994 ESTABLISHED src=6.6.6.6 dst=6.6.6.192 sport=38778 dport=5201 src=6.6.6.192 dst=6.6.6.6 sport=5201 dport=38778 [ASSURED] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=2
at server:[root@computesriov-0 tripleo-admin]# cat /proc/net/nf_conntrack
ipv4 2 udp 17 119 src=6.6.6.6 dst=6.6.6.192 sport=41988 dport=5201 src=6.6.6.192 dst=6.6.6.6 sport=5201 dport=41988 [ASSURED] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=2
ipv4 2 tcp 6 431997 ESTABLISHED src=6.6.6.6 dst=6.6.6.192 sport=38778 dport=5201 src=6.6.6.192 dst=6.6.6.6 sport=5201 dport=38778 [ASSURED] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=2
This extra tcp session gets closed when iPerf data connection ends. Moreover, this extra session does not send/receive traffic during the test except at the beginning and at the end. Then what is the purpose of this extra tcp session?
Let me quickly spill the beans, This is called control connection, iperf uses a control connection between the client and server to manage the start and end of each test. The initial TCP connection is used to exchange test parameters at the start and end of the test, and to exchange test results.
So, what are those parameters?
I started a test iperf udp session between server and client,
Server:
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 6.6.6.192, port 39846
[ 5] local 6.6.6.6 port 5201 connected to 6.6.6.192 port 49424
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 5] 0.00-1.00 sec 116 KBytes 950 Kbits/sec 2.870 ms 0/82 (0%)
[ 5] 1.00-1.04 sec 0.00 Bytes 0.00 bits/sec 2.870 ms 0/0 (0%)
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 5] 0.00-1.04 sec 0.00 Bytes 0.00 bits/sec 2.870 ms 0/82 (0%)
-----------------------------------------------------------
Client:
[root@computesriov-0 tripleo-admin]# iperf3 -c 6.6.6.6 -u -t 1
Connecting to host 6.6.6.6, port 5201
[ 4] local 6.6.6.192 port 49424 connected to 6.6.6.6 port 5201
[ ID] Interval Transfer Bandwidth Total Datagrams
[ 4] 0.00-1.00 sec 116 KBytes 950 Kbits/sec 82
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 4] 0.00-1.00 sec 116 KBytes 950 Kbits/sec 2.870 ms 0/82 (0%)
[ 4] Sent 82 datagrams
At beginning, client sent
- Hostname “computesriov-0.1688909593.908726.6a7”, “
- {“udp”:true,”omit”:0,”time”:1,”parallel”:1,”len”:1448,”bandwidth”:1048576,”client_version”:”3.1.7″}” over tcp connection
and towards the end,
- {“cpu_util_total”:3.943944,”cpu_util_user”:0.157469,”cpu_util_system”:3.786289,”sender_has_retransmits”:0,”streams”:[{“id”:1,”bytes”:118736,”retransmits”:-1,”jitter”:0,”errors”:0,”packets”:82}]}”.
I dont see any meaningful data from server side at the beginning of the tcp session, However, towards the end,
- “”cpu_util_total”:0.006886,”cpu_util_user”:0,”cpu_util_system”:0.006879,”sender_has_retransmits”:-1,”streams”:[{“id”:1,”bytes”:118736,”retransmits”:-1,”jitter”:0.002870,”errors”:0,”packets”:82}]}”
Now, “show me the code” section, Look at below code lines.
1) src/iperf_tcp.c: s = create_socket(test->settings->domain, SOCK_STREAM, test->bind_address, test->bind_dev, test->bind_port, test->server_hostname, test->server_port, &server_res);
2) src/iperf_udp.c: s = netdial(test->settings->domain, Pudp, test->bind_address, test->bind_dev, test->bind_port, test->server_hostname, test->server_port, -1)
3) src/iperf_client_api.c: test->ctrl_sck = netdial(test->settings->domain, Ptcp, test->bind_address, test->bind_dev, 0, test->server_hostname, test->server_port, test->settings->connect_timeout);
1st and 2nd functions are called when data path established for actual user test for tcp and udp respectively, 3rd is called when control connection has to establish. So client initiate 2 sessions,1 for data traffic and another is tcp control connection, port number for control connection is derived from data traffic connection while server uses the same port for both data and control connection as show in connection tracking table earlier.
Now, if someone asks or says iperf in the interview, you know what to do :-).