Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 control/beacon/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ func (b Beacon) String() string {
}

func link(entry seg.ASEntry) (addr.IA, uint16) {
return entry.Local, entry.HopEntry.HopField.ConsIngress
return entry.Local, entry.HopEntry.HopField.ConsEgress
}
44 changes: 41 additions & 3 deletions control/beacon/beacon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/scionproto/scion/control/beacon"
"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/private/xtest/graph"
"github.com/scionproto/scion/pkg/segment"
)

// TestBeaconDiversity tests that diversity is calculated correctly.
func TestBeaconDiversity(t *testing.T) {
var tests = []struct {
name string
beacon []uint16
name string
beacon []uint16
// mBeacon allows to manually specify the other beacon.
Copy link
Contributor

@FR4NK-W FR4NK-W Dec 9, 2025

Choose a reason for hiding this comment

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

nit: Maybe also mention in the comment that beacon should not be set when setting mBeacon? Or simply mention that mBeacon overrides beacon?

mBeacon beacon.Beacon
diversity int
}{
{
Expand All @@ -51,14 +56,47 @@ func TestBeaconDiversity(t *testing.T) {
},
diversity: 2,
},
{
name: "Last link distinct",
mBeacon: beacon.Beacon{
Segment: &segment.PathSegment{
ASEntries: []segment.ASEntry{
{
Local: addr.MustParseIA("1-ff00:0:130"),
Next: addr.MustParseIA("1-ff00:0:110"),
HopEntry: segment.HopEntry{
HopField: segment.HopField{
ConsEgress: graph.If_130_A_110_X,
},
},
},
{
Local: addr.MustParseIA("1-ff00:0:110"),
Next: addr.MustParseIA("2-ff00:0:210"),
HopEntry: segment.HopEntry{
HopField: segment.HopField{
ConsIngress: graph.If_110_X_130_A,
ConsEgress: 2321,
},
},
},
},
},
InIfID: 2123,
},
diversity: 1,
},
}
mctrl := gomock.NewController(t)

g := graph.NewDefaultGraph(mctrl)
bseg := testBeacon(g, tests[0].beacon...)
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
other := testBeacon(g, test.beacon...)
other := test.mBeacon
if len(test.beacon) > 0 {
other = testBeacon(g, test.beacon...)
}
diversity := bseg.Diversity(other)
assert.Equal(t, test.diversity, diversity)
})
Expand Down
5 changes: 2 additions & 3 deletions control/beacon/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,9 @@ func testCoreStoreSelection(t *testing.T,
}

func testBeacon(g *graph.Graph, desc ...uint16) beacon.Beacon {
pseg := testSegment(g, desc)
asEntry := pseg.ASEntries[pseg.MaxIdx()]
pseg := testSegment(g, desc[:len(desc)-1])
return beacon.Beacon{
InIfID: asEntry.HopEntry.HopField.ConsIngress,
InIfID: desc[len(desc)-1],
Segment: pseg,
}
}
Expand Down
Loading