Skip to content

Conversation

@jdslab
Copy link

@jdslab jdslab commented Mar 25, 2025

Modification to border router dataplane to process STUN requests, as described in the design document and discussion.

p.Link = l
// The src address does not need to be recorded in the packet. The link has all the relevant
// information.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems weird that this function is an almost exact duplicate of the function in line 571. I suppose this is out of scope for this PR?

"tailscale.com/net/stun"
)

func main() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add something here like:
"This demo client uses manual STUN commands to demonstrate how STUN can be implemented with SCION.
Normal clients would not do that and instead use a library that performs STUN automatically and transparently."
?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jiceathome
Copy link
Contributor

jiceathome commented Sep 5, 2025 via email

Copy link
Author

@jdslab jdslab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 of 21 files reviewed, 7 unresolved discussions (waiting on @jiceathome, @marcfrei, and @tzaeschke)


demo/stun/test.py line 4 at r1 (raw file):

Previously, jiceathome wrote…
  1. It's new code, right?

Done.


demo/stun/test-client/main.go line 1 at r1 (raw file):

Previously, jiceathome wrote…

Copyright? License?

Done.


demo/stun/test-server/main.go line 1 at r1 (raw file):

Previously, jiceathome wrote…

Ditto

Done.

"tailscale.com/net/stun"
)

func main() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Author

@jdslab jdslab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 of 21 files reviewed, 7 unresolved discussions (waiting on @jiceathome, @marcfrei, and @tzaeschke)


demo/stun/test.py line 114 at r1 (raw file):

Previously, jiceathome wrote…

How reliable is that time guess? Can we probe readiness instead? It is OK for a test take 10 seconds or even much more, but provided we don't have too many of those.

The 10s wait time is sufficient for everything to start up. It is also the same wait time as used in the dr_key acceptance test, which also runs a docker compose topology. Given that optimizing this would likely only shave off a few seconds from the running time, I don't think it is worth the effort to overly optimize this.

@marcfrei marcfrei changed the title router: STUN implementation router: add STUN implementation Oct 13, 2025
Copy link
Contributor

@JordiSubira JordiSubira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add metrics for STUN, it could be useful to debug the "STUN flow", i.e., BR is receiving requests, it is sending them back to clients, etc. This should be fairly easy extending router.trafficMetrics.

}

switch slayers.L4ProtocolType(data[4]) {
case slayers.L4TCP, slayers.L4UDP, slayers.L4SCMP, slayers.L4BFD,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we ever have a protocol type assigned to 0x21 we may identify STUN packets as SCION packets (depending on the result of the if below). We do not need to tackle this now, but documenting it in the function description will help if we ever come across this.

switch slayers.L4ProtocolType(data[4]) {
case slayers.L4TCP, slayers.L4UDP, slayers.L4SCMP, slayers.L4BFD,
slayers.HopByHopClass, slayers.End2EndClass,
253, 254 /* experimentation and testing */ :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would register these values as const in slayers.l4.go . I guess they haven't been needed in the implementation so far, but since they are already documented it would make more clear that the implementation is following what is expected in the doc for these values.

"tester_1-ff00_0_111", "bash", "-c",
'test-client -daemon 192.168.123.3:30255 -local 1-ff00:0:111,192.168.123.4:31000 '
'-remote 1-ff00:0:110,172.20.0.22:31000 -data "abc"')
print(result)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see any ouput when running the test. This is likely because you are using log in test-client and test-server. Go's log package writes to STDERR by default. dc.execute() only captures STDOUT (see docker.py:55 - return res.stdout).

In addition, I would add an assertion since we have a fixed output that we are expecting "abc".

@@ -0,0 +1,61 @@
# STUN Demo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit doubtful how we should better organize the integration test. I believe the main reason for having demo was having the file_transfer demo. Later, Matthias suggested that we could incorporate DRKey in demo instead of acceptance, because we were taking it as an application running over SCION, rather than an inherent part of the SCION protocol (i.e., we do not need DRKey for SCION to work, actually DRKey needs SCION to work, at least as it is defined now). In the case of STUN, I do believe it is a necessary component for SCION to work properly. In any case, this is how I had understood the organization so far, but we can always restructure this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up till now, the intention of this demo was to show how to use STUN on an end host "manually" given that we have support for it in the border router. Once we have STUN support in snet, we can get rid of this demo application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants