Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fix to improve the portability #935

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

xiaoxiang781216
Copy link
Contributor

PLEASE NOTE the following text from the iperf3 license. Submitting a
pull request to the iperf3 repository constitutes "[making]
Enhancements available...publicly":

You are under no obligation whatsoever to provide any bug fixes, patches, or
upgrades to the features, functionality or performance of the source code
("Enhancements") to anyone; however, if you choose to make your Enhancements
available either publicly, or directly to Lawrence Berkeley National
Laboratory, without imposing a separate written license agreement for such
Enhancements, then you hereby grant the following license: a non-exclusive,
royalty-free perpetual license to install, use, modify, prepare derivative
works, incorporate into other computer software, distribute, and sublicense
such enhancements or derivative works thereof, in binary and source code form.

The complete iperf3 license is available in the LICENSE file in the
top directory of the iperf3 source tree.

  • Version of iperf3 (or development branch, such as master or
    3.1-STABLE) to which this pull request applies:

  • Issues fixed (if any):

  • Brief description of code changes (suitable for use as a commit message):

@bmah888
Copy link
Contributor

bmah888 commented Nov 27, 2019

Thanks for the pull request! Out of curiosity...on what platform were you trying to build iperf3? I'm just wondering what the OS and hardware is.

@xiaoxiang781216
Copy link
Contributor Author

xiaoxiang781216 commented Nov 28, 2019

Thanks for the pull request! Out of curiosity...on what platform were you trying to build iperf3? I'm just wondering what the OS and hardware is.

I am trying to port iperf3 to NuttX( a realtime operating system) and test on Photon and Simulator.
You can get more info from these links:
NuttX: https://www.nuttx.org
Photon: https://store.particle.io/products/photon
Simulator: https://nuttx.org/doku.php?id=wiki:nxinternal:simulator

@bmah888
Copy link
Contributor

bmah888 commented Jan 2, 2020

That's great, thanks. I'm looking over the changes...there are a lot of them so I'm trying to see if I can review and merge them one or two at a time.

bmah888 pushed a commit that referenced this pull request Jan 2, 2020
Part of #935.

Change-Id: I5c563ad0cffce1a75b6a8039aa9a2e1543763880
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
(cherry picked from commit d7e30be)
Signed-off-by: Bruce A. Mah <bmah@es.net>
bmah888 pushed a commit that referenced this pull request Jan 2, 2020
…ined

Part of #935.

Change-Id: Ibcc4ad4370a6f99b030ca2c44f151c4550695957
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
(cherry picked from commit 6c10c3e)
Signed-off-by: Bruce A. Mah <bmah@es.net>
@bmah888
Copy link
Contributor

bmah888 commented Jan 2, 2020

I cherry-picked d7e30be and 6c10c3e from the pull request...this seems to be a reasonable workflow for working through your changes. More to come...thanks again for the pull request.

@bmah888 bmah888 self-assigned this Jan 2, 2020
bmah888 pushed a commit that referenced this pull request Jan 2, 2020
since not all platform define these signal number

Part of #935.

Change-Id: I98f14590ad45d1fe7e61076cce5a76b7874772ea
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
(cherry picked from commit d4267b6)
Signed-off-by: Bruce A. Mah <bmah@es.net>
bmah888 pushed a commit that referenced this pull request Jan 2, 2020
by including arpa/inet.h, strings.h and sys/timer.h

Part of #935.

Change-Id: Ibac8d3a992457f2a7cc10f74b144e3ebe69976d8
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
(cherry picked from commit b9aa6ce)
Signed-off-by: Bruce A. Mah <bmah@es.net>
@bmah888
Copy link
Contributor

bmah888 commented Jan 3, 2020

Cherry-picked d4267b6 and b9aa6ce.

bmah888 pushed a commit that referenced this pull request Jan 3, 2020
…erval_results

Part of #935.

Change-Id: Id702dee9d894d91420719928ae2de6b44b72f579
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
(cherry picked from commit 9dab732)
Signed-off-by: Bruce A. Mah <bmah@es.net>
@bmah888
Copy link
Contributor

bmah888 commented Jan 3, 2020

Cherry-picked 9dab732.

@bmah888
Copy link
Contributor

bmah888 commented Jan 3, 2020

Of the commits in this PR I haven't merged so far, I have the following questions/comments:

Regarding 98c8683 : I'm going to merge this...I was debating whether to just fix this by importing a new cJSON, but that's a potentially big undertaking.

Regarding f9dd48e : readentropy() is deliberately written to only open /dev/urandom once per invocation of iperf3. Admittedly I'm not sure what tradeoffs this involves. Does it cause any particular problems in the NuttX environment?

Regarding ecb8c31 : We want to keep this code as-is...if the user doesn't specify a -w flag, we want to know what the default buffer / window size is.

Regarding af35a48 : I'm not sure how to evaluate this change. Are you saying because we unlink the file, whether we do MAP_PRIVATE or MAP_SHARED doesn't matter? (Put another way, is there anything wrong with the mmap() calls as they exist today?

Regarding 69fb9dd : Can you describe a little more detail about the starvation problem that is solved by this change?

Regarding 9098e1d : Is this change just to make the client and server code more consistent? I'm just asking this because I've gotten bit by making changes like this in places where the ordering of various steps is actually important to preserve. So I tend to shy away from making changes like this unless we've tested them really well.

bmah888 pushed a commit that referenced this pull request Jan 3, 2020
the similar change also exist in the offical git:
https://github.com/DaveGamble/cJSON

Part of #935.

Change-Id: I3d98de3ec893ccf0b0cab37acc2dbfef00d9e2b6
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
(cherry picked from commit 98c8683)
Signed-off-by: Bruce A. Mah <bmah@es.net>
@bmah888
Copy link
Contributor

bmah888 commented Jan 3, 2020

Cherry-picked 98c8683.

@xiaoxiang781216
Copy link
Contributor Author

Of the commits in this PR I haven't merged so far, I have the following questions/comments:

Regarding 98c8683 : I'm going to merge this...I was debating whether to just fix this by importing a new cJSON, but that's a potentially big undertaking.

Regarding f9dd48e : readentropy() is deliberately written to only open /dev/urandom once per invocation of iperf3. Admittedly I'm not sure what tradeoffs this involves. Does it cause any particular problems in the NuttX environment?

Yes, the global variables for each application just initialize once in NuttX, the global variables keep the previous value in the second invocation. For iperf3, "/dev/urandom" isn't opened in the second launch. Here has the more explanation:
https://cwiki.apache.org/confluence/display/NUTTX/Linux+Processes+vs+NuttX+Tasks

Regarding ecb8c31 : We want to keep this code as-is...if the user doesn't specify a -w flag, we want to know what the default buffer / window size is.

I made this change just because NuttX doesn't support SO_SNDBUF/SO_RCVBUF, how about we query the buffer size regardless of -w flag, but don't exit the test if getsockopt return error?

Regarding af35a48 : I'm not sure how to evaluate this change. Are you saying because we unlink the file, whether we do MAP_PRIVATE or MAP_SHARED doesn't matter? (Put another way, is there anything wrong with the mmap() calls as they exist today?

Yes, unlink with MAP_SHARED equals MAP_PRIVATE. MAP_PRIVATE has copy-on-write semantics and is very hard to implement without MMU, but most hardware running NuttX don't have MMU, that's why I made this change.

Regarding 69fb9dd : Can you describe a little more detail about the starvation problem that is solved by this change?

If we monitor write_set unconditionally, select will return immediately without sleeping since we haven't sent anything then the buffer should be always available, but iperf_send is called to consume the buffer ony when the state equals to TEST_RUNNING. Then you will see while become a busy loop until the state transit to TEST_RUNNING.

Regarding 9098e1d : Is this change just to make the client and server code more consistent? I'm just asking this because I've gotten bit by making changes like this in places where the ordering of various steps is actually important to preserve. So I tend to shy away from making changes like this unless we've tested them really well.

The change is also a good thing to let the client initiate the close process. Here has a clean explanation:
http://www.serverframework.com/asynchronousevents/2011/01/time-wait-and-its-design-implications-for-protocols-and-scalable-servers.html

avoid frandom keep the previous value in the second run

Change-Id: I7bd66d003b0cc3fccd9720624fbee7aa9053fa4f
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ib82a4e021a6fb5f40f82e1f2c1bae580bb4d2f93
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Id90d02dd60fd3c41aa1dc08d67d22902c19e0f90
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
avoid the continue writable socket state starve the whole system
because the test start the transmit only in TEST_RUNNING state.

Change-Id: I5f0a06ba8e3d8a6bba5cef84d97a8bc25afed6f1
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I2157e78e3cfd528c6922ec39319470ab6ea3180d
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants