zhhyu7 opened a new pull request, #4196:
URL: https://github.com/apache/nuttx-apps/pull/4196
## Summary
This series brings netutils/iperf in line with the version used in Vela.
Command line:
- replace argtable with getopt_long; add long options, --devname to
pick the interface, -l/--len for the buffer length, and the missing
break after -a;
- -a now takes the pid of the instance to stop, so one of several
running servers can be stopped.
New transports:
- --vsock <cid> (AF_VSOCK), with the CID given as a number or a short
string;
- a netpoll UDP datapath benchmark (-N) when CONFIG_NET_NETPOLL is set
in a flat build.
Stop and error handling:
- stop by pid across task groups; block the stop signal in the report
thread so it reaches the traffic thread; wake and join the report
thread on stop; retry the abort and report an incomplete stop;
- free all resources when interrupted by Ctrl-C; close the TCP client
socket when connect() fails; do not report EINTR from our own stop
signal as a socket error.
Configuration:
- traffic/report task priority and stack size are Kconfig options; the
report task stack default is 8192 (4096 overflowed into the TLS area
and crashed in pthread_exit()).
## Impact
- iperf -a now requires a pid (iperf -a <pid>); the old "-a" without an
argument is gone. Users who scripted "iperf -a" have to pass the pid.
- New Kconfig options under NETUTILS_IPERF, all with defaults.
## Testing
sim:dynconns on the nuttx0 bridge, iperf 2.1.5 on the host. Same tests
on apache/master (with -B 10.0.1.2, since master has no --devname).
TCP client to the host:
```
iperf -c 10.0.1.1 -p 5001 -t 5 -i 1
IP: 10.0.1.2
mode=tcp-client sip=10.0.1.2:5001,dip=10.0.1.1:5001, interval=1, time=5
Interval Transfer Bandwidth
[ 1] local 10.0.1.1 port 5001 connected with 10.0.1.2 port 30266
0.00- 1.49 sec 208863232 Bytes 1118.91 Mbits/sec
1.49- 2.50 sec 0 Bytes 0.00 Mbits/sec
2.50- 3.51 sec 81920 Bytes 0.65 Mbits/sec
3.51- 4.52 sec 81920 Bytes 0.65 Mbits/sec
4.52- 5.53 sec 0 Bytes 0.00 Mbits/sec
0.00- 5.53 sec 209027072 Bytes 302.48 Mbits/sec
iperf exit
```
Stop an idle server (blocked in accept()) by pid, reuse the port, then
stop only one of two servers. This branch:
```
nsh> iperf -s -p 5301 &
iperf [8:100]
ps
6 6 5 100 FIFO Task - Running
0000000000000000 0067504 sh
8 8 6 100 FIFO Task - Waiting Semaphore
000000000000a404 0067472 iperf -s -p 5301
9 8 6 100 FIFO pthread - Waiting Semaphore
0000000000000000 0070608 iperf_traffic 0x4004bf20 0x79eb988858e0
nsh> iperf -a 8
iperf exit
Abort iperf process: 8
nsh> ps
6 6 5 100 FIFO Task - Running
0000000000000000 0067504 sh
nsh> iperf -s -p 5301 &
iperf [11:100]
$ iperf -c 10.0.1.2 -p 5301 -t 2 2>&1 | tail -1
[ 1] 0.0000-3.1195 sec 1.13 MBytes 3.03 Mbits/sec
accept: 10.0.1.1:35594
0.00- 3.01 sec 1146160 Bytes 3.05 Mbits/sec
closed by the peer: 10.0.1.1:35594
0.00- 3.01 sec 1146160 Bytes 3.05 Mbits/sec
iperf exit
iperf -s -u -p 5302 &
iperf [14:100]
$ iperf -c 10.0.1.2 -u -p 5302 -t 2 -b 10M 2>&1 | tail -2
[ 1] Sent 1788 datagrams
[ 3] WARNING: did not receive ack of last datagram after 10 tries.
accept: 10.0.1.1:55030
0.00- 3.01 sec 2768010 Bytes 7.36 Mbits/sec
3.01- 6.02 sec 152880 Bytes 0.41 Mbits/sec
iperf -s -p 5303 &
iperf [23:100]
6.02- 9.03 sec 0 Bytes 0.00 Mbits/sec
9.03- 12.04 sec 0 Bytes 0.00 Mbits/sec
iperf -s -p 5304 &
iperf [25:100]
udp server recv error, error code: 11, reason: Try again
12.04- 15.05 sec 0 Bytes 0.00 Mbits/sec
15.05- 18.06 sec 0 Bytes 0.00 Mbits/sec
iperf -a 23
iperf exit
Abort iperf process: 23
ps
6 6 5 100 FIFO Task - Running
0000000000000000 0067504 sh
14 14 6 100 FIFO Task - Waiting Semaphore
000000000000a404 0067456 iperf -s -u -p 5302
15 14 6 100 FIFO pthread - Waiting Semaphore
0000000000000000 0070608 iperf_traffic 0x4004bf20 0x79eb988750d0
20 14 6 101 FIFO pthread - Waiting Semaphore
000000000000a404 0073680 iperf_report 0x4004bb50 0x79eb988750d0
25 25 6 100 FIFO Task - Waiting Semaphore
000000000000a404 0067472 iperf -s -p 5304
26 25 6 100 FIFO pthread - Waiting Semaphore
0000000000000000 0070608 iperf_traffic 0x4004bf20 0x79eb988ca920
$ iperf -c 10.0.1.2 -p 5304 -t 1 2>&1 | tail -1
[ 1] 0.0000-2.2103 sec 896 KBytes 3.32 Mbits/sec
accept: 10.0.1.1:47576
closed by the peer: 10.0.1.1:47576
iperf exit
```
apache/master: "iperf -a" fails with "abort->count: 1", the server keeps
running and the port stays bound:
```
nsh> iperf -B 10.0.1.2 -s -p 5301 &
iperf [8:100]
ps
6 6 5 100 FIFO Task - Running
0000000000000000 0067504 sh
8 8 6 100 FIFO Task - Waiting Semaphore
0000000000000000 0067440 iperf -B 10.0.1.2 -s -p 5301
9 8 6 100 FIFO pthread - Waiting Semaphore
0000000000000000 0069584 iperf_traffic 0x4004e7b0 0x7601c7085b60
nsh> iperf -a
ERROR: abort->count: 1
nsh> ps
6 6 5 100 FIFO Task - Running
0000000000000000 0067504 sh
8 8 6 100 FIFO Task - Waiting Semaphore
0000000000000000 0067440 iperf -B 10.0.1.2 -s -p 5301
9 8 6 100 FIFO pthread - Waiting Semaphore
0000000000000000 0069584 iperf_traffic 0x4004e7b0 0x7601c7085b60
nsh> iperf -B 10.0.1.2 -s -p 5301 &
iperf [11:100]
tcp server bind error, error code: 98, reason: Address already in use
```
Connect to a closed port returns and leaves no task behind:
```
nsh> iperf -c 10.0.1.1 -p 5999 -t 1
IP: 10.0.1.2
mode=tcp-client sip=10.0.1.2:5001,dip=10.0.1.1:5999, interval=3, time=3
tcp client connect error, error code: 111, reason: Connection refused
iperf exit
```
Also built: CONFIG_NET_NETPOLL=y (netpoll mode compiled in).
Known cosmetic issue: a successful "iperf -a <pid>" also prints the
usage text (the abort path jumps to the usage label). Same as in the
Vela tree; left for a follow-up.
checkpatch.sh -c -u -m -g passes for every commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]