Skip to content

Treeless soft-state #53

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

Draft
wants to merge 47 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3fdf3e7
Initial soft-state testing
neilalexander Apr 12, 2022
9cacda9
Fix `pineconeip`
neilalexander Apr 12, 2022
6c53256
Try raising the intervals a bit
neilalexander Apr 12, 2022
a6f5f71
Tighter expiry
neilalexander Apr 12, 2022
9e0e66a
Tweaks
neilalexander Apr 12, 2022
9544421
Try to speed up convergence but reduce idle noise
neilalexander Apr 12, 2022
1eafa35
More tweaks
neilalexander Apr 12, 2022
e980db4
Handle disconnections on destination ports, tweak next-hops
neilalexander Apr 12, 2022
3153da5
All traffic is either bootstrap or not, more tweaking
neilalexander Apr 12, 2022
7217bb8
Merge branch 'main' into softstate
neilalexander Apr 14, 2022
db28a00
Protocol calming, loop detection, bootstrap signatures
neilalexander Apr 14, 2022
ca3f61a
Tidy up sim
neilalexander Apr 14, 2022
9d1278b
Merge remote-tracking branch 'origin/main' into softstate
devonh Apr 26, 2022
73d585b
Merge remote-tracking branch 'origin/main' into softstate
devonh Apr 26, 2022
2e65ba2
Fix unit test
devonh Apr 26, 2022
f8aa052
Don't drop pong responses as looping traffic
devonh Apr 27, 2022
9bd82ae
Remove unused snake path id
devonh Apr 28, 2022
d6fb3d1
Remove unused variable from nextHopsSNEK
devonh Apr 28, 2022
f76b5d8
Unassign setup acks capability from soft state capabilites
devonh Apr 28, 2022
2616e82
Cleanup comments to reflect new softstate logic
devonh Apr 28, 2022
189af67
Remove unused candidate variable from state
devonh Apr 28, 2022
a6b5c11
Update sim and events to reflect softstate changes
devonh Apr 28, 2022
bcba8b3
Update wireshark dissector to match softstate frames
devonh Apr 28, 2022
efe1710
Add unit test for snake bootstrap
devonh Apr 28, 2022
74f0dee
Merge remote-tracking branch 'origin/main' into softstate
devonh Apr 28, 2022
06f2547
Fix incorrect comment about bootstrap forwarding conditions
devonh Apr 28, 2022
a8a5b35
Add `queue` interface
neilalexander Apr 29, 2022
4815c42
Merge branch 'main' into softstate (ping removal)
devonh May 12, 2022
04ac0e1
Merge remote-tracking branch 'origin/main' into softstate
devonh May 13, 2022
1ee3761
Initial docs update for softstate algorithm
devonh May 13, 2022
3740c7f
Softstate doc updates
devonh May 13, 2022
fcb5164
Fix logic for selecting lowest latency links
devonh May 25, 2022
39f8332
Update docs with watermark information (#52)
devonh May 25, 2022
b273631
Remove spanning tree
neilalexander May 26, 2022
a4d9428
Make it work
neilalexander May 26, 2022
df126d9
Clean up some more
neilalexander May 26, 2022
3dbaa6c
Clean up some more
neilalexander May 26, 2022
606aac4
Fix frame reuse
neilalexander May 26, 2022
17e977c
Only keep first highest key update (should settle on lowest latency p…
neilalexander May 27, 2022
bb22a13
Clean up a tree thing
neilalexander May 27, 2022
9ccd008
Make bootstrapping slightly more aggressive
neilalexander May 27, 2022
5e4dcd7
Fix some bugs
neilalexander May 27, 2022
ee335f7
Update comment
neilalexander May 27, 2022
62a5775
Remove bootstrap soon when updating desc node
neilalexander May 27, 2022
c345c29
Speed up updates
neilalexander May 27, 2022
615c321
Try to distribute ascending path information more quickly when peers …
neilalexander Jun 8, 2022
bb13fd7
Fix bugs
neilalexander Jun 8, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

# Stuff from GitHub Pages
docs/_site
.jekyll-metadata
11 changes: 3 additions & 8 deletions cmd/pineconesim/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,9 @@ func userProxyReporter(conn *websocket.Conn, connID uint64, sim *simulator.Simul
AnnTime: node.Announcement.Time,
Coords: node.Coords,
},
Peers: peerConns,
TreeParent: node.Parent,
SnakeAsc: node.AscendingPeer,
SnakeAscPath: node.AscendingPathID,
SnakeDesc: node.DescendingPeer,
SnakeDescPath: node.DescendingPathID,
Peers: peerConns,
TreeParent: node.Parent,
SnakeDesc: node.DescendingPeer,
}

if batchSize == int(maxBatchSize) || end {
Expand Down Expand Up @@ -351,8 +348,6 @@ func handleSimEvents(log *log.Logger, conn *websocket.Conn, ch <-chan simulator.
eventType = simulator.SimPeerRemoved
case simulator.TreeParentUpdate:
eventType = simulator.SimTreeParentUpdated
case simulator.SnakeAscUpdate:
eventType = simulator.SimSnakeAscUpdated
case simulator.SnakeDescUpdate:
eventType = simulator.SimSnakeDescUpdated
case simulator.TreeRootAnnUpdate:
Expand Down
10 changes: 0 additions & 10 deletions cmd/pineconesim/simulator/adversary/drop_packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,7 @@ func NewPacketsReceived() PacketsReceived {
func defaultFrameCount() PeerFrameCount {
frameCount := make(FrameCounts, 9)
frameCount[types.TypeKeepalive] = atomic.NewUint64(0)
frameCount[types.TypeTreeAnnouncement] = atomic.NewUint64(0)
frameCount[types.TypeVirtualSnakeBootstrap] = atomic.NewUint64(0)
frameCount[types.TypeVirtualSnakeBootstrapACK] = atomic.NewUint64(0)
frameCount[types.TypeVirtualSnakeSetup] = atomic.NewUint64(0)
frameCount[types.TypeVirtualSnakeSetupACK] = atomic.NewUint64(0)
frameCount[types.TypeVirtualSnakeTeardown] = atomic.NewUint64(0)
frameCount[types.TypeTreeRouted] = atomic.NewUint64(0)
frameCount[types.TypeVirtualSnakeRouted] = atomic.NewUint64(0)

peerFrameCount := PeerFrameCount{
Expand Down Expand Up @@ -139,10 +133,6 @@ func (a *AdversaryRouter) Ping(ctx context.Context, addr net.Addr) (uint16, time
return 0, 0, nil
}

func (a *AdversaryRouter) Coords() types.Coordinates {
return a.rtr.Coords()
}

func (a *AdversaryRouter) ConfigureFilterDefaults(rates DropRates) {
a.dropSettings.overall = rates
}
Expand Down
16 changes: 6 additions & 10 deletions cmd/pineconesim/simulator/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const (
SimPeerAdded
SimPeerRemoved
SimTreeParentUpdated
SimSnakeAscUpdated
SimSnakeDescUpdated
SimTreeRootAnnUpdated
SimPingStateUpdated
Expand Down Expand Up @@ -68,15 +67,12 @@ const (
)

type InitialNodeState struct {
PublicKey string
NodeType APINodeType
RootState RootState
Peers []PeerInfo
TreeParent string
SnakeAsc string
SnakeAscPath string
SnakeDesc string
SnakeDescPath string
PublicKey string
NodeType APINodeType
RootState RootState
Peers []PeerInfo
TreeParent string
SnakeDesc string
}

type RootState struct {
Expand Down
72 changes: 0 additions & 72 deletions cmd/pineconesim/simulator/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,48 +119,12 @@ func UnmarshalCommandJSON(command *SimCommandMsg) (SimCommand, error) {
} else {
err = fmt.Errorf("%sConfigureAdversaryDefaults.DropRates.Keepalive field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["TreeAnnouncement"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeTreeAnnouncement] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryDefaults.DropRates.TreeAnnouncement field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["TreeRouted"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeTreeRouted] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryDefaults.DropRates.TreeRouted field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["VirtualSnakeBootstrap"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeVirtualSnakeBootstrap] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryDefaults.DropRates.VirtualSnakeBootstrap field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["VirtualSnakeBootstrapACK"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeVirtualSnakeBootstrapACK] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryDefaults.DropRates.VirtualSnakeBootstrapACK field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["VirtualSnakeSetup"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeVirtualSnakeSetup] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryDefaults.DropRates.VirtualSnakeSetup field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["VirtualSnakeSetupACK"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeVirtualSnakeSetupACK] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryDefaults.DropRates.VirtualSnakeSetupACK field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["VirtualSnakeTeardown"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeVirtualSnakeTeardown] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryDefaults.DropRates.VirtualSnakeTeardown field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["VirtualSnakeRouted"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeVirtualSnakeRouted] = uint64(intVal)
Expand Down Expand Up @@ -199,48 +163,12 @@ func UnmarshalCommandJSON(command *SimCommandMsg) (SimCommand, error) {
} else {
err = fmt.Errorf("%sConfigureAdversaryPeer.DropRates.Keepalive field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["TreeAnnouncement"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeTreeAnnouncement] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryPeer.DropRates.TreeAnnouncement field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["TreeRouted"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeTreeRouted] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryPeer.DropRates.TreeRouted field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["VirtualSnakeBootstrap"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeVirtualSnakeBootstrap] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryPeer.DropRates.VirtualSnakeBootstrap field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["VirtualSnakeBootstrapACK"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeVirtualSnakeBootstrapACK] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryPeer.DropRates.VirtualSnakeBootstrapACK field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["VirtualSnakeSetup"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeVirtualSnakeSetup] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryPeer.DropRates.VirtualSnakeSetup field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["VirtualSnakeSetupACK"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeVirtualSnakeSetupACK] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryPeer.DropRates.VirtualSnakeSetupACK field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["VirtualSnakeTeardown"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeVirtualSnakeTeardown] = uint64(intVal)
} else {
err = fmt.Errorf("%sConfigureAdversaryPeer.DropRates.VirtualSnakeTeardown field doesn't exist", FAILURE_PREAMBLE)
}
if subVal, subOk := val.(map[string]interface{})["VirtualSnakeRouted"]; subOk {
intVal, _ := strconv.Atoi(subVal.(string))
dropRates.Frames[types.TypeVirtualSnakeRouted] = uint64(intVal)
Expand Down
21 changes: 4 additions & 17 deletions cmd/pineconesim/simulator/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,10 @@ type TreeParentUpdate struct {
// Tag TreeParentUpdate as an Event
func (e TreeParentUpdate) isEvent() {}

type SnakeAscUpdate struct {
Node string
Peer string
Prev string
PathID string
}

// Tag SnakeAscUpdate as an Event
func (e SnakeAscUpdate) isEvent() {}

type SnakeDescUpdate struct {
Node string
Peer string
Prev string
PathID string
Node string
Peer string
Prev string
}

// Tag SnakeDescUpdate as an Event
Expand Down Expand Up @@ -129,10 +118,8 @@ func (h eventHandler) Run(quit <-chan bool, sim *Simulator) {
sim.handlePeerRemoved(h.node, e.PeerID, int(e.Port))
case events.TreeParentUpdate:
sim.handleTreeParentUpdate(h.node, e.PeerID)
case events.SnakeAscUpdate:
sim.handleSnakeAscUpdate(h.node, e.PeerID, e.PathID)
case events.SnakeDescUpdate:
sim.handleSnakeDescUpdate(h.node, e.PeerID, e.PathID)
sim.handleSnakeDescUpdate(h.node, e.PeerID)
case events.TreeRootAnnUpdate:
sim.handleTreeRootAnnUpdate(h.node, e.Root, e.Sequence, e.Time, e.Coords)
default:
Expand Down
27 changes: 0 additions & 27 deletions cmd/pineconesim/simulator/pathfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,6 @@ import (
"time"
)

func (sim *Simulator) PingTree(from, to string) (uint16, time.Duration, error) {
fromnode := sim.nodes[from]
tonode := sim.nodes[to]
success := false

ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()

defer func() {
sim.treePathConvergenceMutex.Lock()
if _, ok := sim.treePathConvergence[from]; !ok {
sim.treePathConvergence[from] = map[string]bool{}
}
sim.treePathConvergence[from][to] = success
sim.treePathConvergenceMutex.Unlock()
}()

hops, rtt, err := fromnode.Ping(ctx, tonode.Coords())
if err != nil {
return 0, 0, fmt.Errorf("fromnode.TreePing: %w", err)
}

success = true
sim.ReportDistance(from, to, int64(hops), false)
return hops, rtt, nil
}

func (sim *Simulator) PingSNEK(from, to string) (uint16, time.Duration, error) {
fromnode := sim.nodes[from]
tonode := sim.nodes[to]
Expand Down
36 changes: 5 additions & 31 deletions cmd/pineconesim/simulator/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ import (
type PingType uint8

const (
TreePing PingType = iota
TreePong
SNEKPing
SNEKPing PingType = iota
SNEKPong
)

Expand All @@ -47,25 +45,17 @@ func (p *PingPayload) MarshalBinary(buffer []byte) (int, error) {
offset += 2

switch orig := p.origin.(type) {
case types.Coordinates:
on, err := orig.MarshalBinary(buffer[offset:])
if err != nil {
return 0, fmt.Errorf("f.Destination.MarshalBinary: %w", err)
}
offset += on
case types.PublicKey:
offset += copy(buffer[offset:], orig[:ed25519.PublicKeySize])
default:
return 0, fmt.Errorf("unknown address type")
}

switch dest := p.destination.(type) {
case types.Coordinates:
dn, err := dest.MarshalBinary(buffer[offset:])
if err != nil {
return 0, fmt.Errorf("f.Destination.MarshalBinary: %w", err)
}
offset += dn
case types.PublicKey:
offset += copy(buffer[offset:], dest[:ed25519.PublicKeySize])
default:
return 0, fmt.Errorf("unknown address type")
}

return offset, nil
Expand All @@ -78,22 +68,6 @@ func (p *PingPayload) UnmarshalBinary(data []byte) (int, error) {
offset += 3

switch p.pingType {
case TreePing, TreePong:
orig := types.Coordinates{}
oriLen, oriErr := orig.UnmarshalBinary(data[offset:])
if oriErr != nil {
return 0, fmt.Errorf("p.orig.UnmarshalBinary: %w", oriErr)
}
offset += oriLen
p.origin = net.Addr(orig)

dest := types.Coordinates{}
dstLen, dstErr := dest.UnmarshalBinary(data[offset:])
if dstErr != nil {
return 0, fmt.Errorf("p.dest.UnmarshalBinary: %w", dstErr)
}
offset += dstLen
p.destination = net.Addr(dest)
case SNEKPing, SNEKPong:
tempKey := types.PublicKey{}
offset += copy(tempKey[:], data[offset:])
Expand Down
Loading