isLooped checks for any duplicate prefixes#1976
Open
everett1992 wants to merge 1 commit intomeshcore-dev:mainfrom
Open
isLooped checks for any duplicate prefixes#1976everett1992 wants to merge 1 commit intomeshcore-dev:mainfrom
everett1992 wants to merge 1 commit intomeshcore-dev:mainfrom
Conversation
previous implemenation only checked for duplicates self_id.
A node would happily forward a packet that had signs it was already looped.
Since not all nodes in a network will enable loop detection I want
configured nodes to drop these packets.
This is a quadratic loop, but it's upper bound is 64.
It can be improved with a better data structure but I wanted to keep it simple.
The package doesn't have a test framework so I wrote a small harness to
double check the behavior. All the 'self' tests pass with the previous
impl.
```
runTest(1, {0x11, 0x22, 0x33}, max_loop_strict, false, "no dups");
runTest(1, {0xAA, 0x22}, max_loop_strict, true, "dup with self");
runTest(1, {0x11, 0x11, 0x22, 0x33}, max_loop_strict, true, "dup in path");
runTest(2, {0xAA, 0x22, 0xBB, 0x44}, max_loop_strict, false, "2-byte no dup");
runTest(2, {0xAA, 0xBB, 0xCC, 0xDD}, max_loop_strict, true, "2-byte dup with self");
runTest(2, {0x00, 0x11, 0x00, 0x11}, max_loop_strict, true, "2-byte dup in path");
runTest(3, {0xAA, 0xBB, 0xCC}, max_loop_strict, true, "3-byte dup with self");
runTest(3, {0x11, 0x22, 0x33, 0x11, 0x22, 0x33}, max_loop_strict, true, "3-byte dup in path");
runTest(1, {0x11, 0x11, 0x11, 0x11}, max_loop_minimal, false, "4 repeats: under minimal limit");
runTest(1, {0x11, 0x11, 0x11, 0x11, 0x11}, max_loop_minimal, true, "5 repeats: over minimal limit");
runTest(1, {0xAA, 0xAA, 0xAA}, max_loop_minimal, false, "3 repeats and self: under minimal limit");
runTest(1, {0xAA, 0xAA, 0xAA, 0xAA}, max_loop_minimal, true, "4 repeats and self: over minimal limit");
```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
previous implemenation only checked for duplicates self_id. A node would happily forward a packet that had signs it was already looped. Since not all nodes in a network will enable loop detection I want configured nodes to drop these packets.
This is a quadratic loop, but it's upper bound is 64. It can be improved with a better data structure but I wanted to keep it simple.
The package doesn't have a test framework so I wrote a small harness to double check the behavior. All the 'self' tests pass with the previous impl.