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

Improve shuffling algorithm of connection list #634

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Hurukawa2121
Copy link

@Hurukawa2121 Hurukawa2121 commented Oct 26, 2024

I propose implementing the Fisher-Yates shuffle algorithm to improve the shuffling of the connection target list.

Issue:

In the current shuffle algorithm, each element l->array[i] is swapped with a random element at index j in the entire array.
However, this method does not produce all permutations uniformly, resulting in a bias where some permutations occur more frequently than others.

Solution:

To ensure all permutations are generated with equal probability, I suggest using the Fisher-Yates shuffle algorithm.

Thank you for your contribution

You are welcome to open PR, but they are used for discussion only. All
patches must eventually go to the openvpn-devel mailing list for review:

Please send your patch using git-send-email. For example to send your latest commit to the list:

$ git send-email [email protected] HEAD~1

For details, see these Wiki articles:

@cron2
Copy link
Contributor

cron2 commented Nov 6, 2024

This looks interesting.

To progress, please add some comments to the new code explaining what this does ("Shuffle with Fisher-Yates algorithm which has less bias to ...."). Otherwise this creates just code that is not meaningful to the next person looking at it.

Then, send the patch to the openvpn-devel list, or to our gerrit. We do not merge patches from GH.

thanks ;-)

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