find optimal prefix to allocate to avoid fragmentation #14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Given two sets, the first one representing the full IP space which can be used, and a second representing what has already been used or allocated, this algorthim can find a best fit prefix that you can add to reserved set which will minimize the fragmentation of the resulting reserved set.
This can be used to allocate IP address subnets in the best way possible to avoid situations where a subnet cannot be allocated because the space was not allocated carefully enough.
It cannot prevent all fragmentation. Since it has no knowledge of how prefixes may be deallocated in the future, it cannot make decisions to allocate so that deallocations will open up the most contiguous space possible.