1
1
Граф коммитов

772 Коммитов

Автор SHA1 Сообщение Дата
Bruce A. Mah
b0aff8490a Fix a few printf format string warnings seen on macOS / clang. (#593) 2017-06-05 10:57:07 -07:00
Bruce A. Mah
b5597278b5 Towards issue #278. Don't print small, dataless last intervals. (#592)
This is mostly a cosmetic fix...due to timing differences or
interference from data packets, it is possible that the server
will have a very small last measurement window, possibly with
no data transferred.  This looks odd (although it's not incorrect)
and we'd like to eliminate these.  If there's an interval
(presumably it'd be the last measurement interval) less than
10% of the length of a standard measurement/reporting interval,
and there are no bytes transferred in the interval, then suppress
printing the results and don't add them to the grand total.
2017-06-05 10:38:36 -07:00
Bruce A. Mah
7f06146221 Fix out-of-order / loss counting issues with UDP (#457) (#589)
* Towards issue #457.  Try to not count the sequence number
gaps resulting from out-of-order packets as actual losses.

* Put all of the UDP diagnostic output behind the --debug flag.
2017-06-02 09:35:19 -07:00
Bruce A. Mah
c458a115b7 Fix -F problems (#588)
Attempt to fix some brokenness in -F from #301.

In some work related to #125, we introduced a bug in which
chunks of a file being read for the -F option were not
completely sent, particularly with TCP sockets.  We attempt
to fix this by detecting cases in which not all data passed
to a socket could be actually sent (for example due to full
socket buffers) and preserving that data for future send
iterations.

The ending statistics in the "diskfile" JSON structure were
wrong, and did not properly distinguish between sender-side
and receiver-side statistics.  This has been fixed (at least
for the client side).

Specifically mention in the manpage that "iperf -F" is not
a file transfer tool.
2017-05-30 14:15:28 -07:00
Kenneth Wong
acb4c4c9d5 Improve C++ compatibilty (#587)
Improve the compatibility of iperf_api.h with C++ so that libiperf can more easily be used with C++ programs.

This involves function declarations as extern "C" and inclusion of a couple of more headers (which arguably improves the C use case).
2017-05-30 13:30:08 -07:00
Bruce A. Mah
39de1e0f27
Merge branch 'master' of github.com:esnet/iperf 2017-05-24 11:08:37 -07:00
Bruce A. Mah
3410d58fdc
Silence a warning for an unused variable. 2017-05-24 11:08:15 -07:00
Bruce A. Mah
0f081b7b2e Issue 583 (#586)
* s/bandwidth/bitrate/ in user-facing places.  Towards #583.

iperf3 has long misused terminology; bandwidth is a measure of
capacity.  iperf3 measures bitrate or throughput.  We standardize
on "bitrate" because it begins with the same letter as "bandwidth"
(to match the -b command-line option).

User-facing output mentioning "bandwidth" now uses "bitrate".
The long command-line option for -b (--bandwidth) is now --bitrate
(--bandwidth is transparently accepted for backward compatibility).
A few places in documentation that talk about bandwidth as a
measured value have been reworded to use bitrate or throughput.

There are a number of places in code where variables are still
called "bandwidth".  We leave these alone for now.

A mention of "bandwidth" in the test parameters JSON also needs
to remain unchanged to avoid breaking compatibility.  However,
the test results JSON never used the term "bandwidth" in
the first place.

* s/bandwidth/throughput in one place in RPM description.  Towards #583.
2017-05-24 10:50:44 -07:00
Bruce A. Mah
7a15a7ae85 Fix another compiler warning. 2017-05-23 13:05:09 -07:00
Bruce A. Mah
dc74346f26
Fix compiler warning with clang. 2017-05-23 12:52:16 -07:00
Sami Farin
e7ab564cb5 Return random ascii-string in make_cookie. (#582)
Having hostname and microsecond timestamp in the cookie is not
necessary.  Also fill test buffer with data from /dev/urandom
instead of using random().
2017-05-21 11:30:18 -07:00
Bruce A. Mah
2541b86174
Bump manpage date. 2017-05-18 16:39:55 -07:00
Brian Tierney
0c4d5992fd clarified a couple options 2017-05-18 11:43:50 -07:00
Bruce A. Mah
9d7d60aca1 Issue 216 (#581)
* Add configurable timeout for the setup of the control connection.
This is specified using the new --connect-timeout option, with an
integer parameter in ms.  The iperf3 client will wait for this
amount of time for the setup of the control connection to the
server.  If this option is not given, the OS default for TCP
connection setup is used.  Specifying a smaller connection timeout
allows faster detection of a down / unresponsive iperf3 server.

The implementation uses a variation on the timeout_connect()
function from OpenBSD's netcat utility.

Fixes #216.
2017-05-17 12:50:50 -07:00
Bruce A. Mah
52375c105a Grab TCP PMTU during tests (on Linux only). Towards #569. (#578) 2017-05-12 13:42:50 -07:00
Bruce A. Mah
d54d49c0ac
Don't free memory in uninitialized structures
Also, tighten up the scope/lifetime of some memory structures.

Inspired by #577.
2017-05-12 09:12:48 -07:00
Bruce A. Mah
35ec9e545a Bunch of reporting fixes found while investigating bug #236. (#575)
For the case of multiple TCP streams, compute the grand total
summaries using the appropriate times for the sender and receiver
ends.

Add some divide-by-zero checks.

On the server side, only print the side of the grand total lines
where we have data.  (This follows the behavior of the other
end-of-test output lines.)

Fix a minor (compared to all the other problems) bug with
UDP output printing the wrong ending timestamp.
2017-05-11 14:12:16 -07:00
Bruce A. Mah
8f0d9c47ec
Print the cJSON version in our version info. 2017-05-11 12:31:22 -07:00
Bruce A. Mah
c71712875a Fix NaN in summaries with a client talking to an iperf 3.1/3.0 server.
Recent code changes require the server to send the start and end
timestamps for a test, so that the client can accurately compute
statistics for the sender side of a test.  iperf 3.1 and 3.0
servers won't do this, so if this information isn't passed back
in the results at the end of a test, we fall back to using the
client's timestamps.  The results might not match what's displayed
on the server, but this is basically what iperf 3.1 and earlier
did anyway.

Fixes #574.
2017-05-11 11:40:14 -07:00
Bruce A. Mah
cab5dba86c Import cjson 1.5.2 (#573)
* Import source files for cJSON 1.5.2.

* Portability and 64-bit changes for cJSON.
2017-05-11 10:17:34 -07:00
Bruce A. Mah
e255a12eb9 Fix problems in human-readable UDP output
Keep track of UDP packets sent/received and use appropriately.

We were using the number of UDP packets seen on the server
(regardless of whether it was the sender or receiver) for
computing loss percentages, etc.  This caused confusion in the
case that the last UDP packet doesn't make it to the server
before the test finishes (or if a packet gets lost), because
the client and server had different ideas of how many packets were
sent (OK) and we used the wrong number when computing statistics.

This fix changes the human-readable output to make more sense.
It doesn't change the JSON output.  That needs some more review.
I'm reluctant to make structural changes to the JSON output,
because other programs rely on that format.

We also need to investigate whether the last UDP packet can be
still in flight when the test ends (per hypothesis), and if so
what we should do about this.

We apply similar fixes for human-readable summaries for multi-stream UDP tests.

The fixes are similar to those already done for the stream
summary statistics, but these cover a type of output that's only
done if there is more than one stream.

Adjust the JSON computations / output to do a better job of figuring
out the total number of packets sent.

We really need to disentangle the computation and output formatting,
these two operations shouldn't be mixed together like this.

Fixes #252.
2017-05-09 14:29:22 -07:00
Bruce A. Mah
37d913dfcc Improve error handling and documentation for -f/--format. (#568)
We now reject all invalid format characters given as the
argument to the -f/--format flag.  All valid characters are now
documented in the usage message and manual page.

Towards #566.
2017-05-08 10:01:15 -07:00
Bruce A. Mah
67653543ad
Improve / fix comments regarding UDP jitter calculation.
Internal documentation fix only, no functional change.
2017-05-05 08:59:13 -07:00
Bruce A. Mah
103d4318e8 Fix a heap corruption issue leading to a server-side crash. (#564)
Commit 5ab2132c (PR #551) fixed, among other things, a memory
leak.  The solution, however, causes a hazard where a free() of
an invalid pointer can corrupt the heap.  We've observed this
fairly repeatably while running the test_commands.sh script on
CentOS 7.

To remedy this, we NULL out a pointer after the object it
pointed to has been free-d, just like a number of other similar
objects.
2017-05-04 14:16:42 -07:00
Bruce A. Mah
5abc5f29b7
IRIX 6.5 compatibility, via a patch from @canavan in #368.
Not independently tested.
2017-05-04 09:03:43 -07:00
Bruce A. Mah
cba8584b2d Pacing timer (#563)
* Add --pacing-timer option to allow tuning of -b timers.
These control the granularity of the timer and hence burstiness
of iperf3's sends.  The default is 1ms (1000), which is the default
starting with iperf 3.2.  Follow-on to the commit in #460.

* Update manpage and release notes for --pacing-timer.
2017-05-03 16:18:32 -07:00
Bruce A. Mah
e73821cd03 Normalize socket buffer debugging output, put socket buffer sizes in JSON.
These values show up in the start structure as sock_bufsize (requested
size), sndbuf_actual (actual SO_SNDBUF value) and rcvbuf_actual (actual
SO_RCVBUF value).  These values are available for both TCP and UDP.
Both client and server emit these values in their JSON output for their
respective sides, but don't exchange them.

Towards #558.
2017-05-03 14:03:22 -07:00
Bruce A. Mah
246c1bcacd Remove some dead code. 2017-05-03 12:25:32 -07:00
Bruce A. Mah
10e2cc241e Fix various problems with summary statistics (#562)
* Untangle some problems with printing summary statistics.

There were (at least) two problems:

o The server cannot print summary statistics as seen from the
client, because the server has to generate its summaries
before receiving any statistics from the client.  This
shortcoming is somewhat hard-coded into the semantics of
messages on the control channel, and probably can't be easily
changed.

o UDP summary statistics for each stream were ambiguous in that
it wasn't clear whether they were intended to apply to the
sender or receiver.

To fix this, we split UDP summary statistics into two lines,
one for the sender side and one for the receiver side.  This
hopefully eliminates any ambiguity about the statistics.  On the
server, we don't attempt to print the (not very meaningful and
potentially misleading) statistics corresponding to the client.

Possible fix for #560.

* Try to report more accurate ending statistics.

Basically the client side was using only its measured test duration
to compute figures such as bitrate, but the server's test duration
could be different due to network delays/jitter.  So we make sure
that the test durations (for each stream) are passed in the test
results and used appropriately when we print statistics for the
sender and receiver.

Towards #560, also this could help towards #238.

* Silence a warning over an uninitialized variable.
2017-05-03 10:21:34 -07:00
Bruce A. Mah
c8531ca31f
Fix possible integer overflow in tera prefix conversions.
Follow-on commit for #402, possible fix for #561.
2017-05-02 10:21:59 -07:00
Bruce A. Mah
65ed04deb5
Fix bug introduced in 03224c9 where we fail on default UDP blocksize.
Fixes #559, follow up to #390..
2017-05-01 09:14:21 -07:00
Bruce A. Mah
7f996b5e98 Print TOS byte value.
It's at the start of the test output for human-readable output, and in
the test_start object in the JSON.

Fixes #226.
2017-04-27 12:47:03 -07:00
Bruce A. Mah
9c033cbf68 Do sanity checks on -w argument as floating point to avoid integer
overflows.  There might be some other places where this applies,
but this commit at least fixes the observed bug.  Fixes #557.
2017-04-27 11:35:56 -07:00
Gabriel Ganne
d1c64c8a36 fix invalid sizeof on pointer instead of type (#556)
This is only a coherency fix since sizeof(char*) >> sizeof(char)
There should be no functional nor stability impact whatsoever
2017-04-26 10:08:53 -07:00
Bruce A. Mah
b9478db947
Fix a problem when getting snd_cwnd on FreeBSD.
On FreeBSD, unlike Linux (and NetBSD?) snd_cwnd is expressed in
octets instead of segments.  Hilarity ensued when we erroneously
multiplied by snd_mss and integer overflows occureed.

Possible fix for #465, #475, #338.  Testing from FreeBSD users
appreciated.
2017-04-22 07:56:31 -07:00
Bruce A. Mah
89e97f05e0
Manpage fixups. Follow-up to #517. 2017-04-20 17:48:22 -07:00
Bruce A. Mah
4dfe721b10
Merge branch 'master' of git://github.com/dmdailey/iperf into dmdailey-master 2017-04-20 14:13:33 -07:00
Gabriel Ganne
5ab2132ce3 warning fixes (#551)
* fix Wstrict-prototypes warnings found by clang

also fix usage_long() call

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix Wunreachable-code-break warnings found by clang

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix Wshadow warnings found by clang

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix Wmissing-noreturn warning found by clang

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* ix memory leak found by clang

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix Wmisleading-indentation warnings raised by gcc-6

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix warning: Value stored to 'ptr' during its initialization is never read found by clang

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix warning: The left operand of '>' is a garbage value found by clang

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix memory leak in global cleanup

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>
2017-04-20 13:33:15 -07:00
Bruce A. Mah
5e52a8460b
Regen. 2017-04-20 12:38:18 -07:00
Bruce A. Mah
02d411cb02
Fix some help text. Add authentication as a feature in --version.
Follow-up to #517.
2017-04-20 12:26:39 -07:00
asavah
ac2604dda8 fix missing source files in src/Makefile.am (#554)
Follow-up fix for #517.
2017-04-20 12:09:44 -07:00
ralcini
a51045de19 Service Authentication (#517)
Add an optional mode that requires clients to authenticate with the server.

In this mode, clients need to provide a username and a password, which are checked against a password file on the server.  The authentication credentials are protected by an RSA public keypair...the encrypted credentials are sent along with the test parameters.

Operationally the use of this feature places the following additional requirements on the build and installation of iperf3:

o The presence of the OpenSSL headers and libraries to build iperf3, and the libraries available on the client and server at runtime.

o Generation of an RSA public keypair; the private part is used by the server and the public part must be distributed to the clients.

o Username/password pairs for all authorized users, to be stored in a file on the server.

o Loose time synchronization between the server and clients (to within approximately 30 seconds).

o Appropriate command-line flags given on the client and server.

Note that iperf3 can be built and run as before, without fulfilling any of these requirements.

Partial documentation for this feature is included in this commit.  It is anticipated that additional documentation text and editing will follow this merge.

Submitted by @ralcini.  First suggested by @codyhanson in pull request #242.
2017-04-20 10:01:08 -07:00
Bruce A. Mah
05600c201a
Minor follow-ups to #508.
Change the internal command-line option code for --dscp from the literal
'5' to a constant defined as OPT_DSCP.

Add manpage text for --dscp option.

Tweak help text for --dscp (while here, fix problem in --tos text).
2017-04-14 13:44:32 -07:00
Bruce A. Mah
a68712c7a8
Regen, follow up to #508. 2017-04-14 13:29:25 -07:00
Dave Täht
97c95c3be2 add support for specifying --dscp symbolically and numerically (#508)
Using a command line adding dscp (instead of tos) you can:

--dscp EF,CS1,etc.
--dscp 0x08
--dscp 63

These will provide the correct shifted left 2 tos value for these, and
for people that think in terms of dscp values, this is a goodness.

Having this option available lets an enduser clearly distinguish between
an old version of iperf with a non-working --tos facility, vs a
version where it works, with something saner that lets just specify
the dscp.

I did not come up with a good -? option for it, and used -5 internally.
2017-04-14 13:27:18 -07:00
Bruce A. Mah
e9e2d6d19c
Add support for tera- prefix [Tt] in input and output.
Also add some more unit tests for this and prune unused code
from unit test program.

Fixes #402.
2017-04-14 13:14:44 -07:00
Bruce A. Mah
d51501ef83
Make explicitly requested usage output (--help) go to stdout.
Also in this case make the process exit code 0.

Fixes #405.
2017-04-14 12:45:24 -07:00
Bruce A. Mah
b07ed14dae
Be more explicit about the direction of data during tests.
Documentation change only, no functional change.
Fixes #384.
2017-04-14 12:36:47 -07:00
Bruce A. Mah
08758a16d2 More gracefully handle the case where a congestion control
algorithm isn't available on the server.  This can happen
if the client and server machines have different sets of
congestion control algorithms loaded in kernel modules, etc.
If the requested algorithm isn't available on the server, then
print a warning on the server side, but otherwise continue to
run the test.

Towards #549.
2017-04-11 15:11:17 -07:00
Bruce A. Mah
6f414a0408
Ignore SIGPIPE signals to simplify error handling.
This is an attempt to avoid server-side crashes/exits when the
client abruptly closes its control connection, as found in some
testing for #549.

Fixes #550.
2017-04-11 15:06:01 -07:00
Bruce A. Mah
03224c9f56 Prevent specifying a UDP send size that's too small.
We need at least 16 bytes to hold counters and timestamps.
Avoids a problem noted in issue #390.
2017-04-11 09:43:41 -07:00
Tran Viet Hoang
5d14d10697 add tcp rttvar to stream info (#534)
Fixes #525.
2017-03-30 16:29:16 -07:00
Bruce A. Mah
8066a1d222
Fix divide-by-zero / weird output with -F and a zero-length file.
Fixes #361.
2017-03-30 15:33:20 -07:00
f1rebird
a8ee9c650b Fix header includes and build failures on musl (#518)
* Include stdint.h in files where its types are used

Signed-off-by: Moritz Kick <f1rebird@users.noreply.github.com>

* Fix type of len parameter passed to getsockopt

getsockopt expects socklen_t instead of int as its fifth argument

Signed-off-by: Moritz Kick <f1rebird@users.noreply.github.com>

* Remove unnecassary includes of netinet/tcp.h

also cleanup the second include of stdint.h in main.c

This commit fixes #331 and is a replacement for #344.

Signed-off-by: Moritz Kick <f1rebird@users.noreply.github.com>
2017-03-22 12:00:08 -07:00
Bruce A. Mah
b3828fed23
Change "iperf" to "iperf3" in usage strings. Fixes #529. 2017-03-17 07:59:15 -07:00
ShaunCurrier
9f28b247ba Remove unused hstrerror(), bad nanosleep() message in configure.ac (#503) (#523)
* Remove unused hstrerror(), bad nanosleep() message in configure.ac (#503)

* Remove dead code involving h_errno and hstrerror()

h_errno was formerly set as a side effect of a failed
gethostbyname(3) call, but this function has been
deprecated.
2017-03-13 09:36:45 -07:00
Bruce A. Mah
f46e2e3edc Prevent two recently added messages from spamming JSON output on UDP tests.
Stumbled on by:	@daldoyle
2017-02-02 09:23:29 -08:00
Bruce A. Mah
7c79294b5b
Fix a bug where specifying --title leaked into server JSON in future runs.
Fixes #500, based on pull request in #501 submitted by @slankes.
2017-01-25 14:42:15 -08:00
Bruce A. Mah
de3e9d49b6 Revert "Fail gracefully if --fq-rate or --no-fq-socket-pacing are specified on"
This reverts commit 9c83a707eb.

Fixes #504.
2017-01-25 13:53:49 -08:00
Bruce A. Mah
1ff12f4c3e Add 1KB to default UDP socket buffer sizes under certain circumstances.
This fixes a problem observed on FreeBSD and macOS where the MTU on
the loopback interface is larger than the default socket buffer size.
We adjusted the socket buffer size upwards to match the UDP payload
size, but that's apparently not enough and we ended up dropping packets.
This is bad.  Add a 1KB fudge factor, which seesm to avoid this problem.
Affects UDP tests only, not TCP or SCTP.

Part of #496.

(cherry picked from commit d76198944d210e8a575747d3ddbee41a886a10c9)
Signed-off-by: Bruce A. Mah <bmah@es.net>
2017-01-11 11:52:18 -08:00
Bruce A. Mah
0fd60a3686 Issue 496 (#498)
* Dynamically determine an appropriate default UDP send size.

We use the TCP MSS for the control connection as the default UDP
sending length, if the --length parameter is not specified for a
UDP test.  This computation replaces the former hard-coded 8K
default, which was way too large for non-jumbo-frame Ethernet
networks.

The concept for this solution was adapted from nuttcp.  The
iperf3 implementation is pretty easy since we already were
getting the MSS for the control connection anyway (although we
needed to get it slightly earlier in the setup process to be
useful).

Towards issue #496.

While here, s/int/socklen_t/ in one place to fix a compile warning,
and bump a few copyright dates.

* Warn if doing a UDP test and the socket buffer isn't big enough.

This is surprisingly an issue on FreeBSD and macOS, where the MTU
over the loopback interface is actually larger than the default
UDP socket buffer size.  In these cases, doing a UDP test over the
loopback interface (with the new UDP defaults) will fail unless a
smaller --length or a larger --window size is set explicitly.

Linux has larger UDP socket buffers by default (much larger than the
largest possible MTU), but even in the case that the socket buffers
are too small to hold an MTU-sized send, the kernel seems to do the
send correctly anyway.

Still working towards a good solution for issue #496.

* Further refinement on UDP buffer size settings.

If the default buffer size on a UDP test can't hold a packet,
then increase the buffer size to be large enough to hold one
packet payload.  (If the buffer size was explicitly set, but too
small to hold a packet payload, then warn but don't change the
buffer size.)

Minor code refactoring to...factor out some common code into
a new iperf_udp_buffercheck() function.

Still working towards issue #496.
2017-01-10 09:13:57 -08:00
Bruce A. Mah
9c83a707eb
Fail gracefully if --fq-rate or --no-fq-socket-pacing are specified on
platforms where they aren't supported.

Requested by:	@bltierney
2016-12-14 09:32:46 -08:00
Bruce A. Mah
a094d9feef Separate out application-level and fair-queueing-based pacing (#488)
* First try to fix pacing issues.  Code compiles, lightly run-tested.

Make --bandwidth only control application-level pacing, refecting
behavior of iperf 3.1.2 and earlier.

Add a new --fq-rate that controls only FQ-based per-socket pacing.
A given test can use application-level pacing, FQ pacing, both,
or neither.

Deprecate the --no-fq-socket-pacing option; specifying this generates
a warning and is equivalent to --fq-rate=0.

Towards issue #467 and related to issue #325.

* Move --fq-rate in the help text to be just below --b, tweak wording.

* Sigh.  One more tweak on help text.

Some day I probably need to review and rewrite the whole thing.

Still working towards #467.
2016-12-12 13:47:53 -08:00
Bruce A. Mah
7d2d5c41dd
Revert "Fix a bug in FQ pacing, where application pacing wasn't completely disabled."
This reverts commit 1fa41308fe.

This doesn't really do what we want.  Start over.
2016-12-08 15:25:06 -08:00
Bruce A. Mah
5307eae461
Revert "Reduce the default UDP send size to 1452 to avoid IP fragmentation"
This reverts commit f1e62c8d48.

Right idea, but it turns out to be a pretty high-impact change.
Need to rethink this, maybe with a more intelligent implementation
that checks the interface (or path?) MTU.
2016-12-08 15:23:51 -08:00
Bruce A. Mah
f1e62c8d48
Reduce the default UDP send size to 1452 to avoid IP fragmentation
with default parameters.

A UDP payload of 1452, plus an 8-byte UDP header, plus a 40-byte IPv6
header, results in a 1500 byte IP packet.  The IPv4 header is smaller
at 20 bytes.
2016-12-05 14:00:15 -08:00
Bruce A. Mah
1fa41308fe
Fix a bug in FQ pacing, where application pacing wasn't completely disabled.
It was therefore possible to have multiple levels of pacing happening,
which resulted in very nicely smoothed traffic, but wasn't really
the original design.

Do pacing correctly in iperf_check_throttle() and remove a hack in
iperf_send() where we were explicitly checking for the type of
pacing, but didn't really need to.

It turns out that with UDP and only-FQ pacing, iperf3 sends and throws
packets on the floor as fast as it can.  This isn't really desirable,
and probably not what was wanted in a test anyway, so if we're not
doing TCP tests, force the use of application-level pacing.
2016-12-05 10:37:56 -08:00
Bruce A. Mah
55598a072f
Fix socket buffer size checks. Clearly this wasn't tested well.
On Linux it's possible to set the socket buffer to one size but
(correctly it seems) get back some larger size up to 2x what you
asked for (see tcp(7)).

While here, make related debugging output more useful.

Fixes (again) #356.
2016-12-01 11:53:37 -08:00
Bruce A. Mah
a621cc263f
Improve debug output for application and fair-queue-based pacing. 2016-11-30 07:13:28 -08:00
Bruce A. Mah
d2202ee3be
After setting socket buffer sizes, verify they were set correctly.
Do this for both TCP and UDP, but not SCTP (which strangely doesn't
support --window, that's probably a bug).  Fixes #356.
2016-11-23 11:05:47 -08:00
Bruce A. Mah
6aff679e96
Fix executable name and date in the manpage heading. 2016-11-10 13:49:44 -08:00
Nevo Hed
ad2a706fd1 Replace iprintf w/ iperf_printf (cygwin conflict) (#468)
This does not seek to address all cygwin portability issues
just this specific compile-time conflict

See also #280 and #295.
See https://github.com/esnet/iperf/issues/280
2016-10-17 13:25:07 -07:00
Bruce A. Mah
d99a69f92b
Fix a buffer overflow in upstream cJSON.
This is DaveGamble/cJSON#30, and fixes issue #466.
2016-10-05 13:59:40 -07:00
Bruce A. Mah
1a756a949e Only print congestion control algorithm for a TCP test.
Properly (I think) label the two TCP instsances as "sender"
and "receiver".
2016-09-22 15:27:24 -07:00
Bruce A. Mah
7d413a5015 Fix build on FreeBSD. 2016-09-22 14:52:57 -07:00
Bruce A. Mah
7eeaa1cb07 First try at issue #461.
First, realize that we've been setting the congestion control (CC)
algorithm unnecessarily; rather than doing it for all listening or
connecting sockets, do it just for those sockets that are being used
for TCP test streams.

Record the CC algorithm in use (this handles the case where a CC algorithm
hasn't been specified), and have the client and server exchange this
information.

Report the CC algorithms that were used (note that it's theoretically
possible for the two ends of the test to be using different algorithms,
if no algorithm was explicitly specified and the two end hosts have
different defaults, or if one side allows setting the CC algorithm and
the other doesn't).

Committing to a branch to make it easier to test this code on a
wider combination of systems.
2016-09-22 13:34:52 -07:00
Bruce A. Mah
353615b772
Fix divide-by-zero problem that can occur with a zero-length interval
(this can happen at the end of a test under certain circumstances).
Fixes #388, alternate solution from pull request in #389.
2016-09-21 13:22:54 -07:00
Bruce A. Mah
03340fe595
Prevent a double-close on the server side in some cases.
Alternate solution to a problem pointed out by @g-coder in pull request #429.
2016-09-21 11:25:18 -07:00
woody77
93c498d417 Change pacing timer from 100ms to 1ms to smoothen out microbusts as much as possible (#460) 2016-09-21 10:31:48 -07:00
woody77
14caac895c Properly setting the no_fq_socket_pacing option when support for it is not compiled in. (#459) 2016-09-21 10:21:59 -07:00
dmdailey
f7fd67d4a2 Update iperf_server_api.c
When a test in in progress and the client completely disappears, both the control socket and the stream sockets are left around forever.  Patch modified from another patch submitted by mkall to add closing of the data stream sockets.
2016-08-05 16:41:52 -04:00
Bruce A. Mah
b7ab2b4b25
Make the server more tolerant of most types of errors encountered
during tests.

We used to exit if 5 consecutive errors were encountered.  Instead,
only exit if certain types of fatal errors happen.
2016-06-03 09:26:05 -07:00
Bruce A. Mah
4dcb275b5b
Make error handling on the control channel more robust. 2016-06-03 09:25:14 -07:00
Bruce A. Mah
ed94082be2
Fix a buffer overflow / heap corruption issue that could occur if a
malformed JSON string was passed on the control channel.  This issue,
present in the cJSON library, was already fixed upstream, so was
addressed here in iperf3 by importing a newer version of cJSON (plus
local ESnet modifications).

Discovered and reported by Dave McDaniel, Cisco Talos.

Based on a patch by @dopheide-esnet, with input from @DaveGamble.

Cross-references:  TALOS-CAN-0164, ESNET-SECADV-2016-0001,
CVE-2016-4303
2016-06-03 09:23:59 -07:00
Bruce A. Mah
a5f5765c8c
Regen. 2016-05-26 09:49:16 -07:00
Bruce A. Mah
9915746a8b
Squashed commit of the following:
commit 2dc03630a736be2ae9f64823aabb5776e7074c2a
Merge: 61e325c 0da552c
Author: Bruce A. Mah <bmah@es.net>
Date:   Thu May 26 09:40:58 2016 -0700

    Merge branch 'master' into issue-325

commit 61e325c5d0a4e7a9823221ce507db0f478fc98b5
Merge: 227992f ccbcee6
Author: Bruce A. Mah <bmah@es.net>
Date:   Thu May 26 11:09:54 2016 -0400

    Merge branch 'issue-325' of github.com:esnet/iperf into issue-325

    Conflicts:
    	src/iperf3.1

commit 227992f366e7f4895b6762011576ba22a42a752e
Author: Bruce A. Mah <bmah@es.net>
Date:   Thu May 26 11:07:01 2016 -0400

    Don't set SO_MAX_PACING_RATE if the rate is 0.  Also tweak some help text.

    Towards #325, in response to feedback from @bltierney.

commit ccbcee6366d50ec632fc00eb11fde8a886f8febe
Author: Bruce A. Mah <bmah@es.net>
Date:   Tue May 24 09:19:41 2016 -0700

    Fix manpage formatting for consistency.

commit 90ac5a9ce09bd746ca5f943a8226ab864da3ebf8
Author: Bruce A. Mah <bmah@es.net>
Date:   Tue May 24 12:14:16 2016 -0400

    Add some documentation for fair-queueing per-socket pacing.

    For #325.

commit 5571059870f7aefefb574816de70b6406848888f
Author: Bruce A. Mah <bmah@es.net>
Date:   Tue May 24 11:55:44 2016 -0400

    Change the fair-queueing socket pacing logic in response to feedback.

    By default, on platforms where per-socket pacing is available, it
    will be used.  If not available, iperf3 will fall back to application-
    level pacing.

    The --no-fq-socket-pacing option can be used to forcibly disable
    fair-queueing per-socket pacing.  (The earlier --socket-pacing option
    has been removed.)

    Tested on CentOS 7, more testing on other platforms is required to
    be sure it didn't break the old application-level pacing behavior.

    For #325.

commit 3e3f506fe9f375a5771c9e3ddfe8677c1a7146e7
Merge: 50a379e 3b23112
Author: Bruce A. Mah <bmah@es.net>
Date:   Tue May 24 09:54:39 2016 -0400

    Merge branch 'master' into issue-325

commit 50a379eddfa89d1313d2aeeb62a6fbc82f00ea17
Author: Bruce A. Mah <bmah@es.net>
Date:   Sat Apr 16 02:55:42 2016 -0400

    Regen.

commit 200d3fe3917b3d298bdf52a0bde32c47cf2727b0
Author: Bruce A. Mah <bmah@es.net>
Date:   Sat Apr 16 02:41:32 2016 -0400

    Checkpoint for initial work on #325 to add socket pacing.

    This works only on Linux and depends on the availability of
    the SO_MAX_PACING_RATE socket option and the fq queue discipline.
    Use --socket-pacing to use SO_MAX_PACING_RATE instead of the
    default iperf3 user-level rate limiting; in either case, the
    --bandwidth parameter controls the desired rate.

    Lightly tested with both --tcp and --udp, normal and --reverse.
    Real testing requires analysis of packet timestamps between
    multiple hosts.
2016-05-26 09:47:48 -07:00
g-coder
0da552c390 Safe programming practice. Added va_end. (#425)
In file iperf_util.c:
Function 'va_start' is called at line:327. But, 'va_end' is not called before returning from function 'iperf_json_printf()' at line:352 and line:355. 
The va_end performs cleanup for the argp object initialized by a call to va_start. If va_end is not called before a function that calls va_start returns, the behavior is undefined.

Applied Fix: added va_end before returning from the function.
2016-05-26 09:06:16 -07:00
g-coder
8fcfc2479f DEREF_AFTER_NULL in src/iperf_error.c (#423)
DEREF_AFTER_NULL: pointer ‘test’ at line:77 is passed as an argument to function iperf_delete_pidfile(), in which it is dereferenced at iperf_api.c:2832.
Pointer ‘test’ can be NULL and dereferencing a NULL pointer causes seg-fault.

Applied Fix: pointer ‘test’ is checked for NULL before passing it to function iperf_delete_pidfile().
2016-05-26 08:47:29 -07:00
Joe McEachern
3b2311263a Add fix for #412 (#414)
* Add fix for #412
This prevents negative loss counters with UDP when omit is used

* Track the original start time and bytes omitted. This allows the
throttle function to work after the omit timer fires. This is
a fix for issue #419.

* Remove changes to switch the bandwidth to received instead of sent bandwidth

* Roll back bandwidth sent vs received changes
2016-05-20 11:40:18 -07:00
Bruce A. Mah
f88486443c
Fix build on FreeBSD 11-CURRENT, as described in issue #413.
This caused by a combination of the iperf3 build somehow using
the system queue.h on FreeBSD 11 (possibly only on this platform)
and TAILQ_END not being defined in the system queue.h.

Expanding the TAILQ_END macro to NULL seems to solve the problem.

Submitted by:	@rbgarga
2016-05-20 10:05:24 -07:00
QuaSoft
08a2de459b Add command line option --forceflush to allow user to request flushing of output at the end of each interval.
Fixes #299
2016-03-06 16:47:02 +02:00
Bruce A. Mah
670c18584b
Get rid of nan values when there were no packets in a UDP interval.
This was causing some headaches for code trying to parse JSON.
Also revise a prior partial fix that hard-coded 100% loss for the
case of zero packets.

Partially fixes #278.

Merge candidate for 3.0 and 3.1 bugfix branches.
2016-01-28 16:04:33 -08:00
Bruce A. Mah
224ae8c764
Fix a bug where we printed the incorrect value for out-of-order UDP packets.
Fixes #329, submitted by @bhegardt.

While here, add this value to the JSON output.
2015-11-20 08:31:09 -08:00
Bruce A. Mah
956d115851 Improve command error handling.
Exit with non-zero exit code if server mode has too many errors.

Properly detect complain about non-numeric arguments to -A, -L, and -S.

Implement range checks for argument to -S.

Fixes #316.
2015-11-18 09:40:24 -08:00
Bruce A. Mah
44485b5b88
Fix a bug where the -T title option was not being output correctly
in JSON output.

Fixes #292.

Patch from:	@SLX-WI
2015-11-17 10:47:47 -08:00
Bruce A. Mah
6e48bb2a5d
Markup fixes in manpages for Debian compatibility.
Fixes #291.

Merge candidate for 3.1 stable release if applicable.
2015-11-16 12:00:36 -08:00
Bruce A. Mah
7b2abbc59a
Rename the recently-added template member in the iperf_test structure
to improve C++ compatibility.

Fixes #323.
2015-11-16 11:22:15 -08:00
Bruce A. Mah
8774140404 Bump version numbers and dates for iperf 3.1. 2015-10-16 10:00:30 -07:00
Tobias Nießen
20585b9896 Fix bug in iperf_new_stream leading to EINVAL
Fix invocation of snprintf in iperf_new_stream to prevent mkstemp from producing EINVAL.
2015-10-11 15:58:52 +02:00
Bruce A. Mah
ee306250d7 Merge pull request #288 from yeahdongcn/master
Add tmp_path in order to make the template path workable on iOS.
2015-10-07 13:05:32 -07:00
R0CKSTAR
9a3775091b Change tmp_path to template and use snprintf instead of strcpy 2015-09-21 11:07:41 +08:00
Matthieu Coudron
eb3faee64f Fixes a smashing stack problem as described in https://bugzilla.kernel.org/show_bug.cgi?id=104601 2015-09-19 14:08:47 +02:00
R0CKSTAR
7baf44a8b9 Missing one file 2015-08-03 09:40:53 +08:00
R0CKSTAR
01b82c9e3c Add tmp_path in order to make the template path workable on iOS. 2015-08-03 00:01:02 +08:00
Bruce A. Mah
883a465a72
Fix tarball generation (it was missing a file) and regen build goop.
Found by:	@arlake228
2015-06-30 13:19:38 -07:00
Bruce A. Mah
b6a2021c0b
Bump version number and manpage rev dates for 3.1b1. 2015-06-19 11:27:16 -07:00
Eduardo Abinader
1c89715936 iflush for interval results
In order to keep the same behavior of stdout, iflush the results
to files as they are printed.
2015-06-06 10:44:32 -04:00
Bruce A. Mah
25eb62c7cd Handle the case where EAGAIN != EWOULDBLOCK
Fixes #268, suggested by @tvastri.
2015-05-21 10:31:17 -07:00
Bruce A. Mah
7be67e1d2c
Fix a potential syntax error if PACKAGE_BUGREPORT is undefined.
Fixes #269, solution suggested by @tvastri.
2015-05-21 09:58:41 -07:00
Bruce A. Mah
2210d55277 Merge pull request #258 from manojdelphix/master
Fix segfault in signal handler on the server if a signal arrives at the "wrong" time.

The change causes the signal handler to use a stack context whose lifetime should be valid the entire time the signal handler is active.

Fixes #257, #258.
2015-05-11 13:45:14 -07:00
Bruce A. Mah
5824381111
Make --get-server-output properly include all of the server side output.
Fixes #251, with a bug fix based on diagnosis and analysis from @nomel.
2015-05-11 10:44:06 -07:00
Bruce A. Mah
5461579d32
Regen.
This uses a newer automake, than was in use previously, although that
wasn't the main point of doing this change.
2015-05-11 10:42:44 -07:00
Manoj Joseph
9293ec2c2b 257 Segfault in the signal handler 2015-03-31 11:08:16 -07:00
Bruce A. Mah
7645027d0d Remove an extra #ifdef left behind by #248. 2015-03-13 12:59:39 -07:00
Havard Eidnes
86daf673f3 Add support for NetBSD systems which have TCP_INFO implemented. 2015-02-19 14:23:01 +01:00
Bruce A. Mah
a337b698d0 Merge pull request #247 from he32/unused-fix
Remove unused local variable.
2015-02-12 14:51:12 -08:00
Bruce A. Mah
a47aa46b05 Merge pull request #246 from he32/include-fix
Include <sys/time.h> for struct timeval definition.
2015-02-12 14:49:52 -08:00
Havard Eidnes
c95ee19c59 Fix a toupper() usage too to avoid negative signed chars. 2015-02-12 15:13:00 +01:00
Havard Eidnes
bf53fb1304 Remove unused local variable. 2015-02-12 15:07:56 +01:00
Havard Eidnes
621a152b7c Include <sys/time.h> for struct timeval definition. 2015-02-12 15:04:16 +01:00
Havard Eidnes
081ad7c08c Add casts for the two remaining tolower() uses, since
tolower() is undefined for negative character values
(except for -1).

Also simplify the existing casts for tolower() usages.
2015-02-12 14:58:54 +01:00
Bruce A. Mah
6bd4e258d0 Make the combination of -B and -P but not --cport work
The case where we should have been binding the client sockets to
ephemeral ports at a specific address for parallel tests was broken.

Fixes #239

Submitted by:  @jfitzgibbon
2015-01-14 08:40:26 -08:00
Bruce A. Mah
bf32d9de66
Regen. 2015-01-06 10:40:04 -08:00
Bruce A. Mah
3b60f09017 Unbreak (partially) SCTP on Solaris.
Solaris implements an (older?) version of the API for SCTP_MAXSEG,
which takes an integer argument rather than a struct sctp_assoc_val.
We need to test for that and handle it appropriately.  There are some
signs it doesn't even work correctly if we do this, so quietly ignore
errors that happen if the OS complains it's unsupported.

Also, Solaris doesn't support SCTP_DISABLE_FRAGMENTS even though it
defines the preprocessor symbol for this.  Rather than aborting when
we try to unsuccessfully unset this option, just ignore the error.

Lightly tested with SCTP over IPv6 on localhost.
2015-01-06 10:22:00 -08:00
Bruce A. Mah
4874c4a88b
Regen. 2015-01-05 15:23:07 -08:00
Bruce A. Mah
e142062572
Add -X to restrict SCTP binding to a subset of interfaces.
Contains an alternate implementation of previously-submitted patches
to set the maximum segment size and no-delay options.

As a result of this change, SCTP functionality on Linux will generally
require the libsctp library (on CentOS and similar distributions this
is provided by the lksctp-tools RPM).

Part of #131.

Submitted by:	Bruce Simpson <bs48@st-andrews.ac.uk>
2015-01-05 15:19:57 -08:00
Bruce A. Mah
eb9a2c07c3 Unbreak master builds on CentOS 5.
The problem is that the new byte-ordering macros adopted on master
don't support CentOS 5 because they assumed that any Linux system had
endian(3) support.  CentOS 6 (and presumably newer) do, but CentOS 5
doesn't.

So instead we only do glibc endian(3) support if we're on a system
with glibc 2.9 or higher (which is when this functionality was
introduced).

For any other platform that we don't detect (which now includes older
glibc such as CentOS 5), bring back our homebrewed htonll and ntohll
implementation from iperf 3.0.x.

Fixes #224.
2015-01-05 10:42:09 -08:00
Bruce A. Mah
bebb7dea76 Merge branch 'candlerb-multisend' of https://github.com/candlerb/iperf into candlerb-candlerb-multisend 2015-01-02 10:00:37 -08:00
Bruce A. Mah
c0f4fa6ac0 Merge pull request #231 from candlerb/candlerb-sendfile-stats
Fix calculation of sendfile throughput on OSX and FreeBSD.
2015-01-02 09:54:34 -08:00
Bruce A. Mah
d275f166c8 Merge pull request #222 from hasso/timeout-udp
Timeout if UDP port isn't reachable.

This handles the case that a control connection succeeds but UDP packets are blocked by a firewall.
2014-12-23 10:39:11 -08:00
Brian Candler
a80368bb7f Drop out of multisend loop if none of the streams are accepting data 2014-12-23 09:38:50 +00:00
Bruce A. Mah
dba611dbe4 Add one-off mode, where the server serves exactly one request.
Primarily useful for bwctl integration, this is enabled with the -1
and/or --one-off flags.

Fixes #230, based on a patch by @i2aaron.

Signed-off-by: Bruce A. Mah <bmah@es.net>
2014-12-22 14:45:40 -08:00
Brian Candler
8961016f90 Ignore set_test_zerocopy if host does not support it 2014-12-22 18:04:56 +00:00
Brian Candler
588ee5223e Fix calculation of sendfile throughput on OSX
Note that sendfile can return -1 for EINTR whilst having already sent
partial results; these were not being counted previously.
2014-12-22 10:38:59 +00:00
Hasso Tepper
b83791882d Add ifdef to the SO_RCVTIMEO code
Not all platforms have a SO_RCVTIMEO socket option.
2014-12-11 12:59:02 +02:00
Hasso Tepper
9b9dd03096 Timeout if UDP port isn't reachable
Add timeout to the UDP socket. Without it client would block infinitely
if creating a control connection succeeds, but UDP packets are dropped
by firewall.
2014-11-24 10:02:37 +02:00
Bruce A. Mah
72ac83e7f2 Make UDP tests honor the -w option for setting the socket buffer
size.

This appears to be necessary on some long, high-bandwidth paths
to get sane results, either by reducing packet loss or by somehow
allowing the sending host of a test to go faster.

Fixes #219.
2014-11-12 13:58:23 -08:00
Bruce A. Mah
d65986030a Document how we use UDP sockets.
Comment changes only, no functional changes.
2014-11-12 12:10:33 -08:00
Bruce A. Mah
29dbc41c1d Also maintain the min and mean of the RTT.
For issue #215.
2014-10-23 13:39:58 -07:00
Bruce A. Mah
c7b0726a38 Merge branch 'master' of github.com:esnet/iperf 2014-10-23 11:11:08 -07:00
Bruce A. Mah
432ef7ebb3 Retrieve RTT information on platforms supporting it.
This value is available on the sender side, expressed in
microseconds.  It's available in the JSON output.

In the JSON output we also output the maximum observed RTT
per-stream.  Note that since the observation interval is many times
the RTT, it's not clear how good this value would be at capturing the
largest computed RTT value over the lifetime of each stream.

While here, also determine the maximum observed snd_cwnd value over
the lifetime of each stream.

This all works pretty well on Linux, but on FreeBSD (which should
theoretically be supported) we don't do a good job of supporting the
tcp_info structure.  We need to make this code a lot more portable,
rather than just assuming the world of platforms is "Linux"
vs. "everything else".  Fixing this requires some rearchitecting of
the way that we retrieve, compute, and print statistics.

Part of a fix for #215.
2014-10-23 11:10:39 -07:00
Bruce A. Mah
1d85c269a6 Fix an error message. 2014-10-16 12:30:51 -07:00
Bruce A. Mah
662a7ca035 Regen. 2014-10-16 11:30:07 -07:00
Bruce A. Mah
c5cf8972a0 Merge pull request #211 from atcorner/illumos
Fix build on illumos.
2014-10-16 11:13:47 -07:00
Ante Vojvodic
a565fa6b27 Identify Solaris based OS. 2014-10-16 18:01:29 +02:00
Bruce A. Mah
96d0c77ca2 The maximum send length for UDP is the maximum size of a UDP datagram.
For UDP over IPv4, this is the maximum IPv4 packet size (65535) minus
the size of the IPv4 and UDP headers, arriving at 65507.

In theory for a system implementing IPv6 jumbogram support, there is
no maximum packet size for UDP.  In practice we've observed with
CentOS 5 a limitation of 65535 - 8, which is dictated by the size
field in the UDP header (it has a maximum value of 65535, but needs
to count both payload and header bytes, thus subtracting off the 8
bytes for the UDP header).

We take the most conservative approach and use the 65507 value
for UDP / IPv4.

This is (I believe) the last part of issue #212.
2014-10-13 08:55:41 -07:00
Bruce A. Mah
8694d1db0d Make UDP packet reception work right with non-blocking sockets and enable.
We need this to permit a UDP receiving iperf3 server to listen on its
control channel.

The fix for non-blocking sockets basically makes sure that if we do a
read on a non-blocking sockets, but there's no data, the UDP processing
code does *not* try to do the normal protocol packet processing on the
non-existent packet.

This is part of an ongoing fix for issue #212 but also should have been
a part of the fix for issue #125.
2014-10-13 04:28:58 -07:00
Bruce A. Mah
78033c4359 Fix a crash when we try to print ending stats but no tests were run.
This can happen if the server gets into a weird state (see the test
cases for reproducing issue #212).  We need to do a couple of checks
to make sure we're not dereferencing NULL pointers (yay C).

While here, also fix up a couple of related output glitches, where
in this case we can emit some invalid JSON (NaN values, such as what
you get if there's a division by zero, are not valid JSON).

Part of a fix in progress for #212.
2014-10-13 01:50:04 -07:00
Ante Vojvodic
165d10de0f Fix build on illumos. 2014-10-06 18:38:17 +02:00
Bruce A. Mah
da9f046f19
Update license and copyright text to conform to LBNL standards.
Note that the license remains a 3-clause BSD license; the only
license changes were to add the name of the program and to add
some punctuation.
2014-09-29 14:00:46 -07:00