device

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: CC0-1.0 Imports: 8 Imported by: 0

Documentation

Overview

package for simulation-emulation packet

Index

Constants

View Source
const (
	PhysLink          int = iota // wired point-to-point link
	Broadcast                    // wired broadcast link
	DirectedWireless             // point-to-point wireless
	BroadcastWireless            // broadcast wireless
	Meta                         // aggregated connection
)

a nic in i2s2 can be facing different kinds of connections.

Variables

This section is empty.

Functions

This section is empty.

Types

type Child

type Child interface {
	Push_down([]byte, int)
}

---------- interfaces ---------

type MediaType

type MediaType int

type Msg_xfer

type Msg_xfer interface {
	Xfer([]byte) []byte
}

type NIC

type NIC struct {
	Id int // Id numbers are used to identify endpoints.
	// We maintain a map of endpoint ids to NIC struct pointers
	MAC    net.Interface // core golang net package representing a MAC address
	SymMAC int           // MACs that face Meta media have some symbolic representation give
	// the index into a map that points to something describing it
	MAC_is_symbolic bool // flag indicating whether MAC is physical (contained in MAC)
	// or symbolic (contained in SymMAC
	IPAdrs net.IP // using net packages IP representation, which includes IPv6
	Media  MediaType

	// endpoints have integer identities that identify other NICs
	Endpoints map[int]bool
}

a NIC object captures the important details of a NIC

func New

func New(name string, macname string, ipaddr string, media_type MediaType) (*NIC, error)

create a new instance of a NIC

func (*NIC) AddEndpoint

func (n *NIC) AddEndpoint(ep int)

remember that this NIC connects to the NIC with id ep

func (*NIC) AddEndpointSet

func (n *NIC) AddEndpointSet(eps map[int]bool)

remember that this NIC connects to all the NIC in a set of them

type Parent

type Parent interface {
	Push_up([]byte, int)
}

type Protocol_node

type Protocol_node struct {
	Name      string
	Id        int
	Xfer_up   Msg_xfer
	Xfer_down Msg_xfer
	Parents   map[int]Parent
	Children  map[int]Child
}

-------- Protocol_node realization ------

func (*Protocol_node) Add_child

func (pn *Protocol_node) Add_child(child *Protocol_node, child_id int)

func (*Protocol_node) Add_parent

func (pn *Protocol_node) Add_parent(parent *Protocol_node, parent_id int)

func (*Protocol_node) Handle

func (pn *Protocol_node) Handle(context any, message any)

event handler for message delivered to Protocol_node 'context' and 'message' are from event, handed up from event scheduler

func (*Protocol_node) Push_down

func (pn *Protocol_node) Push_down(frame []byte, from int)

func (*Protocol_node) Push_up

func (pn *Protocol_node) Push_up(context Protocol_node_context, frame []byte, from int)

process a message from below, push up to all parents

type Protocol_node_context

type Protocol_node_context struct {
	// what scheduling queue to use
	Evtm *evtm.EventManager

	// entry index is integer identity of source of message being
	// passed along
	Index int
	// contains filtered or unexported fields
}

type SMP

type SMP struct {
	RawPacket []byte
	// MAC addresses
	SrcMAC net.Interface
	DstMAC net.Interface
	// IP address
	SrcIP net.IP
	DstIP net.IP
	// ports
	//
	SrcPort int
	DstPort int
	PayLoad []byte
}

Jump to

Keyboard shortcuts

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