controller

package
v0.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package controller implements the DSNet network controller with testing capabilities. It manages node registrations, message forwarding, and network partitions. It also provides functions to manipulate message delivery according to testing configurations. These include dropping, duplicating, and reordering messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(cfg TestConfig)

Serve starts the gRPC server for the DSNet controller with the given test configuration. Server listens on port 50051.

Types

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node represents a DSNet node that can send messages via the controller.

func (*Node) SendEnvelope added in v0.0.6

func (n *Node) SendEnvelope(env *pb.Envelope) error

SendEnvelope sends the given envelope via the node's gRPC stream.

type Server

type Server struct {
	pb.UnimplementedNetworkControllerServer
	// contains filtered or unexported fields
}

Server implements the DSNet network controller with testing capabilities.

func NewServer added in v0.0.6

func NewServer(cfg TestConfig) *Server

newServer creates a new DSNet controller server with the specified test configuration.

func (*Server) BlockCommunication

func (s *Server) BlockCommunication(a, b string)

BlockCommunication blocks messages from node a to node b.

func (*Server) CreatePartition

func (s *Server) CreatePartition(group1, group2 []string)

CreatePartition creates a partition between two groups of nodes. Nodes in group1 cannot communicate with nodes in group2 and vice versa.

func (*Server) Stream

func (s *Server) Stream(stream pb.NetworkController_StreamServer) error

Stream handles the bi-directional streaming RPC between the controller and a node.

func (*Server) UnblockCommunication

func (s *Server) UnblockCommunication(a, b string)

UnblockCommunication unblocks messages from node a to node b.

type TestConfig added in v0.0.6

type TestConfig struct {
	MsgDropProb          float64
	MsgDupeProb          float64
	AsyncDuplicate       bool
	DisableMessageDelays bool
	MsgMinDelay          int
	MsgMaxDelay          int

	//Network Spikes
	EnableNetworkSpikes bool
	NetSpikeSmallProb   float64
	NetSpikeMedProb     float64
	NetSpikeLargeProb   float64
}

TestConfig holds the configuration parameters for simulating network messaging conditions. These include probabilities for message drops, duplications, and reordering, as well as parameters for reordering delays.

func (*TestConfig) FillDefaults added in v0.0.13

func (cfg *TestConfig) FillDefaults()

FillDefaults fills in default values for TestConfig fields if they are not set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL