Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
194 commits
Select commit Hold shift + click to select a range
cd0c25b
modified gen topology
jdslab Sep 26, 2024
b31d363
nat simulator bug fix
jdslab Sep 28, 2024
210f5a4
nat simulator
jdslab Sep 28, 2024
a0ddeb2
move nat simulator configuration files
jdslab Sep 28, 2024
9723c7e
move nat simulator configuration files
jdslab Sep 28, 2024
e9fb959
regenerate topology certificates
jdslab Sep 28, 2024
3a78db1
nat simulator
jdslab Sep 30, 2024
b541060
renew gen certificates
jdslab Oct 15, 2024
1138987
remove gen files from git
jdslab Oct 15, 2024
d6a12a9
merge testing files to same repository
jdslab Oct 15, 2024
978a4ff
remove gen files from git
jdslab Oct 15, 2024
0a5ad5e
modify tailscale stunc to accept local port argument
jdslab Oct 15, 2024
dcbcddc
proof of concept with STUN
jdslab Oct 15, 2024
7ecdf95
start stun server automatically on border router
jdslab Oct 16, 2024
a0527e4
NAT simulator configuration mount scion-app bin in tester containers …
jdslab Nov 18, 2024
dcb70b2
update design document
jdslab Nov 25, 2024
a1731e7
update design document
jdslab Nov 27, 2024
7ae86ba
Proof of Concept: listen for and process STUN packets on border route…
jdslab Oct 21, 2024
4f02bd0
check STUN fingerprint from beginning
jdslab Oct 22, 2024
486bdac
modify docker config and test application to use same port as dataplane
jdslab Oct 22, 2024
4087ea6
Check for STUN packet only after parsing SCION header failed
jdslab Oct 23, 2024
c83dc1b
NAT use random ports
jdslab Oct 28, 2024
0c03806
fix oversight: actually use port from STUN reply
jdslab Oct 28, 2024
44d532a
packages STUN remove unused functions
jdslab Nov 11, 2024
2f87e20
refactor code
jdslab Dec 5, 2024
409c28c
clean up test files
jdslab Dec 7, 2024
ad4b552
refactor comment
jdslab Dec 9, 2024
e88005b
stun acceptance test
jdslab Jan 15, 2025
9d237df
generalize and cleanup acceptance test
jdslab Jan 15, 2025
192fa67
reset design document
jdslab Feb 18, 2025
7b16dea
refine variables
jdslab Feb 23, 2025
e22efbe
edit test configuration files instead of overwriting
jdslab Feb 23, 2025
cb359f5
add comments
jdslab Feb 23, 2025
96cb00a
fix acceptance test build dependency
jdslab Feb 24, 2025
948df8c
only check fingerprint on slow path
jdslab Feb 24, 2025
751aa4c
cleanup acceptance test
jdslab Feb 25, 2025
68028d0
update comment
jdslab Feb 25, 2025
5daa910
extend unit tests
jdslab Feb 26, 2025
80d6e2a
change test software attribute
jdslab Feb 26, 2025
dce5e4e
Create STUN demo readme
jdslab Mar 14, 2025
df4d1c5
Add diagram
jdslab Mar 14, 2025
68be7bd
Add comments
jdslab Mar 17, 2025
d4aaaf5
Merge branch 'master' into marcfrei/stun-br
marcfrei Aug 27, 2025
51a5d1f
Handle STUN packets in udpip underlay
marcfrei Aug 28, 2025
b45e12e
Handle STUN packets on separate processor
marcfrei Aug 29, 2025
3c25d2f
Generalize procID computation
marcfrei Aug 29, 2025
3357c5d
Improve procID computation
marcfrei Aug 29, 2025
79db4a1
Clean up assignment of packets to processor queues
marcfrei Aug 30, 2025
893d3fe
fix Bazel configuration
Aug 30, 2025
6f7f895
Add stop logic to internal udpip processor
marcfrei Aug 31, 2025
5027d45
Merge remote-tracking branch 'jdslab/stun-br-revision' into marcfrei/…
marcfrei Aug 31, 2025
f5f0d3d
Fix allocation of channel capacity for internal udpip processor
marcfrei Sep 1, 2025
4bbd5b4
Refine allocation of channel capacity for internal udpip processor
marcfrei Sep 1, 2025
fc80b7e
Fix packet to queue assignment for internal udpip link
marcfrei Sep 1, 2025
34b90a5
Update dependency on tailscale.com
marcfrei Sep 2, 2025
f5d5d65
Update dependency on tailscale.com to v1.84.3
marcfrei Sep 2, 2025
51ea202
Update dependency on tailscale.com to v1.84.3
marcfrei Sep 2, 2025
4309a33
copyright comments
Sep 2, 2025
c845636
Update unit tests
marcfrei Sep 3, 2025
7a2963a
STUN demo acceptance test fix command execution
Sep 3, 2025
a2022e2
Document the function computeProcID
marcfrei Sep 3, 2025
f8ccad2
Add STUN packets to computeProcID tests
marcfrei Sep 3, 2025
36e819a
Clean up code formatting
marcfrei Sep 3, 2025
897ccb7
Merge remote-tracking branch 'jdslab/stun-br-revision' into marcfrei/…
marcfrei Sep 3, 2025
bc8c6de
Keep computeProcID test closer to the original version
marcfrei Sep 3, 2025
1b563cc
STUN demo acceptance test fix NAT docker container
Sep 4, 2025
9086a6d
Merge remote-tracking branch 'jdslab/stun-br-revision' into marcfrei/…
marcfrei Sep 4, 2025
401469b
Merge branch 'master' into marcfrei/stun-br
marcfrei Sep 4, 2025
03154d4
Fix dataplane unit tests
marcfrei Sep 4, 2025
7121960
Merge remote-tracking branch 'upstream/master' into stun-br
Oct 11, 2025
0d3a7a2
improve documentation
jdslab Oct 11, 2025
837943b
revert debug modification
jdslab Oct 11, 2025
1a40dc5
reset go.mod go.sum changes
jdslab Oct 13, 2025
f82c63e
Merge branch 'master' into stun-br
jdslab Oct 13, 2025
1de4946
fix style (linter)
jdslab Oct 13, 2025
5b81753
fix styles (linter)
jdslab Oct 14, 2025
93290d6
fix exclude STUN library from linter
jdslab Oct 14, 2025
f0ce41b
run bazel gazelle
jdslab Oct 14, 2025
73b0201
go mod tidy
Oct 27, 2025
8241c2f
Merge branch 'master' into stun-br
jdslab Oct 28, 2025
6c8a0d8
Create interface UDPConn wrapping *net.UDPConn
jdslab Nov 3, 2025
3ae77aa
Add back STUN client methods
jdslab Nov 3, 2025
0a744c0
Update Bazel Configuration
jdslab Nov 4, 2025
4bf913c
Rudimentary STUN handler implementation (untested)
jdslab Nov 5, 2025
f4b0a15
Create test scripts for STUN in snet
jdslab Nov 5, 2025
c6f68de
improve debug logging
Nov 10, 2025
a71be76
mount test scripts in tester container
Nov 10, 2025
32f1790
add test bash scripts
Nov 10, 2025
1e181f2
properly read STUN packets and buffer non-STUN packets
jdslab Nov 10, 2025
8eee4ca
add default route in tester dispatcher container to route traffic thr…
jdslab Nov 10, 2025
3268167
more verbose logging
jdslab Nov 10, 2025
ce22c04
Use mapped port from stunHandler as source port
jdslab Nov 10, 2025
7cd6702
Skip destination AddrPort check if using STUN
jdslab Nov 10, 2025
7722551
Merge branch 'master' into snet-stun-modification
marcfrei Nov 14, 2025
836430a
Merge branch 'master' into stun-br
jdslab Nov 14, 2025
120f987
calculate non-STUN packet queue size
jdslab Dec 2, 2025
d832aed
Merge branch 'master' into stun-br
jdslab Dec 3, 2025
9da4ecb
implement packet queue limited by payload size
jdslab Dec 8, 2025
8b3b8ce
change metadata estimation to 64 bytes
jdslab Dec 8, 2025
d62fb1f
implement time measurement & retransmission timeout calculation
jdslab Dec 8, 2025
b5c8b77
reset retransmission timer completely after 10 minutes of no usage
jdslab Dec 18, 2025
fbadb6f
implement STUN request retransmission on timeout
jdslab Dec 19, 2025
fe27c8c
update Bazel configuration with new dependencies
Dec 22, 2025
9a12c12
make everything concurrency safe:
jdslab Dec 22, 2025
8efe799
Merge branch 'master' into stun-br
jdslab Dec 24, 2025
3f96eac
Merge branch 'refs/heads/stun-br' into snet-stun-modification
jdslab Dec 24, 2025
7669fb2
fix bug: terminate sending goroutine when STUN response received
Dec 24, 2025
e3d54f0
Protect writeDeadline with mutex
jdslab Dec 24, 2025
16d3412
drop STUN packet if STUN channel full
jdslab Dec 25, 2025
f223191
code review modifications (work in progress)
jdslab Dec 25, 2025
659d045
protect queuedBytes with mutex
jdslab Dec 25, 2025
297d56d
simplify queuedBytes mutex, guarantee packet storage if space available
jdslab Dec 25, 2025
afca8b4
fix mappedAddr mapping concurrency
jdslab Dec 25, 2025
dce2175
fix error handling
jdslab Dec 25, 2025
422c9d7
style
jdslab Dec 25, 2025
aaf84af
copyright header
jdslab Dec 25, 2025
b4bba0b
fix concurrency issues (work in progress)
jdslab Dec 27, 2025
983bc34
new background goroutine to continuously read from UDP conn and store…
jdslab Dec 27, 2025
f52ec39
add methods SetDeadline/SetReadDeadline and fix concurrency
jdslab Dec 27, 2025
5a3b18f
modify ReadFrom & getStunResponse to work with background goroutine
jdslab Dec 27, 2025
7038539
change STUN sender/receiver from 2 goroutines to single loop with cha…
jdslab Dec 28, 2025
b26bb4c
improve test docker setup reliability
Dec 29, 2025
f4a3608
code review modifications
Dec 29, 2025
79a9895
code review modifications
Dec 29, 2025
0f23ef9
add metrics for STUN
Dec 29, 2025
6091cd6
improve STUN BR integration test
Dec 29, 2025
dc21ac2
Revert "add metrics for STUN"
Dec 29, 2025
566a834
fix STUN integration test build error
Dec 29, 2025
2f06d44
lint
Dec 30, 2025
40c0062
remove retransmission timer calculation
jdslab Dec 30, 2025
c18f92d
rename stunHandler to stunConn
jdslab Dec 30, 2025
ec8f68e
fix variable and file names
jdslab Dec 30, 2025
5ff4b28
fix STUN integration test permission error on buildkite
Dec 30, 2025
c5b87b8
inline queuePacket
jdslab Dec 30, 2025
cc932c1
64kb receive buffer
jdslab Dec 30, 2025
4cf93fe
fix STUN integration test permission error on buildkite
Dec 30, 2025
318cce5
fix STUN integration test permission error on buildkite
Dec 30, 2025
c3a3877
improve STUN integration test reliability
Dec 30, 2025
9285a65
simplify assertion to satisfy linter
Dec 30, 2025
7650cf5
use netip.AddrPort instead of *net.UDPAddr for STUNConn
jdslab Dec 30, 2025
0bde35b
do not set deadlines on the underlying UDPConn
jdslab Dec 30, 2025
c66b6f2
only set write deadline on the underlying UDPConn
jdslab Dec 30, 2025
b4146a7
don't keep track of write deadline locally
jdslab Dec 30, 2025
8eafe06
improve check for stunConn and drop packets for different IA
jdslab Dec 30, 2025
4e6a9f5
improved error handling with type casts
jdslab Dec 30, 2025
3f17e0f
Merge branch 'stun-br' into snet-stun-modification
jdslab Dec 31, 2025
35e548c
code review modifications
jdslab Dec 31, 2025
95a7b0f
run gazelle
Dec 31, 2025
43e8351
change UDPConn interface to RawPacketConn interface
Dec 31, 2025
e167c29
configurable STUN through exported field
jdslab Dec 31, 2025
0c548d0
run gazelle
Dec 31, 2025
b070baa
modify stunConn to wrap RawPacketConn instead of net.UDPConn
Dec 31, 2025
eb8bdc5
fix bug where STUN request sent to wrong destination
Dec 31, 2025
88dcc39
update testing topology
Dec 31, 2025
8aef827
add NAT flag/env
jdslab Dec 31, 2025
1b47ba0
rename RawPacketConn to sysPacketConn
Dec 31, 2025
20fe070
add snet STUN acceptance test
Dec 31, 2025
0b3e509
remove legacy STUN demo acceptance test
Dec 31, 2025
c28e4f8
remove nat-tester folder
Dec 31, 2025
b78c157
code review modifications
jdslab Jan 2, 2026
d4f8814
fix typo
jdslab Jan 2, 2026
0803484
fix deadline behavior
jdslab Jan 3, 2026
6861cff
lint
Jan 4, 2026
4bbe09a
fix deadline/timeout behavior
jdslab Jan 5, 2026
37b442a
run gazelle
jdslab Jan 5, 2026
db5fa2c
trigger CI
jdslab Jan 5, 2026
f309001
update MODULE.bazel
JordiSubira Jan 5, 2026
a438ef3
Apply suggestions from code review
jdslab Jan 5, 2026
111dc5a
fix potential nil pointer dereference
jdslab Jan 5, 2026
f0bed55
apply linter
jdslab Jan 5, 2026
565e243
Merge branch 'stun-br' into snet-stun-modification
jdslab Jan 5, 2026
d0175b6
lint
jdslab Jan 7, 2026
507509b
Merge branch 'upstream-master' into snet-stun-modification
jdslab Jan 7, 2026
5fb4e90
run gazelle
jdslab Jan 7, 2026
a9188ee
Revert "add NAT flag/env"
jdslab Jan 8, 2026
4bc0555
update docs
jdslab Jan 8, 2026
048e743
improve rcvBufSize query
jdslab Jan 8, 2026
a55339d
code review modification
jdslab Jan 8, 2026
517f41c
Merge branch 'master' into snet-stun-modification
jdslab Jan 12, 2026
705bfb2
Apply suggestions from code review
jdslab Jan 14, 2026
17a2ea5
use anon function to defer mutex unlock
jdslab Jan 14, 2026
be0fd5a
change timer allocation to avoid unnecessary reallocation
jdslab Jan 14, 2026
4141e45
lint
jdslab Jan 14, 2026
dc90e6d
add documentation for STUNEnabled field
jdslab Jan 14, 2026
f3a66bb
code review suggestions
jdslab Jan 15, 2026
a5fcb40
code review suggestions
jdslab Jan 15, 2026
5a5948f
use singleflight group to simplify waiting for pending STUN requests
jdslab Jan 15, 2026
171caf6
update bazel
jdslab Jan 15, 2026
a6a4396
lint
jdslab Jan 16, 2026
c8a2349
move source address rewrite (STUN) to separate function
jdslab Jan 16, 2026
789eef3
cache whether STUN enabled in variable instead of checking by casting
jdslab Jan 16, 2026
3f773ee
rename stunMappedSource function
jdslab Jan 17, 2026
5d6fa53
Merge branch 'master' into snet-stun-modification
jdslab Jan 17, 2026
a7bfaf5
refactor after merge
jdslab Jan 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions acceptance/stun/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("//:scion.bzl", "scion_go_binary")
load("//acceptance/common:topogen.bzl", "topogen_test")

topogen_test(
name = "test",
src = "test.py",
args = [
"--executable=test-client:$(location //acceptance/stun/test-client)",
"--executable=test-server:$(location //acceptance/stun/test-server)",
],
data = [
"//acceptance/stun/test-client",
"//acceptance/stun/test-server",
],
topo = "//topology:tiny.topo",
)
19 changes: 19 additions & 0 deletions acceptance/stun/test-client/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("@rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "github.com/scionproto/scion/acceptance/stun/test-client",
visibility = ["//visibility:private"],
deps = [
"//pkg/daemon:go_default_library",
"//pkg/daemon/types:go_default_library",
"//pkg/snet:go_default_library",
],
)

go_binary(
name = "test-client",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
103 changes: 103 additions & 0 deletions acceptance/stun/test-client/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Copyright 2025 ETH Zurich
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"context"
"flag"
"log"
"os"

"github.com/scionproto/scion/pkg/daemon"
daemontypes "github.com/scionproto/scion/pkg/daemon/types"
"github.com/scionproto/scion/pkg/snet"
)

func main() {
log.SetOutput(os.Stdout)
log.Println("Client running")
var daemonAddr string
var localAddr snet.UDPAddr
var remoteAddr snet.UDPAddr
var data string
flag.StringVar(&daemonAddr, "daemon", "127.0.0.1:30255", "Daemon address")
flag.Var(&localAddr, "local", "Local address")
flag.Var(&remoteAddr, "remote", "Remote address")
flag.StringVar(&data, "data", "", "Data")
flag.Parse()

ctx := context.Background()

dc, err := daemon.NewService(daemonAddr).Connect(ctx)
if err != nil {
log.Fatalf("Failed to create SCION daemon connector: %v", err)
}

ps, err := dc.Paths(ctx, remoteAddr.IA, localAddr.IA, daemontypes.PathReqFlags{Refresh: true})
if err != nil {
log.Fatalf("Failed to lookup paths: %v", err)
}

if len(ps) == 0 {
log.Fatalf("No paths to %v available", remoteAddr.IA)
}

sp := ps[0]

log.Printf("Selected path to %v:", remoteAddr.IA)
log.Printf("\t%v", sp)

topology, err := daemon.LoadTopology(ctx, dc)
if err != nil {
log.Fatalf("Failed to load topology from daemon: %v", err)
}

scionNetwork := snet.SCIONNetwork{
Topology: topology,
STUNEnabled: true,
}

remoteAddr.Path = sp.Dataplane()
remoteAddr.NextHop = sp.UnderlayNextHop()

conn, err := scionNetwork.Dial(ctx, "udp", localAddr.Host, &remoteAddr)
if err != nil {
log.Fatalf("Failed to dial SCION address: %v", err)
}

defer conn.Close()

log.Print("Successfully established SCION connection")

_, err = conn.Write([]byte(data))
if err != nil {
log.Fatalf("Failed to write to SCION connection: %v", err)
}

log.Printf("Successfully sent data to %v", remoteAddr.IA)

buf := make([]byte, 4096)
n, err := conn.Read(buf)
if err != nil {
log.Fatalf("Failed to read from SCION connection: %v", err)
}

response := string(buf[:n])
log.Printf("Received data: \"%s\"", response)
if response != data {
log.Fatalf("Assertion failed: response does not match sent data")
}
os.Exit(0)
}
15 changes: 15 additions & 0 deletions acceptance/stun/test-server/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("@rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "github.com/scionproto/scion/acceptance/stun/test-server",
visibility = ["//visibility:private"],
deps = ["//pkg/snet:go_default_library"],
)

go_binary(
name = "test-server",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
102 changes: 102 additions & 0 deletions acceptance/stun/test-server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright 2025 ETH Zurich
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"flag"
"log"
"net"
"os"

"github.com/scionproto/scion/pkg/snet"
)

func main() {
log.SetOutput(os.Stdout)
log.Print("Server running")

var localAddr snet.UDPAddr
flag.Var(&localAddr, "local", "Local address")
flag.Parse()

conn, err := net.ListenUDP("udp", localAddr.Host)
if err != nil {
log.Fatalf("Failed to listen on UDP connection: %v", err)
}
defer conn.Close()

for {
var pkt snet.Packet
pkt.Prepare()

n, lastHop, err := conn.ReadFrom(pkt.Bytes)
if err != nil {
log.Printf("Failed to read packet: %v", err)
continue
}
pkt.Bytes = pkt.Bytes[:n]

err = pkt.Decode()
if err != nil {
log.Printf("Failed to decode packet: %v", err)
continue
}

pld, ok := pkt.Payload.(snet.UDPPayload)
if !ok {
log.Printf("Failed to read packet payload")
continue
}

if int(pld.DstPort) != localAddr.Host.Port {
continue
}

log.Printf("Received data: %q from %v:%v", string(pld.Payload), pkt.Source, pld.SrcPort)

pkt.Destination, pkt.Source = pkt.Source, pkt.Destination

rp, ok := pkt.Path.(snet.RawPath)
if !ok {
log.Printf("Failed to reverse path, unexpected path type: %v", pkt.Path)
continue
}
replyPather := snet.DefaultReplyPather{}
replyPath, err := replyPather.ReplyPath(rp)
if err != nil {
log.Printf("Failed to reverse path: %v", err)
continue
}
pkt.Path = replyPath

pkt.Payload = snet.UDPPayload{
SrcPort: pld.DstPort,
DstPort: pld.SrcPort,
Payload: pld.Payload,
}

err = pkt.Serialize()
if err != nil {
log.Printf("Failed to serialize SCION packet: %v", err)
continue
}

_, err = conn.WriteTo(pkt.Bytes, lastHop)
if err != nil {
log.Printf("Failed to write packet: %v", err)
continue
}
}
}
Loading
Loading