nom

package
v0.0.0-...-8b36eab Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2016 License: GPL-2.0 Imports: 8 Imported by: 7

Documentation

Overview

Package nom contains the Network Object Model: an abstraction for computer networks. In essence it is a graph of networking nodes similar to what is proposed in ONIX.

NOM models a network as a graph of nodes. Each node has a set of ports with outgoing links that are connected to other ports.

  • +===============================================
  • | Author: Elahe Jalalpour (el.jalalpour@gmail.com)
  • |
  • | Creation Date: 24-11-2015
  • |
  • | File Name: host.go
  • +===============================================

Index

Constants

View Source
const (
	EthTypeIPv4 EthType = 0x0800
	EthTypeIPv6         = 0x86DD
	EthTypeARP          = 0x0806
	EthTypeLLDP         = 0x88CC
)

Valid values for EthType.

View Source
const (
	LinkStateUnknown LinkState = iota
	LinkStateUp                = iota
	LinkStateDown              = iota
)

Valid values for LinkState.

View Source
const (
	PortStateUnknown PortState = iota // Port's state is unknown.
	PortStateDown              = iota // Port is not connected to any link.
	PortStateUp                = iota // Port is up and forwarding packets.
	PortStateBlocked           = iota // Port is blocked.
)

Valid values for PortState.

View Source
const (
	PortConfigDown        PortConfig = 1 << iota // Down.
	PortConfigDropPackets            = 1 << iota // Drop incoming packets.
	PortConfigNoForward              = 1 << iota // Do not forward packets.
	PortConfigNoFlood                = 1 << iota // Do not include in flood.
	PortConfigNoPacketIn             = 1 << iota // Do not send packet ins.
	PortConfigDisableStp             = 1 << iota // Disable STP.
	PortConfigDropStp                = 1 << iota // Drop STP packets.
)

Valid values for PortConfig.

View Source
const (
	PortFeature10MBHD  PortFeature = 1 << iota // 10MB half-duplex.
	PortFeature10MBFD              = 1 << iota // 10MB full-duplex.
	PortFeature100MBHD             = 1 << iota // 100MB half-duplex.
	PortFeature100MBFD             = 1 << iota // 100MB half-duplex.
	PortFeature1GBHD               = 1 << iota // 1GB half-duplex.
	PortFeature1GBFD               = 1 << iota // 1GB half-duplex.
	PortFeature10GBHD              = 1 << iota // 10GB  half-duplex.
	PortFeature10GBFD              = 1 << iota // 10GB half-duplex.
	PortFeatureCopper              = 1 << iota // Copper.
	PortFeatureFiber               = 1 << iota // Fiber.
	PortFeatureAutoneg             = 1 << iota // Auto negotiation.
	PortPause                      = 1 << iota // Pause.
	PortPauseAsym                  = 1 << iota // Asymmetric pause.
)

Valid values for PortFeature

View Source
const (
	Nil = ""
)
View Source
const UIDSeparator = "$$"

UIDSeparator is the token added in between the parts of a UID.

Variables

View Source
var (
	MaskNoneMAC            MACAddr   = [6]byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
	BroadcastMAC           MACAddr   = [6]byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
	CDPMulticastMAC        MACAddr   = [6]byte{0x01, 0x00, 0x0C, 0xCC, 0xCC, 0xCC}
	CiscoSTPMulticastMAC   MACAddr   = [6]byte{0x01, 0x00, 0x0C, 0xCC, 0xCC, 0xCD}
	IEEE802MulticastPrefix MACAddr   = [6]byte{0x01, 0x80, 0xC2, 0x00, 0x00, 0x00}
	IPv4MulticastPrefix    MACAddr   = [6]byte{0x01, 0x00, 0x5E, 0x00, 0x00, 0x00}
	IPv6MulticastPrefix    MACAddr   = [6]byte{0x33, 0x33, 0x00, 0x00, 0x00, 0x00}
	LLDPMulticastMACs      []MACAddr = []MACAddr{
		[6]byte{0x01, 0x80, 0xC2, 0x00, 0x00, 0x0E},
		[6]byte{0x01, 0x80, 0xC2, 0x00, 0x00, 0x0C},
		[6]byte{0x01, 0x80, 0xC2, 0x00, 0x00, 0x00},
	}
	MaskNoneIPV4 IPv4Addr = [4]byte{0xFF, 0xFF, 0xFF, 0xFF}
	MaskNoneIPV6 IPv6Addr = [16]byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
		0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
)

Functions

func ParseLinkUID

func ParseLinkUID(id UID) (NodeID, PortID, LinkID)

ParseLinkUID parses a link UID into the respetive node, port, and link ids.

func ParsePortUID

func ParsePortUID(id UID) (NodeID, PortID)

ParsePortUID parses a UID of a port and returns the respective node and port IDs.

func UIDSplit

func UIDSplit(id UID) []string

UIDSplit splits a UID into its smaller IDs.

Types

type Action

type Action interface {
	Equals(a Action) bool
}

type ActionDrop

type ActionDrop struct {
}

func (ActionDrop) Equals

func (a ActionDrop) Equals(thata Action) bool

func (ActionDrop) String

func (a ActionDrop) String() string

type ActionFlood

type ActionFlood struct {
	InPort UID
}

func (ActionFlood) Equals

func (a ActionFlood) Equals(thata Action) bool

func (ActionFlood) String

func (a ActionFlood) String() string

type ActionForward

type ActionForward struct {
	Ports []UID
}

func (ActionForward) Equals

func (a ActionForward) Equals(thata Action) bool

func (ActionForward) String

func (a ActionForward) String() string

type ActionPopVLAN

type ActionPopVLAN struct{}

func (ActionPopVLAN) Equals

func (a ActionPopVLAN) Equals(thata Action) bool

type ActionPushVLAN

type ActionPushVLAN struct {
	ID VLANID
}

func (ActionPushVLAN) Equals

func (a ActionPushVLAN) Equals(thata Action) bool

type ActionSendToController

type ActionSendToController struct {
	MaxLen uint16
}

func (ActionSendToController) Equals

func (a ActionSendToController) Equals(thata Action) bool

type ActionWriteFields

type ActionWriteFields struct {
	Fields []Field
}

func (ActionWriteFields) Equals

func (a ActionWriteFields) Equals(thata Action) bool

type AddFlowEntry

type AddFlowEntry struct {
	Subscriber bh.AppCellKey
	Flow       FlowEntry
}

AddFlowEntry is a message emitted to install a flow entry on a node.

type AddPath

type AddPath struct {
	Subscriber bh.AppCellKey
	Path       Path
}

AddPath is emitted to install a path in the network.

type AddTrigger

type AddTrigger Trigger

AddTrigger is a message emitted to install a trigger.

type Bandwidth

type Bandwidth uint64

Bandwidth represents bandwidth in Bps.

const (
	KBps Bandwidth = 1000
	MBps Bandwidth = 1000000
	GBps Bandwidth = 1000000000
)

Bandwidth units.

type ChangeDriverRole

type ChangeDriverRole struct {
	Node       UID        // Tho node ID.
	Role       DriverRole // The requested new role.
	Generation uint64     // The generation of role request.
}

ChangeDriverRole is emitted to instruct a driver to change its role for a node.

type DelFlowEntry

type DelFlowEntry struct {
	Match Match
	Exact bool
}

DelFlowEntry is emitted to remove the flow entries with the given match. If Exact is false, it removes all flow entries that are subsumed by the given match.

type DelPath

type DelPath struct {
	Path Path
}

DelPath is emitted to delete a path from the network.

type DelTrigger

type DelTrigger Trigger

DelTrigger is a message emitted to remove a trigger for a specific subscriber.

type Driver

type Driver struct {
	BeeID uint64
	Role  DriverRole
}

Driver represents the Bee that communicates with the actual networking element and adapts the southbound protocol for using in NOM.

func (*Driver) JSONDecode

func (d *Driver) JSONDecode(b []byte) error

JSONDecode decodes the driver from a byte slice using JSON.

func (*Driver) JSONEncode

func (d *Driver) JSONEncode() ([]byte, error)

JSONEncode encodes the driver into a byte slice using JSON.

func (Driver) String

func (d Driver) String() string

type DriverRole

type DriverRole uint8

DriverRole is the role of a driver for a node. The values can be either default, slave or master. Only one driver can be the master, but we can have multiple slaves and multiple defaults.

const (
	DriverRoleDefault DriverRole = iota
	DriverRoleSlave
	DriverRoleMaster
)

Valid values for DriverRole.

type DriverRoleUpdate

type DriverRoleUpdate struct {
	Node       UID
	Driver     Driver
	Generation uint64
}

DriverRoleUpdate is a message emitted when a driver's role is changed or an update (no necessarily a change) is recevied for a node.

type Drivers

type Drivers []Driver

func (*Drivers) JSONDecode

func (d *Drivers) JSONDecode(b []byte) error

JSONDecode decodes the drivers from a byte slice using JSON.

func (*Drivers) JSONEncode

func (d *Drivers) JSONEncode() ([]byte, error)

JSONEncode encodes the drivers into a byte slice using JSON.

type EthAddrField

type EthAddrField struct {
	Addr MACAddr
	Mask MACAddr
}

EthAddrField is a common type for EthDst and EthSrc.

type EthDst

type EthDst MaskedMACAddr

EthDst is the field for Ethernet destination address.

func (EthDst) Equals

func (e EthDst) Equals(f Field) bool

func (EthDst) HasSameType

func (e EthDst) HasSameType(f Field) bool

func (EthDst) String

func (e EthDst) String() string

func (EthDst) Subsumes

func (e EthDst) Subsumes(f Field) bool

type EthSrc

type EthSrc MaskedMACAddr

EthSrc is the field for Ethernet source address.

func (EthSrc) Equals

func (e EthSrc) Equals(f Field) bool

func (EthSrc) HasSameType

func (e EthSrc) HasSameType(f Field) bool

func (EthSrc) String

func (e EthSrc) String() string

func (EthSrc) Subsumes

func (e EthSrc) Subsumes(f Field) bool

type EthType

type EthType uint16

EthType represents the field for an Ethernet type.

func (EthType) Equals

func (e EthType) Equals(f Field) bool

func (EthType) HasSameType

func (e EthType) HasSameType(f Field) bool

func (EthType) String

func (e EthType) String() string

func (EthType) Subsumes

func (e EthType) Subsumes(f Field) bool

type Field

type Field interface {
	HasSameType(f Field) bool
	Equals(f Field) bool
	Subsumes(f Field) bool
}

type FlowEntry

type FlowEntry struct {
	ID          string // ID is defined by the subscriber, not globally unique.
	Node        UID
	Match       Match
	Actions     []Action
	Priority    uint16
	IdleTimeout time.Duration
	HardTimeout time.Duration
}

FlowEntry represents a match-action rule for a specific node.

func (FlowEntry) Equals

func (f FlowEntry) Equals(thatf FlowEntry) bool

func (FlowEntry) String

func (f FlowEntry) String() string

func (FlowEntry) Subsumes

func (f FlowEntry) Subsumes(thatf FlowEntry) bool

Subsumes returns whether everything in f is equal to thatf except that f's match subsumes thatf's match.

type FlowEntryAdded

type FlowEntryAdded struct {
	Flow FlowEntry
}

FlowEntryAdded is emitted (broadcasted and also sent to the subscriber of the flow) when a flow is added. If the flow already existed, the message is emitted to the subscriber.

type FlowEntryDeleted

type FlowEntryDeleted struct {
	Flow FlowEntry
}

FlowEntryDeleted is emitted (broadcasted and also sent to the subscriber of the flow) when a flow is deleted.

type FlowStats

type FlowStats struct {
	Match    Match
	Duration time.Duration
	Packets  uint64
	Bytes    uint64
}

FlowStats is the statistics of flow

func (FlowStats) BW

func (stats FlowStats) BW() Bandwidth

type FlowStatsQuery

type FlowStatsQuery struct {
	Node  UID
	Match Match
}

FlowStatsQuery queries the flows that would match the query. If Exact is false, it removes all flow entries that are subsumed by the given match.

type FlowStatsQueryResult

type FlowStatsQueryResult struct {
	Node  UID
	Stats []FlowStats
}

FlowStatsQueryResult is the result for a FlowStatQuery

type Host

type Host struct {
	ID       HostID
	Net      UID
	MACAddr  MACAddr
	IPv4Addr IPv4Addr
	Node     UID
}

Host represnts a end point element, such as your pc.

func (*Host) JSONDecode

func (n *Host) JSONDecode(b []byte) error

JSONDecode decodes the host from a byte array using JSON.

func (*Host) JSONEncode

func (n *Host) JSONEncode() ([]byte, error)

JSONEncode encodes the host into a byte array using JSON.

func (Host) String

func (h Host) String() string

func (Host) UID

func (n Host) UID() UID

UID returns the node's unique ID. This id is in the form of net_id$$host_id.

type HostConnected

type HostConnected Host

HostConnected is a message emitted when a host connects to network, we use this event in order to add host into our cells.

type HostDisconnected

type HostDisconnected Host

HostConnected is a message emitted when a host disconnects from network, we use this event in order to remove host from our cells.

type HostID

type HostID string

HostID is the ID of a host. This must be unique among all hosts in the network.

func ParseHostUID

func ParseHostUID(id UID) HostID

ParseHostUID parses a UID of a host and returns the respective host IDs.

func (HostID) UID

func (id HostID) UID() UID

UID converts id into a UID.

type HostJoined

type HostJoined Host

HostJoined is a message emitted when a host connects to network and we added it into our cells.

type HostLeft

type HostLeft Host

TODO(elahe): add documentation ..

type IPProto

type IPProto uint8

func (IPProto) Equals

func (p IPProto) Equals(f Field) bool

func (IPProto) HasSameType

func (p IPProto) HasSameType(f Field) bool

func (IPProto) String

func (p IPProto) String() string

func (IPProto) Subsumes

func (p IPProto) Subsumes(f Field) bool

type IPv4Addr

type IPv4Addr [4]byte

IPv4Addr represents an IP version 4 address in big endian byte order. For example, 127.0.0.1 is represented as IPv4Addr{127, 0, 0, 1}.

func (IPv4Addr) AsCIDRMask

func (ip IPv4Addr) AsCIDRMask() int

AsCIDRMask returns the CIDR prefix number based on this address. For example, it returns 24 for 255.255.255.0.

func (*IPv4Addr) FromUint

func (ip *IPv4Addr) FromUint(addr uint32)

FromUint loads the ip address from addr.

func (IPv4Addr) Less

func (ip IPv4Addr) Less(thatip IPv4Addr) bool

Less returns whether ip is less than thatip.

func (IPv4Addr) Mask

func (ip IPv4Addr) Mask(mask IPv4Addr) IPv4Addr

Mask masked the IP address with mask.

func (IPv4Addr) PopCount

func (ip IPv4Addr) PopCount() uint32

PopCount returns the number of ones in the IP address. For example, it returns 16 for IPv4Addr{255, 255, 0, 0}.

func (IPv4Addr) String

func (ip IPv4Addr) String() string

func (IPv4Addr) Uint

func (ip IPv4Addr) Uint() uint32

Uint converts the IP version 4 address into a 32-bit integer in little endian byte order.

type IPv4Dst

type IPv4Dst MaskedIPv4Addr

func (IPv4Dst) Equals

func (ip IPv4Dst) Equals(f Field) bool

func (IPv4Dst) HasSameType

func (ip IPv4Dst) HasSameType(f Field) bool

func (IPv4Dst) String

func (ip IPv4Dst) String() string

func (IPv4Dst) Subsumes

func (ip IPv4Dst) Subsumes(f Field) bool

type IPv4Src

type IPv4Src MaskedIPv4Addr

func (IPv4Src) Equals

func (ip IPv4Src) Equals(f Field) bool

func (IPv4Src) HasSameType

func (ip IPv4Src) HasSameType(f Field) bool

func (IPv4Src) String

func (ip IPv4Src) String() string

func (IPv4Src) Subsumes

func (ip IPv4Src) Subsumes(f Field) bool

type IPv6Addr

type IPv6Addr [16]byte

IPv6Addr represents an IP version 6 address in big-endian byte order.

func (IPv6Addr) AsCIDRMask

func (ip IPv6Addr) AsCIDRMask() int

AsCIDRMask returns the CIDR prefix number based on this address.

func (IPv6Addr) Less

func (ip IPv6Addr) Less(thatip IPv6Addr) bool

Less returns whether ip is less than thatip.

func (IPv6Addr) Mask

func (ip IPv6Addr) Mask(mask IPv6Addr) IPv6Addr

Mask masked the IP address with mask.

func (IPv6Addr) String

func (ip IPv6Addr) String() string

type IPv6Dst

type IPv6Dst MaskedIPv6Addr

func (IPv6Dst) Equals

func (ip IPv6Dst) Equals(f Field) bool

func (IPv6Dst) HasSameType

func (ip IPv6Dst) HasSameType(f Field) bool

func (IPv6Dst) String

func (ip IPv6Dst) String() string

func (IPv6Dst) Subsumes

func (ip IPv6Dst) Subsumes(f Field) bool

type IPv6Src

type IPv6Src MaskedIPv6Addr

func (IPv6Src) Equals

func (ip IPv6Src) Equals(f Field) bool

func (IPv6Src) HasSameType

func (ip IPv6Src) HasSameType(f Field) bool

func (IPv6Src) String

func (ip IPv6Src) String() string

func (IPv6Src) Subsumes

func (ip IPv6Src) Subsumes(f Field) bool

type InPort

type InPort UID

InPort is the input port field.

func (InPort) Equals

func (in InPort) Equals(f Field) bool

func (InPort) HasSameType

func (in InPort) HasSameType(f Field) bool

func (InPort) String

func (in InPort) String() string

func (InPort) Subsumes

func (in InPort) Subsumes(f Field) bool
type Link struct {
	ID    LinkID    // Link's ID.
	From  UID       // From is the link's port.
	To    UID       // To stores the port(s) connected to From using this link.
	State LinkState // The link's state.
}

Link represents an outgoing link from a port.

func (*Link) JSONDecode

func (l *Link) JSONDecode(b []byte) error

JSONDecode decodes the node from a byte array using JSON.

func (*Link) JSONEncode

func (l *Link) JSONEncode() ([]byte, error)

JSONEncode encodes the node into a byte array using JSON.

func (Link) UID

func (l Link) UID() UID

UID returns the UID of the link in the form of net_id$$node_id$$port_id$$link_id.

type LinkAdded

type LinkAdded Link

LinkAdded is emitted when a new link is discovered.

type LinkDeleted

type LinkDeleted Link

LinkDeleted is emitted when a new link is removed.

type LinkID

type LinkID string

LinkID is a link's ID which is unique among the outgoing links of a port.

type LinkState

type LinkState uint8

LinkState represents the status of a link.

type MACAddr

type MACAddr [6]byte

MACAddr represents a MAC address.

func (MACAddr) IsBroadcast

func (m MACAddr) IsBroadcast() bool

IsBroadcast returns whether the MAC address is a broadcast address.

func (MACAddr) IsLLDP

func (m MACAddr) IsLLDP() bool

IsLLDP returns whether the mac address is a multicast address used for LLDP.

func (MACAddr) IsMulticast

func (m MACAddr) IsMulticast() bool

IsMulticast returns whether the MAC address is a multicast address.

func (MACAddr) Key

func (m MACAddr) Key() string

Key returns an string represtation of the MAC address suitable to store in dictionaries. It is more efficient compared to MACAddr.String().

func (MACAddr) Less

func (m MACAddr) Less(thatm MACAddr) bool

func (MACAddr) Mask

func (m MACAddr) Mask(mask MACAddr) MACAddr

func (MACAddr) String

func (m MACAddr) String() string

type MaskedIPv4Addr

type MaskedIPv4Addr struct {
	Addr IPv4Addr
	Mask IPv4Addr
}

MaskedIPv4Addr represents a masked IP address (ie, an IPv4 prefix)

func CIDRToMaskedIPv4

func CIDRToMaskedIPv4(addr uint32, mask uint) MaskedIPv4Addr

CIDRToMaskedIPv4 converts a CIDR-style IP address into a NOM masked IP address. For example, if addr is 0x7F000001 and mask is 24, this function returns {IPv4Addr{127, 0, 0, 1}, IPv4Addr{255, 255, 255, 0}}.

func (MaskedIPv4Addr) Match

func (mi MaskedIPv4Addr) Match(ip IPv4Addr) bool

Match returns whether the masked IP address matches ip.

func (MaskedIPv4Addr) String

func (mi MaskedIPv4Addr) String() string

func (MaskedIPv4Addr) Subsumes

func (mi MaskedIPv4Addr) Subsumes(thatmi MaskedIPv4Addr) bool

type MaskedIPv6Addr

type MaskedIPv6Addr struct {
	Addr IPv6Addr
	Mask IPv6Addr
}

MaskedIPv6Addr represents a masked IPv6 address.

func (MaskedIPv6Addr) Match

func (mi MaskedIPv6Addr) Match(ip IPv6Addr) bool

Match returns whether the masked IP address matches ip.

func (MaskedIPv6Addr) String

func (mi MaskedIPv6Addr) String() string

func (MaskedIPv6Addr) Subsumes

func (mi MaskedIPv6Addr) Subsumes(thatmi MaskedIPv6Addr) bool

type MaskedMACAddr

type MaskedMACAddr struct {
	Addr MACAddr // The MAC address.
	Mask MACAddr // The mask of the MAC address.
}

MaskedMACAddr is a MAC address that is wildcarded with a mask.

func (MaskedMACAddr) Match

func (mm MaskedMACAddr) Match(mac MACAddr) bool

Match returns whether the masked mac address matches mac.

func (MaskedMACAddr) Subsumes

func (mm MaskedMACAddr) Subsumes(thatmm MaskedMACAddr) bool

Subsumes returns whether this mask address includes all the addresses matched by thatmm.

type Match

type Match struct {
	Fields []Field
}

Match is a collection of fields that will match packets.

func (*Match) AddField

func (m *Match) AddField(f Field)

AddField adds the field to the list of fields in the match.

func (Match) Clone

func (m Match) Clone() Match

Clone creates a copy of the match.

func (Match) Equals

func (m Match) Equals(thatm Match) bool

func (Match) EthDst

func (m Match) EthDst() (EthDst, bool)

func (Match) EthSrc

func (m Match) EthSrc() (EthSrc, bool)

func (Match) EthType

func (m Match) EthType() (EthType, bool)

func (Match) IPv4Dst

func (m Match) IPv4Dst() (IPv4Dst, bool)

func (Match) IPv4Src

func (m Match) IPv4Src() (IPv4Src, bool)

func (Match) IPv6Dst

func (m Match) IPv6Dst() (IPv6Dst, bool)

func (Match) IPv6Src

func (m Match) IPv6Src() (IPv6Src, bool)

func (Match) InPort

func (m Match) InPort() (InPort, bool)

func (Match) String

func (m Match) String() string

func (Match) Subsumes

func (m Match) Subsumes(thatm Match) bool

func (Match) TransportPortDst

func (m Match) TransportPortDst() (TransportPortDst, bool)

func (Match) TransportPortSrc

func (m Match) TransportPortSrc() (TransportPortSrc, bool)

func (Match) VLANID

func (m Match) VLANID() (VLANID, bool)

func (Match) VLANPCP

func (m Match) VLANPCP() (VLANPCP, bool)

type Network

type Network struct {
	ID   NetworkID // The id of the network.
	Desc string    // A human-readable description of the network.
}

Network represents a virtual or physical network in NOM.

func (*Network) JSONDecode

func (n *Network) JSONDecode(b []byte) error

JSONDecode decodes the network from a byte slice using JSON.

func (*Network) JSONEncode

func (n *Network) JSONEncode() ([]byte, error)

JSONEncode encodes the network into a byte slice using JSON.

func (Network) UID

func (n Network) UID() UID

UID returns the UID of the network.

type NetworkID

type NetworkID string

NetworkID is the ID of the network.

func ParseNetworkUID

func ParseNetworkUID(id UID) NetworkID

ParseNetworkUID parses a network UID into the network ID. Note that for network these IDs of the same.

type Node

type Node struct {
	ID           NodeID
	Net          UID
	Capabilities []NodeCapability
	MACAddr      MACAddr
}

Node represents a forwarding element, such as switches and routers.

func (Node) HasCapability

func (n Node) HasCapability(c NodeCapability) bool

func (*Node) JSONDecode

func (n *Node) JSONDecode(b []byte) error

JSONDecode decodes the node from a byte array using JSON.

func (*Node) JSONEncode

func (n *Node) JSONEncode() ([]byte, error)

JSONEncode encodes the node into a byte array using JSON.

func (Node) String

func (n Node) String() string

func (Node) UID

func (n Node) UID() UID

UID returns the node's unique ID. This id is in the form of net_id$$node_id.

type NodeCapability

type NodeCapability uint32

NodeCapability is a capability of a NOM node.

const (
	CapDriverRole NodeCapability = 1 << iota // Node can set the driver's role.
)

Valid values for NodeCapability.

type NodeConnected

type NodeConnected struct {
	Node   Node
	Driver Driver
}

NodeConnected is a message emitted when a node connects to a driver.

type NodeDisconnected

type NodeDisconnected struct {
	Node   Node
	Driver Driver
}

NodeDisconnected is a message emitted when a node disconnects from its driver.

type NodeID

type NodeID string

NodeID is the ID of a node. This must be unique among all nodes in the network.

func ParseNodeUID

func ParseNodeUID(id UID) NodeID

ParseNodeUID parses a UID of a node and returns the respective node IDs.

func (NodeID) UID

func (id NodeID) UID() UID

UID converts id into a UID.

type NodeJoined

type NodeJoined Node

NodeJoined is a message emitted when a node joins the network through the controller. It is always emitted after processing NodeConnected in the controller.

type NodeLeft

type NodeLeft Node

NodeLeft is a message emitted when a node disconnects from its driver. It is always emitted after processing NodeDisconnected in the controller.

type NodeQuery

type NodeQuery struct {
	Node UID
}

NodeQuery queries the information of a node.

type NodeQueryResult

type NodeQueryResult struct {
	Err  error
	Node Node
}

NodeQueryResult is the result for NodeQuery.

type Object

type Object interface {
	// JSONDecode decodes the object from a byte array using the JSON encoding.
	JSONDecode(b []byte) error
	// JSONEncode encodes the object into a byte array using the JSON encoding.
	JSONEncode() ([]byte, error)
	// UID returns a unique ID of this object. This ID is unique in the network
	// among all other objects.
	UID() UID
}

Object is the interface of all structs in the network object model.

type Packet

type Packet []byte

Packet is simply the packet data.

func (Packet) DstMAC

func (p Packet) DstMAC() MACAddr

DstMAC returns the destination MAC address from the ethernet header.

func (Packet) SrcMAC

func (p Packet) SrcMAC() MACAddr

SrcMAC returns the source MAC address from the ethernet header.

type PacketBufferID

type PacketBufferID uint32

PacketBufferID represents a packet buffered in the switch.

type PacketIn

type PacketIn struct {
	Node     UID
	InPort   UID
	BufferID PacketBufferID
	Packet   Packet
}

PacketIn messages are emitted when a packet is forwarded to the controller.

func (PacketIn) String

func (in PacketIn) String() string

type PacketOut

type PacketOut struct {
	Node     UID
	InPort   UID
	BufferID PacketBufferID
	Packet   Packet
	Actions  []Action
}

PacketOut messages are emitted to send a packet out of a port.

type Path

type Path struct {
	ID       string    // ID needs to be unique only to the subscriber.
	Pathlets []Pathlet // Pathlets in the path.
	Priority uint16    // Priority of this path.
}

Path is a logical sequence of pathlets, where pathlet[i+1] will match the output of pathlet[i]. If pathlet[i+1] matches on an incoming port p1, pathlet[i] should have a forward action that forwards to a port 2 directly connected to p1. Clearly, this rule does not apply to the first and the last pathlets in the path.

func (Path) Equals

func (p Path) Equals(thatp Path) bool

type PathAdded

type PathAdded struct {
	Path Path
}

PathAdded is emitted to the subscriber when the path is successfully added.

type PathDelReason

type PathDelReason int

PathDelReason is the reason that a path is deleted.

const (
	// PathDelExplicit means that the path is explicitly deleted using a DelPath.
	PathDelExplicit PathDelReason = iota
	// PathDelInvalid means that the path has contradicting pathlets.
	PathDelInvalid
	// PathDelInfeasible means that the path is valid but cannot be formed due to
	// the current state of the network.
	PathDelInfeasible
)

type PathDeleted

type PathDeleted struct {
	Path   Path
	Reason PathDelReason
}

PathDeleted is emitted to the subscriber when the path is deleted (because it cannot be installed in the network, or because it is explicitly removed).

type Pathlet

type Pathlet struct {
	Match   Match    // Pathlet's match.
	Exclude []InPort // Exclude packets from these ports in the pathlet.
	Actions []Action // Action that are applied.
}

Pathlet represents a logical connection pathlet in a path, where incoming packets matching Match are processing using Actions.

func (Pathlet) Equals

func (pt Pathlet) Equals(thatpt Pathlet) bool

type Ping

type Ping struct{}

Ping represents a ping message sent to a driver. It is used to health-check the driver.

type Pong

type Pong struct{}

Pong represents a reply to a ping message sent by the driver.

type Port

type Port struct {
	ID      PortID      // ID is unique among the ports of this node.
	Name    string      // Human-readable name of the port.
	MACAddr MACAddr     // Hardware address of the port.
	Node    UID         // The node.
	Link    UID         // The outgoing link.
	State   PortState   // Is the state of the port.
	Config  PortConfig  // Is the configuration of the port.
	Feature PortFeature // Features of this port.
}

Port is either a physical or a virtual port of a node.

func (*Port) JSONDecode

func (p *Port) JSONDecode(b []byte) error

JSONDecode decodes the port from a byte array using JSON.

func (*Port) JSONEncode

func (p *Port) JSONEncode() ([]byte, error)

JSONEncode encodes the port into a byte array using JSON.

func (Port) String

func (p Port) String() string

func (Port) UID

func (p Port) UID() UID

UID returns the unique ID of the port in the form of net_id$$node_id$$port_id.

type PortConfig

type PortConfig uint8

PortConfig is the NOM specific configuration of the port.

type PortFeature

type PortFeature uint16

PortFeature represents port features.

type PortID

type PortID string

PortID is the ID of a port and is unique among the ports of a node.

type PortQuery

type PortQuery struct {
	Port UID
}

PortQuery queries the information of a port.

type PortQueryResult

type PortQueryResult struct {
	Err  error
	Port Port
}

PortQueryResult is the result for a PortQuery.

type PortState

type PortState uint8

PortState is the current state of a port.

type PortStatusChanged

type PortStatusChanged struct {
	Port   Port
	Driver Driver
}

PortStatusChanged is emitted when a driver receives a port status

type PortUpdated

type PortUpdated Port

PortUpdated is a high-level event emitted when a port is added, removed, or its state/configuration is changed.

type Ports

type Ports []Port

Ports is a slice of ports with useful auxilaries.

func (*Ports) AddPort

func (ports *Ports) AddPort(p Port)

AddPort adds p to ports.

func (*Ports) DelPort

func (ports *Ports) DelPort(port Port) bool

DelPort deletes port from ports. If there is no such port, it returns false.

func (Ports) GetPort

func (ports Ports) GetPort(id UID) (Port, bool)

GetPort retrieves a port by its ID, and returns false if no port is found.

func (Ports) HasPort

func (ports Ports) HasPort(port Port) bool

HasPort returns whether port is in ports.

type TransportPortDst

type TransportPortDst uint16

func (TransportPortDst) Equals

func (p TransportPortDst) Equals(f Field) bool

func (TransportPortDst) HasSameType

func (p TransportPortDst) HasSameType(f Field) bool

func (TransportPortDst) String

func (p TransportPortDst) String() string

func (TransportPortDst) Subsumes

func (p TransportPortDst) Subsumes(f Field) bool

type TransportPortSrc

type TransportPortSrc uint16

func (TransportPortSrc) Equals

func (p TransportPortSrc) Equals(f Field) bool

func (TransportPortSrc) HasSameType

func (p TransportPortSrc) HasSameType(f Field) bool

func (TransportPortSrc) String

func (p TransportPortSrc) String() string

func (TransportPortSrc) Subsumes

func (p TransportPortSrc) Subsumes(f Field) bool

type Trigger

type Trigger struct {
	Subscriber bh.AppCellKey // Triggered messages sent to the Subscriber.
	Node       UID           // The node.
	Match      Match         // The mathing criteria.
	Exact      bool          // Whether Match should exactly match the flow.
	Duration   time.Duration // Minimum live duration to trigger.
	Bandwidth  Bandwidth     // Minimum bandwidth consumption to trigger.
}

Trigger represents a flow trigger. When a trigger is installed on a node, the node will be queried continuiously. Whenever any matching flow goes beyond the given bandwidth consumption or lives beyond the given duration, a Triggered message will be emitted.

func (Trigger) Equals

func (t Trigger) Equals(that Trigger) bool

func (Trigger) Fired

func (t Trigger) Fired(stats FlowStats) bool

Fired returns whether the trigger is fired according to the stats.

type Triggered

type Triggered struct {
	Node      UID
	Match     Match
	Duration  time.Duration
	Bandwidth Bandwidth
}

Triggered is a message emitted when a trigger is triggered.

type UID

type UID string

UID is a unique ID of a NOM object. Unlike UUID/GUID, this ID contains redundant information about the object. For example a port's UID contains its network and node ID along with an ID for the port.

const (
	PortFlood UID = "Ports.PortBcast"
	PortAll   UID = "Ports.PortAll"
)

Special ports.

func NodeFromPortUID

func NodeFromPortUID(port UID) (node UID)

NodeFromPortUID returns the node UID from the port's UID.

func UIDJoin

func UIDJoin(ids ...string) UID

UIDJoin joins an array of IDs into a UID.

type VLANID

type VLANID uint16

VLANID represents the field for the VLAN ID.

func (VLANID) Equals

func (e VLANID) Equals(f Field) bool

func (VLANID) HasSameType

func (e VLANID) HasSameType(f Field) bool

func (VLANID) String

func (e VLANID) String() string

func (VLANID) Subsumes

func (e VLANID) Subsumes(f Field) bool

type VLANPCP

type VLANPCP uint8

VLANPCP represents the field for the VLAN PCP.

func (VLANPCP) Equals

func (p VLANPCP) Equals(f Field) bool

func (VLANPCP) HasSameType

func (p VLANPCP) HasSameType(f Field) bool

func (VLANPCP) String

func (p VLANPCP) String() string

func (VLANPCP) Subsumes

func (p VLANPCP) Subsumes(f Field) bool

Jump to

Keyboard shortcuts

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