net

package
v0.0.0-...-918ceb5 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default port
	HORUS_UDP_PORT layers.UDPPort = 1234

	// Pkt types
	PKT_TYPE_IDLE_SIGNAL   byte = 0x06
	PKT_TYPE_IDLE_REMOVE   byte = 0x0A
	PKT_TYPE_KEEP_ALIVE    byte = 0x0B
	PKT_TYPE_WORKER_ID     byte = 0x0C
	PKT_TYPE_WORKER_ID_ACK byte = 0x0D

	// Dst types
	DST_TYPE_LEAF  uint16 = 0x0001
	DST_TYPE_SPINE uint16 = 0x0002
)
View Source
const DefaultRpcRecvSize = 1000
View Source
const DefaultRpcSendSize = 1000
View Source
const DefaultUnixSockRecvSize = 1000
View Source
const DefaultUnixSockSendSize = 1000
View Source
const MaximumConnectionTrialCount = 10

Variables

View Source
var LayerTypeHorus = gopacket.RegisterLayerType(
	2001,
	gopacket.LayerTypeMetadata{
		Name:    "Horus",
		Decoder: gopacket.DecodeFunc(decodeHorus),
	},
)

Register the layer type so we can use it The first argument is an ID. Use negative or 2000+ for custom layers. It must be unique

Functions

func CreateFullHorusPacket

func CreateFullHorusPacket(horus *HorusPacket,
	srcIP net.IP,
	dstIP net.IP) ([]byte, error)

func InitHorusDefinitions

func InitHorusDefinitions()

func NewCentralSrvServer

func NewCentralSrvServer(topology *model.Topology,
	vcm *core.VCManager,
	failedLeaves chan *LeafFailedMessage,
	failedServers chan *ServerFailedMessage,
	newLeaves chan *LeafAddedMessage,
	newServers chan *ServerAddedMessage,
	newVCs chan *VCUpdatedMessage,
	enabledPorts chan *PortEnabledMessage,
	disabledPorts chan *PortDisabledMessage,
) *centralSrvServer

func NewLeafSrvServer

func NewLeafSrvServer(topology *model.Topology,
	vcm *core.VCManager,
	updatedServers chan *core.LeafHealthMsg,
	newServers chan *ServerAddedMessage,
	newVCs chan *VCUpdatedMessage,
) *leafSrvServer

func NewManagerSrvServer

func NewManagerSrvServer(
	failedLeaves chan *LeafFailedMessage,
	newLeaves chan *LeafAddedMessage,
) *managerSrvServer

func NewSpineSrvServer

func NewSpineSrvServer(topology *model.Topology,
	vcm *core.VCManager,
	failedLeavesToRPC chan *LeafFailedMessage,
	updatedLeavesToRPC chan *LeafUpdatedMessage,
	failedServersToRPC chan *ServerFailedMessage,
	newLeavesToRPC chan *LeafAddedMessage,
	newServers chan *ServerAddedMessage,
	newVCs chan *VCUpdatedMessage,
) *spineSrvServer

func TestHorusPkt

func TestHorusPkt(pkt_type byte,
	pool_id uint16,
	src_id uint16,
	dst_id uint16,
	task_id uint16,
	payload []byte)

Types

type CentralRpcEndpoint

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

func NewCentralRpcEndpoint

func NewCentralRpcEndpoint(srvLAddr string,
	topology *model.Topology,
	vcm *core.VCManager,
	enabledPorts chan *PortEnabledMessage,
	disabledPorts chan *PortDisabledMessage,
) *CentralRpcEndpoint

func (*CentralRpcEndpoint) Start

func (s *CentralRpcEndpoint) Start()

type HorusPacket

type HorusPacket struct {
	layers.BaseLayer

	PktType   byte
	ClusterID uint16
	SrcID     uint16
	DstID     uint16
	QLen      uint16
	SeqNum    uint16
	// fields below are sample app layer headers: not needed for task scheduling and not parsed by switches
	RestOfData []byte
}

Horus Create custom layer structure

func (*HorusPacket) CanDecode

func (horus *HorusPacket) CanDecode() gopacket.LayerClass

func (*HorusPacket) DecodeFromBytes

func (horus *HorusPacket) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error

Custom decode function. We can name it whatever we want but it should have the same arguments and return value When the layer is registered we tell it to use this decode function

func (*HorusPacket) LayerPayload

func (horus *HorusPacket) LayerPayload() []byte

LayerPayload returns the subsequent layer built on top of our layer or raw payload

func (*HorusPacket) LayerType

func (horus *HorusPacket) LayerType() gopacket.LayerType

When we inquire about the type, what type of layer should we say it is? We want it to return our custom layer type

func (*HorusPacket) NextLayerType

func (horus *HorusPacket) NextLayerType() gopacket.LayerType

func (*HorusPacket) SerializeTo

func (horus *HorusPacket) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error

SerializeTo writes the serialized form of this layer into the SerializationBuffer, implementing gopacket.SerializableLayer. See the docs for gopacket.SerializableLayer for more info.

type LeafAddedMessage

type LeafAddedMessage struct {
	Leaf *horus_pb.LeafInfo
	Dst  *model.Node
}

func NewLeafAddedMessage

func NewLeafAddedMessage(leaf *horus_pb.LeafInfo, dst *model.Node) *LeafAddedMessage

type LeafFailedMessage

type LeafFailedMessage struct {
	Leaf *horus_pb.LeafInfo
	Dsts []*model.Node
}

func NewLeafFailedMessage

func NewLeafFailedMessage(leaf *horus_pb.LeafInfo, dsts []*model.Node) *LeafFailedMessage

type LeafRpcEndpoint

type LeafRpcEndpoint struct {
	sync.RWMutex

	SrvCentralAddr string
	SrvLAddr       string

	DoneChan chan bool
	// contains filtered or unexported fields
}

func NewBareLeafRpcEndpoint

func NewBareLeafRpcEndpoint(ctrlID uint16, srvCentralAddr string,
	updatedServers chan *core.LeafHealthMsg,
	newServers chan *ServerAddedMessage,
	newVCs chan *VCUpdatedMessage,
) *LeafRpcEndpoint

func NewLeafRpcEndpoint

func NewLeafRpcEndpoint(srvLAddr, srvCentralAddr string,
	topology *model.Topology,
	vcm *core.VCManager,
	updatedServers chan *core.LeafHealthMsg,
	newServers chan *ServerAddedMessage,
	newVCs chan *VCUpdatedMessage,
) *LeafRpcEndpoint

func (*LeafRpcEndpoint) GetTopology

func (s *LeafRpcEndpoint) GetTopology() (*horus_pb.TopoInfo, error)

func (*LeafRpcEndpoint) GetVCs

func (s *LeafRpcEndpoint) GetVCs() ([]*horus_pb.VCInfo, error)

func (*LeafRpcEndpoint) SetLocalAddress

func (s *LeafRpcEndpoint) SetLocalAddress(address string)

func (*LeafRpcEndpoint) SetTopology

func (s *LeafRpcEndpoint) SetTopology(topology *model.Topology)

func (*LeafRpcEndpoint) SetVCManager

func (s *LeafRpcEndpoint) SetVCManager(vcm *core.VCManager)

func (*LeafRpcEndpoint) Start

func (s *LeafRpcEndpoint) Start()

func (*LeafRpcEndpoint) StartClient

func (s *LeafRpcEndpoint) StartClient()

func (*LeafRpcEndpoint) StartServer

func (s *LeafRpcEndpoint) StartServer()

type LeafUpdatedMessage

type LeafUpdatedMessage struct {
	Leaves []*model.Node
}

func NewLeafUpdatedMessage

func NewLeafUpdatedMessage(leaves []*model.Node) *LeafUpdatedMessage

type LocalSock

type LocalSock interface {
	Connect() error

	Close() error

	Start()
}

type ManagerRpcEndpoint

type ManagerRpcEndpoint struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewManagerRpcEndpoint

func NewManagerRpcEndpoint(srvLAddress string,
	failedLeaves chan *LeafFailedMessage,
	newLeaves chan *LeafAddedMessage,
) *ManagerRpcEndpoint

func (*ManagerRpcEndpoint) Start

func (s *ManagerRpcEndpoint) Start()

type PortDisabledMessage

type PortDisabledMessage struct {
	Port *model.Port
}

type PortEnabledMessage

type PortEnabledMessage struct {
	Port *model.Port
}

type RawSockClient

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

func NewRawSockClient

func NewRawSockClient(ifName string, sendChan chan []byte, recvChan chan []byte) *RawSockClient

func (*RawSockClient) Close

func (rsc *RawSockClient) Close() error

func (*RawSockClient) Connect

func (rsc *RawSockClient) Connect() error

func (*RawSockClient) Start

func (rsc *RawSockClient) Start()

type ServerAddedMessage

type ServerAddedMessage struct {
	Server *horus_pb.ServerInfo
	Dst    *model.Node
}

func NewServerAddedMessage

func NewServerAddedMessage(server *horus_pb.ServerInfo, dst *model.Node) *ServerAddedMessage

type ServerFailedMessage

type ServerFailedMessage struct {
	Server *horus_pb.ServerInfo
	Dsts   []*model.Node
}

func NewServerFailedMessage

func NewServerFailedMessage(server *horus_pb.ServerInfo, dsts []*model.Node) *ServerFailedMessage

type SpineRpcEndpoint

type SpineRpcEndpoint struct {
	sync.RWMutex
	SrvLAddr       string
	SrvCentralAddr string
	// contains filtered or unexported fields
}

func NewSpineRpcEndpoint

func NewSpineRpcEndpoint(srvLAddr, srvCentralAddr string,
	topology *model.Topology,
	vcm *core.VCManager,
	failedLeaves chan *LeafFailedMessage,
	failedServers chan *ServerFailedMessage,
	newLeaves chan *LeafAddedMessage,
	newServers chan *ServerAddedMessage,
	newVCs chan *VCUpdatedMessage,
) *SpineRpcEndpoint

func (*SpineRpcEndpoint) GetVCs

func (s *SpineRpcEndpoint) GetVCs() ([]*horus_pb.VCInfo, error)

func (*SpineRpcEndpoint) Start

func (s *SpineRpcEndpoint) Start()

type SpineRpcEndpointLite

type SpineRpcEndpointLite struct {
	sync.RWMutex
	SrvCentralAddr string
}

func NewSpineRpcEndpointLite

func NewSpineRpcEndpointLite(srvCentralAddr string) *SpineRpcEndpointLite

func (*SpineRpcEndpointLite) GetTopology

func (s *SpineRpcEndpointLite) GetTopology() (*horus_pb.TopoInfo, error)

type UnixSockClient

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

func NewUnixSockClient

func NewUnixSockClient(sockName string, sendChan chan []byte, recvChan chan []byte) *UnixSockClient

func (*UnixSockClient) Close

func (usc *UnixSockClient) Close() error

func (*UnixSockClient) Connect

func (usc *UnixSockClient) Connect() error

func (*UnixSockClient) Start

func (usc *UnixSockClient) Start()

type VCUpdateType

type VCUpdateType uint32
const (
	VCUpdateAdd VCUpdateType = iota
	VCUpdateRem
)

type VCUpdatedMessage

type VCUpdatedMessage struct {
	VCInfo *horus_pb.VCInfo
	Dsts   []*model.Node
	Type   VCUpdateType
}

func NewVCUpdatedMessage

func NewVCUpdatedMessage(vcInfo *horus_pb.VCInfo, vcType VCUpdateType, dsts []*model.Node) *VCUpdatedMessage

Jump to

Keyboard shortcuts

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