-
Notifications
You must be signed in to change notification settings - Fork 4
use PATH_CHALLENGE for hole punching #231
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
base: main-iroh
Are you sure you want to change the base?
Changes from 8 commits
3467051
59187e1
8975e9d
132f969
8ba015b
443346b
fa72173
cc59abb
4b1fbde
d7947f2
4f57a1c
24f2318
ff990de
1d5daee
52f3d2d
41367e8
0ec61d4
9f22564
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -892,26 +892,6 @@ impl Connection { | |
| max_datagrams: usize, | ||
| buf: &mut Vec<u8>, | ||
| ) -> Option<Transmit> { | ||
| if let Some(probing) = self | ||
| .iroh_hp | ||
| .server_side_mut() | ||
| .ok() | ||
| .and_then(iroh_hp::ServerState::next_probe) | ||
| { | ||
| let destination = probing.remote(); | ||
| trace!(%destination, "RAND_DATA packet"); | ||
| let token: u64 = self.rng.random(); | ||
| buf.put_u64(token); | ||
| probing.finish(token); | ||
| return Some(Transmit { | ||
| destination, | ||
| ecn: None, | ||
| size: 8, | ||
| segment_size: None, | ||
| src_ip: None, | ||
| }); | ||
| } | ||
|
|
||
| assert!(max_datagrams != 0); | ||
| let max_datagrams = match self.config.enable_segmentation_offload { | ||
| false => 1, | ||
|
|
@@ -1118,6 +1098,47 @@ impl Connection { | |
| break; | ||
| } | ||
|
|
||
| if transmit.is_empty() { | ||
| // Nothing to send on this path, and nothing yet built; try to send hole punching | ||
| // path challenges. | ||
| if let Some(probing) = self | ||
| .iroh_hp | ||
| .server_side_mut() | ||
| .ok() | ||
| .and_then(iroh_hp::ServerState::next_probe) | ||
| { | ||
| if let Some(new_cid) = self | ||
| .rem_cids | ||
| .get_mut(&path_id) | ||
| .and_then(CidQueue::next_reserved) | ||
| { | ||
| let destination = probing.remote(); | ||
| let token: u64 = self.rng.random(); | ||
| trace!(%destination, cid=%new_cid, token=format!("{:08x}", token), "Nat traversal: PATH_CHALLENGE packet"); | ||
| // TODO(@divma): abstract writting path challenges, this logic should | ||
| // no be here | ||
|
||
|
|
||
| buf.write(frame::FrameType::PATH_CHALLENGE); | ||
| buf.write(token); | ||
| // TODO(@divma): can I just create a new qlog? | ||
| // qlog.frame(&Frame::PathChallenge(token)); | ||
| // TODO(@divma): separate stat? | ||
| self.stats.frame_tx.path_challenge += 1; | ||
|
|
||
| // Remember the token sent to this remote | ||
| probing.finish(token); | ||
| // TODO(@divma): figure out padding if any | ||
| return Some(Transmit { | ||
| destination, | ||
| ecn: None, | ||
| size: 8, | ||
| segment_size: None, | ||
| src_ip: None, | ||
| }); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| match self.paths.keys().find(|&&next| next > path_id) { | ||
| Some(next_path_id) => { | ||
| // See if this next path can send anything. | ||
|
|
@@ -4261,6 +4282,9 @@ impl Connection { | |
| self.ping_path(path_id).ok(); | ||
| } | ||
| } | ||
| } else if self.iroh_hp.client_side().is_ok() { | ||
| // TODO(@divma): temp log. This might be too much | ||
| debug!("Potential Nat traversal PATH_CHALLENGE received"); | ||
| } | ||
| } | ||
| Frame::PathResponse(token) => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: see the suggestion i make above to address these things.
I know we've tried to cover this bit about where to put this before, but upon reading this again I wondered:
path_should_sendis false. but since holepunching is time-sensitive, should it should probably be prioritised over any other data to be sent on this path. otherwise application data can starve out the holepunching.I think the congestion controller bit is fine to ignore at first. We can not count the off-path path challenges to a congestion controller for now (but should create an issue).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another problem with this location that I hadn't realised before is that this is now prioritised over a CONNECTION_CLOSE frame, which it shouldn't.