Skip to content
Merged
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
6 changes: 3 additions & 3 deletions core/router_algo.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func ComputeRoutes(s *state.RouterState, r Router) {
continue
}
}
if ShouldSwitch(oldRoute, newRoute) {
if ShouldSwitch(oldRoute, newRoute, s.RouterTunables) {
newTable[prefix] = newRoute
}
}
Expand Down Expand Up @@ -671,11 +671,11 @@ func SolveStarvation(router *state.RouterState, r Router) {
// requests are expected to actually reach the source.)
}

func ShouldSwitch(curRoute state.SelRoute, newRoute state.SelRoute) bool {
func ShouldSwitch(curRoute state.SelRoute, newRoute state.SelRoute, tunable *state.RouterTunables) bool {
// TODO: Investigate stable routing heuristics
curMetric := float64(curRoute.Metric)
newMetric := float64(newRoute.Metric)
if newMetric > curMetric {
if newMetric*tunable.LinkSwitchDeadband > curMetric {
return false
}
return true
Expand Down
12 changes: 6 additions & 6 deletions core/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestRouterNet2S_SolveStarvation(t *testing.T) {
// / | FD(A) = 1
// S |1
// \ | D(B) = 2
// 2 \| FD(B) = 2
// 3 \| FD(B) = 2
// B

h := &RouterHarness{}
Expand All @@ -172,7 +172,7 @@ func TestRouterNet2S_SolveStarvation(t *testing.T) {
}

AS := AddLink(rs, NewMockEndpoint("A", 1))
_ = AddLink(rs, NewMockEndpoint("B", 2))
_ = AddLink(rs, NewMockEndpoint("B", 3))

// A's advertised routes
h.NeighUpdate(rs, "A", "S", nodeToPrefix("S"), 0, 1)
Expand All @@ -182,7 +182,7 @@ func TestRouterNet2S_SolveStarvation(t *testing.T) {
// B's advertised routes
h.NeighUpdate(rs, "B", "B", nodeToPrefix("B"), 0, 0)
h.NeighUpdate(rs, "B", "A", nodeToPrefix("A"), 0, 1)
h.NeighUpdate(rs, "B", "S", nodeToPrefix("S"), 0, 2)
h.NeighUpdate(rs, "B", "S", nodeToPrefix("S"), 0, 3)

ComputeRoutes(rs, h)
a := h.GetActions()
Expand All @@ -193,7 +193,7 @@ func TestRouterNet2S_SolveStarvation(t *testing.T) {
)
assert.Equal(t, `10.0.0.1/32 via (nh: A, router: A, prefix: 10.0.0.1/32, seqno: 0, metric: 1)
10.0.0.19/32 via (nh: S, router: S, prefix: 10.0.0.19/32, seqno: 0, metric: 0)
10.0.0.2/32 via (nh: B, router: B, prefix: 10.0.0.2/32, seqno: 0, metric: 2)`, rs.StringRoutes())
10.0.0.2/32 via (nh: A, router: B, prefix: 10.0.0.2/32, seqno: 0, metric: 2)`, rs.StringRoutes())

// check feasibility distances
assert.Equal(t, state.FD{Seqno: 0, Metric: 1}, rs.Sources[state.Source{NodeId: "A", Prefix: nodeToPrefix("A")}])
Expand All @@ -206,7 +206,7 @@ func TestRouterNet2S_SolveStarvation(t *testing.T) {
// | FD(A) = 1
// S |1
// \ | D(B) = 2
// 2 \| FD(B) = 2
// 3 \| FD(B) = 2
// B

RemoveLink(rs, AS)
Expand Down Expand Up @@ -244,7 +244,7 @@ func TestRouterNet2S_SolveStarvation(t *testing.T) {
},
FD: state.FD{
Seqno: 1,
Metric: 3,
Metric: 4,
},
}
a.AssertContains(t, BroadcastUpdateRoute(pr))
Expand Down
14 changes: 8 additions & 6 deletions state/tunables.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ type RouterTunables struct {
// MinimumConfidenceWindow is the minimum number of samples before we lower the ping
MinimumConfidenceWindow int

GcDelay time.Duration
LinkDeadThreshold time.Duration
RouteExpiryTime time.Duration
GcDelay time.Duration
LinkDeadThreshold time.Duration
RouteExpiryTime time.Duration
LinkSwitchDeadband float64 // We will switch to a new feasible route if: metric(new) * LinkSwitchDeadband <= metric(old)

// client configuration
ClientKeepaliveInterval time.Duration
Expand Down Expand Up @@ -75,9 +76,10 @@ func DefaultRouterTunables() RouterTunables {
OutlierPercentage: 0.05,
MinimumConfidenceWindow: int(time.Second * 15 / probeDelay),

GcDelay: time.Millisecond * 1000,
LinkDeadThreshold: 5 * probeDelay,
RouteExpiryTime: 5 * routeUpdateDelay,
GcDelay: time.Millisecond * 1000,
LinkDeadThreshold: 5 * probeDelay,
RouteExpiryTime: 5 * routeUpdateDelay,
LinkSwitchDeadband: 1.1,

ClientKeepaliveInterval: 3 * probeDelay,
ClientDeadThreshold: 6 * probeDelay, // 2 * ClientKeepaliveInterval
Expand Down
Loading