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

Random unexpected port after walk_to #1310

Open
bacox opened this issue Aug 14, 2024 · 3 comments
Open

Random unexpected port after walk_to #1310

bacox opened this issue Aug 14, 2024 · 3 comments
Labels
priority: medium Enhancements, features or exotic bugs

Comments

@bacox
Copy link
Contributor

bacox commented Aug 14, 2024

When I use a manual introduction between two communities using walk_to, on rare occasions it uses a random port for the connection.
Around 5% of the runs have this behavior.

Description

For community A the host and port are set to 192.168.55.10:9090.
For community B the host and port are set to 192.168.55.11:9091.

The communities run in separate docker containers.

When using a manual walk_to(192.168.55.11,42:9091) the connection can end up like ('192.168.55.11', 51061) when I call get_peers(). In normal occasions, the host and port looks like ('192.168.55.11', 9091).

Output

Currently I do not have a traceback of an error because no error is thrown.
The output in my application is as follows:

node1-1  | [Node 1] Starting with delay 3 and connections: [(0, 9090)]
node0-1  | [Node 0] Starting with delay 0 and connections: [(1, 9091)]
node0-1  | [Node 0] Walking to ('192.168.55.11', 9091)
node1-1  | [Node 1] Walking to ('192.168.55.10', 9090)
node1-1  | [Node 1] send introduction to Peer: Peer<192.168.55.10:9090, B8jTPERrIo5JsfYPRoamo0XahlM=>
node0-1  | [Node 0] self.get_peers()=[('192.168.55.11', 59638)]
node1-1  | [Node 1] Starting
node1-1  | [Node 1] self.get_peers()=[('192.168.55.10', 9090)]
node0-1  | [Node 0] Walking to ('192.168.55.11', 9091)
node0-1  | [Node 0] self.get_peers()=[('192.168.55.11', 59638)]
node0-1  | [Node 0] Walking to ('192.168.55.11', 9091)
node0-1  | [Node 0] self.get_peers()=[('192.168.55.11', 59638)]

Is there an explanation why some connections end up with a random port instead of the port that is creates the community with?

@bacox bacox added the priority: unknown Requires further investigation label Aug 14, 2024
@qstokkink qstokkink added question Programmer to programmer ad-hoc documentation and removed priority: unknown Requires further investigation labels Aug 15, 2024
@qstokkink
Copy link
Collaborator

There is certainly a reason. Long story short, this is by design: it is occurring because IPv8 is continuously trying to be smart about the ports it uses to more effectively traverse your network address translation. This is also why the big warning block is in our "Creating your first overlay" documentation: never, ever, depend on the (IP, port) of a peer.

You can get a more complete overview from https://www.usenix.org/legacy/event/usenix05/tech/general/full_papers/ford/ford.pdf (if you're interested).

@bacox
Copy link
Contributor Author

bacox commented Aug 19, 2024

Although a port change can happen and is expected behavior, communication breaks down after this. The UDPv4Address and the UDPv4LANAddress are different after the port change. Only when I force IPV8 to ignore the port change and continue with the original ports communication resumes.
This last part doesn't sound like expected behavior.

@qstokkink qstokkink added priority: medium Enhancements, features or exotic bugs and removed question Programmer to programmer ad-hoc documentation labels Aug 19, 2024
@qstokkink
Copy link
Collaborator

Indeed. I'll put this on the roadmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium Enhancements, features or exotic bugs
Development

No branches or pull requests

2 participants